[asterisk-commits] dvossel: branch 1.8 r288821 - /branches/1.8/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 24 12:05:18 CDT 2010


Author: dvossel
Date: Fri Sep 24 12:05:12 2010
New Revision: 288821

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=288821
Log:
Inspect Require header on BYE transaction according to RFC3261 section 8.2.2.3.

ABE-2293

Modified:
    branches/1.8/channels/chan_sip.c

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=288821&r1=288820&r2=288821
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Fri Sep 24 12:05:12 2010
@@ -22252,7 +22252,8 @@
 	struct ast_channel *c=NULL;
 	int res;
 	struct ast_channel *bridged_to;
-	
+	const char *required;
+
 	/* If we have an INCOMING invite that we haven't answered, terminate that transaction */
 	if (p->pendinginvite && !ast_test_flag(&p->flags[0], SIP_OUTGOING) && !req->ignore) {
 		transmit_response_reliable(p, "487 Request Terminated", &p->initreq);
@@ -22373,7 +22374,23 @@
 		ast_debug(3, "Received bye, no owner, selfdestruct soon.\n");
 	}
 	ast_clear_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
-	transmit_response(p, "200 OK", req);
+
+	/* Find out what they require */
+	required = get_header(req, "Require");
+	if (!ast_strlen_zero(required)) {
+		char unsupported[256] = { 0, };
+		parse_sip_options(required, unsupported, ARRAY_LEN(unsupported));
+		/* If there are any options required that we do not support,
+		 * then send a 420 with only those unsupported options listed */
+		if (!ast_strlen_zero(unsupported)) {
+			transmit_response_with_unsupported(p, "420 Bad extension (unsupported)", req, unsupported);
+			ast_log(LOG_WARNING, "Received SIP BYE with unsupported required extension: required:%s unsupported:%s\n", required, unsupported);
+		} else {
+			transmit_response(p, "200 OK", req);
+		}
+	} else {
+		transmit_response(p, "200 OK", req);
+	}
 
 	return 1;
 }




More information about the asterisk-commits mailing list