<div dir="ltr">Here is simple way to check NAT devices:<br><div><span class="" style="white-space:pre">        </span>if ( search_body('IN IP4 10.') )<span class="" style="white-space:pre">         </span>{ setflag(NAT); }</div><div><span class="" style="white-space:pre">        </span>if ( search_body("IN IP4 192.168.") )<span style="white-space:pre"> </span>{ setflag(NAT); }</div><div><span class="" style="white-space:pre">        </span>if ( search_body("IN IP4 172.16.") )<span class="" style="white-space:pre">         </span>{ setflag(NAT); }</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-04 19:31 GMT+02:00 Rodrigo Pimenta Carvalho <span dir="ltr"><<a href="mailto:pimenta@inatel.br" target="_blank">pimenta@inatel.br</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi.</p>
<p><br>
</p>
<p>Nowadays I'm having problems to take right control of SIP messages, in a situation with user agents present in the LAN and WAN (some of them are behind NAT, to the point of view of OpenSIPS).</p>
<p>To control everything, I'm using local domain and public domain registered in the Domain table. In addiction I intend to implement the following algorithm:</p>
<p><br>
</p>
<br>
<p>If message == SIP INVITE </p>
<p>{</p>
<p><span> </span>//Tries to guess if client's request originated behind a nat. The parameter determines what heuristics is used</p>
<p><span> </span>// <span><em>2</em></span> - the "received" test is used: address in Via is compared against source IP address of signaling .</p>
<p><span> </span>// <span><em>32</em></span> - address in Contact is compared against source IP address of signaling.<br>
</p>
<p><span> </span>If ( ! nat_uac_test(2 + 32))</p>
<p><span> </span>{</p>
<p><span> </span><span> </span>//caller is in local network</p>
<p><br>
</p>
<p><span> </span><span> <span style="color:rgb(0,111,201)">If callee is behind a NAT from the point of view of opensips</span></span></p>
<p><span> </span><span> </span>{</p>
<p> avp_db_query("select domain from domain where attrs = public", "$avp(DOMAIN)");<br>
</p>
<p><span> </span><span> </span><span> </span>set_advertised_address ("$avp(DOMAIN));<br>
</p>
<p><span> </span><span> </span>}</p>
<p><span> </span><span> </span>else</p>
<p><span> </span><span> </span>{</p>
<p><span> </span><span> </span><span> avp_db_query("select domain from domain where attrs = local", "$avp(DOMAIN)");<br>
<span> </span><span> </span><span> </span>set_advertised_address ("$avp(DOMAIN));</span><br>
</p>
<p><span> </span><span> </span>}<br>
</p>
<p><span> </span>}</p>
<p><span> </span>else</p>
<p><span> </span>{</p>
<p><span> </span><span> avp_db_query("select domain from domain where attrs = public", "$avp(DOMAIN)");<br>
<span> </span><span> </span><span></span>set_advertised_address ("$avp(DOMAIN));</span><br>
</p>
<p><span> </span>}<br>
</p>
<p>}</p>
<br>
<p>However, how can I know whether the callee is not in the same network area as the caller, so the callee is behind a NAT?</p>
<p><br>
</p>
<p>Any hint will be very helpful!<span class="HOEnZb"><font color="#888888"><br>
</font></span></p><span class="HOEnZb"><font color="#888888">
<p><br>
</p>
<div>
<div name="divtagdefaultwrapper">
<div><font size="2">
<div>RODRIGO PIMENTA CARVALHO<br>
Inatel Competence Center<br>
Software<br>
Ph: <a href="tel:%2B55%2035%203471%209200" value="+553534719200" target="_blank">+55 35 3471 9200</a> RAMAL 979<br>
</div>
</font></div>
</div>
</div>
</font></span></div>
</div>
<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" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>