SIP parser provider interface. More...
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/msg.h>
#include <sofia-sip/msg_parser.h>
#include <sofia-sip/sip.h>
#include <sofia-sip/sip_header.h>
#include <sofia-sip/su_string.h>
Go to the source code of this file.
Defines | |
#define | SIP_PARSER_H |
Defined when <sofia-sip/sip_parser.h> has been included. | |
#define | SIP_HEADER_CLASS(c, l, s, params, kind, dup) |
Define a header class for a SIP header. | |
#define | SIP_HEADER_CLASS_C(c, l, s, params, kind, dup) |
Define a header class for a critical SIP header. | |
#define | SIP_HEADER_CLASS_G(c, l, s, kind) |
Define a header class for headers without any extra data to copy. | |
#define | SIP_HEADER_CLASS_LIST(c, l, s, kind) |
Define a header class for a msg_list_t kind of header. | |
#define | SIP_HEADER_CLASS_AUTH(c, l, kind) |
Define a authorization header class. | |
Functions | |
int | sip_version_d (char **ss, char const **ver) |
Parse SIP version. | |
isize_t | sip_version_xtra (char const *version) |
Calculate extra space required by version string. | |
void | sip_version_dup (char **pp, char const **dd, char const *s) |
Duplicate a transport string. | |
issize_t | sip_transport_d (char **ss, char const **ttransport) |
Decode transport. | |
isize_t | sip_transport_xtra (char const *transport) |
Calculate extra space required by sip_transport_dup(). | |
void | sip_transport_dup (char **pp, char const **dd, char const *s) |
Duplicate a transport string. | |
sip_method_t | sip_method_d (char **ss, char const **nname) |
Parse a SIP method name. | |
char * | sip_word_at_word_d (char **ss) |
Parse SIP <word "@" word> construct used in Call-ID. | |
issize_t | sip_extract_body (msg_t *, sip_t *, char b[], isize_t bsiz, int eos) |
Extract SIP message body, including separator line. | |
issize_t | sip_any_route_d (su_home_t *, sip_header_t *, char *s, isize_t slen) |
Parse a Route or a Record-Route header. | |
issize_t | sip_name_addr_d (su_home_t *home, char **inout_s, char const **return_display, url_t *out_url, msg_param_t const **return_params, char const **return_comment) |
Parse name-addr. | |
issize_t | sip_name_addr_e (char b[], isize_t bsiz, int flags, char const *display, int always_ltgt, url_t const url[], msg_param_t const params[], char const *comment) |
Encode name-addr and parameter list. | |
isize_t | sip_name_addr_xtra (char const *display, url_t const *addr, msg_param_t const params[], isize_t offset) |
Calculate the extra size needed to duplicate a name-addr-params construct. | |
char * | sip_name_addr_dup (char const **d_display, char const *display, url_t *d_addr, url_t const *addr, msg_param_t const **d_params, msg_param_t const params[], char *b, isize_t xtra) |
Duplicate a name-addr-params construct. |
SIP parser provider interface.
This file contains functions and macros used to create a SIP parser using generic text message parser, and to define new SIP header classes.
#define SIP_PARSER_H |
Defined when <sofia-sip/sip_parser.h> has been included.
issize_t sip_any_route_d | ( | su_home_t * | home, | |
sip_header_t * | h, | |||
char * | s, | |||
isize_t | slen | |||
) |
Parse a Route or a Record-Route header.
0 | when successful, | |
-1 | upon an error. |
Extract SIP message body, including separator line.
Extract SIP message body, including separator line.
msg | message object [IN] | |
sip | public SIP message structure [IN/OUT] | |
b | buffer containing unparsed data [IN] | |
bsiz | buffer size [IN] | |
eos | true if buffer contains whole message [IN] |
-1 | error | |
0 | cannot proceed | |
m |
sip_method_t sip_method_d | ( | char ** | ss, | |
char const ** | return_name | |||
) |
Parse a SIP method name.
Parse a SIP method name and return a code corresponding to the method. The address of the first non-LWS character after method name is stored in *ss.
ss | pointer to pointer to string to be parsed | |
return_name | value-result parameter for method name |
-1
(sip_method_invalid()) if an error occurred.If the value-result argument return_name is not NULL
, a pointer to the method name is stored to it.
issize_t sip_name_addr_d | ( | su_home_t * | home, | |
char ** | inout_s, | |||
char const ** | return_display, | |||
url_t * | return_url, | |||
msg_param_t const ** | return_params, | |||
char const ** | return_comment | |||
) |
Parse name-addr.
Parses ( name-addr | addr-spec ) construct on Contact, From, To, and other compatible headers. It splits the argument string in four parts:
home | pointer to memory home | |
inout_s | pointer to pointer to string to be parsed | |
return_display | value-result parameter for display-name | |
return_url | value-result parameter for addr-spec | |
return_params | value-result paramater for parameters | |
return_comment | value-result parameter for comment |
sip_name_addr_d()
, *ss contains pointer to the first character not beloging to name-addr, most probably a comma. If that character is a separator, the last parameter may not be NUL (zero) terminated. So, after examining value of **ss, the calling function MUST set it to NUL.0 | if successful | |
-1 | upon an error |
char* sip_name_addr_dup | ( | char const ** | d_display, | |
char const * | display, | |||
url_t * | d_addr, | |||
url_t const * | addr, | |||
msg_param_t const ** | d_params, | |||
msg_param_t const | params[], | |||
char * | b, | |||
isize_t | xtra | |||
) |
Duplicate a name-addr-params construct.
d_display | value-result parameter for copied name (may be NULL) | |
display | display name (may be NULL) | |
d_addr | value-result parameter for copied address | |
addr | pointer to URL address structure | |
d_params | value-result parameter for copied parameters (may be NULL) | |
params | pointer to parameter list (may be NULL) | |
b | pointer to memory pool | |
xtra | size of the memory pool |
End | of the memory area used. |
issize_t sip_name_addr_e | ( | char | b[], | |
isize_t | bsiz, | |||
int | flags, | |||
char const * | display, | |||
int | brackets, | |||
url_t const | url[], | |||
msg_param_t const | params[], | |||
char const * | comment | |||
) |
Encode name-addr and parameter list.
Encodes name-addr headers, like From, To, Call-Info, Error-Info, Route, and Record-Route.
b | buffer to store the encoding result | |
bsiz | size of the buffer b | |
flags | encoding flags | |
display | display name encoded before the url (may be NULL) | |
brackets | if true, use always brackets around url | |
url | pointer to URL structure | |
params | pointer to parameter list (may be NULL) | |
comment | comment string encoded after others (may be NULL) |
isize_t sip_name_addr_xtra | ( | char const * | display, | |
url_t const * | addr, | |||
msg_param_t const | params[], | |||
isize_t | offset | |||
) |
Calculate the extra size needed to duplicate a name-addr-params construct.
display | display name (may be NULL) | |
addr | pointer to URL structure | |
params | pointer to parameter list (may be NULL) | |
offset | base offset |
Size | of duplicated name-addr-params construct, including base offset. |
int sip_version_d | ( | char ** | ss, | |
char const ** | ver | |||
) |
Parse SIP version.
Parse a SIP version string. Update the pointer at ss to first non-LWS character after the version string.
ss | string to be parsed [IN/OUT] | |
ver | value result for version [OUT] |
0 | when successful, | |
-1 | upon an error. |
char* sip_word_at_word_d | ( | char ** | ss | ) |
Parse SIP <word "@" word> construct used in Call-ID.