libosip  4.0.0
Classes | Macros | Typedefs | Functions
oSIP message API
The parser modules

Classes

struct  osip_message

Macros

#define SIP_MESSAGE_MAX_LENGTH   4000
#define BODY_MESSAGE_MAX_SIZE   4000
#define MSG_IS_RESPONSE(msg)   ((msg)->status_code!=0)
#define MSG_IS_REQUEST(msg)   ((msg)->status_code==0)
#define MSG_IS_INVITE(msg)
#define MSG_IS_ACK(msg)
#define MSG_IS_REGISTER(msg)
#define MSG_IS_BYE(msg)
#define MSG_IS_OPTIONS(msg)
#define MSG_IS_INFO(msg)
#define MSG_IS_CANCEL(msg)
#define MSG_IS_REFER(msg)
#define MSG_IS_NOTIFY(msg)
#define MSG_IS_SUBSCRIBE(msg)
#define MSG_IS_MESSAGE(msg)
#define MSG_IS_PRACK(msg)
#define MSG_IS_UPDATE(msg)
#define MSG_IS_PUBLISH(msg)
#define MSG_IS_STATUS_1XX(msg)
#define MSG_IS_STATUS_2XX(msg)
#define MSG_IS_STATUS_3XX(msg)
#define MSG_IS_STATUS_4XX(msg)
#define MSG_IS_STATUS_5XX(msg)
#define MSG_IS_STATUS_6XX(msg)
#define MSG_TEST_CODE(msg, code)
#define MSG_IS_RESPONSE_FOR(msg, requestname)
#define osip_generic_param_init(GP)   osip_uri_param_init(GP)
#define osip_generic_param_free(GP)   osip_uri_param_free(GP)
#define osip_generic_param_set(GP, NAME, VALUE)   osip_uri_param_set(GP, NAME, VALUE)
#define osip_generic_param_clone   osip_uri_param_clone
#define osip_generic_param_add(LIST, NAME, VALUE)   osip_uri_param_add(LIST,NAME,VALUE)
#define osip_generic_param_get_byname(LIST, NAME, DEST)   osip_uri_param_get_byname(LIST,NAME,DEST)

Typedefs

typedef struct osip_message osip_message_t

Functions

int osip_message_init (osip_message_t **sip)
void osip_message_free (osip_message_t *sip)
int osip_message_parse (osip_message_t *sip, const char *buf, size_t length)
int osip_message_parse_sipfrag (osip_message_t *sip, const char *buf, size_t length)
int osip_message_to_str (osip_message_t *sip, char **dest, size_t *message_length)
int osip_message_to_str_sipfrag (osip_message_t *sip, char **dest, size_t *message_length)
int osip_message_clone (const osip_message_t *sip, osip_message_t **dest)
void osip_message_set_reason_phrase (osip_message_t *sip, char *reason)
char * osip_message_get_reason_phrase (const osip_message_t *sip)
void osip_message_set_status_code (osip_message_t *sip, int statuscode)
int osip_message_get_status_code (const osip_message_t *sip)
void osip_message_set_method (osip_message_t *sip, char *method)
char * osip_message_get_method (const osip_message_t *sip)
void osip_message_set_version (osip_message_t *sip, char *version)
char * osip_message_get_version (const osip_message_t *sip)
void osip_message_set_uri (osip_message_t *sip, osip_uri_t *uri)
osip_uri_tosip_message_get_uri (const osip_message_t *sip)
void osip_generic_param_set_name (osip_generic_param_t *generic_param, char *name)
char * osip_generic_param_get_name (const osip_generic_param_t *generic_param)
void osip_generic_param_set_value (osip_generic_param_t *generic_param, char *value)
char * osip_generic_param_get_value (const osip_generic_param_t *generic_param)
int osip_message_get_knownheaderlist (osip_list_t *header_list, int pos, void **dest)

Detailed Description

Macro Definition Documentation

#define BODY_MESSAGE_MAX_SIZE   4000

You can define the maximum length for a body inside a SIP message.

Referenced by sdp_message_to_str().

#define MSG_IS_ACK (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"ACK"))

Test if the message is an ACK REQUEST

Parameters
msgthe SIP message.

Referenced by osip_create_transaction(), and osip_transaction_find().

#define MSG_IS_BYE (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"BYE"))

Test if the message is a BYE REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_CANCEL (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"CANCEL"))

Test if the message is a CANCEL REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_INFO (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"INFO"))

Test if the message is an INFO REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_INVITE (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"INVITE"))

Test if the message is an INVITE REQUEST

Parameters
msgthe SIP message.

Referenced by osip_transaction_find().

#define MSG_IS_MESSAGE (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"MESSAGE"))

Test if the message is a MESSAGE REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_NOTIFY (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"NOTIFY"))

Test if the message is a NOTIFY REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_OPTIONS (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"OPTIONS"))

Test if the message is an OPTIONS REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_PRACK (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"PRACK"))

Test if the message is a PRACK REQUEST (!! PRACK IS NOT SUPPORTED by the fsm!!)

Parameters
msgthe SIP message.
#define MSG_IS_PUBLISH (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"PUBLISH"))

Test if the message is an UPDATE REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_REFER (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"REFER"))

Test if the message is a REFER REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_REGISTER (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"REGISTER"))

Test if the message is a REGISTER REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_REQUEST (   msg)    ((msg)->status_code==0)

Test if the message is a SIP REQUEST

Parameters
msgthe SIP message.

Referenced by osip_create_transaction(), osip_new_outgoing_sipmessage(), and osip_parse().

#define MSG_IS_RESPONSE (   msg)    ((msg)->status_code!=0)

Test if the message is a SIP RESPONSE

Parameters
msgthe SIP message.

Referenced by osip_message_fix_last_via_header().

#define MSG_IS_RESPONSE_FOR (   msg,
  requestname 
)
Value:
(MSG_IS_RESPONSE(msg) && \
0==strcmp((msg)->cseq->method,(requestname)))

Test if the message is a response for a REQUEST of certain type

Parameters
msgthe SIP message.
requestnamethe method name to match.

Referenced by osip_transaction_find().

#define MSG_IS_STATUS_1XX (   msg)
Value:
((msg)->status_code >= 100 && \
(msg)->status_code < 200)

Test if the message is a response with status between 100 and 199

Parameters
msgthe SIP message.
#define MSG_IS_STATUS_2XX (   msg)
Value:
((msg)->status_code >= 200 && \
(msg)->status_code < 300)

Test if the message is a response with status between 200 and 299

Parameters
msgthe SIP message.

Referenced by osip_dialog_update_route_set_as_uac().

#define MSG_IS_STATUS_3XX (   msg)
Value:
((msg)->status_code >= 300 && \
(msg)->status_code < 400)

Test if the message is a response with status between 300 and 399

Parameters
msgthe SIP message.
#define MSG_IS_STATUS_4XX (   msg)
Value:
((msg)->status_code >= 400 && \
(msg)->status_code < 500)

Test if the message is a response with status between 400 and 499

Parameters
msgthe SIP message.
#define MSG_IS_STATUS_5XX (   msg)
Value:
((msg)->status_code >= 500 && \
(msg)->status_code < 600)

Test if the message is a response with status between 500 and 599

Parameters
msgthe SIP message.
#define MSG_IS_STATUS_6XX (   msg)
Value:
((msg)->status_code >= 600 && \
(msg)->status_code < 700)

Test if the message is a response with status between 600 and 699

Parameters
msgthe SIP message.
#define MSG_IS_SUBSCRIBE (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"SUBSCRIBE"))

Test if the message is a SUBSCRIBE REQUEST

Parameters
msgthe SIP message.
#define MSG_IS_UPDATE (   msg)
Value:
(MSG_IS_REQUEST(msg) && \
0==strcmp((msg)->sip_method,"UPDATE"))

Test if the message is an UPDATE REQUEST

Parameters
msgthe SIP message.
#define MSG_TEST_CODE (   msg,
  code 
)
Value:
(MSG_IS_RESPONSE(msg) && \
(code)==(msg)->status_code)

Test if the message is a response with a status set to the code value.

Parameters
msgthe SIP message.
codethe status code.
#define osip_generic_param_add (   LIST,
  NAME,
  VALUE 
)    osip_uri_param_add(LIST,NAME,VALUE)

Allocate and add a generic parameter element in a list.

Parameters
LISTThe list of generic parameter element to work on.
NAMEThe token name.
VALUEThe token value.
#define osip_generic_param_clone   osip_uri_param_clone

Clone a generic parameter element.

Parameters
GPThe element to work on.
DESTThe resulting new allocated buffer.

Referenced by osip_accept_encoding_clone(), osip_call_info_clone(), osip_content_type_clone(), osip_from_clone(), and osip_via_clone().

#define osip_generic_param_free (   GP)    osip_uri_param_free(GP)

Free a generic parameter element.

Parameters
GPThe element to work on.
#define osip_generic_param_get_byname (   LIST,
  NAME,
  DEST 
)    osip_uri_param_get_byname(LIST,NAME,DEST)

Find in a generic parameter element in a list.

Parameters
LISTThe list of generic parameter element to work on.
NAMEThe name of the parameter element to find.
DESTA pointer on the element found.
#define osip_generic_param_init (   GP)    osip_uri_param_init(GP)

Allocate a generic parameter element.

Parameters
GPThe element to work on.
#define osip_generic_param_set (   GP,
  NAME,
  VALUE 
)    osip_uri_param_set(GP, NAME, VALUE)

Set values of a generic parameter element.

Parameters
GPThe element to work on.
NAMEThe token name.
VALUEThe token value.
#define SIP_MESSAGE_MAX_LENGTH   4000

You can re-define your own maximum length for SIP message.

Typedef Documentation

Structure for SIP Message (REQUEST and RESPONSE).

Function Documentation

char* osip_generic_param_get_name ( const osip_generic_param_t generic_param)

Get the name of a generic parameter element.

Parameters
generic_paramThe element to work on.

References osip_uri_param::gname.

char* osip_generic_param_get_value ( const osip_generic_param_t generic_param)

Get the value of a generic parameter element.

Parameters
generic_paramThe element to work on.

References osip_uri_param::gname, and osip_uri_param::gvalue.

void osip_generic_param_set_name ( osip_generic_param_t generic_param,
char *  name 
)

Set the name of a generic parameter element.

Parameters
generic_paramThe element to work on.
namethe token name to set.

References osip_uri_param::gname.

void osip_generic_param_set_value ( osip_generic_param_t generic_param,
char *  value 
)

Set the value of a generic parameter element.

Parameters
generic_paramThe element to work on.
valuethe token name to set.

References osip_uri_param::gvalue.

int osip_message_clone ( const osip_message_t sip,
osip_message_t **  dest 
)

Clone a osip_message_t element.

Parameters
sipThe element to clone.
destThe new allocated element cloned.

References osip_message::accept_encodings, osip_message::accept_languages, osip_message::accepts, osip_message::alert_infos, osip_message::allows, osip_message::authentication_infos, osip_message::authorizations, osip_message::bodies, osip_message::call_id, osip_message::call_infos, osip_message::contacts, osip_message::content_encodings, osip_message::content_length, osip_message::content_type, osip_message::cseq, osip_message::error_infos, osip_message::from, osip_message::headers, osip_message::message, osip_message::message_length, osip_message::message_property, osip_message::mime_version, osip_accept_clone, osip_accept_encoding_clone(), osip_accept_language_clone, osip_alert_info_clone, osip_allow_clone, osip_authentication_info_clone(), osip_authorization_clone(), osip_body_clone(), osip_call_id_clone(), osip_call_info_clone(), osip_contact_clone(), osip_content_encoding_clone, osip_content_length_clone(), osip_content_type_clone(), osip_cseq_clone(), osip_error_info_clone, osip_from_clone(), osip_header_clone(), osip_list_add(), osip_list_clone(), osip_list_eol(), osip_list_get(), osip_message_free(), osip_message_init(), osip_mime_version_clone, osip_proxy_authenticate_clone, osip_proxy_authentication_info_clone, osip_proxy_authorization_clone, osip_record_route_clone, osip_route_clone, osip_to_clone(), osip_uri_clone(), osip_via_clone(), osip_www_authenticate_clone(), osip_message::proxy_authenticates, osip_message::proxy_authentication_infos, osip_message::proxy_authorizations, osip_message::reason_phrase, osip_message::record_routes, osip_message::req_uri, osip_message::routes, osip_message::sip_method, osip_message::sip_version, osip_message::status_code, osip_message::to, osip_message::vias, and osip_message::www_authenticates.

Referenced by osip_start_200ok_retransmissions(), and osip_start_ack_retransmissions().

void osip_message_free ( osip_message_t sip)

Free all resource in a osip_message_t element.

Parameters
sipThe element to free.

References osip_message::accept_encodings, osip_message::accept_languages, osip_message::accepts, osip_message::alert_infos, osip_message::allows, osip_message::authentication_infos, osip_message::authorizations, osip_message::bodies, osip_message::call_id, osip_message::call_infos, osip_message::contacts, osip_message::content_encodings, osip_message::content_length, osip_message::content_type, osip_message::cseq, osip_message::error_infos, osip_message::from, osip_message::headers, osip_message::message, osip_message::mime_version, osip_accept_encoding_free(), osip_accept_free, osip_accept_language_free, osip_alert_info_free, osip_allow_free, osip_authentication_info_free(), osip_authorization_free(), osip_body_free(), osip_call_id_free(), osip_call_info_free(), osip_contact_free(), osip_content_encoding_free, osip_content_length_free(), osip_content_type_free(), osip_cseq_free(), osip_error_info_free, osip_from_free(), osip_header_free(), osip_list_special_free(), osip_mime_version_free, osip_proxy_authenticate_free, osip_proxy_authentication_info_free, osip_proxy_authorization_free, osip_record_route_free(), osip_route_free(), osip_to_free(), osip_uri_free(), osip_via_free(), osip_www_authenticate_free(), osip_message::proxy_authenticates, osip_message::proxy_authentication_infos, osip_message::proxy_authorizations, osip_message::reason_phrase, osip_message::record_routes, osip_message::req_uri, osip_message::routes, osip_message::sip_method, osip_message::sip_version, osip_message::to, osip_message::vias, and osip_message::www_authenticates.

Referenced by osip_event_free(), osip_message_clone(), osip_parse(), osip_transaction_execute(), and osip_transaction_free2().

int osip_message_get_knownheaderlist ( osip_list_t header_list,
int  pos,
void **  dest 
)

Get the a known header from a list of known header.

Parameters
header_listThe element to work on.
posThe index of the element to get.
destA pointer on the header found.

References osip_list_get(), and osip_list_size().

char* osip_message_get_method ( const osip_message_t sip)

Get the method name.

Parameters
sipThe element to work on.

References osip_message::sip_method.

char* osip_message_get_reason_phrase ( const osip_message_t sip)

Get the reason phrase. This is entirely free in SIP.

Parameters
sipThe element to work on.

References osip_message::reason_phrase.

int osip_message_get_status_code ( const osip_message_t sip)

Get the status code.

Parameters
sipThe element to work on.

References osip_message::status_code.

osip_uri_t* osip_message_get_uri ( const osip_message_t sip)

Get the Request-URI.

Parameters
sipThe element to work on.

References osip_message::req_uri.

char* osip_message_get_version ( const osip_message_t sip)

Get the SIP version.

Parameters
sipThe element to work on.

References osip_message::sip_version.

int osip_message_init ( osip_message_t **  sip)

Allocate a osip_message_t element.

Parameters
sipThe element to allocate.

References osip_list_init().

Referenced by osip_message_clone(), and osip_parse().

int osip_message_parse ( osip_message_t sip,
const char *  buf,
size_t  length 
)

Parse a osip_message_t element.

Parameters
sipThe resulting element.
bufThe buffer to parse.
lengthThe length of the buffer to parse.

Referenced by osip_parse().

int osip_message_parse_sipfrag ( osip_message_t sip,
const char *  buf,
size_t  length 
)

Parse a message/sipfrag part and store it in an osip_message_t element.

Parameters
sipThe resulting element.
bufThe buffer to parse.
lengthThe length of the buffer to parse.
void osip_message_set_method ( osip_message_t sip,
char *  method 
)

Set the method. You can set any string here.

Parameters
sipThe element to work on.
methodThe method name.

References osip_message::sip_method.

void osip_message_set_reason_phrase ( osip_message_t sip,
char *  reason 
)

Set the reason phrase. This is entirely free in SIP.

Parameters
sipThe element to work on.
reasonThe reason phrase.

References osip_message::reason_phrase.

void osip_message_set_status_code ( osip_message_t sip,
int  statuscode 
)

Set the status code. This is entirely free in SIP.

Parameters
sipThe element to work on.
statuscodeThe status code.

References osip_message::status_code.

void osip_message_set_uri ( osip_message_t sip,
osip_uri_t uri 
)

Set the Request-URI.

Parameters
sipThe element to work on.
uriThe uri to set.

References osip_message::req_uri.

void osip_message_set_version ( osip_message_t sip,
char *  version 
)

Set the SIP version used. (default is "SIP/2.0")

Parameters
sipThe element to work on.
versionThe version of SIP.

References osip_message::sip_version.

int osip_message_to_str ( osip_message_t sip,
char **  dest,
size_t *  message_length 
)

Get a string representation of a osip_message_t element.

Parameters
sipThe element to work on.
destnew allocated buffer returned.
message_lengthThe length of the returned buffer.
int osip_message_to_str_sipfrag ( osip_message_t sip,
char **  dest,
size_t *  message_length 
)

Get a string representation of a message/sipfrag part stored in an osip_message_t element.

Parameters
sipThe element to work on.
destnew allocated buffer returned.
message_lengthThe length of the returned buffer.