]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Clarify log WARNING message when port-zero SDP 'm' lines received.
authorKevin P. Fleming <kpfleming@digium.com>
Mon, 30 Jan 2012 12:42:16 +0000 (12:42 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Mon, 30 Jan 2012 12:42:16 +0000 (12:42 +0000)
Previously, if an m-line in an SDP offer or answer had a port number of zero,
that line was skipped, and resulted in an 'Unsupported SDP media type...'
warning message. This was misleading, as the media type was not unsupported,
but was ignored because the m-line indicated that the media stream had been
rejected (in an answer) or was not going to be used (in an offer).

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

channels/chan_sip.c

index ba05877e2a439e707c51478e55ef69555de289e4..247f442c8a18a965dd97d3f7df23fa57ce4ca761 100644 (file)
@@ -8904,8 +8904,12 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                nextm = get_sdp_iterate(&next, req, "m");
 
                /* Search for audio media definition */
-               if ((sscanf(m, "audio %30u/%30u RTP/%4s %n", &x, &numberofports, protocol, &len) == 3 && len > 0 && x) ||
-                   (sscanf(m, "audio %30u RTP/%4s %n", &x, protocol, &len) == 2 && len > 0 && x)) {
+               if ((sscanf(m, "audio %30u/%30u RTP/%4s %n", &x, &numberofports, protocol, &len) == 3 && len > 0) ||
+                   (sscanf(m, "audio %30u RTP/%4s %n", &x, protocol, &len) == 2 && len > 0)) {
+                       if (x == 0) {
+                               ast_log(LOG_WARNING, "ignoring 'audio' media offer because port number is zero");
+                               continue;
+                       }
                        if (!strcmp(protocol, "SAVP")) {
                                secure_audio = 1;
                        } else if (strcmp(protocol, "AVP")) {
@@ -8930,12 +8934,16 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                                }
                                if (debug)
                                        ast_verbose("Found RTP audio format %d\n", codec);
-                               
+
                                ast_rtp_codecs_payloads_set_m_type(&newaudiortp, NULL, codec);
                        }
                /* Search for video media definition */
-               } else if ((sscanf(m, "video %30u/%30u RTP/%4s %n", &x, &numberofports, protocol, &len) == 3 && len > 0 && x) ||
-                          (sscanf(m, "video %30u RTP/%4s %n", &x, protocol, &len) == 2 && len >= 0 && x)) {
+               } else if ((sscanf(m, "video %30u/%30u RTP/%4s %n", &x, &numberofports, protocol, &len) == 3 && len > 0) ||
+                          (sscanf(m, "video %30u RTP/%4s %n", &x, protocol, &len) == 2 && len > 0)) {
+                       if (x == 0) {
+                               ast_log(LOG_WARNING, "ignoring 'video' media offer because port number is zero");
+                               continue;
+                       }
                        if (!strcmp(protocol, "SAVP")) {
                                secure_video = 1;
                        } else if (strcmp(protocol, "AVP")) {
@@ -8964,8 +8972,12 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                                ast_rtp_codecs_payloads_set_m_type(&newvideortp, NULL, codec);
                        }
                /* Search for text media definition */
-               } else if ((sscanf(m, "text %30u/%30u RTP/AVP %n", &x, &numberofports, &len) == 2 && len > 0 && x) ||
-                          (sscanf(m, "text %30u RTP/AVP %n", &x, &len) == 1 && len > 0 && x)) {
+               } else if ((sscanf(m, "text %30u/%30u RTP/AVP %n", &x, &numberofports, &len) == 2 && len > 0) ||
+                          (sscanf(m, "text %30u RTP/AVP %n", &x, &len) == 1 && len > 0)) {
+                       if (x == 0) {
+                               ast_log(LOG_WARNING, "ignoring 'text' media offer because port number is zero");
+                               continue;
+                       }
                        if (p->offered_media[SDP_TEXT].order_offered) {
                                ast_log(LOG_WARNING, "Multiple text streams are not supported\n");
                                return -3;
@@ -8988,8 +9000,12 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                                ast_rtp_codecs_payloads_set_m_type(&newtextrtp, NULL, codec);
                        }
                /* Search for image media definition */
-               } else if (((sscanf(m, "image %30u udptl t38%n", &x, &len) == 1 && len > 0 && x) ||
-                                       (sscanf(m, "image %30u UDPTL t38%n", &x, &len) == 1 && len > 0 && x) )) {
+               } else if (((sscanf(m, "image %30u udptl t38%n", &x, &len) == 1 && len > 0) ||
+                           (sscanf(m, "image %30u UDPTL t38%n", &x, &len) == 1 && len > 0))) {
+                       if (x == 0) {
+                               ast_log(LOG_WARNING, "ignoring 'image' media offer because port number is zero");
+                               continue;
+                       }
                        if (initialize_udptl(p)) {
                                continue;
                        }