aboutsummaryrefslogtreecommitdiffstats
path: root/channels/sip/include
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-04-09 16:04:16 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-04-09 16:04:16 +0000
commitb9509b446ffbc321f3acb7c78d1ebabe9980c28f (patch)
tree22aadabe7400160d5fd2b4522fabdfe2a59d3e68 /channels/sip/include
parentfc9cd201e458ce16357e18beef84e7d4fad0285c (diff)
Add routines for parsing SIP URIs consistently.
From the original issue report opened by Nick Lewis: Many sip headers in many sip methods contain the ABNF structure name-andor-addr = name-addr / addr-spec Examples include the to-header, from-header, contact-header, replyto-header At the moment chan_sip.c makes various different attempts to parse this name-andor-addr structure for each header type and for each sip method with sometimes limited degrees of success. I recommend that this name-andor-addr structure be parsed by a dedicated function and that it be used irrespective of the specific method or header that contains the name-andor-addr structure Nick has also included unit tests for verifying these routines as well, so...heck yeah. (closes issue #16708) Reported by: Nick_Lewis Patches: reqresp_parser-nameandoraddr2.patch uploaded by Nick Lewis (license 657 Review: https://reviewboard.asterisk.org/r/549 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@256530 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/sip/include')
-rw-r--r--channels/sip/include/reqresp_parser.h36
-rw-r--r--channels/sip/include/sip.h30
2 files changed, 66 insertions, 0 deletions
diff --git a/channels/sip/include/reqresp_parser.h b/channels/sip/include/reqresp_parser.h
index d322e7e55..60fc64698 100644
--- a/channels/sip/include/reqresp_parser.h
+++ b/channels/sip/include/reqresp_parser.h
@@ -45,6 +45,15 @@
int parse_uri(char *uri, const char *scheme, char **ret_name, char **pass, char **domain, char **port, char **transport);
/*!
+ * \brief parses a URI in to all of its components and any trailing residue
+ *
+ * \retval 0 on success
+ * \retval -1 on error.
+ *
+ */
+int parse_uri_full(char *uri, const char *scheme, char **user, char **pass, char **host, char **port, struct uriparams *params, char **headers, char **residue);
+
+/*!
* \brief Get caller id name from SIP headers, copy into output buffer
*
* \retval input string pointer placed after display-name field if possible
@@ -76,6 +85,33 @@ int get_name_and_number(const char *hdr, char **name, char **number);
*/
char *get_in_brackets(char *tmp);
+/*! \brief Get text in brackets and any trailing residue
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ * \retval 1 no brackets so got all
+ */
+int get_in_brackets_full(char *tmp, char **out, char **residue);
+
+/*! \brief Parse the ABNF structure
+ * name-andor-addr = name-addr / addr-spec
+ * into its components and return any trailing message-header parameters
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int parse_name_andor_addr(char *uri, const char *scheme, char **name, char **user, char **pass, char **host, char **port, struct uriparams *params, char **headers, char **remander);
+
+/*! \brief Parse all contact header contacts
+ * \retval 0 success
+ * \retval -1 failure
+ * \retval 1 all contacts (star)
+ */
+
+int get_comma(char *parse, char **out);
+
+int parse_contact_header(char *contactheader, struct contactliststruct *contactlist);
+
/*!
* \brief register request parsing tests
*/
diff --git a/channels/sip/include/sip.h b/channels/sip/include/sip.h
index 1d900eb58..49f8ed098 100644
--- a/channels/sip/include/sip.h
+++ b/channels/sip/include/sip.h
@@ -1647,4 +1647,34 @@ struct sip_monitor_instance {
struct sip_epa_entry *suspension_entry;
};
+/*!
+ * \brief uri parameters
+ *
+ */
+
+struct uriparams {
+ char *transport;
+ char *user;
+ char *method;
+ char *ttl;
+ char *maddr;
+ int lr;
+};
+
+struct contact {
+ AST_LIST_ENTRY(contact) list;
+ char *name;
+ char *user;
+ char *pass;
+ char *host;
+ char *port;
+ struct uriparams params;
+ char *headers;
+ char *expires;
+ char *q;
+};
+
+AST_LIST_HEAD_NOLOCK(contactliststruct, contact);
+
+
#endif