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.
#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_t * | sip_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_t * | sip_status_create (su_home_t *home, unsigned status, char const *phrase, char const *version) |
Create a status line object. | |
sip_payload_t * | sip_payload_create (su_home_t *home, void const *data, isize_t len) |
Create a SIP payload structure. | |
sip_separator_t * | sip_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_t * | sip_call_id_create (su_home_t *home, char const *domain) |
Create a Call-ID header object. | |
sip_cseq_t * | sip_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_t * | sip_content_length_create (su_home_t *home, uint32_t n) |
Create a Content-Length header object. | |
sip_date_t * | sip_date_create (su_home_t *home, sip_time_t date) |
Create an Date header object. | |
sip_expires_t * | sip_expires_create (su_home_t *home, sip_time_t delta) |
Create an Expires header object. | |
sip_from_t * | sip_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_t * | sip_route_create (su_home_t *home, url_t const *url, url_t const *maddr) |
Create a Route header object. | |
sip_record_route_t * | sip_record_route_create (su_home_t *home, url_t const *rq_url, url_t const *maddr) |
Create a Record-Route header object. | |
sip_to_t * | sip_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_t * | sip_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. |
issize_t sip_any_route_d | ( | su_home_t * | home, | |
sip_header_t * | h, | |||
char * | s, | |||
isize_t | slen | |||
) |
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.
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 |
NULL
upon an error. 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:
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 |
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.0 | if successful | |
-1 | upon an error |
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.
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) |