[OpenSIPS-Users] Missing contacts when handling 300 in OnReply route

Dan Cooper dan at dcsoftwaresystems.com
Mon May 2 22:36:11 UTC 2022


Hello,

I'm handling a 300 Multiple Choices reply in an onreply_route as 
described the Opensips Blog post "Handling SIP Redirect Requests in 
realtime".

The problem I'm seeing is while iterating the contacts through the $ct 
variable, only one of the two contact records in the SIP message is 
returned.  Instead it seemingly substitutes the initial contact for one 
of the returned contacts.  I think I should be getting all the contacts 
in the message and not the initial contact as I read the documentation.

This system is running Opensips v3.2.6

Below is the SIP message (from sngrep), the onreply_route script, and 
the log output.

2022/05/02 21:12:54.183024 23.101.143.54:5060 -> 192.46.219.150:5060
SIP/2.0 300 Multiple Choices
Via: SIP/2.0/UDP 192.46.219.150:5060;branch=z9hG4bKe01e.fcabc446.0;i=881249d1
Via: SIP/2.0/TCP 192.168.49.125:5080;received=67.172.178.64;branch=z9hG4bKBHcBe35Be3KjH
Max-Forwards: 69
From: 15074529949 <sip:15074529949 at sip-test.reliancetelephone.com>;tag=jDtDtDmmXaXtQ
To: 12187299716 <sip:12187299716 at tfvoip.cloudapp.net:5060>;tag=6ayH1QZrymXSS
Call-ID: 79021022-44ff-123b-42ba-001fc69ce9dd
CSeq: 51209194 INVITE
Contact: "unknown" <sip:12187299716 at 104.41.158.217>;q=0.129
Contact: "unknown" <sip:12187299716 at 23.101.137.105>;q=0.128
User-Agent: FreeSWITCH-mod_sofia/1.10.5-release-17-25569c1631~64bit
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, refer
Reason: Q.850;cause=31;text="NORMAL_UNSPECIFIED"
Content-Length: 0
X-FS-Display-Name: 12187299716
X-FS-Display-Number: sip:12187299716 at tfvoip.cloudapp.net
Remote-Party-ID: "12187299716" <sip:12187299716 at tfvoip.cloudapp.net>;party=calling;privacy=off;screen=no

onreply_route[RTPENGINE]{

   xlog("OnReply RTPENGINE: Status = $rs");

   if (t_check_status("300")){
     $var(n) = 0;

     xlog("OnReply RTPENGINE: contact $ct.fields(uri)");
     xlog("OnReply RTPENGINE: last contact $(ct.fields(uri)[-1])");
     xlog("OnReply RTPENGINE: first contact $(ct.fields(uri)[0])");
     xlog("OnReply RTPENGINE: second contact $(ct.fields(uri)[1])");
     xlog("OnReply RTPENGINE: third contact $(ct.fields(uri)[2])");

     while ($(ct[$var(n)]) != NULL) {

       xlog("OnReply RTPENGINE: var(n) = $var(n)");
       if ($(ct.fields(uri)[$var(n)]) != NULL) {

          xlog("OnReply RTPENGINE: appending branch = $(ct.fields(uri)[$var(n)]) : var(n) = $var(n)");
          append_branch($(ct.fields(uri)[$var(n)]));

       }
       $var(n) = $var(n) + 1;
     }

     t_inject_branches("msg");
   }

   if (has_body("application/sdp")){
     # c flag handles duplicate c= lines in SDP
     rtpengine_answer("c");
   }
}

May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: Status = 300
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:tm:t_check_status: checked status is <300>
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: contact sip:12187299716 at 23.101.143.54:5060
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_params: Parsing params for:[q=0.128]
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: last contact sip:12187299716 at 23.101.137.105
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: first contact sip:12187299716 at 23.101.143.54:5060
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: second contact sip:12187299716 at 23.101.137.105
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: third contact <null>
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: var(n) = 0
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: appending branch = sip:12187299716 at 23.101.143.54:5060 : va
r(n) = 0
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: var(n) = 1
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: DBG:core:parse_headers: flags=ffffffffffffffff
May  2 21:12:54 opensipsprod1 /usr/sbin/opensips[30007]: OnReply RTPENGINE: appending branch = sip:12187299716 at 23.101.137.105 : var(n)
  = 1

Thanks for your help

Dan Cooper




More information about the Users mailing list