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


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

<div>Review request for Asterisk Developers, Russell Bryant, Mark Michelson, Jared Smith, David Vossel, and leifmadsen.</div>
<div>By jrose.</div>


<p style="color: grey;"><i>Updated 2011-05-11 19:13:29.473120</i></p>



<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Changes</h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="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;">Added Leif and Jared</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="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;">This is sort of a natural follow-up to https://reviewboard.asterisk.org/r/1188/

Reading over RFC3261 and talking to mmichelson made the following things clear to me:

1.  semi-colons are allowed in the user field of the uri.  In fact, the very data I was trying to parse out is described as belonging in the user field by pages 156-158.
2.  Theoretically, a user could make an extension something like 2005;bunch-of-uri-user-parameters
3.  Since that&#39;s the case, simply parsing out this data before it ever gets used by anything based on semicolons could interfere with current behavior.

What I did to address it:

1.  In the case of the user field in the uri from the bug...
&quot;4254883646;phone-context=+1;npdi=yes&quot; -- Asterisk needs to match 4254883646.  Since this can&#39;t be safely removed in parsing, there is now a fail-triggered semi-colon delimited removal
performed in chan_sip&#39;s get_destination.  If no extensions are made before it reaches the end, we check to see if there was a semicolon in the uri/decoded uri and if there was, we start the searches
over again with the uri terminated at the first semicolon.

2.  If one of those uri semicolons is found, we preserve that data within a string field which can be accessed from the channel function.

3.  A test was added to check that teluris that are converted into sip uris are read like it appears they should according to RFC3261.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="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;">I tested to make sure it didn&#39;t interfere with regular dialing behavior of sip phones by using one of my own sip phones.

I tested the basic behavior by forcing the following sip message using sipp:

INVITE sip:2005;phone-context=+1;npdi=yes@127.0.0.1:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:5062;branch=z9hG4bK-23024-1-0
From: &quot;Lrrrr Schmrrr&quot; &lt;sip:sipp@127.0.1.1:5062&gt;;tag=1
To: Asterisk &lt;sip:2005:whoop;phone-context=+1;npdi=yes@127.0.0.1:5060&gt;
Call-ID: 1-23024@127.0.1.1
CSeq: 1 OPTIONS
Contact: sip:sipp@127.0.1.1:5062
Max-Forwards: 70
Subject: Asterisk Testsuite
Content-Length: 0

And using this dialplan setup I&#39;d check to make sure values were what I expected:
[sipp]
exten =&gt; 2005,1,Answer()
exten =&gt; 2005,n,Background(tt-weasels)
exten =&gt; 2005,n,NoOp(callerid =&gt; ${CALLERID(all)})
exten =&gt; 2005,n,NoOp(exten =&gt; ${EXTEN})
exten =&gt; 2005,n,NoOp(uri =&gt; ${CHANNEL(uri)})
exten =&gt; 2005,n,NoOp(user_options =&gt; ${CHANNEL(uri_user_parameters)})
exten =&gt; 2005,n,Wait(1)
exten =&gt; 2005,n,HangUp()

yielding these results:
   -- Executing [2005@sipp:1] Answer(&quot;SIP/sipp-00000000&quot;, &quot;&quot;) in new stack
    -- Executing [2005@sipp:2] BackGround(&quot;SIP/sipp-00000000&quot;, &quot;tt-weasels&quot;) in new stack
    -- &lt;SIP/sipp-00000000&gt; Playing &#39;tt-weasels.gsm&#39; (language &#39;en&#39;)
    -- Executing [2005@sipp:3] NoOp(&quot;SIP/sipp-00000000&quot;, &quot;callerid =&gt; &quot;Lrrrr Schmrrr&quot; &lt;sipp&gt;&quot;) in new stack
    -- Executing [2005@sipp:4] NoOp(&quot;SIP/sipp-00000000&quot;, &quot;exten =&gt; 2005&quot;) in new stack
    -- Executing [2005@sipp:5] NoOp(&quot;SIP/sipp-00000000&quot;, &quot;uri =&gt; sip:sipp@127.0.1.1:5062&quot;) in new stack
    -- Executing [2005@sipp:6] NoOp(&quot;SIP/sipp-00000000&quot;, &quot;user_options =&gt; phone-context=+1;npdi=yes&quot;) in new stack
    -- Executing [2005@sipp:7] Wait(&quot;SIP/sipp-00000000&quot;, &quot;1&quot;) in new stack
    -- Executing [2005@sipp:8] Hangup(&quot;SIP/sipp-00000000&quot;, &quot;&quot;) in new stack

I was paranoid that my goto statement would potentially cause a memory leak, so I also compared &quot;memory show summary chan_sip.c&quot; before and after the channel lived for both the case of the normal call and the case where it has to do the repetition with goto.  I repeated the process with pbx.c and likewise saw no memory leak (though I thought I did at first when 4 allocations were made to pbx.c, but it turned out to be unrelated since I performed the test while creating hundreds of similar sip channels and saw no additional increases)  Still, it&#39;s something worth looking at since I&#39;m still rather likely to miss that sort of thing.</pre>
  </td>
 </tr>
</table>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="https://issues.asterisk.org/view.php?id=18344">18344</a>


</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/branches/1.8/channels/chan_sip.c <span style="color: grey">(318337)</span></li>

 <li>/branches/1.8/channels/sip/dialplan_functions.c <span style="color: grey">(318337)</span></li>

 <li>/branches/1.8/channels/sip/include/sip.h <span style="color: grey">(318337)</span></li>

 <li>/branches/1.8/channels/sip/reqresp_parser.c <span style="color: grey">(318337)</span></li>

 <li>/branches/1.8/funcs/func_channel.c <span style="color: grey">(318337)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/1214/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>




  </div>
 </body>
</html>