No subject


Fri Sep 2 03:59:05 CDT 2011


=20
I have some devices in the following scenario:
=20
Asterisk server with public IP address
Mobile devices (clients):
=20
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 same time, and I can not request the user to activate different =
accounts depending on its location.
=20
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.
=20
It also adds to cli interface results (sip show peer/s) info on this (so =
now you could see "N" for NAT and nothing for no NAT as before, "a" for =
auto detect no NAT, and "A" for autodetect NAT.

Testing=20


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=3Dauto =
to make sure that it responded the same with existing and non-existing =
peers.

Bugs: ASTERISK-17860 =
<https://issues.asterisk.org/jira/browse/ASTERISK-17860> =20


Diffs=20


*	/trunk/channels/chan_sip.c (352610)
*	/trunk/channels/sip/include/sip.h (352610)
*	/trunk/configs/sip.conf.sample (352610)

View Diff <https://reviewboard.asterisk.org/r/1698/diff/>=20

=20


------=_NextPart_000_0074_01CCDCE3.9F561ED0
Content-Type: text/html;
	charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8"><meta =
name=3DGenerator content=3D"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:=EF=82=B7;
	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:=EF=82=A7;
	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:=EF=82=A7;
	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:=EF=82=A7;
	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:=EF=82=A7;
	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:=EF=82=A7;
	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:=EF=82=A7;
	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:=EF=82=A7;
	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=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'>Th=
is is a really useful patch! <o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'><o=
:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'>On=
e question:<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'>Wo=
uld nat=3Dauto be valid for the [general] context of sip.conf as =
well?=C2=A0 Or should this always be explicitly yes/no.=C2=A0 I ask =
because after the recent vulnerability related to having disparate =
nat=3D settings for peers I haven't been setting the nat=3D value =
per-peer, and instead set it once at [general].<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'><o=
:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'>Lu=
ke<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Georgia","serif";color:#1F497D'><o=
:p>&nbsp;</o:p></span></p><div><div =
style=3D'border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in =
0in 0in'><p class=3DMsoNormal><b><span =
style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span>=
</b><span style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'> =
asterisk-dev-bounces at lists.digium.com =
[mailto:asterisk-dev-bounces at 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=3Dauto =
setting<o:p></o:p></span></p></div></div><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><div><table =
class=3DMsoNormalTable border=3D1 cellpadding=3D0 width=3D"100%" =
style=3D'width:100.0%;background:#F9F3C9;border:solid #C9C399 =
1.0pt'><tr><td style=3D'border:none;padding:6.0pt 6.0pt 6.0pt 6.0pt'><p =
class=3DMsoNormal>This is an automatically generated e-mail. To reply, =
visit: <a =
href=3D"https://reviewboard.asterisk.org/r/1698/">https://reviewboard.ast=
erisk.org/r/1698/</a> <o:p></o:p></p></td></tr></table><p =
class=3DMsoNormal><span =
style=3D'font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p>=
<p><span style=3D'font-family:"Verdana","sans-serif"'>Ship =
it!<o:p></o:p></span></p><pre =
style=3D'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=3D"http://www.cisco.com/en/US/docs/routers/asr1000/configuration/gui=
de/sbcu/sbc_nat.html#wp1000953">http://www.cisco.com/en/US/docs/routers/a=
sr1000/configuration/guide/sbcu/sbc_nat.html#wp1000953</a><o:p></o:p></pr=
e><pre><o:p>&nbsp;</o:p></pre><pre>Could nat=3Dauto become the new =
default?<o:p></o:p></pre><p class=3DMsoNormal><span =
style=3D'font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p>=
<div><table class=3DMsoNormalTable border=3D1 cellspacing=3D0 =
cellpadding=3D0 width=3D"100%" =
style=3D'width:100.0%;background:white;border-collapse:collapse;border:no=
ne;margin:padding: 2px'><thead><tr><td colspan=3D4 style=3D'border:solid =
silver 1.0pt;background:#E4D9CB;padding:3.0pt 6.0pt 3.0pt 6.0pt'><p =
class=3DMsoNormal><b><span style=3D'font-size:9.0pt'><a =
href=3D"https://reviewboard.asterisk.org/r/1698/diff/2/?file=3D23678#file=
23678line16228"><span =
style=3D'color:black'>/trunk/channels/chan_sip.c</span></a> =
</span></b><span style=3D'font-size:9.0pt'>(Diff revision 2) =
<b><o:p></o:p></b></span></p></td></tr></thead><tr><td colspan=3D4 =
style=3D'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=3D'text-align:center;line-height:140%'><span =
style=3D'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=3D'border:solid =
silver 1.0pt;border-top:none;background:#B1EBB0;padding:.75pt .75pt =
.75pt .75pt'></td><td width=3D"50%" =
style=3D'width:50.0%;border:none;border-bottom:solid silver =
1.0pt;background:#C5FFC4;padding:.75pt .75pt .75pt .75pt'></td><td =
style=3D'border:solid silver =
1.0pt;border-top:none;background:#B1EBB0;padding:.75pt .75pt .75pt =
.75pt'><p class=3DMsoNormal align=3Dright =
style=3D'text-align:right'><b><span =
style=3D'font-size:10.0pt'>16228</span></b><b><o:p></o:p></b></p></td><td=
 width=3D"50%" =
style=3D'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=3D'line-height:140%'><span =
style=3D'font-size:8.0pt;line-height:140%'>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 <span class=3Dn>ast_debug</span><span =
class=3Dp>(</span><span class=3Dmi>3</span><span class=3Dp>,</span> =
<span class=3Ds>&quot;Global nat=3Dauto, so force nat=3Dyes so we reply =
to non-peers like we would peers.</span><span class=3Dse>\n</span><span =
class=3Ds>&quot;</span><span =
class=3Dp>);</span><o:p></o:p></span></pre></td></tr></table><pre =
style=3D'margin-left:24.0pt;white-space:pre-wrap;white-space:-moz-pre-wra=
p;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=3DMsoNormal><span =
style=3D'font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p>=
<p><span style=3D'font-family:"Verdana","sans-serif"'>- =
Simon<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p>=
<p><span style=3D'font-family:"Verdana","sans-serif"'>On January 26th, =
2012, 8:28 p.m., Terry Wilson wrote:<o:p></o:p></span></p><table =
class=3DMsoNormalTable border=3D1 cellspacing=3D0 cellpadding=3D0 =
width=3D"100%" style=3D'width:100.0%;background:#FEFADF;border:solid =
black 1.0pt;background-position-x:0%;background-position-y:0%'><tr><td =
style=3D'border:none;padding:6.0pt 6.0pt 6.0pt 6.0pt'><div><p =
class=3DMsoNormal>Review request for Asterisk =
Developers.<o:p></o:p></p></div><div><p class=3DMsoNormal>By Terry =
Wilson.<o:p></o:p></p></div><p style=3D'color:grey'><i>Updated Jan. 26, =
2012, 8:28 p.m.</i><o:p></o:p></p><h1 style=3D'margin-top:.25in'><span =
style=3D'font-size:10.0pt;color:#575012'>Description =
<o:p></o:p></span></h1><table class=3DMsoNormalTable border=3D1 =
cellspacing=3D0 cellpadding=3D0 width=3D"100%" =
style=3D'width:100.0%;background:white;border:solid #B8B5A0 =
1.0pt'><tr><td style=3D'border:none;padding:7.5pt 7.5pt 7.5pt =
7.5pt'><pre =
style=3D'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=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.<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=3D'margin-top:.25in'><span =
style=3D'font-size:10.0pt;color:#575012'>Testing =
<o:p></o:p></span></h1><table class=3DMsoNormalTable border=3D1 =
cellspacing=3D0 cellpadding=3D0 width=3D"100%" =
style=3D'width:100.0%;background:white;border:solid #B8B5A0 =
1.0pt'><tr><td style=3D'border:none;padding:7.5pt 7.5pt 7.5pt =
7.5pt'><pre =
style=3D'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=3Dauto to make sure that =
it responded the same with existing and non-existing =
peers.<o:p></o:p></pre></td></tr></table><div =
style=3D'margin-top:.25in'><p class=3DMsoNormal><b><span =
style=3D'font-size:10.0pt;color:#575012'>Bugs: </span></b><a =
href=3D"https://issues.asterisk.org/jira/browse/ASTERISK-17860">ASTERISK-=
17860</a> <o:p></o:p></p></div><h1 style=3D'margin-top:.25in'><span =
style=3D'font-size:10.0pt;color:#575012'>Diffs =
<o:p></o:p></span></h1><ul type=3Ddisc><li class=3DMsoNormal =
style=3D'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=3DMsoNormal =
style=3D'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=3DMsoNormal =
style=3D'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=3D"https://reviewboard.asterisk.org/r/1698/diff/">View =
Diff</a><o:p></o:p></p></td></tr></table><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p></div></div></body></html>
------=_NextPart_000_0074_01CCDCE3.9F561ED0--




More information about the asterisk-dev mailing list