No subject


Fri Sep 2 03:59:05 CDT 2011


I have some devices in the following scenario:

Asterisk server with public IP address
Mobile devices (clients):

When in internal network, no NAT between the client and the server
When in "roaming" (i.e. a Hotel with WiFi), the client is behing a NAT
When in 3G, operator transparent sip proxy so it looks as no NAT, but does =
not support symmetric RTP.
Sometime, the device gets a public IP with no NAT at all.
No NAT setting available in asterisk works for all these scenarios at the s=
ame time, and I can not request the user to activate different accounts dep=
ending on its location.

I have added a new NAT setting (nat=3Dauto) to the current ones. When set, =
chan_sip auto detects from the Via header, the recv sockaddr, and the rport=
 setting if the client is behind a NAT.

It also adds to cli interface results (sip show peer/s) info on this (so no=
w you could see "N" for NAT and nothing for no NAT as before, "a" for auto =
detect no NAT, and "A" for autodetect NAT.


This addresses bug ASTERISK-17860.
    https://issues.asterisk.org/jira/browse/ASTERISK-17860


Diffs (updated)
-----

  /trunk/configs/sip.conf.sample 354465 =

  /trunk/channels/sip/config_parser.c 354465 =

  /trunk/channels/sip/include/config_parser.h 354465 =

  /trunk/channels/sip/include/sip.h 354465 =

  /trunk/channels/sip/include/sip_utils.h 354465 =

  /trunk/channels/sip/utils.c PRE-CREATION =

  /trunk/CHANGES 354465 =

  /trunk/channels/chan_sip.c 354465 =


Diff: https://reviewboard.asterisk.org/r/1698/diff


Testing
-------

Lots of reloads with changing values, and registry natted and un-natted pho=
nes. I also set the nat_supertest in testsuite to run with nat=3Dauto to ma=
ke sure that it responded the same with existing and non-existing peers.


Thanks,

Terry


--===============7839930294606650385==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable




<html>
 <body>
  <div style=3D"font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor=3D"#f9f3c9" width=3D"100%" cellpadding=3D"8" style=3D"bor=
der: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href=3D"https://reviewboard.asterisk.org/r/1698/">https://reviewbo=
ard.asterisk.org/r/1698/</a>
     </td>
    </tr>
   </table>
   <br />


<table bgcolor=3D"#fefadf" width=3D"100%" cellspacing=3D"0" cellpadding=3D"=
8" style=3D"background-image: url('https://reviewboard.asterisk.org/media/r=
b/images/review_request_box_top_bg.png'); background-position: left top; ba=
ckground-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers.</div>
<div>By Terry Wilson.</div>


<p style=3D"color: grey;"><i>Updated Feb. 8, 2012, 11:34 p.m.</i></p>



<h1 style=3D"color: #575012; font-size: 10pt; margin-top: 1.5em;">Changes</=
h1>
<table width=3D"100%" bgcolor=3D"#ffffff" cellspacing=3D"0" cellpadding=3D"=
10" style=3D"border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style=3D"margin: 0; padding: 0; white-space: pre-wrap; white-space:=
 -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap=
: break-word;">Implement changes proposed by Kevin Fleming here: http://lis=
ts.digium.com/pipermail/asterisk-dev/2012-February/053586.html

The nat=3D setting is now a comma separated list of combinable options. nat=
=3Dyes, while handled, is now an undocumented option replaced by nat=3Dforc=
e_rport,comedia. That nat=3Dauto option has been split into nat=3Dauto_forc=
e_rport,auto_comedia. When parsing that nat=3D line, the first &#39;yes&#39=
; or &#39;no&#39; will cause parsing to stop and override any previous opti=
ons. If an auto_ option is set at the same time its non-auto_ counterpart i=
s set, the auto setting is honored.

I added some helper functions for displaying the textual output of the forc=
e_rport and comedia options for CLI use. They are declared in the existing =
channels/sip/include/sip_utils.h file, but implemented in a new file channe=
ls/sip/utils.c. There are several other functions in that header that shoul=
d probably be moved over from chan_sip.c later.

The parser function for the nat=3D setting was added to channels/sip/config=
_parser.c. I added a unit test for it as well.</pre>
  </td>
 </tr>
</table>


<h1 style=3D"color: #575012; font-size: 10pt; margin-top: 1.5em;">Descripti=
on </h1>
<table width=3D"100%" bgcolor=3D"#ffffff" cellspacing=3D"0" cellpadding=3D"=
10" style=3D"border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style=3D"margin: 0; padding: 0; white-space: pre-wrap; white-space:=
 -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap=
: break-word;">First, this patch as originally posted is from JIRA user ped=
ro-garcia. It has been in JIRA for a long while, and has finally come up to=
 be considered. There were some changes that I wanted to made to the origin=
al patch, so I tried contacting the author to get them to put the patch on =
reviewboard, but after a week I got no response. So, I&#39;m putting the or=
iginal patch up, then will immediately add a review with my changes. Many t=
hanks to pedro-garcia for his contribution.



More information about the asterisk-dev mailing list