Hi Deon,<br><br>For better or worse there are many ways to configure opensips depending upon exactly what you are doing. Re your route6, it should be invoked from some branch route. One way branch routes are established is using t_on_branch(). Your route(3) (or somewhere) must be doing a lookup() and establish a branch route.<br>

<br>As someone else said, a key question with what you&#39;re trying to do is: is your network an open or closed environment? If open environment (where you cannot control/know the networks where your users are) then non-ICE short-circuiting media relay will fail for people behind non-hairpinning firewalls or double firewalls. ICE (and yes, full ICE, not just STUN) is more robust way of avoiding media-relay when not needed. Of course, it has its own issues :-).<br>

<br>Kennard<br><br><div class="gmail_quote">On Tue, Nov 2, 2010 at 11:11 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 Kennard<br>
<br>
Thanks for the ideas.<br>
I really appreciate it.<br>
<br>
I got the config as an example from the Building Telephony systems<br>
with OpenSER.<br>
I choose the OpenSER implementation as it describes the implenetation<br>
of MediaProxy.<br>
Reason for choosing MediaProxy is because I am very, very interested<br>
in getting the ICE feature.<br>
<br>
I thought best to first get this config working before playing around<br>
with the ICE configuration.<br>
<br>
Could you be so kind and perhaps show me where I should call up<br>
route(6)?<br>
<br>
I use fully qualified domain names (i.e <a href="http://domaina.com" target="_blank">domaina.com</a>) for the domain.<br>
At the moment I specify the proxy with the IP of my Server as I<br>
haven&#39;t setup the DNS records yet.<br>
<br>
I really appreciate your feedback and assistance.<br>
<br>
Regards<br>
<font color="#888888">Deon<br>
</font><div><div></div><div class="h5"><br>
<br>
On 02 Nov 2010, at 5:08 PM, Kennard White wrote:<br>
<br>
&gt; Hi Deon,<br>
&gt;<br>
&gt; Some ideas:<br>
&gt; 1. Capture the SIP traffic and see if media proxy is being invoked<br>
&gt; in the request and/or response (look for your P-hint messages), and<br>
&gt; the IP addresses.<br>
&gt; 2. Add xlog messages when you invoke mediarelay to confirm that they<br>
&gt; are getting called.<br>
&gt; 3. You&#39;re comparing $dd (which is a domain) to $si (which is an IP<br>
&gt; address). I don&#39;t think this will work in the general case, but<br>
&gt; maybe you&#39;re using IP addresses as your domains?<br>
&gt; 4. I don&#39;t see the code that invokes route(6) -- I assume that is in<br>
&gt; a branch_route not the request route?<br>
&gt;<br>
&gt; Good luck,<br>
&gt; Kennard<br>
&gt;<br>
&gt; On Tue, Nov 2, 2010 at 5:25 AM, Deon Vermeulen &lt;<a href="mailto:vermeulen.deon@gmail.com">vermeulen.deon@gmail.com</a><br>
&gt; &gt; wrote:<br>
&gt; Hi List<br>
&gt;<br>
&gt; I&#39;m trying to setup NAT to NOT use MediaProxy when it detects that 2<br>
&gt; devices are behind the same NAT Device, but rather have coms go<br>
&gt; directly between them.<br>
&gt; At the moment I can dial between the 2 phones and answer the call.<br>
&gt; The callee phone says &quot;Call Established&quot; upon answer, but the caller<br>
&gt; phone still says &quot;trying/connecting&quot;.<br>
&gt; I am sure this has something to do with my configuration, but I have<br>
&gt; &quot;NO IDEA&quot; where to start looking.<br>
&gt; The phones are setup to use their local IPs with no other STUN, ICE,<br>
&gt; or &quot;proxy like&quot; configurations.<br>
&gt; Below is a snipped from my opensips.cfg with the NAT configs and would<br>
&gt; really appreciate any help to get this working.<br>
&gt;<br>
&gt; modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>
&gt; modparam(&quot;registrar&quot;, &quot;received_avp&quot;, &quot;$avp(i:42)&quot;)<br>
&gt; modparam(&quot;usrloc&quot;, &quot;db_mode&quot;,   2)<br>
&gt; modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, 6)<br>
&gt; modparam(&quot;domain&quot;, &quot;db_mode&quot;, 1) # Use caching<br>
&gt; modparam(&quot;auth_db|usrloc|uri|avpops&quot;, &quot;use_domain&quot;, 1)<br>
&gt; modparam(&quot;auth_db|alias_db|domain|uri|uri_db|usrloc|permissions|<br>
&gt; siptrace|group|avpops|presence&quot;, &quot;db_url&quot;, &quot;mysql://<br>
&gt; opensips:opensipsrw@localhost/opensips&quot;)<br>
&gt; modparam(&quot;nathelper&quot;, &quot;natping_interval&quot;, 10)<br>
&gt; modparam(&quot;nathelper&quot;, &quot;received_avp&quot;, &quot;$avp(i:42)&quot;)<br>
&gt; modparam(&quot;mediaproxy&quot;, &quot;mediaproxy_socket&quot;, &quot;/var/run/mediaproxy-<br>
&gt; dispatcher.sock&quot;)<br>
&gt; modparam(&quot;mediaproxy&quot;, &quot;mediaproxy_timeout&quot;, 500)<br>
&gt; modparam(&quot;mi_datagram&quot;, &quot;socket_name&quot;, &quot;/var/run/opensips/<br>
&gt; opensips.sock&quot;)<br>
&gt; modparam(&quot;mi_datagram&quot;, &quot;children_count&quot;, 4)<br>
&gt;<br>
&gt;<br>
&gt; # -------------------------  request routing logic<br>
&gt; ------------------- #<br>
&gt;<br>
&gt; route{<br>
&gt;<br>
&gt;     #<br>
&gt;     # -- 1 -- Request Validation<br>
&gt;     #<br>
&gt;     if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>
&gt;         sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>
&gt;         exit;<br>
&gt;     }<br>
&gt;<br>
&gt;     if (msg:len &gt;=  2048 ) {<br>
&gt;         sl_send_reply(&quot;513&quot;, &quot;Message too big&quot;);<br>
&gt;         exit;<br>
&gt;     }<br>
&gt;<br>
&gt;     #<br>
&gt;     # -- 2 -- Routing Preprocessing<br>
&gt;     #<br>
&gt;     ## Record-route all except Register<br>
&gt;     ## Mark packets with nat=yes<br>
&gt;     ## This mark will be used to identify the request in the loose<br>
&gt;     ## route section<br>
&gt;     if(!is_method(&quot;REGISTER&quot;)){<br>
&gt;         if(nat_uac_test(&quot;19&quot;)){<br>
&gt;             record_route(&quot;;nat=yes&quot;);<br>
&gt;         } else {<br>
&gt;             record_route();<br>
&gt;         }<br>
&gt;     }<br>
&gt;<br>
&gt;     ##Loose_route packets<br>
&gt;     if (has_totag()) {<br>
&gt;         #sequential request withing a dialog should<br>
&gt;         # take the path determined by record-routing<br>
&gt;         if (loose_route()) {<br>
&gt;             #Check authentication of re-invites<br>
&gt;             if(method==&quot;INVITE&quot;) {<br>
&gt;                 if (!proxy_authorize(&quot;&quot;,&quot;subscriber&quot;)) {<br>
&gt;                 proxy_challenge(&quot;&quot;,&quot;1&quot;);<br>
&gt;                 exit;<br>
&gt;             } else if (!db_check_from()) {<br>
&gt;                 sl_send_reply(&quot;403&quot;, &quot;Forbidden, use From=ID&quot;);<br>
&gt;                 exit;<br>
&gt;             }<br>
&gt;         }<br>
&gt;                 ## BYE and CANCEL message handling<br>
&gt;         if(method==&quot;BYE&quot; || method==&quot;CANCEL&quot;) {<br>
&gt;             end_media_session();<br>
&gt;         }<br>
&gt;         ##Detect requests in the dialog behind NAT and flag with 6<br>
&gt;             if(nat_uac_test(&quot;19&quot;) || search(&quot;^Route:.*;nat=yes&quot;)){<br>
&gt;                 append_hf(&quot;P-hint: LR|fixcontact,setflag6, mediaproxy<br>
&gt; \r\n&quot;);<br>
&gt;                 fix_contact();<br>
&gt;                 setbflag(6);<br>
&gt;                 use_media_proxy();<br>
&gt;             }<br>
&gt;             route(1);<br>
&gt;         } else {<br>
&gt;             sl_send_reply(&quot;404&quot;,&quot;Not here&quot;);<br>
&gt;         }<br>
&gt;         exit;<br>
&gt;     }<br>
&gt;<br>
&gt;     #CANCEL processing<br>
&gt;     if (is_method(&quot;CANCEL&quot;)) {<br>
&gt;         if (t_check_trans()) {<br>
&gt;             end_media_session();<br>
&gt;             t_relay();<br>
&gt;         }<br>
&gt;         exit;<br>
&gt;     }<br>
&gt;<br>
&gt;     t_check_trans();<br>
&gt;<br>
&gt;     #<br>
&gt;     # -- 3 -- Determine Request Target<br>
&gt;     #<br>
&gt;     if (method==&quot;REGISTER&quot;) {<br>
&gt;         route(2);<br>
&gt;     } else {<br>
&gt;         route(3);<br>
&gt;     }<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; route[1] {<br>
&gt;     #<br>
&gt;     # -- 4 -- Forward request to target<br>
&gt;     #<br>
&gt;     # Forward statefully<br>
&gt;     t_on_reply(&quot;1&quot;);<br>
&gt;     t_on_failure(&quot;1&quot;);<br>
&gt;     if (!t_relay()) {<br>
&gt;         sl_reply_error();<br>
&gt;     }<br>
&gt;     exit;<br>
&gt; }<br>
&gt;<br>
&gt; route[2] {<br>
&gt;     ## Register request handler<br>
&gt;     if (is_uri_host_local()) {<br>
&gt;         if (!www_authorize(&quot;&quot;, &quot;subscriber&quot;)) {<br>
&gt;             www_challenge(&quot;&quot;, &quot;1&quot;);<br>
&gt;             exit;<br>
&gt;         }<br>
&gt;<br>
&gt;         if (!db_check_to()) {<br>
&gt;             sl_send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>
&gt;             exit;<br>
&gt;         }<br>
&gt;<br>
&gt;            # Test to see if Caller is behind NAT<br>
&gt;         if(!search(&quot;^Contact:[ ]*\*&quot;) &amp;&amp; client_nat_test(&quot;7&quot;)) {<br>
&gt;             setbflag(6);<br>
&gt;             fix_nated_register();<br>
&gt;             force_rport();<br>
&gt;         }<br>
&gt;         save(&quot;location&quot;);<br>
&gt;         exit;<br>
&gt;<br>
&gt;     } else {<br>
&gt;         sl_send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>
&gt;     }<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; route[3] {<br>
&gt;     ## Requests handler<br>
&gt;     if (is_from_local()){<br>
&gt;         # From an internal domain -&gt; check the credentials and the<br>
&gt; FROM<br>
&gt;         #if(!allow_trusted()){<br>
&gt;             if (!proxy_authorize(&quot;&quot;,&quot;subscriber&quot;)) {<br>
&gt;                 proxy_challenge(&quot;&quot;,&quot;0&quot;);<br>
&gt;                 exit;<br>
&gt;             } else if(!db_check_from()) {<br>
&gt;             sl_send_reply(&quot;403&quot;, &quot;Forbidden, use From=ID&quot;);<br>
&gt;             exit;<br>
&gt;         }<br>
&gt;<br>
&gt;         if (client_nat_test(&quot;3&quot;)) {<br>
&gt;             append_hf(&quot;P-hint: route(3)|<br>
&gt; setflag7,forcerport,fix_contact\r\n&quot;);<br>
&gt;             setbflag(7);<br>
&gt;             force_rport();<br>
&gt;             fix_contact();<br>
&gt;         }<br>
&gt;<br>
&gt; ..............<br>
&gt;<br>
&gt; route[6] {<br>
&gt;     #<br>
&gt;     # -- NAT Traversal handling --<br>
&gt;     #<br>
&gt;     # Route[6] is the routing block responsible for activating the<br>
&gt; MediaProxy, whenever<br>
&gt;     # the caller or callee is behind NAT (flags 6 or 7 respectively).<br>
&gt;     if (isbflagset(6) || isbflagset(7)) {<br>
&gt;            if ( $dd == $si ) {<br>
&gt;                    xlog(&quot;L_INFO&quot;, &quot;Both users behind same NAT, so we<br>
&gt; dont use MediaProxy\n&quot;);<br>
&gt;                    resetbflag(6);  # Unset NAT flag general.<br>
&gt;                    resetbflag(7);  # Unset NAT flag general.<br>
&gt;         } else<br>
&gt;         append_hf(&quot;P-hint: Route[6]: mediaproxy \r\n&quot;);<br>
&gt;         use_media_proxy();<br>
&gt;     }<br>
&gt; }<br>
&gt;<br>
&gt; .............<br>
&gt;<br>
&gt; onreply_route[1] {<br>
&gt; #<br>
&gt; #-- On-replay block routing --<br>
&gt; #<br>
&gt;     if (client_nat_test(&quot;1&quot;)) {<br>
&gt;         append_hf(&quot;P-hint: Onreply-route - fixcontact \r\n&quot;);<br>
&gt;         fix_contact();<br>
&gt;     }<br>
&gt;<br>
&gt;     if ((isbflagset(6) || isbflagset(7)) &amp;&amp; (status=~&quot;(180)|(183)|<br>
&gt; 2[0-9][0-9]&quot;)) {<br>
&gt;         if (search(&quot;^Content-Type:[ ]*application/sdp&quot;)) {<br>
&gt;             append_hf(&quot;P-hint: onreply_route|usemediaproxy \r\n&quot;);<br>
&gt;         use_media_proxy();<br>
&gt;         }<br>
&gt;     }<br>
&gt;     exit;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; Thanks again for helping. Really appreciate it.<br>
&gt;<br>
&gt; Regards<br>
&gt; Deon<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<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>
</div></div></blockquote></div><br>