libosip  5.3.0
Classes | Macros | Typedefs | Functions
oSIP message API

Classes

struct  osip_message
 

Macros

#define SIP_MESSAGE_MAX_LENGTH   8000
 
#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)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "INVITE"))
 
#define MSG_IS_ACK(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "ACK"))
 
#define MSG_IS_REGISTER(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "REGISTER"))
 
#define MSG_IS_BYE(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "BYE"))
 
#define MSG_IS_OPTIONS(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "OPTIONS"))
 
#define MSG_IS_INFO(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "INFO"))
 
#define MSG_IS_CANCEL(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "CANCEL"))
 
#define MSG_IS_REFER(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "REFER"))
 
#define MSG_IS_NOTIFY(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "NOTIFY"))
 
#define MSG_IS_SUBSCRIBE(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "SUBSCRIBE"))
 
#define MSG_IS_MESSAGE(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "MESSAGE"))
 
#define MSG_IS_PRACK(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "PRACK"))
 
#define MSG_IS_UPDATE(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "UPDATE"))
 
#define MSG_IS_PUBLISH(msg)   (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "PUBLISH"))
 
#define MSG_IS_STATUS_1XX(msg)   ((msg)->status_code >= 100 && (msg)->status_code < 200)
 
#define MSG_IS_STATUS_2XX(msg)   ((msg)->status_code >= 200 && (msg)->status_code < 300)
 
#define MSG_IS_STATUS_3XX(msg)   ((msg)->status_code >= 300 && (msg)->status_code < 400)
 
#define MSG_IS_STATUS_4XX(msg)   ((msg)->status_code >= 400 && (msg)->status_code < 500)
 
#define MSG_IS_STATUS_5XX(msg)   ((msg)->status_code >= 500 && (msg)->status_code < 600)
 
#define MSG_IS_STATUS_6XX(msg)   ((msg)->status_code >= 600 && (msg)->status_code < 700)
 
#define MSG_TEST_CODE(msg, code)   (MSG_IS_RESPONSE(msg) && (code) == (msg)->status_code)
 
#define MSG_IS_RESPONSE_FOR(msg, requestname)   (MSG_IS_RESPONSE(msg) && 0 == strcmp((msg)->cseq->method, (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

◆ BODY_MESSAGE_MAX_SIZE

#define BODY_MESSAGE_MAX_SIZE   4000

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

◆ MSG_IS_ACK

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

Test if the message is an ACK REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_BYE

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

Test if the message is a BYE REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_CANCEL

#define MSG_IS_CANCEL (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "CANCEL"))

Test if the message is a CANCEL REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_INFO

#define MSG_IS_INFO (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "INFO"))

Test if the message is an INFO REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_INVITE

#define MSG_IS_INVITE (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "INVITE"))

Test if the message is an INVITE REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_MESSAGE

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

Test if the message is a MESSAGE REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_NOTIFY

#define MSG_IS_NOTIFY (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "NOTIFY"))

Test if the message is a NOTIFY REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_OPTIONS

#define MSG_IS_OPTIONS (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "OPTIONS"))

Test if the message is an OPTIONS REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_PRACK

#define MSG_IS_PRACK (   msg)    (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.

◆ MSG_IS_PUBLISH

#define MSG_IS_PUBLISH (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "PUBLISH"))

Test if the message is an UPDATE REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_REFER

#define MSG_IS_REFER (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "REFER"))

Test if the message is a REFER REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_REGISTER

#define MSG_IS_REGISTER (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "REGISTER"))

Test if the message is a REGISTER REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_REQUEST

#define MSG_IS_REQUEST (   msg)    ((msg)->status_code == 0)

Test if the message is a SIP REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_RESPONSE

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

Test if the message is a SIP RESPONSE

Parameters
msgthe SIP message.

◆ MSG_IS_RESPONSE_FOR

#define MSG_IS_RESPONSE_FOR (   msg,
  requestname 
)    (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.

◆ MSG_IS_STATUS_1XX

#define MSG_IS_STATUS_1XX (   msg)    ((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.

◆ MSG_IS_STATUS_2XX

#define MSG_IS_STATUS_2XX (   msg)    ((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.

◆ MSG_IS_STATUS_3XX

#define MSG_IS_STATUS_3XX (   msg)    ((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.

◆ MSG_IS_STATUS_4XX

#define MSG_IS_STATUS_4XX (   msg)    ((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.

◆ MSG_IS_STATUS_5XX

#define MSG_IS_STATUS_5XX (   msg)    ((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.

◆ MSG_IS_STATUS_6XX

#define MSG_IS_STATUS_6XX (   msg)    ((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.

◆ MSG_IS_SUBSCRIBE

#define MSG_IS_SUBSCRIBE (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "SUBSCRIBE"))

Test if the message is a SUBSCRIBE REQUEST

Parameters
msgthe SIP message.

◆ MSG_IS_UPDATE

#define MSG_IS_UPDATE (   msg)    (MSG_IS_REQUEST(msg) && 0 == strcmp((msg)->sip_method, "UPDATE"))

Test if the message is an UPDATE REQUEST

Parameters
msgthe SIP message.

◆ MSG_TEST_CODE

#define MSG_TEST_CODE (   msg,
  code 
)    (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.

◆ osip_generic_param_add

#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.

◆ osip_generic_param_clone

#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.

◆ osip_generic_param_free

#define osip_generic_param_free (   GP)    osip_uri_param_free(GP)

Free a generic parameter element.

Parameters
GPThe element to work on.

◆ osip_generic_param_get_byname

#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.

◆ osip_generic_param_init

#define osip_generic_param_init (   GP)    osip_uri_param_init(GP)

Allocate a generic parameter element.

Parameters
GPThe element to work on.

◆ osip_generic_param_set

#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.

◆ SIP_MESSAGE_MAX_LENGTH

#define SIP_MESSAGE_MAX_LENGTH   8000

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

Typedef Documentation

◆ osip_message_t

Structure for SIP Message (REQUEST and RESPONSE).

Function Documentation

◆ osip_generic_param_get_name()

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.

◆ osip_generic_param_get_value()

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.

◆ osip_generic_param_set_name()

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.

◆ osip_generic_param_set_value()

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.

◆ osip_message_clone()

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::application_data, 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_clone(), 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().

◆ osip_message_free()

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().

◆ osip_message_get_knownheaderlist()

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().

◆ osip_message_get_method()

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.

◆ osip_message_get_reason_phrase()

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.

◆ osip_message_get_status_code()

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_message_get_uri()

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.

◆ osip_message_get_version()

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.

◆ osip_message_init()

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().

◆ osip_message_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().

◆ osip_message_parse_sipfrag()

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.

◆ osip_message_set_method()

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.

◆ osip_message_set_reason_phrase()

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.

◆ osip_message_set_status_code()

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.

◆ osip_message_set_uri()

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.

◆ osip_message_set_version()

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.

◆ osip_message_to_str()

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. NOTE: You need to release the sip buffer returned by this API when you are done with the buffer. ie: osip_free(dest)

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

◆ osip_message_to_str_sipfrag()

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. NOTE: You need to release the sip buffer returned by this API when you are done with the buffer. ie: osip_free(dest)

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