<HTML dir=ltr><HEAD><TITLE>Re: [OpenSIPS-Users] UAC_REDIRECT : get_redirects doesnot rewritehost</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6001.18148" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText96943 dir=ltr>
<DIV dir=ltr><FONT face="Courier New" color=#000000 size=2>Hi, I found&nbsp;a fix to this problem, in some circumstances the contact header is already parsed&nbsp;when hiting shmcontact2dset() </FONT></DIV>
<DIV dir=ltr><FONT face="Courier New" color=#000000 size=2>however it is not parsed by parse_contact(), I have set a logging entry in there.</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Courier New" size=2>My fix/workaround is&nbsp;simply to force it to parse again :</FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Courier New" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // start modification</FONT></DIV>
<DIV dir=ltr><FONT face="Courier New" color=#000000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int* b=0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contact_hdr-&gt;parsed =(void*)b;</FONT></DIV>
<DIV dir=ltr><FONT face="Courier New" color=#000000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // end modification<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* parse the body of contact header */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (contact_hdr-&gt;parsed==0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( parse_contact(contact_hdr)&lt;0 ) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LM_ERR("contact hdr parse failed\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret = -1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto restore;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (dup==0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dup = 1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR></FONT></DIV>
<DIV dir=ltr><FONT face="Courier New" color=#000000 size=2>Could we find out why it is parsed in a way that result in this confusion between</FONT></DIV>
<DIV dir=ltr><FONT face="Courier New" color=#000000 size=2>Contact and VIA header, this would be better.</DIV></FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> users-bounces@lists.opensips.org on behalf of Julien Chavanton<BR><B>Sent:</B> Tue 18/08/2009 12:06 AM<BR><B>To:</B> OpenSIPS users mailling list; OpenSIPS users mailling list<BR><B>Subject:</B> Re: [OpenSIPS-Users] UAC_REDIRECT : get_redirectsdoesnot rewritehost<BR></FONT><BR></DIV>
<DIV dir=ltr>
<DIV id=idOWAReplyText66095 dir=ltr>
<DIV dir=ltr><FONT face=Verdana color=#000000 size=2>Hi Bogdan, I installed&nbsp;a test server with</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Verdana size=2>1.5.1</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2>1.5.2</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2>and the SVN </FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Verdana size=2>I have the&nbsp;same behavior, where the IP adress is not taken from the contact header but from somewhere else (maybe the VIA hdr)</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Verdana size=2>The setup I have in my lab :</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2>X-Lite(caller computer) and another X-Lite(called computer).</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2>I set X-Lite(called computer), to forward the call to another target <A href="mailto:new_target@1.1.1.1">new_target@1.1.1.1</A>&nbsp;for example.</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Verdana size=2>Maybe I should test with gateway instead of registered phones.</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Verdana size=2>Regards</FONT></DIV></DIV>
<DIV dir=ltr>
<DIV dir=ltr><BR></DIV></DIV>
<DIV dir=ltr>
<DIV dir=ltr>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr><FONT face=Tahoma size=2><B>From:</B> users-bounces@lists.opensips.org on behalf of Bogdan-Andrei Iancu<BR><B>Sent:</B> Fri 14/08/2009 8:51 AM<BR><B>To:</B> OpenSIPS users mailling list<BR><B>Subject:</B> Re: [OpenSIPS-Users] UAC_REDIRECT : get_redirects doesnot rewritehost<BR></FONT><BR></DIV></DIV>
<DIV>
<P><FONT size=2>Hi Julien,<BR><BR>Could you please try the latest 1.5 from SVN (1.5.2) ? I remember there<BR>were some fixes in the uac_redirect part and I want to be sure we are<BR>not troubleshooting it again.<BR><BR>What is really strange is that the IP in the printed contacts is<BR>actually the IP + port from VIA hdr&nbsp; :-/..<BR><BR>If upgrading is an issue for you, I can prepare some debuging patch to<BR>print more stuff and to see where the change comes from.<BR><BR>Regards,<BR>Bogdan<BR><BR>Julien Chavanton wrote:<BR>&gt; I have activated full debug mode, sort_contacts() seems to find the<BR>&gt; host somewhere else ?<BR>&gt; Maybe this will help you understand what is going on<BR>&gt;&nbsp;<BR>&gt;&nbsp;<BR>&gt; #<BR>&gt; U 10.0.1.73:57226 -&gt; 10.0.5.10:5060<BR>&gt; SIP/2.0 302 Moved Temporarily.<BR>&gt; Via: SIP/2.0/UDP 10.0.5.10;branch=z9hG4bK2714.0ee86a21.0.<BR>&gt; Via: SIP/2.0/UDP<BR>&gt; 10.0.1.73:57226;received=10.0.1.73;branch=z9hG4bK-d8754z-7048034193434959-1---d8754z-;rport=57226.<BR>&gt; Contact: &lt;sip:new_target@10.0.1.1:5060&gt;.<BR>&gt; To: "777"&lt;sip:777@osip.domain.com&gt;;tag=944d064a.<BR>&gt; From: "777"&lt;sip:777@osip.domain.com&gt;;tag=d650bd17.<BR>&gt; Call-ID: YmI3ZmQ0Mzk2MDE3OGY0M2FlNjVkNGVlY2EwZmI5NzM..<BR>&gt; CSeq: 1 INVITE.<BR>&gt; User-Agent: X-Lite release 1103d stamp 53117.<BR>&gt; Content-Length: 0.<BR>&gt;&nbsp;<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]: ***FAILURE ROUTE<BR>&gt; - REDIRECT ru[sip:777@10.0.1.73:57226;rinstance=c699f35c276783d3]**<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]:<BR>&gt; DBG:uac_redirect:get_redirect: resume branch=0<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]:<BR>&gt; DBG:uac_redirect:get_redirect: checking branch=0 (added=0)<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]:<BR>&gt; DBG:uac_redirect:get_redirect: branch=0 is a redirect (added=0)<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]:<BR>&gt; DBG:uac_redirect:sort_contacts: sort_contacts:<BR>&gt; &lt;sip:new_target@10.0.1.73:57226&gt; q=10<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]:<BR>&gt; DBG:uac_redirect:shmcontact2dset: adding contact<BR>&gt; &lt;sip:new_target@10.0.1.73:57226&gt;<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]:<BR>&gt; DBG:core:parse_headers: flags=78<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]: ACC: request<BR>&gt; accounted:<BR>&gt; timestamp=1250195007;method=INVITE;from_tag=d61cb370;to_tag=;call_id=NDA2ZmI4YmNmMjJmMGNjYjI4YjUxODUyNTNkZmUyNzQ.;code=;reason=redirect<BR>&gt;<BR>&gt; Aug 13 21:23:27 osip /usr/local/sbin/opensips[16925]: ***FAILURE ROUTE<BR>&gt; - REDIRECTED TO: sip:new_target@10.0.1.73:57226]** .<BR>&gt;&nbsp;<BR>&gt;<BR>&gt; ------------------------------------------------------------------------<BR>&gt; *From:* users-bounces@lists.opensips.org on behalf of Julien Chavanton<BR>&gt; *Sent:* Thu 13/08/2009 6:43 PM<BR>&gt; *To:* OpenSIPS users mailling list; OpenSIPS users mailling list<BR>&gt; *Subject:* Re: [OpenSIPS-Users] UAC_REDIRECT : get_redirects does not<BR>&gt; rewritehost<BR>&gt;<BR>&gt; Hi Bogdan,<BR>&gt;&nbsp;<BR>&gt; version: opensips 1.5.1-notls (x86_64/linux)<BR>&gt;&nbsp;<BR>&gt; failure_route[1] {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sip_trace();<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (t_check_status("302")) {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlog("L_NOTICE", "***FAILURE ROUTE - REDIRECT<BR>&gt; ru[$ru]**\n");<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get_redirects("6:2","redirect");<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlog("L_NOTICE", "***FAILURE ROUTE - REDIRECTED TO:<BR>&gt; $ru]**\n");<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t_relay();<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&gt; }<BR>&gt;&nbsp;<BR>&gt; Aug 13 18:44:17 osip /usr/local/sbin/opensips[16565]: ***FAILURE ROUTE<BR>&gt; - REDIRECT ru[sip:777@10.0.1.73:57226;rinstance=c699f35c276783d3]**<BR>&gt; Aug 13 18:44:17 osip /usr/local/sbin/opensips[16565]: ***FAILURE ROUTE<BR>&gt; - REDIRECTED TO: ru[sip:new_target@10.0.1.73:57226]**<BR>&gt;&nbsp;<BR>&gt;<BR>&gt; ------------------------------------------------------------------------<BR>&gt; *From:* users-bounces@lists.opensips.org on behalf of Bogdan-Andrei Iancu<BR>&gt; *Sent:* Thu 13/08/2009 6:29 PM<BR>&gt; *To:* OpenSIPS users mailling list<BR>&gt; *Subject:* Re: [OpenSIPS-Users] UAC_REDIRECT : get_redirects does not<BR>&gt; rewrite host<BR>&gt;<BR>&gt; Hi Julien,<BR>&gt;<BR>&gt; The get_redirects() function does replace the entire RURI with the<BR>&gt; contact URI. My feeling is you (by mistake) rewrite the domain part<BR>&gt; after the new RURI is set - try printing the RURI just after the<BR>&gt; get_redirects() function.<BR>&gt;<BR>&gt; BTW, what version of opensips are you using?<BR>&gt;<BR>&gt; Regards,<BR>&gt; Bogdan<BR>&gt;<BR>&gt; Julien Chavanton wrote:<BR>&gt; &gt; I am looking to handle redirect 302 request, get_redirect does not<BR>&gt; &gt; replace the domain/host part of the new target ?<BR>&gt; &gt;<BR>&gt; &gt; How do we handle redirection to a different IP address ?<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; Example :<BR>&gt; &gt;<BR>&gt; &gt; U 10.0.4.44:5060 -&gt; 10.0.1.73:57226<BR>&gt; &gt; INVITE sip:777@10.0.1.73:57226;rinstance=c699f35c276783d3 SIP/2.0.<BR>&gt; &gt;<BR>&gt; &gt; U 10.0.1.73:57226 -&gt; 10.0.4.44:5060<BR>&gt; &gt; SIP/2.0 302 Moved Temporarily.<BR>&gt; &gt; Contact: &lt;sip:new_target@10.0.1.1:5060&gt;.<BR>&gt; &gt;<BR>&gt; &gt; U 10.0.4.44:5060 -&gt; 10.0.1.73:57226<BR>&gt; &gt; INVITE sip:new_target@10.0.1.73:57226 SIP/2.0.<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt;<BR>&gt; &gt; _______________________________________________<BR>&gt; &gt; Users mailing list<BR>&gt; &gt; Users@lists.opensips.org<BR>&gt; &gt; <A href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</A><BR>&gt; &gt;&nbsp;<BR>&gt;<BR>&gt;<BR>&gt; _______________________________________________<BR>&gt; Users mailing list<BR>&gt; Users@lists.opensips.org<BR>&gt; <A href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</A><BR>&gt;<BR>&gt; ------------------------------------------------------------------------<BR>&gt;<BR>&gt; _______________________________________________<BR>&gt; Users mailing list<BR>&gt; Users@lists.opensips.org<BR>&gt; <A href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</A><BR>&gt;&nbsp;&nbsp;<BR><BR><BR>_______________________________________________<BR>Users mailing list<BR>Users@lists.opensips.org<BR><A href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</A><BR></FONT></P></DIV></DIV></BODY></HTML>