diff options
author | David Vossel <dvossel@digium.com> | 2010-02-15 15:45:02 +0000 |
---|---|---|
committer | David Vossel <dvossel@digium.com> | 2010-02-15 15:45:02 +0000 |
commit | 2003243947d6cc11141a264f7b04b57b35b0cc00 (patch) | |
tree | 72b0e2d48f3f92adf9294911b59271a48180b958 /channels/sip/include | |
parent | 7d5d0311c1d08f98424764b3c392f214cddc52d2 (diff) |
chan_sip parse code refactoring plus two new unit tests
Code Refactoring Changes
- read_to_parts() moved to reqresp_parser.c and has been renamed as
get_name_and_number()
- get_in_brackets() moved to reqresp_parser.c
- find_closing_quotes() added to sip_utils.h
Logic Changes
- get_name_and_number() now uses parse_uri() and get_calleridname()
for parsing. Before this change only names within quotes were
found, when names not within quotes are possible.
New Unit Tests
-sip_get_name_and_number_test
-sip_get_in_brackets_test
(closes issue #16707)
Reported by: Nick_Lewis
Patches:
issue16706.diff uploaded by dvossel (license 671)
Review: https://reviewboard.asterisk.org/r/499/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246627 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sip/include')
-rw-r--r-- | channels/sip/include/reqresp_parser.h | 25 | ||||
-rw-r--r-- | channels/sip/include/sip_utils.h | 7 |
2 files changed, 32 insertions, 0 deletions
diff --git a/channels/sip/include/reqresp_parser.h b/channels/sip/include/reqresp_parser.h index e724c98dd..d322e7e55 100644 --- a/channels/sip/include/reqresp_parser.h +++ b/channels/sip/include/reqresp_parser.h @@ -52,6 +52,31 @@ int parse_uri(char *uri, const char *scheme, char **ret_name, char **pass, char const char *get_calleridname(const char *input, char *output, size_t outputsize); /*! + * \brief Get name and number from sip header + * + * \note name and number point to malloced memory on return and must be + * freed. If name or number is not found, they will be returned as NULL. + * + * \retval 0 success + * \retval -1 failure + */ +int get_name_and_number(const char *hdr, char **name, char **number); + +/*! \brief Pick out text in brackets from character string + * \return pointer to terminated stripped string + * \param tmp input string that will be modified + * + * Examples: + * \verbatim + * "foo" <bar> valid input, returns bar + * foo returns the whole string + * < "foo ... > returns the string between brackets + * < "foo... bogus (missing closing bracket), returns the whole string + * \endverbatim + */ +char *get_in_brackets(char *tmp); + +/*! * \brief register request parsing tests */ void sip_request_parser_register_tests(void); diff --git a/channels/sip/include/sip_utils.h b/channels/sip/include/sip_utils.h index 86eb81933..549f9392f 100644 --- a/channels/sip/include/sip_utils.h +++ b/channels/sip/include/sip_utils.h @@ -33,4 +33,11 @@ */ unsigned int port_str2int(const char *pt, unsigned int standard); +/*! \brief Locate closing quote in a string, skipping escaped quotes. + * optionally with a limit on the search. + * start must be past the first quote. + */ +const char *find_closing_quote(const char *start, const char *lim); + + #endif |