summaryrefslogtreecommitdiff
path: root/channels/sip/include
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2010-06-28 18:38:47 +0000
committerDavid Vossel <dvossel@digium.com>2010-06-28 18:38:47 +0000
commit8a07dbf95ddcf1dc2bda06fd82a58a26866493df (patch)
tree2c6d4a9d05f24a0925c629ac851823ef159bd598 /channels/sip/include
parentdc877759cba8b295c50fa05d256bf62d793c7a5e (diff)
rfc compliant sip option parsing + new unit test
RFC 3261 section 8.2.2.3 states that if any unsupported options are found in the Require header field, a "420 (Bad Extension)" response should be sent with an Unsupported header field containing only the unsupported options. This is not currently being done correctly. Right now, if Asterisk detects any unsupported sip options in a Require header the entire list of options are returned in the Unsupported header even if some of those options are in fact supported. This patch fixes that by building an unsupported options character buffer when parsing the options that can be sent with the 420 response. A unit test verifying this functionality has been created. Some code refactoring was required. Review: https://reviewboard.asterisk.org/r/680/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@272880 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sip/include')
-rw-r--r--channels/sip/include/reqresp_parser.h14
-rw-r--r--channels/sip/include/sip.h52
2 files changed, 66 insertions, 0 deletions
diff --git a/channels/sip/include/reqresp_parser.h b/channels/sip/include/reqresp_parser.h
index 60fc64698..58784a621 100644
--- a/channels/sip/include/reqresp_parser.h
+++ b/channels/sip/include/reqresp_parser.h
@@ -122,4 +122,18 @@ void sip_request_parser_register_tests(void);
*/
void sip_request_parser_unregister_tests(void);
+/*!
+ * \brief Parse supported header in incoming packet
+ *
+ * \details This function parses through the options parameters and
+ * builds a bit field representing all the SIP options in that field. When an
+ * item is found that is not supported, it is copied to the unsupported
+ * out buffer.
+ *
+ * \param option list
+ * \param unsupported out buffer (optional)
+ * \param unsupported out buffer length (optional)
+ */
+unsigned int parse_sip_options(const char *options, char *unsupported, size_t unsupported_len);
+
#endif
diff --git a/channels/sip/include/sip.h b/channels/sip/include/sip.h
index ca8a897f4..01cbb2c73 100644
--- a/channels/sip/include/sip.h
+++ b/channels/sip/include/sip.h
@@ -1698,5 +1698,57 @@ struct contact {
AST_LIST_HEAD_NOLOCK(contactliststruct, contact);
+/*! \brief List of well-known SIP options. If we get this in a require,
+ we should check the list and answer accordingly. */
+static const struct cfsip_options {
+ int id; /*!< Bitmap ID */
+ int supported; /*!< Supported by Asterisk ? */
+ char * const text; /*!< Text id, as in standard */
+} sip_options[] = { /* XXX used in 3 places */
+ /* RFC3262: PRACK 100% reliability */
+ { SIP_OPT_100REL, NOT_SUPPORTED, "100rel" },
+ /* RFC3959: SIP Early session support */
+ { SIP_OPT_EARLY_SESSION, NOT_SUPPORTED, "early-session" },
+ /* SIMPLE events: RFC4662 */
+ { SIP_OPT_EVENTLIST, NOT_SUPPORTED, "eventlist" },
+ /* RFC 4916- Connected line ID updates */
+ { SIP_OPT_FROMCHANGE, NOT_SUPPORTED, "from-change" },
+ /* GRUU: Globally Routable User Agent URI's */
+ { SIP_OPT_GRUU, NOT_SUPPORTED, "gruu" },
+ /* RFC4244 History info */
+ { SIP_OPT_HISTINFO, NOT_SUPPORTED, "histinfo" },
+ /* RFC3911: SIP Join header support */
+ { SIP_OPT_JOIN, NOT_SUPPORTED, "join" },
+ /* Disable the REFER subscription, RFC 4488 */
+ { SIP_OPT_NOREFERSUB, NOT_SUPPORTED, "norefersub" },
+ /* SIP outbound - the final NAT battle - draft-sip-outbound */
+ { SIP_OPT_OUTBOUND, NOT_SUPPORTED, "outbound" },
+ /* RFC3327: Path support */
+ { SIP_OPT_PATH, NOT_SUPPORTED, "path" },
+ /* RFC3840: Callee preferences */
+ { SIP_OPT_PREF, NOT_SUPPORTED, "pref" },
+ /* RFC3312: Precondition support */
+ { SIP_OPT_PRECONDITION, NOT_SUPPORTED, "precondition" },
+ /* RFC3323: Privacy with proxies*/
+ { SIP_OPT_PRIVACY, NOT_SUPPORTED, "privacy" },
+ /* RFC-ietf-sip-uri-list-conferencing-02.txt conference invite lists */
+ { SIP_OPT_RECLISTINV, NOT_SUPPORTED, "recipient-list-invite" },
+ /* RFC-ietf-sip-uri-list-subscribe-02.txt - subscription lists */
+ { SIP_OPT_RECLISTSUB, NOT_SUPPORTED, "recipient-list-subscribe" },
+ /* RFC3891: Replaces: header for transfer */
+ { SIP_OPT_REPLACES, SUPPORTED, "replaces" },
+ /* One version of Polycom firmware has the wrong label */
+ { SIP_OPT_REPLACES, SUPPORTED, "replace" },
+ /* RFC4412 Resource priorities */
+ { SIP_OPT_RESPRIORITY, NOT_SUPPORTED, "resource-priority" },
+ /* RFC3329: Security agreement mechanism */
+ { SIP_OPT_SEC_AGREE, NOT_SUPPORTED, "sec_agree" },
+ /* RFC4092: Usage of the SDP ANAT Semantics in the SIP */
+ { SIP_OPT_SDP_ANAT, NOT_SUPPORTED, "sdp-anat" },
+ /* RFC4028: SIP Session-Timers */
+ { SIP_OPT_TIMER, SUPPORTED, "timer" },
+ /* RFC4538: Target-dialog */
+ { SIP_OPT_TARGET_DIALOG,NOT_SUPPORTED, "tdialog" },
+};
#endif