<div dir="ltr">Why don't you use "nat_uac_test()" when you receive a request to examine NAT? Using nat_uac_tes() you can tell if the message is coming from a client behind the nat or not. With lookup and the nat_bflg, you can tell if the destination is behind a nat. They are two different things.<div>
<br></div><div>Regards,</div><div>Ali Pey<br><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 25, 2013 at 11:40 PM, dpa <span dir="ltr"><<a href="mailto:denis7979@mail.ru" target="_blank">denis7979@mail.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="RU" link="blue" vlink="purple"><div><p class="MsoNormal">
<span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">“</span><span lang="EN-US">What is it that you are trying to do?</span><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">”<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I try to check if message came from behind NAT or not and make some actions depending on result of checking.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">To speak the truth I tried to include in opensips.cfg logic about direction of the call.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">What I thought. I thought that nat_bflag activated only after lookup() function processing, i.e. when call goes TO UAC behind NAT and NOT activated when call came FROM UAC behind NAT. So in onreply route I make the test about this flag and waiting (in my current case) that the test of natb_flag will be failed.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif"> <a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a> [mailto:<a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a>] <b>On Behalf Of </b>Ali Pey<br>
<b>Sent:</b> Tuesday, November 26, 2013 8:16 AM</span></p><div><div class="h5"><br><b>To:</b> OpenSIPS users mailling list<br><b>Subject:</b> Re: [OpenSIPS-Users] Opensips 1.9.1 and NAT<u></u><u></u></div></div><p></p><div>
<div class="h5"><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><div><p class="MsoNormal">As I said earlier, there is no such a thing as FROM or TO (i.e. direction) unless it's implemented in your logic. When a SIP request reaches the IP address of your opensips server, it goes through your routing script in opensips.cfg and then it's routed out. What you have there, it would apply to the request message. Put yourself in opensips shoes and follow the logic - that's how we debugged code while at uni :)<u></u><u></u></p>
<div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">If you have a concept of direction and you need different behavior based on your concept of direction, you need to implement it in your logic. For instance you can examine the source IP or subnet to decide if this message is from internal or external and then apply different logic to it - or whatever else that is specific to your environment. <u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">What is it that you are trying to do?<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">
Regards,<u></u><u></u></p></div><div><p class="MsoNormal">Ali Pey<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Mon, Nov 25, 2013 at 10:52 PM, dpa <<a href="mailto:denis7979@mail.ru" target="_blank">denis7979@mail.ru</a>> wrote:<u></u><u></u></p>
<div><div><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">OK, but in the current case another question.</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Is nat_bflag appear in transaction when call goes TO uac behind nat (by using lookup(), for example), or it appears in transaction when call goes FROM uac behind nat?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Thank you.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> <a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a> [mailto:<a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a>] <b>On Behalf Of </b>Ali Pey<br>
<b>Sent:</b> Monday, November 25, 2013 8:38 PM</span><u></u><u></u></p><div><div><p class="MsoNormal"><br><b>To:</b> OpenSIPS users mailling list<br><b>Subject:</b> Re: [OpenSIPS-Users] Opensips 1.9.1 and NAT<u></u><u></u></p>
</div></div><div><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">You also examining <span style="font-size:10.5pt;font-family:'Courier New'">isbflagset(10)</span>. Isn't that set?<u></u><u></u></p>
<div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">Regards,<u></u><u></u></p></div><div><p class="MsoNormal">Ali Pey<u></u><u></u></p></div><div><p class="MsoNormal" style="margin-bottom:12pt"> <u></u><u></u></p>
<div><p class="MsoNormal">On Mon, Nov 25, 2013 at 3:09 AM, dpa <<a href="mailto:denis7979@mail.ru" target="_blank">denis7979@mail.ru</a>> wrote:<u></u><u></u></p><div><div><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hello</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I understand but in onreply route I make a test:</span><span lang="EN-US"> </span><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">nat_uac_test("55") and only if it successful I make “</span><span lang="EN-US" style="font-size:10.5pt;font-family:'Courier New'">fix_nated_contact()</span><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">”.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">In my case nat_uac_test("55") must be fail after checking 183 ringing and 200 OK.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> <a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a> [mailto:<a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a>] <b>On Behalf Of </b>Ali Pey<br>
<b>Sent:</b> Friday, November 22, 2013 5:37 PM<br><b>To:</b> OpenSIPS users mailling list<br><b>Subject:</b> Re: [OpenSIPS-Users] Opensips 1.9.1 and NAT</span><u></u><u></u></p><div><div><p class="MsoNormal"> <u></u><u></u></p>
<div><p class="MsoNormal">Hello,<u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">The question is not quite clear. In your opensips.cfg you call "<span style="font-size:10.5pt;font-family:'Courier New'">fix_nated_contact()" on both route and reply route. that's why it changes the route.</span><u></u><u></u></p>
</div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><div><p class="MsoNormal">There is no such a thing as direction in opensips unless it's implemented in your logic. A message goes through your route or reply route scripts when it reaches opensips. <u></u><u></u></p>
</div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Regards,<u></u><u></u></p></div><div><p class="MsoNormal">Ali<u></u><u></u></p></div><div><p class="MsoNormal" style="margin-bottom:12pt">
<u></u><u></u></p><div><p class="MsoNormal">On Fri, Nov 22, 2013 at 1:10 AM, dpa <<a href="mailto:denis7979@mail.ru" target="_blank">denis7979@mail.ru</a>> wrote:<u></u><u></u></p><div><p class="MsoNormal"><img border="0" width="39" height="38" src="cid:image001.gif@01CEEA80.9BF56FF0"><u></u><u></u></p>
<div><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">Hello</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">I have a one question about nat processing of Opensips.</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">There is such scheme</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">UAC1 (softphone behind nat) </span><span lang="EN-US" style="font-size:11pt;font-family:Wingdings">à</span><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> Opensips -> UAC2 (another softswitch), i.e. UAC1 initiates a call to Opensips and a signaling port = 5068.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">So UAC2 becomes “ringing” by sending 183 message.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">In attachment 183 message from UAC2 and some parts of opensips.cfg</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">After 183 processing by Opensips port in Contact header of 183 (and later 200 OK) messages become 5060, i.e. Opensips detects NAT and changes Contact header.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">So my question is, Why does Opensips changes Contact header?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">Once Opensips detects nat transaction (setting setflag(21)) is it check all reply messages (and doesn`t matter from which UAC they have been received) or Opensips can detect direction and makes decision about nat process?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">Thank you for any help.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p></div></div><p class="MsoNormal" style="margin-bottom:12pt"><br>_______________________________________________<br>
Users mailing list<br><a href="mailto:Users@lists.opensips.org" target="_blank">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><u></u><u></u></p>
</div><p class="MsoNormal"> <u></u><u></u></p></div></div></div></div></div></div></div><p class="MsoNormal" style="margin-bottom:12pt"><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.opensips.org" target="_blank">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><u></u><u></u></p></div><p class="MsoNormal"> <u></u><u></u></p></div><p class="MsoNormal">
<u></u><u></u></p></div></div></div></div></div></div><p class="MsoNormal" style="margin-bottom:12pt"><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.opensips.org" target="_blank">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><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">
<img border="0"><u></u><u></u></p></div></div></div></div></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" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div><img class="" src="https://contactmonkey.com/api/v1/tracker?cm_session=638d03d2-30e2-4b93-824d-92bb818466db&cm_type=open&cm_user_email=alipey@gmail.com"></div></div>