SIP Witch 1.9.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
osip.h File Reference

oSIP fsm Routines More...

#include <osipparser2/osip_const.h>
#include <osip2/osip_time.h>
#include <osipparser2/osip_parser.h>
#include <osip2/osip_fifo.h>
Include dependency graph for osip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  osip_ict
 Structure for INVITE CLIENT TRANSACTION. More...
 
struct  osip_nict
 Structure for NON-INVITE CLIENT TRANSACTION. More...
 
struct  osip_ist
 Structure for INVITE SERVER TRANSACTION. More...
 
struct  osip_nist
 Structure for NON-INVITE SERVER TRANSACTION. More...
 
struct  osip_srv_entry
 Structure for SRV record entry. More...
 
struct  osip_srv_record
 Structure for SRV record entry. More...
 
struct  osip_naptr
 Structure for NAPTR record entry. More...
 
struct  osip_transaction
 Structure for transaction handling. More...
 
struct  ixt
 Structure for 2XX retransmission management. More...
 
struct  osip
 Structure for osip handling. More...
 
struct  osip_event
 Structure for osip event handling. More...
 

Macros

#define DEFAULT_T1   500 /* 500 ms */
 You can re-define the default value for T1. More...
 
#define DEFAULT_T1_TCP_PROGRESS   50 /* 50ms */
 You can re-define the default value for T1_TCP_PROGRESS. More...
 
#define DEFAULT_T2   4000 /* 4s */
 You can re-define the default value for T2. More...
 
#define DEFAULT_T4   5000 /* 5s */
 You can re-define the default value for T4. More...
 
#define OSIP_SRV_STATE_UNKNOWN   0
 unknown More...
 
#define OSIP_SRV_STATE_RETRYLATER   2
 retry later More...
 
#define OSIP_SRV_STATE_COMPLETED   3
 completed More...
 
#define OSIP_SRV_STATE_NOTSUPPORTED   4
 not supported More...
 
#define OSIP_NAPTR_STATE_UNKNOWN   0
 unknown More...
 
#define OSIP_NAPTR_STATE_INPROGRESS   1
 in progress More...
 
#define OSIP_NAPTR_STATE_NAPTRDONE   2
 naptr done More...
 
#define OSIP_NAPTR_STATE_SRVINPROGRESS   3
 srv in progress More...
 
#define OSIP_NAPTR_STATE_SRVDONE   4
 srv done More...
 
#define OSIP_NAPTR_STATE_RETRYLATER   5
 retry later More...
 
#define OSIP_NAPTR_STATE_NOTSUPPORTED   6
 not supported More...
 
#define EVT_IS_RCV_INVITE(event)   (event->type==RCV_REQINVITE)
 Check if the sipevent is of type RCV_REQINVITE. More...
 
#define EVT_IS_RCV_ACK(event)   (event->type==RCV_REQACK)
 Check if the sipevent is of type RCV_REQACK. More...
 
#define EVT_IS_RCV_REQUEST(event)   (event->type==RCV_REQUEST)
 Check if the sipevent is of type RCV_REQUEST. More...
 
#define EVT_IS_RCV_STATUS_1XX(event)   (event->type==RCV_STATUS_1XX)
 Check if the sipevent is of type RCV_STATUS_1XX. More...
 
#define EVT_IS_RCV_STATUS_2XX(event)   (event->type==RCV_STATUS_2XX)
 Check if the sipevent is of type RCV_STATUS_2XX. More...
 
#define EVT_IS_RCV_STATUS_3456XX(event)   (event->type==RCV_STATUS_3456XX)
 Check if the sipevent is of type RCV_STATUS_3456XX. More...
 
#define EVT_IS_SND_INVITE(event)   (event->type==SND_REQINVITE)
 Check if the sipevent is of type SND_REQINVITE. More...
 
#define EVT_IS_SND_ACK(event)   (event->type==SND_REQACK)
 Check if the sipevent is of type SND_REQACK. More...
 
#define EVT_IS_SND_REQUEST(event)   (event->type==SND_REQUEST)
 Check if the sipevent is of type SND_REQUEST. More...
 
#define EVT_IS_SND_STATUS_1XX(event)   (event->type==SND_STATUS_1XX)
 Check if the sipevent is of type SND_STATUS_1XX. More...
 
#define EVT_IS_SND_STATUS_2XX(event)   (event->type==SND_STATUS_2XX)
 Check if the sipevent is of type SND_STATUS_2XX. More...
 
#define EVT_IS_SND_STATUS_3456XX(event)   (event->type==SND_STATUS_3456XX)
 Check if the sipevent is of type SND_STATUS_3456XX. More...
 
#define EVT_IS_INCOMINGMSG(event)
 Check if the sipevent is of an incoming SIP MESSAGE. More...
 
#define EVT_IS_INCOMINGREQ(event)
 Check if the sipevent is of an incoming SIP REQUEST. More...
 
#define EVT_IS_INCOMINGRESP(event)
 Check if the sipevent is of an incoming SIP RESPONSE. More...
 
#define EVT_IS_OUTGOINGMSG(event)
 Check if the sipevent is of an outgoing SIP MESSAGE. More...
 
#define EVT_IS_OUTGOINGREQ(event)
 Check if the sipevent is of an outgoing SIP REQUEST. More...
 
#define EVT_IS_OUTGOINGRESP(event)
 Check if the sipevent is of an outgoing SIP RESPONSE. More...
 
#define EVT_IS_MSG(event)
 Check if the sipevent is a SIP MESSAGE. More...
 
#define EVT_IS_KILL_TRANSACTION(event)   (event->type==KILL_TRANSACTION)
 Check if the sipevent is of type KILL_TRANSACTION. More...
 

Typedefs

typedef enum _state_t state_t
 Enumeration for transaction state. More...
 
typedef enum type_t type_t
 Enumeration for event type. More...
 
typedef enum osip_fsm_type_t osip_fsm_type_t
 Enumeration for transaction type. More...
 
typedef struct osip_ict osip_ict_t
 Structure for INVITE CLIENT TRANSACTION (outgoing INVITE transaction). More...
 
typedef struct osip_nict osip_nict_t
 Structure for NON-INVITE CLIENT TRANSACTION (outgoing NON-INVITE transaction). More...
 
typedef struct osip_ist osip_ist_t
 Structure for INVITE SERVER TRANSACTION (incoming INVITE transaction). More...
 
typedef struct osip_nist osip_nist_t
 Structure for NON-INVITE SERVER TRANSACTION (incoming SERVER transaction). More...
 
typedef struct osip_srv_entry osip_srv_entry_t
 Structure for SRV record entry. More...
 
typedef struct osip_srv_record osip_srv_record_t
 Structure for SRV record. More...
 
typedef struct osip_naptr osip_naptr_t
 Structure for NAPTR record. More...
 
typedef struct osip_transaction osip_transaction_t
 Structure for transaction handling. More...
 
typedef enum
osip_message_callback_type 
osip_message_callback_type_t
 Enumeration for callback type. More...
 
typedef enum
osip_kill_callback_type 
osip_kill_callback_type_t
 Enumeration for callback type used when transaction is over. More...
 
typedef enum
osip_transport_error_callback_type 
osip_transport_error_callback_type_t
 Enumeration for callback type used when a transport error is detected. More...
 
typedef void(* osip_message_cb_t )(int type, osip_transaction_t *, osip_message_t *)
 Callback definition for message announcements. More...
 
typedef void(* osip_kill_transaction_cb_t )(int type, osip_transaction_t *)
 Callback definition for end of transaction announcements. More...
 
typedef void(* osip_transport_error_cb_t )(int type, osip_transaction_t *, int error)
 Callback definition for transport error announcements. More...
 
typedef struct ixt ixt_t
 Structure for 2XX retransmission management. More...
 
typedef struct osip osip_t
 Structure for osip handling. More...
 
typedef struct osip_event osip_event_t
 Structure for osip event handling. More...
 

Enumerations

enum  _state_t {
  ICT_PRE_CALLING, ICT_CALLING, ICT_PROCEEDING, ICT_COMPLETED,
  ICT_TERMINATED, IST_PRE_PROCEEDING, IST_PROCEEDING, IST_COMPLETED,
  IST_CONFIRMED, IST_TERMINATED, NICT_PRE_TRYING, NICT_TRYING,
  NICT_PROCEEDING, NICT_COMPLETED, NICT_TERMINATED, NIST_PRE_TRYING,
  NIST_TRYING, NIST_PROCEEDING, NIST_COMPLETED, NIST_TERMINATED,
  DIALOG_EARLY, DIALOG_CONFIRMED, DIALOG_CLOSE
}
 Enumeration for transaction state. More...
 
enum  type_t {
  TIMEOUT_A, TIMEOUT_B, TIMEOUT_D, TIMEOUT_E,
  TIMEOUT_F, TIMEOUT_K, TIMEOUT_G, TIMEOUT_H,
  TIMEOUT_I, TIMEOUT_J, RCV_REQINVITE, RCV_REQACK,
  RCV_REQUEST, RCV_STATUS_1XX, RCV_STATUS_2XX, RCV_STATUS_3456XX,
  SND_REQINVITE, SND_REQACK, SND_REQUEST, SND_STATUS_1XX,
  SND_STATUS_2XX, SND_STATUS_3456XX, KILL_TRANSACTION, UNKNOWN_EVT
}
 Enumeration for event type. More...
 
enum  osip_fsm_type_t { ICT, IST, NICT, NIST }
 Enumeration for transaction type. More...
 
enum  osip_message_callback_type {
  OSIP_ICT_INVITE_SENT = 0, OSIP_ICT_INVITE_SENT_AGAIN, OSIP_ICT_ACK_SENT, OSIP_ICT_ACK_SENT_AGAIN,
  OSIP_ICT_STATUS_1XX_RECEIVED, OSIP_ICT_STATUS_2XX_RECEIVED, OSIP_ICT_STATUS_2XX_RECEIVED_AGAIN, OSIP_ICT_STATUS_3XX_RECEIVED,
  OSIP_ICT_STATUS_4XX_RECEIVED, OSIP_ICT_STATUS_5XX_RECEIVED, OSIP_ICT_STATUS_6XX_RECEIVED, OSIP_ICT_STATUS_3456XX_RECEIVED_AGAIN,
  OSIP_IST_INVITE_RECEIVED, OSIP_IST_INVITE_RECEIVED_AGAIN, OSIP_IST_ACK_RECEIVED, OSIP_IST_ACK_RECEIVED_AGAIN,
  OSIP_IST_STATUS_1XX_SENT, OSIP_IST_STATUS_2XX_SENT, OSIP_IST_STATUS_2XX_SENT_AGAIN, OSIP_IST_STATUS_3XX_SENT,
  OSIP_IST_STATUS_4XX_SENT, OSIP_IST_STATUS_5XX_SENT, OSIP_IST_STATUS_6XX_SENT, OSIP_IST_STATUS_3456XX_SENT_AGAIN,
  OSIP_NICT_REGISTER_SENT, OSIP_NICT_BYE_SENT, OSIP_NICT_OPTIONS_SENT, OSIP_NICT_INFO_SENT,
  OSIP_NICT_CANCEL_SENT, OSIP_NICT_NOTIFY_SENT, OSIP_NICT_SUBSCRIBE_SENT, OSIP_NICT_UNKNOWN_REQUEST_SENT,
  OSIP_NICT_REQUEST_SENT_AGAIN, OSIP_NICT_STATUS_1XX_RECEIVED, OSIP_NICT_STATUS_2XX_RECEIVED, OSIP_NICT_STATUS_2XX_RECEIVED_AGAIN,
  OSIP_NICT_STATUS_3XX_RECEIVED, OSIP_NICT_STATUS_4XX_RECEIVED, OSIP_NICT_STATUS_5XX_RECEIVED, OSIP_NICT_STATUS_6XX_RECEIVED,
  OSIP_NICT_STATUS_3456XX_RECEIVED_AGAIN, OSIP_NIST_REGISTER_RECEIVED, OSIP_NIST_BYE_RECEIVED, OSIP_NIST_OPTIONS_RECEIVED,
  OSIP_NIST_INFO_RECEIVED, OSIP_NIST_CANCEL_RECEIVED, OSIP_NIST_NOTIFY_RECEIVED, OSIP_NIST_SUBSCRIBE_RECEIVED,
  OSIP_NIST_UNKNOWN_REQUEST_RECEIVED, OSIP_NIST_REQUEST_RECEIVED_AGAIN, OSIP_NIST_STATUS_1XX_SENT, OSIP_NIST_STATUS_2XX_SENT,
  OSIP_NIST_STATUS_2XX_SENT_AGAIN, OSIP_NIST_STATUS_3XX_SENT, OSIP_NIST_STATUS_4XX_SENT, OSIP_NIST_STATUS_5XX_SENT,
  OSIP_NIST_STATUS_6XX_SENT, OSIP_NIST_STATUS_3456XX_SENT_AGAIN, OSIP_ICT_STATUS_TIMEOUT, OSIP_NICT_STATUS_TIMEOUT,
  OSIP_MESSAGE_CALLBACK_COUNT
}
 Enumeration for callback type. More...
 
enum  osip_kill_callback_type {
  OSIP_ICT_KILL_TRANSACTION, OSIP_IST_KILL_TRANSACTION, OSIP_NICT_KILL_TRANSACTION, OSIP_NIST_KILL_TRANSACTION,
  OSIP_KILL_CALLBACK_COUNT
}
 Enumeration for callback type used when transaction is over. More...
 
enum  osip_transport_error_callback_type {
  OSIP_ICT_TRANSPORT_ERROR, OSIP_IST_TRANSPORT_ERROR, OSIP_NICT_TRANSPORT_ERROR, OSIP_NIST_TRANSPORT_ERROR,
  OSIP_TRANSPORT_ERROR_CALLBACK_COUNT
}
 Enumeration for callback type used when a transport error is detected. More...
 

Functions

int osip_set_message_callback (osip_t *osip, int type, osip_message_cb_t cb)
 Set a callback for each transaction operation. More...
 
int osip_set_kill_transaction_callback (osip_t *osip, int type, osip_kill_transaction_cb_t cb)
 Set a callback for transaction operation related to the end of transactions. More...
 
int osip_set_transport_error_callback (osip_t *osip, int type, osip_transport_error_cb_t cb)
 Set a callback for each transaction operation related to network error. More...
 
int osip_transaction_init (osip_transaction_t **transaction, osip_fsm_type_t ctx_type, osip_t *osip, osip_message_t *request)
 Allocate an osip_transaction_t element. More...
 
int osip_transaction_free (osip_transaction_t *transaction)
 Free all resource in a osip_transaction_t element. More...
 
int osip_transaction_free2 (osip_transaction_t *transaction)
 Free all resource in a osip_transaction_t element. More...
 
void osip_response_get_destination (osip_message_t *response, char **address, int *portnum)
 Search in a SIP response the destination where the message should be sent. More...
 
int osip_ict_set_destination (osip_ict_t *ict, char *destination, int port)
 Set the host and port destination used for sending the SIP message. More...
 
int osip_nict_set_destination (osip_nict_t *nict, char *destination, int port)
 Set the host and port destination used for sending the SIP message. More...
 
int osip_transaction_add_event (osip_transaction_t *transaction, osip_event_t *evt)
 Add a SIP event in the fifo of a osip_transaction_t element. More...
 
int osip_transaction_execute (osip_transaction_t *transaction, osip_event_t *evt)
 Consume one osip_event_t element previously added in the fifo. More...
 
int osip_transaction_set_your_instance (osip_transaction_t *transaction, void *ptr)
 Set a pointer to your personal context associated with this transaction. More...
 
int osip_transaction_set_reserved1 (osip_transaction_t *transaction, void *ptr)
 Set a pointer to your personal context associated with this transaction. More...
 
int osip_transaction_set_reserved2 (osip_transaction_t *transaction, void *ptr)
 Set a pointer to your personal context associated with this transaction. More...
 
int osip_transaction_set_reserved3 (osip_transaction_t *transaction, void *ptr)
 Set a pointer to your personal context associated with this transaction. More...
 
int osip_transaction_set_reserved4 (osip_transaction_t *transaction, void *ptr)
 Set a pointer to your personal context associated with this transaction. More...
 
int osip_transaction_set_reserved5 (osip_transaction_t *transaction, void *ptr)
 Set a pointer to your personal context associated with this transaction. More...
 
int osip_transaction_set_reserved6 (osip_transaction_t *transaction, void *ptr)
 Set a pointer to your personal context associated with this transaction. More...
 
void * osip_transaction_get_your_instance (osip_transaction_t *transaction)
 Get a pointer to your personal context associated with this transaction. More...
 
void * osip_transaction_get_reserved1 (osip_transaction_t *transaction)
 Get a pointer to your personal context associated with this transaction. More...
 
void * osip_transaction_get_reserved2 (osip_transaction_t *transaction)
 Get a pointer to your personal context associated with this transaction. More...
 
void * osip_transaction_get_reserved3 (osip_transaction_t *transaction)
 Get a pointer to your personal context associated with this transaction. More...
 
void * osip_transaction_get_reserved4 (osip_transaction_t *transaction)
 Get a pointer to your personal context associated with this transaction. More...
 
void * osip_transaction_get_reserved5 (osip_transaction_t *transaction)
 Get a pointer to your personal context associated with this transaction. More...
 
void * osip_transaction_get_reserved6 (osip_transaction_t *transaction)
 Get a pointer to your personal context associated with this transaction. More...
 
int osip_transaction_get_destination (osip_transaction_t *transaction, char **ip, int *port)
 Get target ip and port for this request. More...
 
int osip_transaction_set_srv_record (osip_transaction_t *transaction, osip_srv_record_t *record)
 Set SRV lookup information to be used by state machine. More...
 
int osip_transaction_set_naptr_record (osip_transaction_t *transaction, osip_naptr_t *record)
 Set NAPTR lookup information to be used by state machine. More...
 
int osip_transaction_set_in_socket (osip_transaction_t *transaction, int sock)
 Set the socket for incoming message. More...
 
int osip_transaction_set_out_socket (osip_transaction_t *transaction, int sock)
 Set the socket for outgoing message. More...
 
int osip_init (osip_t **osip)
 Allocate an osip_t element. More...
 
void osip_release (osip_t *osip)
 Free all resource in a osip_t element. More...
 
void osip_set_application_context (osip_t *osip, void *pointer)
 Set a pointer in a osip_t element. More...
 
void * osip_get_application_context (osip_t *osip)
 Get a pointer in a osip_t element. More...
 
int osip_remove_transaction (osip_t *osip, osip_transaction_t *ict)
 Remove a transaction from the osip stack. More...
 
int osip_ict_execute (osip_t *osip)
 Consume ALL pending osip_event_t previously added in the fifos of ict transactions. More...
 
int osip_ist_execute (osip_t *osip)
 Consume ALL pending osip_event_t previously added in the fifos of ist transactions. More...
 
int osip_nict_execute (osip_t *osip)
 Consume ALL pending osip_event_t previously added in the fifos of nict transactions. More...
 
int osip_nist_execute (osip_t *osip)
 Consume ALL pending osip_event_t previously added in the fifos of nist transactions. More...
 
void osip_timers_gettimeout (osip_t *osip, struct timeval *lower_tv)
 Retreive the minimum timer value to be used by an application so that the osip_timer_*_execute method don't have to be called often. More...
 
void osip_timers_ict_execute (osip_t *osip)
 Check if an ict transactions needs a timer event. More...
 
void osip_timers_ist_execute (osip_t *osip)
 Check if an ist transactions needs a timer event. More...
 
void osip_timers_nict_execute (osip_t *osip)
 Check if a nict transactions needs a timer event. More...
 
void osip_timers_nist_execute (osip_t *osip)
 Check if a nist transactions needs a timer event. More...
 
osip_transaction_tosip_transaction_find (osip_list_t *transactions, osip_event_t *evt)
 Search for a transaction that match this event (MUST be a MESSAGE event). More...
 
osip_transaction_t__osip_find_transaction (osip_t *osip, osip_event_t *evt, int consume)
 Some race conditions can happen in multi threaded applications. More...
 
int osip_find_transaction_and_add_event (osip_t *osip, osip_event_t *evt)
 Search for a transaction that match this event (MUST be a MESSAGE event) and add this event if a transaction is found. More...
 
osip_transaction_tosip_create_transaction (osip_t *osip, osip_event_t *evt)
 Create a transaction for this event (MUST be a SIP REQUEST event). More...
 
osip_event_tosip_parse (const char *buf, size_t length)
 Create a sipevent from a SIP message string. More...
 
void osip_retransmissions_execute (osip_t *osip)
 Send required retransmissions. More...
 
void osip_start_200ok_retransmissions (osip_t *osip, struct osip_dialog *dialog, osip_message_t *msg200ok, int sock)
 Start out of fsm 200 Ok retransmissions. More...
 
void osip_start_ack_retransmissions (osip_t *osip, struct osip_dialog *dialog, osip_message_t *ack, char *dest, int port, int sock)
 Start out of fsm ACK retransmissions. More...
 
struct osip_dialogosip_stop_200ok_retransmissions (osip_t *osip, osip_message_t *ack)
 Stop the out of fsm 200 Ok retransmissions matching an incoming ACK. More...
 
void osip_stop_retransmissions_from_dialog (osip_t *osip, struct osip_dialog *dialog)
 Stop out of fsm retransmissions (ACK or 200 Ok) associated to a given dialog. More...
 
osip_event_tosip_new_outgoing_sipmessage (osip_message_t *sip)
 Allocate a sipevent (we know this message is an OUTGOING SIP message). More...
 
void osip_event_free (osip_event_t *event)
 Free all resource in a sipevent. More...
 
void osip_set_cb_send_message (osip_t *cf, int(*cb)(osip_transaction_t *, osip_message_t *, char *, int, int))
 Register the callback used to send SIP message. More...
 

Detailed Description

oSIP fsm Routines

Definition in file osip.h.