Asterisk - The Open Source Telephony Project
GIT-master-a24979a
|
sip request response parser header file More...
Go to the source code of this file.
Data Structures | |
struct | contact |
struct | uriparams |
uri parameters More... | |
Functions | |
AST_LIST_HEAD_NOLOCK (contactliststruct, contact) | |
void | free_via (struct sip_via *v) |
Free parsed Via data. More... | |
const char * | get_calleridname (const char *input, char *output, size_t outputsize) |
Get caller id name from SIP headers, copy into output buffer. More... | |
int | get_comma (char *parse, char **out) |
Parse all contact header contacts. More... | |
char * | get_in_brackets (char *tmp) |
Pick out text in brackets from character string. More... | |
int | get_in_brackets_const (const char *src, const char **start, int *length) |
Get text in brackets on a const without copy. More... | |
int | get_in_brackets_full (char *tmp, char **out, char **residue) |
Get text in brackets and any trailing residue. More... | |
int | get_name_and_number (const char *hdr, char **name, char **number) |
Get name and number from sip header. More... | |
int | parse_contact_header (char *contactheader, struct contactliststruct *contactlist) |
int | parse_name_andor_addr (char *uri, const char *scheme, char **name, char **user, char **pass, char **domain, struct uriparams *params, char **headers, char **residue) |
Parse the ABNF structure name-andor-addr = name-addr / addr-spec into its components and return any trailing message-header parameters. More... | |
unsigned int | parse_sip_options (const char *options, char *unsupported, size_t unsupported_len) |
Parse supported header in incoming packet. More... | |
int | parse_uri (char *uri, const char *scheme, char **ret_name, char **pass, char **hostport, char **transport) |
parses a URI in its components. More... | |
int | parse_uri_full (char *uri, const char *scheme, char **user, char **pass, char **hostport, struct uriparams *params, char **headers, char **residue) |
parses a URI in to all of its components and any trailing residue More... | |
struct sip_via * | parse_via (const char *header) |
Parse a Via header. More... | |
void | sip_reqresp_parser_exit (void) |
Free resources used by request and response parser. More... | |
int | sip_reqresp_parser_init (void) |
initialize request and response parser data More... | |
void | sip_request_parser_register_tests (void) |
register request parsing tests More... | |
void | sip_request_parser_unregister_tests (void) |
unregister request parsing tests More... | |
int | sip_uri_cmp (const char *input1, const char *input2) |
Compare two URIs as described in RFC 3261 Section 19.1.4. More... | |
sip request response parser header file
Definition in file reqresp_parser.h.
AST_LIST_HEAD_NOLOCK | ( | contactliststruct | , |
contact | |||
) |
Referenced by __ast_answer(), __ast_queue_frame(), announce_thread(), channel_do_masquerade(), hook_event_cb(), and safe_sleep_conditional().
void free_via | ( | struct sip_via * | v | ) |
Free parsed Via data.
Definition at line 2375 of file reqresp_parser.c.
References ast_free, and sip_via::via.
Referenced by __find_call(), __sip_alloc(), match_req_to_dialog(), and parse_via().
const char* get_calleridname | ( | const char * | input, |
char * | output, | ||
size_t | outputsize | ||
) |
Get caller id name from SIP headers, copy into output buffer.
Definition at line 695 of file reqresp_parser.c.
References ast_log, ast_skip_blanks(), input(), and LOG_WARNING.
Referenced by get_name_and_number(), parse_name_andor_addr(), and receive_message().
int get_comma | ( | char * | parse, |
char ** | out | ||
) |
Parse all contact header contacts.
0 | success |
-1 | failure |
1 | all contacts (star) |
Definition at line 1438 of file reqresp_parser.c.
References ast_log, c, find_closing_quote(), in, LOG_WARNING, NULL, out, and parse().
Referenced by parse_contact_header().
char* get_in_brackets | ( | char * | tmp | ) |
Pick out text in brackets from character string.
tmp | input string that will be modified |
Examples:
* "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 *
Definition at line 1173 of file reqresp_parser.c.
References get_in_brackets_full(), NULL, out, and tmp().
Referenced by determine_sip_publish_type(), extract_uri(), get_also_info(), get_destination(), get_domain(), get_name_and_number(), get_pai(), get_refer_info(), handle_cc_notify(), parse_moved_contact(), parse_ok_contact(), receive_message(), reqprep(), sip_get_cc_information(), transmit_refer(), transmit_state_notify(), uac_sips_contact(), and uas_sips_contact().
int get_in_brackets_const | ( | const char * | src, |
const char ** | start, | ||
int * | length | ||
) |
Get text in brackets on a const without copy.
src | String to search | |
[out] | start | Set to first character inside left bracket. |
[out] | length | Set to lenght of string inside brackets |
0 | success |
-1 | failure |
1 | no brackets so got all |
Definition at line 1052 of file reqresp_parser.c.
References ast_log, ast_strlen_zero(), find_closing_quote(), LOG_WARNING, NULL, and parse().
Referenced by build_route(), and sip_route_process_header().
int get_in_brackets_full | ( | char * | tmp, |
char ** | out, | ||
char ** | residue | ||
) |
Get text in brackets and any trailing residue.
0 | success |
-1 | failure |
1 | no brackets so got all |
Definition at line 1105 of file reqresp_parser.c.
References ast_log, ast_strlen_zero(), find_closing_quote(), LOG_WARNING, NULL, out, parse(), and tmp().
Referenced by get_in_brackets(), and parse_name_andor_addr().
int get_name_and_number | ( | const char * | hdr, |
char ** | name, | ||
char ** | number | ||
) |
Get name and number from sip header.
0 | success |
-1 | failure |
Definition at line 905 of file reqresp_parser.c.
References ast_copy_string(), ast_log, ast_strdup, ast_strlen_zero(), ast_uri_decode(), ast_uri_sip_user, dummy(), get_calleridname(), get_in_brackets(), LOG_ERROR, name, NULL, and parse_uri().
Referenced by change_redirecting_information(), and get_pai().
int parse_contact_header | ( | char * | contactheader, |
struct contactliststruct * | contactlist | ||
) |
Definition at line 1475 of file reqresp_parser.c.
References ast_calloc, AST_LIST_HEAD_SET_NOLOCK, AST_LIST_INSERT_TAIL, contact::expires, get_comma(), contact::headers, contact::hostport, last, contact::name, NULL, contact::params, parse_name_andor_addr(), contact::pass, contact::q, contact::user, and value.
int parse_name_andor_addr | ( | char * | uri, |
const char * | scheme, | ||
char ** | name, | ||
char ** | user, | ||
char ** | pass, | ||
char ** | domain, | ||
struct uriparams * | params, | ||
char ** | headers, | ||
char ** | residue | ||
) |
Parse the ABNF structure name-andor-addr = name-addr / addr-spec into its components and return any trailing message-header parameters.
0 | success |
-1 | failure |
Definition at line 1262 of file reqresp_parser.c.
References buf, get_calleridname(), get_in_brackets_full(), name, NULL, parse_uri_full(), and pass.
Referenced by parse_contact_header().
unsigned int parse_sip_options | ( | const char * | options, |
char * | unsupported, | ||
size_t | unsupported_len | ||
) |
Parse supported header in incoming packet.
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.
options | list | |
[in,out] | unsupported | buffer (optional) |
[in,out] | unsupported_len | buffer length |
options
to unsupported
. Callers of this function should make sure the unsupported buffer is clear before calling this function.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.
Definition at line 1689 of file reqresp_parser.c.
References ARRAY_LEN, ast_copy_string(), ast_debug, ast_strdupa, ast_strip(), ast_strlen_zero(), FALSE, cfsip_options::id, NULL, options, out, SIP_OPT_UNKNOWN, sip_options, SUPPORTED, text, and TRUE.
Referenced by handle_request_bye(), and handle_request_invite().
int parse_uri | ( | char * | uri, |
const char * | scheme, | ||
char ** | ret_name, | ||
char ** | pass, | ||
char ** | hostport, | ||
char ** | transport | ||
) |
parses a URI in its components.
0 | on success |
-1 | on error. |
* general form we are expecting is sip:user:password;user-parameters@host:port;uri-parameters?headers *
Definition at line 517 of file reqresp_parser.c.
References NULL, parse_uri_full(), pass, and uriparams::transport.
Referenced by determine_sip_publish_type(), get_name_and_number(), and parse_uri_legacy_check().
int parse_uri_full | ( | char * | uri, |
const char * | scheme, | ||
char ** | user, | ||
char ** | pass, | ||
char ** | hostport, | ||
struct uriparams * | params, | ||
char ** | headers, | ||
char ** | residue | ||
) |
parses a URI in to all of its components and any trailing residue
0 | on success |
-1 | on error. |
parses a URI in to all of its components and any trailing residue
Definition at line 37 of file reqresp_parser.c.
References ast_debug, ast_strdupa, ast_strlen_zero(), c, error(), uriparams::lr, uriparams::maddr, uriparams::method, NULL, pass, strsep(), uriparams::transport, uriparams::ttl, uriparams::user, and value.
Referenced by parse_name_andor_addr(), and parse_uri().
struct sip_via* parse_via | ( | const char * | header | ) |
Parse a Via header.
This function parses the Via header and processes it according to section 18.2 of RFC 3261 and RFC 3581. Since we don't have a transport layer, we only care about the maddr and ttl parms. The received and rport params are not parsed.
Definition at line 2385 of file reqresp_parser.c.
References ast_calloc, ast_log, ast_skip_blanks(), ast_strdup, ast_strlen_zero(), sip_via::branch, c, free_via(), LOG_ERROR, sip_via::maddr, NULL, sip_via::port, sip_via::protocol, sip_via::sent_by, strsep(), sip_via::ttl, and sip_via::via.
Referenced by __find_call(), __sip_alloc(), and match_req_to_dialog().
void sip_reqresp_parser_exit | ( | void | ) |
Free resources used by request and response parser.
Definition at line 2678 of file reqresp_parser.c.
References NULL.
int sip_reqresp_parser_init | ( | void | ) |
initialize request and response parser data
0 | Success |
-1 | Failure |
Definition at line 2667 of file reqresp_parser.c.
References NULL.
Referenced by load_module().
void sip_request_parser_register_tests | ( | void | ) |
register request parsing tests
Definition at line 2640 of file reqresp_parser.c.
References AST_TEST_REGISTER.
Referenced by sip_register_tests().
void sip_request_parser_unregister_tests | ( | void | ) |
unregister request parsing tests
Definition at line 2653 of file reqresp_parser.c.
References AST_TEST_UNREGISTER.
int sip_uri_cmp | ( | const char * | input1, |
const char * | input2 | ||
) |
Compare two URIs as described in RFC 3261 Section 19.1.4.
input1 | First URI |
input2 | Second URI |
0 | URIs match |
nonzero | URIs do not match or one or both is malformed |
Definition at line 2149 of file reqresp_parser.c.
References ast_strdupa, ast_strlen_zero(), ast_uri_decode(), ast_uri_sip_user, S_OR, sip_uri_domain_cmp(), sip_uri_headers_cmp(), sip_uri_params_cmp(), and strsep().
Referenced by find_by_notify_uri_helper(), find_by_subscribe_uri_helper(), and handle_request_invite().