]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix The Payload Being Set On CN Packets And Do Not Set Marker Bit
authorMichael L. Young <elgueromexicano@gmail.com>
Thu, 9 May 2013 03:58:42 +0000 (03:58 +0000)
committerMichael L. Young <elgueromexicano@gmail.com>
Thu, 9 May 2013 03:58:42 +0000 (03:58 +0000)
When we send out a CN packet (for instance, in the case of using rtpkeepalives),
we are not setting the payload code properly.  Also, we are setting the marker
bit when we shouldn't be according to RFC 3389, section 4.

AST_RTP_CN is not defined by AST_FORMAT codes.  Therefore, we should be using
ast_rtp_codecs_payload_code() rather than ast_rtp_codecs_payload_lookup().

11 and trunk already use the appropriate function.

* In 1.8, use ast_rtp_codecs_payload_code()

* Remove the setting of the marker bit

* Fix the debug message by incrementing the seqno after the debug message is set
  in order to display the correct seqno that was sent out

(closes issue ASTERISK-21246)
Reported by: Peter Katzmann
Tested by: Peter Katzmann, Michael L. Young
Patches:
    asterisk-21246-rtp-cng-payload-error_1.8_v2.diff
                                     uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/2500/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@388111 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_rtp_asterisk.c

index 801b2f26e77bf95cc3a07b3926f260e9038924cd..6fb919504058c6c80a5c3f08d57605245de455c5 100644 (file)
@@ -2794,8 +2794,7 @@ static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
 {
        unsigned int *rtpheader;
        int hdrlen = 12;
-       int res;
-       struct ast_rtp_payload_type payload;
+       int res, payload = 0;
        char data[256];
        struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
        struct ast_sockaddr remote_address = { {0,} };
@@ -2806,7 +2805,7 @@ static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
                return -1;
        }
 
-       payload = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(instance), AST_RTP_CN);
+       payload = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 0, AST_RTP_CN);
 
        level = 127 - (level & 0x7f);
        
@@ -2814,7 +2813,7 @@ static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
 
        /* Get a pointer to the header */
        rtpheader = (unsigned int *)data;
-       rtpheader[0] = htonl((2 << 30) | (1 << 23) | (payload.code << 16) | (rtp->seqno++));
+       rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno));
        rtpheader[1] = htonl(rtp->lastts);
        rtpheader[2] = htonl(rtp->ssrc); 
        data[12] = level;
@@ -2829,6 +2828,8 @@ static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
                                AST_RTP_CN, rtp->seqno, rtp->lastdigitts, res - hdrlen);
        }
 
+       rtp->seqno++;
+
        return res;
 }