summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2010-09-24 17:06:02 +0000
committerDavid Vossel <dvossel@digium.com>2010-09-24 17:06:02 +0000
commit344bd58d564b42d9a8290afc82978a48c029303d (patch)
tree1c29c9cf401f352540b18f11660e7400c968e0e6 /channels/chan_sip.c
parent4e473de5e24ffb6406786f817a499e4ad624f988 (diff)
Merged revisions 288821 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r288821 | dvossel | 2010-09-24 12:05:12 -0500 (Fri, 24 Sep 2010) | 4 lines Inspect Require header on BYE transaction according to RFC3261 section 8.2.2.3. ABE-2293 ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@288822 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 1576a5cd9..01f184fec 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -22350,7 +22350,8 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
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);
@@ -22471,7 +22472,23 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
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;
}