[asterisk-commits] mjordan: branch 13 r426597 - in /branches/13: ./ channels/ channels/sip/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 29 20:47:29 CDT 2014
Author: mjordan
Date: Wed Oct 29 20:47:25 2014
New Revision: 426597
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=426597
Log:
channels/chan_sip: Support mutltiple Supported and Required headers
A SIP request may contain multiple Supported: and Required: headers. Currently,
chan_sip only parses the first Supported/Required header it finds. This patch
adds support for multiple Supported/Required headers for INVITE requests.
Review: https://reviewboard.asterisk.org/r/2478
ASTERISK-21721 #close
Reported by: Olle Johansson
patches:
rb2478.patch uploaded by oej (License 5267)
........
Merged revisions 426594 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 426595 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 426596 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
branches/13/ (props changed)
branches/13/channels/chan_sip.c
branches/13/channels/sip/reqresp_parser.c
Propchange: branches/13/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: branches/13/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/channels/chan_sip.c?view=diff&rev=426597&r1=426596&r2=426597
==============================================================================
--- branches/13/channels/chan_sip.c (original)
+++ branches/13/channels/chan_sip.c Wed Oct 29 20:47:25 2014
@@ -25071,7 +25071,9 @@
int reinvite = 0;
struct ast_party_redirecting redirecting;
struct ast_set_party_redirecting update_redirecting;
-
+ int supported_start = 0;
+ int require_start = 0;
+ char unsupported[256] = { 0, };
struct {
char exten[AST_MAX_EXTENSION];
char context[AST_MAX_CONTEXT];
@@ -25083,30 +25085,36 @@
/* Find out what they support */
if (!p->sipoptions) {
- const char *supported = sip_get_header(req, "Supported");
- if (!ast_strlen_zero(supported)) {
- p->sipoptions = parse_sip_options(supported, NULL, 0);
- }
+ const char *supported = NULL;
+ do {
+ supported = __get_header(req, "Supported", &supported_start);
+ if (!ast_strlen_zero(supported)) {
+ p->sipoptions |= parse_sip_options(supported, NULL, 0);
+ }
+ } while (!ast_strlen_zero(supported));
}
/* Find out what they require */
- required = sip_get_header(req, "Require");
- if (!ast_strlen_zero(required)) {
- char unsupported[256] = { 0, };
- required_profile = 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 INVITE with unsupported required extension: required:%s unsupported:%s\n", required, unsupported);
- p->invitestate = INV_COMPLETED;
- if (!p->lastinvite)
- sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- res = INV_REQ_ERROR;
- goto request_invite_cleanup;
- }
- }
+ do {
+ required = __get_header(req, "Require", &require_start);
+ if (!ast_strlen_zero(required)) {
+ required_profile |= parse_sip_options(required, unsupported, ARRAY_LEN(unsupported));
+ }
+ } while (!ast_strlen_zero(required));
+
+ /* 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 INVITE with unsupported required extension: required:%s unsupported:%s\n", required, unsupported);
+ p->invitestate = INV_COMPLETED;
+ if (!p->lastinvite) {
+ sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ }
+ res = -1;
+ goto request_invite_cleanup;
+ }
+
/* The option tags may be present in Supported: or Require: headers.
Include the Require: option tags for further processing as well */
Modified: branches/13/channels/sip/reqresp_parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/channels/sip/reqresp_parser.c?view=diff&rev=426597&r1=426596&r2=426597
==============================================================================
--- branches/13/channels/sip/reqresp_parser.c (original)
+++ branches/13/channels/sip/reqresp_parser.c Wed Oct 29 20:47:25 2014
@@ -1691,10 +1691,6 @@
char *out = unsupported;
size_t outlen = unsupported_len;
char *cur_out = out;
-
- if (out && (outlen > 0)) {
- memset(out, 0, outlen);
- }
if (ast_strlen_zero(options) )
return 0;
More information about the asterisk-commits
mailing list