sip_basic.c File Reference


Detailed Description

Basic SIP headers.

Implementation of header classes for basic SIP headers, like request and status lines, payload, Call-ID, CSeq, Contact, Content-Length, Date, Expires, From, Route, Record-Route, To, and Via.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>.
Date:
Created: Tue Jun 13 02:57:51 2000 ppessi

#include "config.h"
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/string0.h>
#include "sofia-sip/sip_parser.h"
#include <sofia-sip/sip_util.h>
#include <sofia-sip/sip_status.h>
#include <sofia-sip/msg_date.h>
#include <sofia-sip/su_uniqueid.h>
#include <stddef.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>

Include dependency graph for sip_basic.c:


Functions

issize_t sip_request_d (su_home_t *home, sip_header_t *h, char *s, isize_t slen)
 Parse request line from a a SIP message.
issize_t sip_request_e (char b[], isize_t bsiz, sip_header_t const *h, int flags)
 Encode request line of a a SIP message.
char * sip_request_dup_one (sip_header_t *dst, sip_header_t const *src, char *b, isize_t xtra)
 Duplicate one request header.
sip_request_tsip_request_create (su_home_t *home, sip_method_t method, char const *name, url_string_t const *uri, char const *version)
 Create a request line object.
issize_t sip_status_d (su_home_t *home, sip_header_t *h, char *s, isize_t slen)
 Parse status line.
isize_t sip_status_dup_xtra (sip_header_t const *h, isize_t offset)
 Extra size of a sip_status_t object.
char * sip_status_dup_one (sip_header_t *dst, sip_header_t const *src, char *b, isize_t xtra)
 Duplicate one status header.
sip_status_tsip_status_create (su_home_t *home, unsigned status, char const *phrase, char const *version)
 Create a status line object.
sip_payload_tsip_payload_create (su_home_t *home, void const *data, isize_t len)
 Create a SIP payload structure.
sip_separator_tsip_separator_create (su_home_t *home)
 Create a SIP separator line structure.
issize_t sip_error_d (su_home_t *home, msg_header_t *h, char *s, isize_t slen)
 Parse a SIP erroneous headers.
issize_t sip_error_e (char b[], isize_t bsiz, msg_header_t const *h, int flags)
 Print a SIP erroneous headers.
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.
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.
issize_t sip_addr_d (su_home_t *home, sip_header_t *h, char *s, isize_t slen)
 Parse To or From headers.
isize_t sip_call_id_dup_xtra (sip_header_t const *h, isize_t offset)
 Extra size of a sip_call_id_t object.
char * sip_call_id_dup_one (sip_header_t *dst, sip_header_t const *src, char *b, isize_t xtra)
 Duplicate a sip_call_id object.
sip_call_id_tsip_call_id_create (su_home_t *home, char const *domain)
 Create a Call-ID header object.
sip_cseq_tsip_cseq_create (su_home_t *home, uint32_t seq, unsigned method, char const *method_name)
 Create a CSeq header object.
int sip_contact_add_param (su_home_t *home, sip_contact_t *m, char const *param)
 Add a parameter to a Contact header object.
sip_content_length_tsip_content_length_create (su_home_t *home, uint32_t n)
 Create a Content-Length header object.
sip_date_tsip_date_create (su_home_t *home, sip_time_t date)
 Create an Date header object.
sip_expires_tsip_expires_create (su_home_t *home, sip_time_t delta)
 Create an Expires header object.
sip_from_tsip_from_create (su_home_t *home, url_string_t const *s)
 Create a From header object.
int sip_from_add_param (su_home_t *home, sip_from_t *from, char const *param)
 Add a parameter to an sip_from_t object.
int sip_from_tag (su_home_t *home, sip_from_t *from, char const *tag)
 Add a tag to a From header.
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.
sip_route_tsip_route_create (su_home_t *home, url_t const *url, url_t const *maddr)
 Create a Route header object.
sip_record_route_tsip_record_route_create (su_home_t *home, url_t const *rq_url, url_t const *maddr)
 Create a Record-Route header object.
sip_to_tsip_to_create (su_home_t *home, url_string_t const *url)
 Create a To header object.
int sip_to_add_param (su_home_t *home, sip_to_t *to, char const *param)
 Add a parameter to a sip_to_t object.
char * sip_via_dup_one (sip_header_t *dst, sip_header_t const *src, char *b, isize_t xtra)
 Duplicate one sip_via_t object.
int sip_via_add_param (su_home_t *home, sip_via_t *v, char const *param)
 Add a parameter to a Via header object.
sip_via_tsip_via_create (su_home_t *home, char const *host, char const *port, char const *transport,...)
 Create a Via object.
char const * sip_via_port (sip_via_t const *v, int *using_rport)
 Get port number corresponding to a Via line.

Variables

msg_hclass_t sip_request_class []
 Header class for request line.
msg_hclass_t sip_status_class []
 Header class for status line.
msg_hclass_t sip_payload_class []
 Header class for message payload.
msg_hclass_t sip_separator_class []
 Header class for separator line between headers and body.
msg_hclass_t sip_unknown_class []
 Header class for unknown headers.
msg_hclass_t sip_error_class []
 Header class for erroneous headers.
msg_hclass_t sip_call_id_class []
 Header class for Call-ID header.
msg_hclass_t sip_cseq_class []
 Header class for CSeq header.
msg_hclass_t sip_contact_class []
 Header class for Contact header.
msg_hclass_t sip_content_length_class []
 Header class for Content-Length header.
msg_hclass_t sip_date_class []
 Header class for Date header.
msg_hclass_t sip_expires_class []
 Header class for Expires header.
msg_hclass_t sip_from_class []
 Header class for From header.
msg_hclass_t sip_max_forwards_class []
 Header class for Max-Forwards header.
msg_hclass_t sip_min_expires_class []
 Header class for Min-Expires header.
msg_hclass_t sip_retry_after_class []
 Header class for Retry-After header.
msg_hclass_t sip_route_class []
 Header class for Route header.
msg_hclass_t sip_record_route_class []
 Header class for Record-Route header.
msg_hclass_t sip_to_class []
 Header class for To header.
msg_hclass_t sip_via_class []
 Header class for Via header.

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.

char* sip_call_id_dup_one ( sip_header_t dst,
sip_header_t const *  src,
char *  b,
isize_t  xtra 
)

Duplicate a sip_call_id object.

Duplicate (copy deeply) a single sip_call_id_t header object.

Parameters:
dst pointer to newly allocated header object
src pointer to a header object to be duplicated
b memory buffer used to copy external references
xtra number bytes in buffer b
Returns:
Pointer to the new copy of sip_call_id_t object, or NULL upon an error.

isize_t sip_call_id_dup_xtra ( sip_header_t const *  h,
isize_t  offset 
)

Extra size of a sip_call_id_t object.

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.

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.

issize_t sip_request_d ( su_home_t *  home,
sip_header_t h,
char *  s,
isize_t  slen 
)

Parse request line from a a SIP message.

char* sip_request_dup_one ( sip_header_t dst,
sip_header_t const *  src,
char *  b,
isize_t  xtra 
)

Duplicate one request header.

issize_t sip_request_e ( char  b[],
isize_t  bsiz,
sip_header_t const *  h,
int  flags 
)

Encode request line of a a SIP message.

char* sip_status_dup_one ( sip_header_t dst,
sip_header_t const *  src,
char *  b,
isize_t  xtra 
)

Duplicate one status header.

isize_t sip_status_dup_xtra ( sip_header_t const *  h,
isize_t  offset 
)

Extra size of a sip_status_t object.


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