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: https://origsvn.digium.com/svn/asterisk/trunk@256530 65c4cc65-6c06-0410-ace0-fbb531ad65f3
certified/1.8.6
Mark Michelson 15 years ago
parent ae7b76a1b9
commit 4b8f1c8cac

@ -44,6 +44,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
*
@ -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
*/

@ -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

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save