[Asterisk-cvs] asterisk/channels chan_sip.c,1.510.2.56,1.510.2.57

russell at lists.digium.com russell at lists.digium.com
Mon Apr 4 02:13:01 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv30642/channels

Modified Files:
      Tag: v1-0
	chan_sip.c 
Log Message:
correctly respond to an INVITE with T.38 (bug #3818)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.510.2.56
retrieving revision 1.510.2.57
diff -u -d -r1.510.2.56 -r1.510.2.57
--- chan_sip.c	28 Mar 2005 06:42:14 -0000	1.510.2.56
+++ chan_sip.c	4 Apr 2005 07:05:55 -0000	1.510.2.57
@@ -2616,8 +2616,8 @@
 	char host[258];
 	char iabuf[INET_ADDRSTRLEN];
 	int len = -1;
-	int portno=0;
-	int vportno=0;
+	int portno = -1;
+	int vportno = -1;
 	int peercapability, peernoncodeccapability;
 	int vpeercapability=0, vpeernoncodeccapability=0;
 	struct sockaddr_in sin;
@@ -2628,6 +2628,7 @@
 	int iterator;
 	int sendonly = 0;
 	int x;
+	int found;
 	int debug=sip_debug_test_pvt(p);
 
 	/* Update our last rtprx when we receive an SDP, too */
@@ -2657,7 +2658,9 @@
 	sdpLineNum_iterator_init(&iterator);
 	p->novideo = 1;
 	while ((m = get_sdp_iterate(&iterator, req, "m"))[0] != '\0') {
+		found = 0;	
 		if ((sscanf(m, "audio %d RTP/AVP %n", &x, &len) == 1)) {
+			found = 1;	
 			portno = x;
 			/* Scan through the RTP payload types specified in a "m=" line: */
 			ast_rtp_pt_clear(p->rtp);
@@ -2679,6 +2682,7 @@
 			ast_rtp_pt_clear(p->vrtp);  /* Must be cleared in case no m=video line exists */
 
 		if (p->vrtp && (sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1)) {
+			found = 1;	
 			p->novideo = 0;
 			vportno = x;
 			/* Scan through the RTP payload types specified in a "m=" line: */
@@ -2696,6 +2700,12 @@
 				while(*codecs && (*codecs < 33)) codecs++;
 			}
 		}
+		if (!found)
+			ast_log(LOG_WARNING, "Unknown SDP media type in offer %s\n", m);
+	}
+	if (portno == -1 && vportno == -1) {
+		/* No acceptable offer found in SDP */
+		return -2;
 	}
 
 	/* RTP addresses and ports for audio and video */
@@ -2726,21 +2736,22 @@
 	 */
 	sdpLineNum_iterator_init(&iterator);
 	while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') {
-      char* mimeSubtype = ast_strdupa(a); /* ensures we have enough space */
-	  if (!strcasecmp(a, "sendonly")) {
-	  	sendonly=1;
-		continue;
-	  }
-	  if (!strcasecmp(a, "sendrecv")) {
-	  	sendonly=0;
-	  }
-	  if (sscanf(a, "rtpmap: %u %[^/]/", &codec, mimeSubtype) != 2) continue;
-	  if (debug)
-		ast_verbose("Found description format %s\n", mimeSubtype);
-	  /* Note: should really look at the 'freq' and '#chans' params too */
-	  ast_rtp_set_rtpmap_type(p->rtp, codec, "audio", mimeSubtype);
-	  if (p->vrtp)
-		  ast_rtp_set_rtpmap_type(p->vrtp, codec, "video", mimeSubtype);
+		char* mimeSubtype = ast_strdupa(a); /* ensures we have enough space */
+		if (!strcasecmp(a, "sendonly")) {
+			sendonly=1;
+			continue;
+		}
+		if (!strcasecmp(a, "sendrecv")) {
+			sendonly=0;
+		}
+		if (sscanf(a, "rtpmap: %u %[^/]/", &codec, mimeSubtype) != 2) 
+			continue;
+		if (debug)
+			ast_verbose("Found description format %s\n", mimeSubtype);
+		/* Note: should really look at the 'freq' and '#chans' params too */
+		ast_rtp_set_rtpmap_type(p->rtp, codec, "audio", mimeSubtype);
+		if (p->vrtp)
+			ast_rtp_set_rtpmap_type(p->vrtp, codec, "video", mimeSubtype);
 	}
 
 	/* Now gather all of the codecs that were asked for: */
@@ -7271,8 +7282,11 @@
 			if (p->owner) {
 				/* Handle SDP here if we already have an owner */
 				if (!ast_strlen_zero(get_header(req, "Content-Type"))) {
-					if (process_sdp(p, req))
+					if (process_sdp(p, req)) {
+						transmit_response(p, "488 Not acceptable here", req);
+						p->needdestroy = 1;
 						return -1;
+					}
 				} else {
 					p->jointcapability = p->capability;
 					ast_log(LOG_DEBUG, "Hm....  No sdp for the moment\n");
@@ -7296,8 +7310,11 @@
 			}
 			/* Process the SDP portion */
 			if (!ast_strlen_zero(get_header(req, "Content-Type"))) {
-				if (process_sdp(p, req))
+				if (process_sdp(p, req)) {
+					transmit_response(p, "488 Not acceptable here", req);
+					p->needdestroy = 1;
 					return -1;
+				}
 			} else {
 				p->jointcapability = p->capability;
 				ast_log(LOG_DEBUG, "Hm....  No sdp for the moment\n");




More information about the svn-commits mailing list