[asterisk-commits] jrose: branch 10 r342603 - in /branches/10: ./ res/res_rtp_multicast.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 27 14:41:49 CDT 2011


Author: jrose
Date: Thu Oct 27 14:41:44 2011
New Revision: 342603

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342603
Log:
Fix sequence number overflow over 16 bits causing codec change in RTP packets.

Sequence number was handled as an unsigned integer (usually 32 bits I think, more
depending on the architecture) and was put into the rtp packet which is basically
just a bunch of bits using an or operation. Sequence number only has 16 bits
allocated to it in an RTP packet anyway, so it would add to the next field which
just happened to be the codec. This makes sure the sequence number is set to be
a 16 bit integer regardless of architecture (hopefully) and also makes it so the
incrementing of the sequence number does bitwise or at the peak of a 16 bit number
so that the value will be set back to 0 when going beyond 65535 anyway.

(closes issue ASTERISK-18291)
Reported by: Will Schick
Review: https://reviewboard.asterisk.org/r/1542/
........

Merged revisions 342602 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/res/res_rtp_multicast.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/res/res_rtp_multicast.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/res/res_rtp_multicast.c?view=diff&rev=342603&r1=342602&r2=342603
==============================================================================
--- branches/10/res/res_rtp_multicast.c (original)
+++ branches/10/res/res_rtp_multicast.c Thu Oct 27 14:41:44 2011
@@ -89,7 +89,7 @@
 	/*! Synchronization source value, used when creating/sending the RTP packet */
 	unsigned int ssrc;
 	/*! Sequence number, used when creating/sending the RTP packet */
-	unsigned int seqno;
+	uint16_t seqno;
 };
 
 /* Forward Declarations */
@@ -228,9 +228,12 @@
 
 	/* Construct an RTP header for our packet */
 	rtpheader = (unsigned char *)(f->data.ptr - hdrlen);
-	put_unaligned_uint32(rtpheader, htonl((2 << 30) | (codec << 16) | (multicast->seqno++) | (0 << 23)));
+	put_unaligned_uint32(rtpheader, htonl((2 << 30) | (codec << 16) | (multicast->seqno)));
 	put_unaligned_uint32(rtpheader + 4, htonl(f->ts * 8));
 	put_unaligned_uint32(rtpheader + 8, htonl(multicast->ssrc));
+
+	/* Increment sequence number and wrap to 0 if it overflows 16 bits. */
+	multicast->seqno = 0xFFFF & (multicast->seqno + 1);
 
 	/* Finally send it out to the eager phones listening for us */
 	ast_rtp_instance_get_remote_address(instance, &remote_address);




More information about the asterisk-commits mailing list