sip_basic.c File Reference


Detailed Description

Basic SIP headers.

The file sip_basic.c contains 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

int sip_request_d (su_home_t *home, sip_header_t *h, char *s, int slen)
 Parse request line.
int sip_request_e (char b[], int bsiz, sip_header_t const *h, int flags)
 Encode a SIP request line.
char * sip_request_dup_one (sip_header_t *dst, sip_header_t const *src, char *b, int 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.
int sip_status_d (su_home_t *home, sip_header_t *h, char *s, int slen)
 Parse status line.
int sip_status_dup_xtra (sip_header_t const *h, int 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, int 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, int len)
 Create a SIP payload structure.
sip_separator_tsip_separator_create (su_home_t *home)
 Create a SIP separator line structure.
int sip_error_d (su_home_t *home, msg_header_t *h, char *s, int slen)
 Parse a erroneous headers.
int sip_error_e (char b[], int bsiz, msg_header_t const *h, int flags)
 Print a erroneous headers.
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.
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.
int sip_addr_d (su_home_t *home, sip_header_t *h, char *s, int slen)
 Parse To or From headers.
int sip_call_id_dup_xtra (sip_header_t const *h, int 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, int 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)
 The function sip_from_tag() adds a tag to a From header.
int sip_any_route_d (su_home_t *home, sip_header_t *h, char *s, int slen)
 Parse a Route/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 an sip_to_t object.
char * sip_via_dup_one (sip_header_t *dst, sip_header_t const *src, char *b, int 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 SIP request line.
msg_hclass_t sip_status_class []
 Header class for SIP status line.
msg_hclass_t sip_payload_class []
 Header class for SIP message payload.
msg_hclass_t sip_separator_class []
 Header class for SIP separator line between headers and payload.
msg_hclass_t sip_unknown_class []
 Header class for SIP unknown headers.
msg_hclass_t sip_error_class []
 Header class for SIP erroneous headers.
msg_hclass_t sip_call_id_class []
 Header class for SIP Call-ID header.
msg_hclass_t sip_cseq_class []
 Header class for SIP CSeq header.
msg_hclass_t sip_contact_class []
 Header class for SIP Contact header.
msg_hclass_t sip_content_length_class []
 Header class for SIP Content-Length header.
msg_hclass_t sip_date_class []
 Header class for SIP Date header.
msg_hclass_t sip_expires_class []
 Header class for SIP Expires header.
msg_hclass_t sip_from_class []
 Header class for SIP From header.
msg_hclass_t sip_max_forwards_class []
 Header class for SIP Max-Forwards header.
msg_hclass_t sip_min_expires_class []
 Header class for SIP Min-Expires header.
msg_hclass_t sip_retry_after_class []
 Header class for SIP Retry-After header.
msg_hclass_t sip_route_class []
 Header class for SIP Route header.
msg_hclass_t sip_record_route_class []
 Header class for SIP Record-Route header.
msg_hclass_t sip_to_class []
 Header class for SIP To header.
msg_hclass_t sip_via_class []
 Header class for SIP Via header.

Function Documentation

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.

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

Duplicate a sip_call_id object.

The function sip_call_id_dup_one() duplicates (deep copies) a sip_call_id 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.

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.

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.

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

Parse request line.

The function sip_request_d() parses the request line from a a SIP message.

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

Encode a SIP request line.

The function sip_request_e() prints a SIP request line.


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