sip 1.12.11devel
Loading...
Searching...
No Matches
Macros | Functions
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.

Macros

#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.nosp@m..Pes.nosp@m.si@no.nosp@m.kia..nosp@m.com.
Date
Created: Thu Mar 8 15:13:11 2001 ppessi

Macro Definition Documentation

◆ SIP_HEADER_CLASS_G

#define SIP_HEADER_CLASS_G (   c,
  l,
  s,
  kind 
)

Define a header class for headers without any extra data to copy.


Function Documentation

◆ sip_any_route_d()

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
0when successful,
-1upon an error.

◆ sip_extract_body()

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
msgmessage object [IN]
sippublic SIP message structure [IN/OUT]
bbuffer containing unparsed data [IN]
bsizbuffer size [IN]
eostrue if buffer contains whole message [IN]
Return values
-1error
0cannot proceed
m

◆ sip_method_d()

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
sspointer to pointer to string to be parsed
return_namevalue-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.

◆ sip_name_addr_d()

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
homepointer to memory home
inout_spointer to pointer to string to be parsed
return_displayvalue-result parameter for display-name
return_urlvalue-result parameter for addr-spec
return_paramsvalue-result paramater for parameters
return_commentvalue-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
0if successful
-1upon an error
See also
From, To, Contact
See also
Discussion about comma, semicolon and question mark in RFC 3261 section 20.10.

◆ sip_name_addr_dup()

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_displayvalue-result parameter for copied name (may be NULL)
displaydisplay name (may be NULL)
d_addrvalue-result parameter for copied address
addrpointer to URL address structure
d_paramsvalue-result parameter for copied parameters (may be NULL)
paramspointer to parameter list (may be NULL)
bpointer to memory pool
xtrasize of the memory pool
Return values
Endof the memory area used.
Since
New in 1.12.7.

◆ sip_name_addr_e()

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
bbuffer to store the encoding result
bsizsize of the buffer b
flagsencoding flags
displaydisplay name encoded before the url (may be NULL)
bracketsif true, use always brackets around url
urlpointer to URL structure
paramspointer to parameter list (may be NULL)
commentcomment 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.

◆ sip_name_addr_xtra()

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
displaydisplay name (may be NULL)
addrpointer to URL structure
paramspointer to parameter list (may be NULL)
offsetbase offset
Return values
Sizeof duplicated name-addr-params construct, including base offset.
Since
New in 1.12.7.

◆ sip_version_d()

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
ssstring to be parsed [IN/OUT]
vervalue result for version [OUT]
Return values
0when successful,
-1upon an error.

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