is_first_hop() fails to detect 'myself' when using advertise
Hi ppl, If I add a FQDN advertise address to the listen statement, *is_first_hop() <https://kamailio.org/docs/modules/4.3.x/modules/siputils.html#siputils.f.is_first_hop>* seems to return FALSE no matter how I play with the listen and alias settings. listen=udp:1.1.1.1:5060 advertise sip.mydomain.net:5060 alias="sip.mydomain.net:5060" This statement doesn't get executed in the *onreply_route* *onreply_route[MANAGE_REPLY] {* *if(is_first_hop())* *set_contact_alias(); # contact alias doesn't get set?* *}* *is_first_hop()* *"The function returns true if the proxy is first hop after the original sender. For incoming SIP replies, it means that top Record-Route URI is 'myself' and source address is not matching it"* *This is the reply.* 2018/10/03 17:03:38.276846 2.2.2.2:62033 -> 1.1.1.1:5060 SIP/2.0 200 OK Via: SIP/2.0/UDP sip.mydomain.net:5060 ;branch=z9hG4bK49b3.bfbe15.0;received=1.1.1.1 Via: SIP/2.0/UDP 10.10.10.10:5060;rport=5060;branch=z9hG4bK1af96136 *Record-Route*: <sip:sip.mydomain.net;lr=on;did=4cc.734> Contact: <sip:888@10.17.0.35:62033> Suggestions? Thanks.
I actually had this exact problem, and because I knew when I was first hop and when not, I ended up adding if conditions to solve the problem. I would love to know the answer to this too and the correct reason as to why it happens and how to correct it. On Wed, Oct 3, 2018 at 11:34 PM Sergiu Pojoga <pojogas@gmail.com> wrote:
Hi ppl,
If I add a FQDN advertise address to the listen statement, *is_first_hop() <https://kamailio.org/docs/modules/4.3.x/modules/siputils.html#siputils.f.is_first_hop>* seems to return FALSE no matter how I play with the listen and alias settings.
listen=udp:1.1.1.1:5060 advertise sip.mydomain.net:5060 alias="sip.mydomain.net:5060"
This statement doesn't get executed in the *onreply_route*
*onreply_route[MANAGE_REPLY] {*
*if(is_first_hop())*
*set_contact_alias(); # contact alias doesn't get set?*
*}*
*is_first_hop()* *"The function returns true if the proxy is first hop after the original sender. For incoming SIP replies, it means that top Record-Route URI is 'myself' and source address is not matching it"*
*This is the reply.* 2018/10/03 17:03:38.276846 2.2.2.2:62033 -> 1.1.1.1:5060 SIP/2.0 200 OK Via: SIP/2.0/UDP sip.mydomain.net:5060 ;branch=z9hG4bK49b3.bfbe15.0;received=1.1.1.1 Via: SIP/2.0/UDP 10.10.10.10:5060;rport=5060;branch=z9hG4bK1af96136 *Record-Route*: <sip:sip.mydomain.net;lr=on;did=4cc.734> Contact: <sip:888@10.17.0.35:62033>
Suggestions?
Thanks. _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Hello, I just added a note in the docs that it works only when RR has IP address in its URI. The reason is that the IP in RR is compared with source address in order to see if it is a loop, so if there is no IP in RR, then it returns false/-1. It is how the function was designed, if someone wants to make some alternative, just propose a patch. Cheers, Daniel On 03.10.18 23:46, Joel Serrano wrote:
I actually had this exact problem, and because I knew when I was first hop and when not, I ended up adding if conditions to solve the problem. I would love to know the answer to this too and the correct reason as to why it happens and how to correct it.
On Wed, Oct 3, 2018 at 11:34 PM Sergiu Pojoga <pojogas@gmail.com <mailto:pojogas@gmail.com>> wrote:
Hi ppl,
If I add a FQDN advertise address to the listen statement, /is_first_hop() <https://kamailio.org/docs/modules/4.3.x/modules/siputils.html#siputils.f.is_first_hop>/ seems to return FALSE no matter how I play with the listen and alias settings.
listen=udp:1.1.1.1:5060 <http://1.1.1.1:5060> advertise sip.mydomain.net:5060 <http://sip.mydomain.net:5060> alias="sip.mydomain.net:5060 <http://sip.mydomain.net:5060>"
This statement doesn't get executed in the /onreply_route/
/onreply_route[MANAGE_REPLY] {/
/if(is_first_hop())/
/set_contact_alias(); # contact alias doesn't get set?/
/}/
*is_first_hop()* /"The function returns true if the proxy is first hop after the original sender. For incoming SIP replies, it means that top Record-Route URI is 'myself' and source address is not matching it"/
*This is the reply.* 2018/10/03 17:03:38.276846 2.2.2.2:62033 <http://2.2.2.2:62033> -> 1.1.1.1:5060 <http://1.1.1.1:5060> SIP/2.0 200 OK Via: SIP/2.0/UDP sip.mydomain.net:5060;branch=z9hG4bK49b3.bfbe15.0;received=1.1.1.1 Via: SIP/2.0/UDP 10.10.10.10:5060;rport=5060;branch=z9hG4bK1af96136 *Record-Route*: <sip:sip.mydomain.net <http://sip.mydomain.net>;lr=on;did=4cc.734> Contact: <sip:888@10.17.0.35:62033 <http://sip:888@10.17.0.35:62033>>
Suggestions?
Thanks. _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio World Conference -- www.kamailioworld.com Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com
participants (3)
-
Daniel-Constantin Mierla -
Joel Serrano -
Sergiu Pojoga