sofia-sip/sip_parser.h File Reference


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

#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 dependency graph for sip_parser.h:

Go to the source code of this file.

Defines

#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

SOFIAPUBFUN int sip_version_d (char **ss, char const **ver)
 Parse SIP version.
SOFIAPUBFUN int sip_version_xtra (char const *version)
 Calculate extra space required by version string.
SOFIAPUBFUN void sip_version_dup (char **pp, char const **dd, char const *s)
 Duplicate a transport string.
SOFIAPUBFUN int sip_transport_d (char **ss, char const **ttransport)
 Decode transport.
SOFIAPUBFUN int sip_transport_xtra (char const *transport)
 Calculate extra space required by sip_transport_dup().
SOFIAPUBFUN void sip_transport_dup (char **pp, char const **dd, char const *s)
 Duplicate a transport string.
SOFIAPUBFUN sip_method_t sip_method_d (char **ss, char const **nname)
 Parse a SIP method name.
SOFIAPUBFUN char * sip_word_at_word_d (char **ss)
 Parse SIP <word "@" word> construct.
SOFIAPUBFUN int sip_extract_body (msg_t *, sip_t *, char b[], int bsiz, int eos)
 Extract SIP message body, including separator line.
SOFIAPUBFUN int sip_any_route_d (su_home_t *, sip_header_t *, char *s, int slen)
 Parse a Route/Record-Route header.
SOFIAPUBFUN int 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.
SOFIAPUBFUN int sip_name_addr_e (char b[], int 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.


Function Documentation

SOFIAPUBFUN int sip_any_route_d ( su_home_t home,
sip_header_t *  h,
char *  s,
int  slen 
)

Parse a Route/Record-Route header.

The function sip_route_d() parses a Route or a Record-Route header.

Return values:
0 when successful,
-1 upon an error.

SOFIAPUBFUN int sip_extract_body ( msg_t msg,
sip_t sip,
char  b[],
int  bsiz,
int  eos 
)

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 

SOFIAPUBFUN sip_method_t sip_method_d ( char **  ss,
char const **  return_name 
)

Parse a SIP method name.

The function sip_method_d() parses a SIP method, and returns a code corresponding to the method. It stores the address of the first non-LWS character after method name 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 *nname 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 function sip_method_d 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 nname is not NULL, sip_method_d() stores a pointer to the method name to it.

SOFIAPUBFUN int 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 comma. If that character is a separator, the last parameter may not be NUL (zero) terminated. So, after examining value of **ss, tohe calling function MUST set it to NUL.

Other header like Route or Route-Record may require some tweaking.

Returns:
The function sip_name_addr_d() returns 0 if successful, and -1 upon an error.

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

SOFIAPUBFUN int sip_name_addr_e ( char  b[],
int  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.

SOFIAPUBFUN int sip_version_d ( char **  ss,
char const **  ver 
)

Parse SIP version.

The function sip_version_d() parses a SIP version string. It updates 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.


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