Defines | Functions

sofia-sip/sip_parser.h File Reference

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>
Include dependency graph for sip_parser.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.

Detailed Description

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.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>.
Date:
Created: Thu Mar 8 15:13:11 2001 ppessi

Define Documentation

#define SIP_PARSER_H

Defined when <sofia-sip/sip_parser.h> has been included.


Function Documentation

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.

Return values:
0 when successful,
-1 upon an error.
issize_t sip_extract_body ( msg_t msg,
sip_t sip,
char  b[],
isize_t  bsiz,
int  eos 
)

Extract SIP message body, including separator line.

Extract SIP message body, including separator line.

Parameters:
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]
Return values:
-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.

Parameters:
ss pointer to pointer to string to be parsed
return_name value-result parameter for method name
Note:
If there is no whitespace after method name, the value in *return_name may not be NUL-terminated. The calling function must NUL terminate the value by setting the **ss to NUL after first examining its value.
Returns:
The method code if method was identified, 0 (sip_method_unknown()) if method is not known, or -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:

[display-name] addr-spec [parameters] [comment] [ss]
Parameters:
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
Note:
After succesful call to the function 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.
Return values:
0 if successful
-1 upon an error
See also:
From, To, Contact

See also:
Discussion about comma, semicolon and question mark in RFC 3261 section 20.10.

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.

Parameters:
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
Return values:
End of the memory area used.
Since:
New in 1.12.7.
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.

Parameters:
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)
Returns:
Returns number of characters in encoding, excluding the final NUL.
Note:
The encoding result may be incomplete if the buffer size is not large enough to store the whole encoding result.
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.

Parameters:
display display name (may be NULL)
addr pointer to URL structure
params pointer to parameter list (may be NULL)
offset base offset
Return values:
Size of duplicated name-addr-params construct, including base offset.
Since:
New in 1.12.7.
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.

Parameters:
ss string to be parsed [IN/OUT]
ver value result for version [OUT]
Return values:
0 when successful,
-1 upon an error.
char* sip_word_at_word_d ( char **  ss  ) 

Parse SIP <word "@" word> construct used in Call-ID.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Sofia-SIP 1.12.11 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.