<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/1699/">https://reviewboard.asterisk.org/r/1699/</a>
     </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On January 27th, 2012, 9:45 a.m., <b>Mark Michelson</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">In section 8.1.1.5, RFC 3261 says &quot;The sequence number MUST be expressible as a 32-bit unsigned integer and MUST be less than 2**31.&quot; So you definitely need to make sure to uncomment those lines you added to limit the value from getting too high.</pre>
 </blockquote>







</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">RFC 4475     SIP Torture Test Messages                May 2006
http://tools.ietf.org/rfc/rfc4475.txt

Backs up that the CSeq number can get to 2**32-1.

3.1.2.4.  Request Scalar Fields with Overlarge Values

   This request contains several scalar header field values outside
   their legal range.

      o  The CSeq sequence number is &gt;2**32-1.

=============

The only problem I have now, is the earlier but obsolete RFC 2543 Section 6.17, states;
  &quot;... sequence numbers do not wrap around.&quot;

And the constant references to the next Cseq must be higher.

Thus the 3 places where ocseq or icseq are incremented like below: 
  p-&gt;ocseq++;
  p-&gt;ocseq &amp;= 0x7FFFFFFF

would need to change, to something like

if ( p-&gt;ocseq &lt; 0xFFFFFFFF)
   p-&gt;ocseq++;
</pre>
<br />








<p>- Alec</p>


<br />
<p>On January 27th, 2012, 3:34 p.m., Alec Davis wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/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.</div>
<div>By Alec Davis.</div>


<p style="color: grey;"><i>Updated Jan. 27, 2012, 3:34 p.m.</i></p>




<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;">RFC 3261 Section 8.1 documents intial value of CSeq and it&#39;s maximum out side of a dialog.
  8.1 UAC Behavior
     This section covers UAC behavior outside of a dialog.
  8.1.1.5
     .. &quot;The sequence number value MUST be expressible as a 32-bit unsigned integer and MUST be less than 2**31.&quot; 
     &quot;Section 12.2.1.1 discusses construction of the CSeq for requests within a dialog.&quot;

RFC 3261 Section 12.2.1.1, documents the maximum value a seqno can get to within a dialog, 2^32-1. (136 years equals 2^32 seconds).
   &quot;If the local sequence number is empty, an initial value MUST be chosen using the guidelines of Section 8.1.1.5&quot;  
   .. &quot;With a length of 32 bits, a client could generate, within a single call, one request a second for about 136 years before needing to wrap around.&quot;
  
===============================================================================

By defining INITIAL_CSEQ to values near the maximum, it can clearly be seen that asterisk will represent the cseqno as negative numbers as %d is used in most places.

//#define INITIAL_CSEQ              101    /*!&lt; Our initial sip sequence number */
#define INITIAL_CSEQ              2147483640 /*!&lt; Our initial sip sequence number */
#define INITIAL_CSEQ              4294967290UL   /*!&lt; Our initial sip sequence number */ 

Examples below after a few messages with INITIAL_CSEQ set to 214783640

...
Call-ID: d469d55c9e9e81ae@192.168.y.yyy
CSeq: -2147483639 NOTIFY
User-Agent: Asterisk PBX SVN-trunk-r352864M
Subscription-State: active
Event: dialog
Content-Type: application/dialog-info+xml
Content-Length: 206

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;dialog-info xmlns=&quot;urn:ietf:params:xml:ns:dialog-info&quot; version=&quot;16&quot; state=&quot;full&quot; entity=&quot;sip:8612@192.168.x.xxx&quot;&gt;

...
Call-ID: 7d1d964b7867eee008705e1e64386d4e@192.168.x.xxx:5060
CSeq: -5 NOTIFY
User-Agent: Asterisk PBX SVN-trunk-r352864M
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: 92

Messages-Waiting: no
Message-Account: sip:asterisk@192.168.x.xxx
Voice-Message: 0/0 (0/0)

 </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;">Noted that Notify for BLF and MWI, that the CSeq numbers now wrapped around to 0.

After using the 2nd maximum of 2^32 minus a few (#define INITIAL_CSEQ              4294967290UL) phones, BLF and MWI still workign as normal.

Previously the BLF would stop functioning after the minus values were reached.
Now it wraps around from 4294967295 to 0, as below.

Call-ID: c2aaba2919cfcd4a@192.168.y.yyy
CSeq: 4294967295 NOTIFY
User-Agent: Asterisk PBX SVN-trunk-r352864M
Subscription-State: active
Event: dialog
Content-Type: application/dialog-info+xml
Content-Length: 205

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;dialog-info xmlns=&quot;urn:ietf:params:xml:ns:dialog-info&quot; version=&quot;4&quot; state=&quot;full&quot; entity=&quot;sip:8612@192.168.x.xxx&quot;&gt;
&lt;dialog id=&quot;8612&quot;&gt;

...
Call-ID: c2aaba2919cfcd4a@192.168.y.yyy
CSeq: 0 NOTIFY
User-Agent: Asterisk PBX SVN-trunk-r352864M
Subscription-State: active
Event: dialog
Content-Type: application/dialog-info+xml
Content-Length: 205

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;dialog-info xmlns=&quot;urn:ietf:params:xml:ns:dialog-info&quot; version=&quot;5&quot; state=&quot;full&quot; entity=&quot;sip:8612@192.168.x.xxx&quot;&gt;
&lt;dialog id=&quot;8612&quot;&gt;
</pre>
  </td>
 </tr>
</table>




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

 <li>trunk/channels/chan_sip.c <span style="color: grey">(352913)</span></li>

 <li>trunk/channels/sip/include/dialog.h <span style="color: grey">(352913)</span></li>

 <li>trunk/channels/sip/include/sip.h <span style="color: grey">(352913)</span></li>

</ul>

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




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








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