Hi Deon,<br><br>Some ideas:<br>1. Capture the SIP traffic and see if media proxy is being invoked in the request and/or response (look for your P-hint messages), and the IP addresses.<br>2. Add xlog messages when you invoke mediarelay to confirm that they are getting called.<br>

3. You&#39;re comparing $dd (which is a domain) to $si (which is an IP address). I don&#39;t think this will work in the general case, but maybe you&#39;re using IP addresses as your domains?<br>4. I don&#39;t see the code that invokes route(6) -- I assume that is in a branch_route not the request route?<br>

<br>Good luck,<br>Kennard<br><br><div class="gmail_quote">On Tue, Nov 2, 2010 at 5:25 AM, Deon Vermeulen <span dir="ltr">&lt;<a href="mailto:vermeulen.deon@gmail.com">vermeulen.deon@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hi List<br>
<br>
I&#39;m trying to setup NAT to NOT use MediaProxy when it detects that 2<br>
devices are behind the same NAT Device, but rather have coms go<br>
directly between them.<br>
At the moment I can dial between the 2 phones and answer the call.<br>
The callee phone says &quot;Call Established&quot; upon answer, but the caller<br>
phone still says &quot;trying/connecting&quot;.<br>
I am sure this has something to do with my configuration, but I have<br>
&quot;NO IDEA&quot; where to start looking.<br>
The phones are setup to use their local IPs with no other STUN, ICE,<br>
or &quot;proxy like&quot; configurations.<br>
Below is a snipped from my opensips.cfg with the NAT configs and would<br>
really appreciate any help to get this working.<br>
<br>
modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>
modparam(&quot;registrar&quot;, &quot;received_avp&quot;, &quot;$avp(i:42)&quot;)<br>
modparam(&quot;usrloc&quot;, &quot;db_mode&quot;,   2)<br>
modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, 6)<br>
modparam(&quot;domain&quot;, &quot;db_mode&quot;, 1) # Use caching<br>
modparam(&quot;auth_db|usrloc|uri|avpops&quot;, &quot;use_domain&quot;, 1)<br>
modparam(&quot;auth_db|alias_db|domain|uri|uri_db|usrloc|permissions|<br>
siptrace|group|avpops|presence&quot;, &quot;db_url&quot;, &quot;mysql://<br>
opensips:opensipsrw@localhost/opensips&quot;)<br>
modparam(&quot;nathelper&quot;, &quot;natping_interval&quot;, 10)<br>
modparam(&quot;nathelper&quot;, &quot;received_avp&quot;, &quot;$avp(i:42)&quot;)<br>
modparam(&quot;mediaproxy&quot;, &quot;mediaproxy_socket&quot;, &quot;/var/run/mediaproxy-<br>
dispatcher.sock&quot;)<br>
modparam(&quot;mediaproxy&quot;, &quot;mediaproxy_timeout&quot;, 500)<br>
modparam(&quot;mi_datagram&quot;, &quot;socket_name&quot;, &quot;/var/run/opensips/<br>
opensips.sock&quot;)<br>
modparam(&quot;mi_datagram&quot;, &quot;children_count&quot;, 4)<br>
<br>
<br>
# -------------------------  request routing logic ------------------- #<br>
<br>
route{<br>
<br>
     #<br>
     # -- 1 -- Request Validation<br>
     #<br>
     if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>
         sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>
         exit;<br>
     }<br>
<br>
     if (msg:len &gt;=  2048 ) {<br>
         sl_send_reply(&quot;513&quot;, &quot;Message too big&quot;);<br>
         exit;<br>
     }<br>
<br>
     #<br>
     # -- 2 -- Routing Preprocessing<br>
     #<br>
     ## Record-route all except Register<br>
     ## Mark packets with nat=yes<br>
     ## This mark will be used to identify the request in the loose<br>
     ## route section<br>
     if(!is_method(&quot;REGISTER&quot;)){<br>
         if(nat_uac_test(&quot;19&quot;)){<br>
             record_route(&quot;;nat=yes&quot;);<br>
         } else {<br>
             record_route();<br>
         }<br>
     }<br>
<br>
     ##Loose_route packets<br>
     if (has_totag()) {<br>
         #sequential request withing a dialog should<br>
         # take the path determined by record-routing<br>
         if (loose_route()) {<br>
             #Check authentication of re-invites<br>
             if(method==&quot;INVITE&quot;) {<br>
                 if (!proxy_authorize(&quot;&quot;,&quot;subscriber&quot;)) {<br>
                 proxy_challenge(&quot;&quot;,&quot;1&quot;);<br>
                 exit;<br>
             } else if (!db_check_from()) {<br>
                 sl_send_reply(&quot;403&quot;, &quot;Forbidden, use From=ID&quot;);<br>
                 exit;<br>
             }<br>
         }<br>
                 ## BYE and CANCEL message handling<br>
         if(method==&quot;BYE&quot; || method==&quot;CANCEL&quot;) {<br>
             end_media_session();<br>
         }<br>
         ##Detect requests in the dialog behind NAT and flag with 6<br>
             if(nat_uac_test(&quot;19&quot;) || search(&quot;^Route:.*;nat=yes&quot;)){<br>
                 append_hf(&quot;P-hint: LR|fixcontact,setflag6, mediaproxy<br>
\r\n&quot;);<br>
                 fix_contact();<br>
                 setbflag(6);<br>
                 use_media_proxy();<br>
             }<br>
             route(1);<br>
         } else {<br>
             sl_send_reply(&quot;404&quot;,&quot;Not here&quot;);<br>
         }<br>
         exit;<br>
     }<br>
<br>
     #CANCEL processing<br>
     if (is_method(&quot;CANCEL&quot;)) {<br>
         if (t_check_trans()) {<br>
             end_media_session();<br>
             t_relay();<br>
         }<br>
         exit;<br>
     }<br>
<br>
     t_check_trans();<br>
<br>
     #<br>
     # -- 3 -- Determine Request Target<br>
     #<br>
     if (method==&quot;REGISTER&quot;) {<br>
         route(2);<br>
     } else {<br>
         route(3);<br>
     }<br>
}<br>
<br>
<br>
route[1] {<br>
     #<br>
     # -- 4 -- Forward request to target<br>
     #<br>
     # Forward statefully<br>
     t_on_reply(&quot;1&quot;);<br>
     t_on_failure(&quot;1&quot;);<br>
     if (!t_relay()) {<br>
         sl_reply_error();<br>
     }<br>
     exit;<br>
}<br>
<br>
route[2] {<br>
     ## Register request handler<br>
     if (is_uri_host_local()) {<br>
         if (!www_authorize(&quot;&quot;, &quot;subscriber&quot;)) {<br>
             www_challenge(&quot;&quot;, &quot;1&quot;);<br>
             exit;<br>
         }<br>
<br>
         if (!db_check_to()) {<br>
             sl_send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>
             exit;<br>
         }<br>
<br>
            # Test to see if Caller is behind NAT<br>
         if(!search(&quot;^Contact:[ ]*\*&quot;) &amp;&amp; client_nat_test(&quot;7&quot;)) {<br>
             setbflag(6);<br>
             fix_nated_register();<br>
             force_rport();<br>
         }<br>
         save(&quot;location&quot;);<br>
         exit;<br>
<br>
     } else {<br>
         sl_send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>
     }<br>
}<br>
<br>
<br>
route[3] {<br>
     ## Requests handler<br>
     if (is_from_local()){<br>
         # From an internal domain -&gt; check the credentials and the FROM<br>
         #if(!allow_trusted()){<br>
             if (!proxy_authorize(&quot;&quot;,&quot;subscriber&quot;)) {<br>
                 proxy_challenge(&quot;&quot;,&quot;0&quot;);<br>
                 exit;<br>
             } else if(!db_check_from()) {<br>
             sl_send_reply(&quot;403&quot;, &quot;Forbidden, use From=ID&quot;);<br>
             exit;<br>
         }<br>
<br>
         if (client_nat_test(&quot;3&quot;)) {<br>
             append_hf(&quot;P-hint: route(3)|<br>
setflag7,forcerport,fix_contact\r\n&quot;);<br>
             setbflag(7);<br>
             force_rport();<br>
             fix_contact();<br>
         }<br>
<br>
..............<br>
<br>
route[6] {<br>
     #<br>
     # -- NAT Traversal handling --<br>
     #<br>
     # Route[6] is the routing block responsible for activating the<br>
MediaProxy, whenever<br>
     # the caller or callee is behind NAT (flags 6 or 7 respectively).<br>
     if (isbflagset(6) || isbflagset(7)) {<br>
            if ( $dd == $si ) {<br>
                    xlog(&quot;L_INFO&quot;, &quot;Both users behind same NAT, so we<br>
dont use MediaProxy\n&quot;);<br>
                    resetbflag(6);  # Unset NAT flag general.<br>
                    resetbflag(7);  # Unset NAT flag general.<br>
         } else<br>
         append_hf(&quot;P-hint: Route[6]: mediaproxy \r\n&quot;);<br>
         use_media_proxy();<br>
     }<br>
}<br>
<br>
.............<br>
<br>
onreply_route[1] {<br>
#<br>
#-- On-replay block routing --<br>
#<br>
     if (client_nat_test(&quot;1&quot;)) {<br>
         append_hf(&quot;P-hint: Onreply-route - fixcontact \r\n&quot;);<br>
         fix_contact();<br>
     }<br>
<br>
     if ((isbflagset(6) || isbflagset(7)) &amp;&amp; (status=~&quot;(180)|(183)|<br>
2[0-9][0-9]&quot;)) {<br>
         if (search(&quot;^Content-Type:[ ]*application/sdp&quot;)) {<br>
             append_hf(&quot;P-hint: onreply_route|usemediaproxy \r\n&quot;);<br>
         use_media_proxy();<br>
         }<br>
     }<br>
     exit;<br>
}<br>
<br>
<br>
Thanks again for helping. Really appreciate it.<br>
<br>
Regards<br>
Deon<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div><br>