<!DOCTYPE html>
<html><head>
    <meta charset="UTF-8">
</head><body><p></p><div class="io-ox-signature"></div><div class="io-ox-signature">Thank you John for your idea but it seem that when rtpproxy_manage change the SDP, it also change the RTP port that fit the rtpproxy session.</div><div class="io-ox-signature"><br></div><div class="io-ox-signature">So basically, I need to call rtpproxy_manage with the invite to change the SDP attribute but when falling back to the failure_route, I need to destroy the current rtpproxy session and create a new one base on the new parameters of the session (the changed user and destination ip) for the RTP stream.</div><div class="io-ox-signature"><br></div><div class="io-ox-signature">So to manage this correctly, I may need to destroy the first created rtpproxy session and create a new one with the new invite parameters.</div><div class="io-ox-signature"><br></div><div class="io-ox-signature">I will try to work on this.</div><div class="io-ox-signature"><br></div><blockquote type="cite">On June 14, 2017 at 5:19 PM John Petrini <jpetrini@coredial.com> wrote:<br><br><div dir="ltr">You might try using the fix_nated_sdp function from the nathelper module to rewrite the c line in the SDP body.</div><div class="ox-f8fad8a1a7-gmail_extra"><br clear="all"><div><div class="ox-f8fad8a1a7-gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><p style="margin-top: 8px; margin-bottom: 8px; font-family: Helvetica,Verdana,Arial,sans-serif; font-size: 0.85em; color: #333333;"><span style="font-size: 0.85em;">___</span><br></p><p style="margin-top: 8px; margin-bottom: 8px; font-family: Helvetica,Verdana,Arial,sans-serif; font-size: 1.1em; color: #333333;">John Petrini</p><p style="margin-top: 8px; margin-bottom: 8px; font-family: Helvetica,Verdana,Arial,sans-serif; font-size: 0.85em; color: #333333;">NOC Systems Administrator   //   <strong>CoreDial, LLC</strong>   //   <a href="http://coredial.com/" style="color: #2368b3; text-decoration: none;" target="_blank">coredial.com</a>   //   <a href="https://twitter.com/coredial" target="_blank"><img src="http://cdn2.hubspot.net/hub/210539/file-2353637622-gif/email/twitter-1.gif" alt="Twitter" style="vertical-align: text-bottom;"></a>   <a href="http://www.linkedin.com/company/99631" target="_blank"><img src="http://cdn2.hubspot.net/hub/210539/file-2351103565-gif/email/linkedin-1.gif" alt="LinkedIn" style="vertical-align: text-bottom;"></a>   <a href="https://plus.google.com/104062177220750809525/posts" target="_blank"><img src="http://cdn2.hubspot.net/hub/210539/file-2353637617-gif/email/googleplus-1.gif" alt="Google Plus" style="vertical-align: text-bottom;"></a>   <a href="http://success.coredial.com/blog" target="_blank"><img src="http://cdn2.hubspot.net/hub/210539/file-2351103560-gif/email/rss-1.gif" alt="Blog" style="vertical-align: text-bottom;"></a> <br>Hillcrest I, 751 Arbor Way, Suite 150, Blue Bell PA, 19422 <br><strong>P: </strong><a style="color: #2368b3;">215.297.4400</a> x232   //   <strong>F: </strong><a style="color: #2368b3;">215.297.4401</a>   //   <strong>E: </strong><a href="mailto:jpetrini@coredial.com" style="color: #2368b3; text-decoration: none;" target="_blank">jpetrini@coredial.com</a></p><p><img src="http://success.coredial.com/hubfs/images/CD16-PC17-Email-Signature-Final-Mar-v2-1.gif"><br></p><p style="margin-top: 10px; margin-bottom: 8px; font-family: Helvetica,Verdana,Arial,sans-serif; font-size: 0.85em; color: #333333;">Interested in sponsoring PartnerConnex 2017? <a href="http://success.coredial.com/partnerconnex-2017-sponsorship" style="color: #2368b3; text-decoration: none;" target="_blank">Learn more.</a></p><p style="padding-bottom: 15px; max-width: 600px; font-family: Helvetica,Verdana,Arial,sans-serif; font-size: 0.6em; color: #333333;">The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission,  dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.</p></div></div></div></div></div></div></div></div></div></div></div></div><br><div class="ox-f8fad8a1a7-gmail_quote">On Wed, Jun 14, 2017 at 5:00 PM, Pascal Poudrier <<a href="mailto:pascal.poudrier@quebecinternet.net" target="_blank">pascal.poudrier@quebecinternet.net</a>> wrote:<br><blockquote><u></u><div><p>Hi, first of all, here's the architecture of what I'm trying to do :</p><p>Public client --> Kamailio and there is a private freeswitch behind  kamailio. I use rtpproxy to connect the client and the freeswitch that is used at media server.</p><p>If a call is not answered from userA to userB and userB doesn't have a voicemail configured, I route the Invite to FreeSwitch and I change the destination user to 666666 that take care of playing a nice message that the user doesn't have a voicemail.</p><p>My problem is that the SDP Connection doesn't get updated to the right IP. It get changed to the external IP instead of the internal.</p><p>Here's the original INVITE Packet :</p><p>13:21:22.824290 IP 8.8.8.16.30893 > 8.8.8.18.5060: SIP: INVITE sip:<a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:101@mydomain.com" target="_blank">101@mydomain.com</a> SIP/2.0 <br>Eh....@.?...........x......<wbr/>mINVITE sip:<a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:101@mydomain.com" target="_blank">101@mydomain.com</a> SIP/2.0 <br>Via: SIP/2.0/UDP 192.168.0.236:5060;branch=<wbr/>z9hG4bK-3e3b9e22 <br>From: <a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:sip:102@mydomain.com" target="_blank">102</a>;tag=cacbdfac40ddd17ao0 <br>To: <sip:<a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:101@mydomain.com" target="_blank">101@mydomain.com</a>> <br>Remote-Party-ID: <a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:sip:102@mydomain.com" target="_blank">102</a>;screen=yes;party=calling <br>Call-ID: <a href="mailto:3ae5b914-591b8732@192.168.0.236" target="_blank">3ae5b914-591b8732@192.168.0.<wbr/>236</a> <br>CSeq: 101 INVITE <br>Max-Forwards: 70 <br>Contact: <a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:sip:102@192.168.0.236:5060;ref=102" target="_blank">102</a> <br>Expires: 240 <br>User-Agent: Cisco/SPA122-1.3.5r(003) <br>Content-Length: 263 <br>Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER <br>Supported: replaces <br>Content-Type: application/sdp <br><br>v=0 <br>o=- 16833207 16833207 IN IP4 192.168.0.236 <br>s=- <br>c=IN IP4 192.168.0.236 <br>t=0 0 <br>m=audio 16396 RTP/AVP 0 100 101 <br>a=rtpmap:0 PCMU/8000 <br>a=rtpmap:100 NSE/8000 <br>a=fmtp:100 192-193 <br>a=rtpmap:101 telephone-event/8000 <br>a=fmtp:101 0-15 <br>a=ptime:20 <br>a=sendrecv<br><br></p><p>Note that 192.168.0.x in the internal network of the clients and 8.8.8.16 is the public IP of the client and 8.8.8.18 is the kamailio ip.</p><p>Here's the INVITE packet sent from kamailio to Freeswitch</p><p>13:21:32.947196 IP 172.16.0.18.5060 > 172.16.0.19.5080: SIP: INVITE <a href="http://sip:666666666666666@172.16.0.19:5080" target="_blank">sip:666666666666666@172.16.0.<wbr/>19:5080</a> SIP/2.0 <br>E... ...@.      ...e...e.......P1INVITE <a href="http://sip:666666666666666@172.16.0.19:5080" target="_blank">sip:666666666666666@172.16.0.<wbr/>19:5080</a> SIP/2.0 <br>Record-Route: <sip:8.8.8.18;lr=on;ftag=<wbr/>cacbdfac40ddd17ao0;did=f3f.<wbr/>205> <br>Test-Pascal: SDP avec freeswitch <br>Via: SIP/2.0/UDP 172.16.0.18;branch=<wbr/>z9hG4bK31ea.<wbr/>e52b370f8248032680211fc7c25390<wbr/>2a.1 <br>Via: SIP/2.0/UDP 192.168.0.236:5060;rport=<wbr/>30893;received=8.8.8.16;<wbr/>branch=z9hG4bK-3e3b9e22 <br>From: <a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:sip:102@mydomain.com" target="_blank">102</a>;tag=cacbdfac40ddd17ao0 <br>To: <sip:<a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:101@mydomain.com" target="_blank">101@mydomain.com</a>> <br>Remote-Party-ID: <a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:sip:102@mydomain.com" target="_blank">102</a>;screen=yes;party=calling <br>Call-ID: <a href="mailto:3ae5b914-591b8732@192.168.0.236" target="_blank">3ae5b914-591b8732@192.168.0.<wbr/>236</a> <br>CSeq: 101 INVITE <br>Max-Forwards: 69 <br>Contact: <a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:sip:102@192.168.0.236:5060;ref=102;alias=8.8.8.16~30893~1" target="_blank">102</a> <br>Expires: 240 <br>User-Agent: Cisco/SPA122-1.3.5r(003) <br>Content-Length: 279 <br>Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER <br>Supported: replaces <br>Content-Type: application/sdp <br><br>v=0 <br>o=- 16833207 16833207 IN IP4 8.8.8.18 <br>s=- <br>c=IN IP4 8.8.8.18 <br>t=0 0 <br>m=audio 46134 RTP/AVP 0 100 101 <br>a=rtpmap:0 PCMU/8000 <br>a=rtpmap:100 NSE/8000 <br>a=fmtp:100 192-193 <br>a=rtpmap:101 telephone-event/8000 <br>a=fmtp:101 0-15 <br>a=ptime:20 <br>a=sendrecv <br>a=nortpproxy:yes<br></p><p>Note that 172.16.0.18 is the internal IP of kamailio and 172.16.0.19 is the internal IP of FreeSwitch</p><p>Here's the revealing par of kamailio configuration that us use when falling back to freeswitch :</p><p>failure_route[TOVOICEMAIL] {</p><p>$ru = "sip:666666666666666@" + $sel(cfg_get.freeswitch.<wbr/>bindip)<br>+ ":" + $sel(cfg_get.freeswitch.<wbr/>bindport);<br>$du = "sip:666666666666666@"+ $sel(cfg_get.freeswitch.<wbr/>bindip)<br>+ ":" + $sel(cfg_get.freeswitch.<wbr/>bindport);<br>force_send_socket(udp:<a href="http://172.16.0.18:5060" target="_blank">172.16.<wbr/>0.18:5060</a>);<br></p><p>if (is_request()) { <br>       xlog("L_INFO","$ft -- NATMANAGE -- Request"); <br>       if(has_totag()) { <br>           if(check_route_<wbr/>param("nat=yes")) { <br>               setbflag(FLT_<wbr/>NATS); <br>           } <br>       } <br>   }<br><br>       if(nat_uac_test("8")) { <br>           xlog("L_INFO","----<wbr/>------------------------------<wbr/>-----------------"); <br>           xlog("L_INFO","----<wbr/>------------------------------<wbr/>-----------------"); <br>           xlog("L_INFO","SDP Body avant : $fu --> $du | $ru"); <br>           xlog("L_INFO","----<wbr/>------------------------------<wbr/>-----------------"); <br>           xlog("L_INFO","$ft -- RTPMANAGE(FreeSwitch) : NAT SDP"); <br>           rtpproxy_manage("<wbr/>1cowei",'192.168.101.18'); <br>           insert_hf("Test-<wbr/>Pascal: SDP avec freeswitch\r\n"); <br>           xlog("L_INFO","----<wbr/>------------------------------<wbr/>-----------------"); <br>       }    <br>       else { <br>           xlog("L_INFO","$ft -- RTPMANAGE(FreeSwitch) : PAS DE NAT SDP"); <br>           rtpproxy_manage("<wbr/>cowrei"); <br>       }    <br>   if (is_reply()) { <br>       xlog("L_INFO","$ft -- NATMANAGE -- Reply"); <br>       if(isbflagset(FLT_NATS)<wbr/>) { <br>           if(is_first_hop()) <br>               set_contact_<wbr/>alias(); <br><br>       } <br>       if ( $si == $sel(cfg_get.freeswitch.<wbr/>bindip) && is_method("SUBSCRIBE") ) { <br>           remove_hf("Contact"<wbr/>); <br>           insert_hf("Contact: \<a class="ox-f8fad8a1a7-m_-8244530551436555704mailto-link" href="mailto:sip:$fU@8.8.8.18:5060" target="_blank">$fU\</a>\r\n","Expires"); <br><br>       } <br>       else { <br>           fix_nated_contact()<wbr/>; <br>       } <br><br>   }<br><br>if ( is_method("INVITE") )<br>       setflag(FLT_DIALOG);<br><br>if (!t_relay()) { <br>       xlog("L_INFO","$ft -- ERROR Relay : $rc"); <br>       sl_reply_error(); <br>   }<br><br>------------------------------<wbr/>------------------</p><p>This configuration is working if the call is not going through failure_route</p><p>I use Kamailio version 5.0.1 on Debian.</p><p>Thank you</p><p><br></p><p>Pascal</p></div><br>______________________________<wbr/>_________________<br> Kamailio (SER) - Users Mailing List<br> <a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br> <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">https://lists.kamailio.org/<wbr/>cgi-bin/mailman/listinfo/sr-<wbr/>users</a><br> <br></blockquote></div><br></div></blockquote></body></html>