<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Georgia;
        panose-1:2 4 5 2 5 4 5 2 3 3;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
h1
        {mso-style-priority:9;
        mso-style-link:"Heading 1 Char";
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:24.0pt;
        font-family:"Times New Roman","serif";
        font-weight:bold;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Consolas","serif";}
span.n
        {mso-style-name:n;}
span.p
        {mso-style-name:p;}
span.mi
        {mso-style-name:mi;}
span.s
        {mso-style-name:s;}
span.se
        {mso-style-name:se;}
span.Heading1Char
        {mso-style-name:"Heading 1 Char";
        mso-style-priority:9;
        mso-style-link:"Heading 1";
        font-family:"Cambria","serif";
        color:#365F91;
        font-weight:bold;}
span.EmailStyle26
        {mso-style-type:personal-reply;
        font-family:"Georgia","serif";
        color:#1F497D;
        font-weight:normal;
        font-style:normal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1043604151;
        mso-list-template-ids:-117671264;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:"Courier New";
        mso-bidi-font-family:"Times New Roman";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'>This is a really useful patch! <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'>One question:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'>Would nat=auto be valid for the [general] context of sip.conf as well?  Or should this always be explicitly yes/no.  I ask because after the recent vulnerability related to having disparate nat= settings for peers I haven't been setting the nat= value per-peer, and instead set it once at [general].<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'>Luke<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> asterisk-dev-bounces@lists.digium.com [mailto:asterisk-dev-bounces@lists.digium.com] <b>On Behalf Of </b>Simon Perreault<br><b>Sent:</b> Friday, January 27, 2012 8:55 AM<br><b>To:</b> Simon Perreault; Terry Wilson; Asterisk Developers<br><b>Subject:</b> Re: [asterisk-dev] [Code Review] Add a SIP nat=auto setting<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><table class=MsoNormalTable border=1 cellpadding=0 width="100%" style='width:100.0%;background:#F9F3C9;border:solid #C9C399 1.0pt'><tr><td style='border:none;padding:6.0pt 6.0pt 6.0pt 6.0pt'><p class=MsoNormal>This is an automatically generated e-mail. To reply, visit: <a href="https://reviewboard.asterisk.org/r/1698/">https://reviewboard.asterisk.org/r/1698/</a> <o:p></o:p></p></td></tr></table><p class=MsoNormal><span style='font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p><p><span style='font-family:"Verdana","sans-serif"'>Ship it!<o:p></o:p></span></p><pre style='white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap: break-word'>Looks good.<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>It is similar to what Cisco SBC does:<o:p></o:p></pre><pre><a href="http://www.cisco.com/en/US/docs/routers/asr1000/configuration/guide/sbcu/sbc_nat.html#wp1000953">http://www.cisco.com/en/US/docs/routers/asr1000/configuration/guide/sbcu/sbc_nat.html#wp1000953</a><o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>Could nat=auto become the new default?<o:p></o:p></pre><p class=MsoNormal><span style='font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p><div><table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width="100%" style='width:100.0%;background:white;border-collapse:collapse;border:none;margin:padding: 2px'><thead><tr><td colspan=4 style='border:solid silver 1.0pt;background:#E4D9CB;padding:3.0pt 6.0pt 3.0pt 6.0pt'><p class=MsoNormal><b><span style='font-size:9.0pt'><a href="https://reviewboard.asterisk.org/r/1698/diff/2/?file=23678#file23678line16228"><span style='color:black'>/trunk/channels/chan_sip.c</span></a> </span></b><span style='font-size:9.0pt'>(Diff revision 2) <b><o:p></o:p></b></span></p></td></tr></thead><tr><td colspan=4 style='border-top:none;border-left:solid silver 1.0pt;border-bottom:none;border-right:solid silver 1.0pt;padding:.75pt .75pt .75pt .75pt'><pre style='text-align:center;line-height:140%'><span style='font-size:8.0pt;line-height:140%'>static void check_via(struct sip_pvt *p, struct sip_request *req)<o:p></o:p></span></pre></td></tr><tr><td style='border:solid silver 1.0pt;border-top:none;background:#B1EBB0;padding:.75pt .75pt .75pt .75pt'></td><td width="50%" style='width:50.0%;border:none;border-bottom:solid silver 1.0pt;background:#C5FFC4;padding:.75pt .75pt .75pt .75pt'></td><td style='border:solid silver 1.0pt;border-top:none;background:#B1EBB0;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=right style='text-align:right'><b><span style='font-size:10.0pt'>16228</span></b><b><o:p></o:p></b></p></td><td width="50%" style='width:50.0%;border-top:none;border-left:none;border-bottom:solid silver 1.0pt;border-right:solid silver 1.0pt;background:#C5FFC4;padding:.75pt .75pt .75pt .75pt'><pre style='line-height:140%'><span style='font-size:8.0pt;line-height:140%'>                                   <span class=n>ast_debug</span><span class=p>(</span><span class=mi>3</span><span class=p>,</span> <span class=s>&quot;Global nat=auto, so force nat=yes so we reply to non-peers like we would peers.</span><span class=se>\n</span><span class=s>&quot;</span><span class=p>);</span><o:p></o:p></span></pre></td></tr></table><pre style='margin-left:24.0pt;white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap: break-word'>The use of the term &quot;peer&quot; is confusing me. I have no idea what the sentence means.<o:p></o:p></pre></div><p class=MsoNormal><span style='font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p><p><span style='font-family:"Verdana","sans-serif"'>- Simon<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p><p><span style='font-family:"Verdana","sans-serif"'>On January 26th, 2012, 8:28 p.m., Terry Wilson wrote:<o:p></o:p></span></p><table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width="100%" style='width:100.0%;background:#FEFADF;border:solid black 1.0pt;background-position-x:0%;background-position-y:0%'><tr><td style='border:none;padding:6.0pt 6.0pt 6.0pt 6.0pt'><div><p class=MsoNormal>Review request for Asterisk Developers.<o:p></o:p></p></div><div><p class=MsoNormal>By Terry Wilson.<o:p></o:p></p></div><p style='color:grey'><i>Updated Jan. 26, 2012, 8:28 p.m.</i><o:p></o:p></p><h1 style='margin-top:.25in'><span style='font-size:10.0pt;color:#575012'>Description <o:p></o:p></span></h1><table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width="100%" style='width:100.0%;background:white;border:solid #B8B5A0 1.0pt'><tr><td style='border:none;padding:7.5pt 7.5pt 7.5pt 7.5pt'><pre style='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 pedro-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 original 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'm putting the original patch up, then will immediately add a review with my changes. Many thanks to pedro-garcia for his contribution.<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>From the JIRA issue:<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>I have some devices in the following scenario:<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>Asterisk server with public IP address<o:p></o:p></pre><pre>Mobile devices (clients):<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>When in internal network, no NAT between the client and the server<o:p></o:p></pre><pre>When in &quot;roaming&quot; (i.e. a Hotel with WiFi), the client is behing a NAT<o:p></o:p></pre><pre>When in 3G, operator transparent sip proxy so it looks as no NAT, but does not support symmetric RTP.<o:p></o:p></pre><pre>Sometime, the device gets a public IP with no NAT at all.<o:p></o:p></pre><pre>No NAT setting available in asterisk works for all these scenarios at the same time, and I can not request the user to activate different accounts depending on its location.<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>I have added a new NAT setting (nat=auto) 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.<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>It also adds to cli interface results (sip show peer/s) info on this (so now you could see &quot;N&quot; for NAT and nothing for no NAT as before, &quot;a&quot; for auto detect no NAT, and &quot;A&quot; for autodetect NAT.<o:p></o:p></pre></td></tr></table><h1 style='margin-top:.25in'><span style='font-size:10.0pt;color:#575012'>Testing <o:p></o:p></span></h1><table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width="100%" style='width:100.0%;background:white;border:solid #B8B5A0 1.0pt'><tr><td style='border:none;padding:7.5pt 7.5pt 7.5pt 7.5pt'><pre style='white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap: break-word'>Lots of reloads with changing values, and registry natted and un-natted phones. I also set the nat_supertest in testsuite to run with nat=auto to make sure that it responded the same with existing and non-existing peers.<o:p></o:p></pre></td></tr></table><div style='margin-top:.25in'><p class=MsoNormal><b><span style='font-size:10.0pt;color:#575012'>Bugs: </span></b><a href="https://issues.asterisk.org/jira/browse/ASTERISK-17860">ASTERISK-17860</a> <o:p></o:p></p></div><h1 style='margin-top:.25in'><span style='font-size:10.0pt;color:#575012'>Diffs <o:p></o:p></span></h1><ul type=disc><li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1'>/trunk/channels/chan_sip.c (352610)<o:p></o:p></li><li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1'>/trunk/channels/sip/include/sip.h (352610)<o:p></o:p></li><li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1'>/trunk/configs/sip.conf.sample (352610)<o:p></o:p></li></ul><p><a href="https://reviewboard.asterisk.org/r/1698/diff/">View Diff</a><o:p></o:p></p></td></tr></table><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></div></body></html>