📄 osip.h
字号:
/* TIMEOUT EVENTS for ICT */ TIMEOUT_A, /**< Timer A */ TIMEOUT_B, /**< Timer B */ TIMEOUT_D, /**< Timer D */ /* TIMEOUT EVENTS for NICT */ TIMEOUT_E, /**< Timer E */ TIMEOUT_F, /**< Timer F */ TIMEOUT_K, /**< Timer K */ /* TIMEOUT EVENTS for IST */ TIMEOUT_G, /**< Timer G */ TIMEOUT_H, /**< Timer H */ TIMEOUT_I, /**< Timer I */ /* TIMEOUT EVENTS for NIST */ TIMEOUT_J, /**< Timer J */ /* FOR INCOMING MESSAGE */ RCV_REQINVITE, /**< Event is an incoming INVITE request */ RCV_REQACK, /**< Event is an incoming ACK request */ RCV_REQUEST, /**< Event is an incoming NON-INVITE and NON-ACK request */ RCV_STATUS_1XX, /**< Event is an incoming informational response */ RCV_STATUS_2XX, /**< Event is an incoming 2XX response */ RCV_STATUS_3456XX,/**< Event is an incoming final response (not 2XX) */ /* FOR OUTGOING MESSAGE */ SND_REQINVITE, /**< Event is an outgoing INVITE request */ SND_REQACK, /**< Event is an outgoing ACK request */ SND_REQUEST, /**< Event is an outgoing NON-INVITE and NON-ACK request */ SND_STATUS_1XX, /**< Event is an outgoing informational response */ SND_STATUS_2XX, /**< Event is an outgoing 2XX response */ SND_STATUS_3456XX,/**< Event is an outgoing final response (not 2XX) */ KILL_TRANSACTION, /**< Event to 'kill' the transaction before termination */ UNKNOWN_EVT } type_t;#ifndef DOXYGEN typedef struct statemachine_t statemachine_t; struct statemachine_t { list_t *transitions; };#endif/** * Enumeration for transaction type. * A transaction can be either of: * ICT, * IST, * NICT, * NIST, */ typedef enum context_type_t { ICT, /**< Invite Client (outgoing) Transaction */ IST, /**< Invite Server (incoming) Transaction */ NICT,/**< Non-Invite Client (outgoing) Transaction */ NIST /**< Non-Invite Server (incoming) Transaction */ } context_type_t;#ifndef DEFAULT_T1/** * You can re-define the default value for T1. (T1 is defined in rfcxxxx) * The default value is 500ms. */#define DEFAULT_T1 500 /* 500 ms */#endif#ifndef DEFAULT_T2/** * You can re-define the default value for T2. (T2 is defined in rfcxxxx) * The default value is 4000ms. */#define DEFAULT_T2 4000 /* 4s */#endif#ifndef DEFAULT_T4/** * You can re-define the default value for T4. (T1 is defined in rfcxxxx) * The default value is 5000ms. */#define DEFAULT_T4 5000 /* 5s */#endif/** * Structure for INVITE CLIENT TRANSACTION (outgoing INVITE transaction). * @defvar ict_t */ typedef struct ict_t ict_t; struct ict_t { /* state machine is implied... */ int timer_a_length; /* A=T1, A=2xT1... (unreliable transport only) */ time_t timer_a_start; int timer_b_length; /* B = 64* T1 */ time_t timer_b_start; /* fire when transaction timeouts */ int timer_d_length; /* D >= 32s for unreliable transport (else = 0) */ time_t timer_d_start; /* should be equal to timer H */ char *destination; /* url used to send requests */ int port; /* port of next hop */ };/** * Structure for NON-INVITE CLIENT TRANSACTION (outgoing NON-INVITE transaction). * @defvar nict_t */ typedef struct nict_t nict_t; struct nict_t { /* state machine is implied... */ int timer_e_length; /* A=T1, A=2xT1... (unreliable transport only) */ time_t timer_e_start; /* (else = -1) not active */ int timer_f_length; /* B = 64* T1 */ time_t timer_f_start; /* fire when transaction timeouts */ int timer_k_length; /* K = T4 (else = 0) */ time_t timer_k_start; char *destination; /* url used to send requests */ int port; /* port of next hop */ };/** * Structure for INVITE SERVER TRANSACTION (incoming INVITE transaction). * @defvar ist_t */ typedef struct ist_t ist_t; struct ist_t { int timer_g_length; /* G=MIN(T1*2,T2) for unreliable transport (else=0) */ time_t timer_g_start; /* else = 0 when reliable transport is used! */ int timer_h_length; /* H = 64* T1 */ time_t timer_h_start; /* fire when if no ACK is received */ int timer_i_length; /* I = T4 for unreliable transport (else = 0) */ time_t timer_i_start; /* absorb all ACK */ int auto_send_100; /* set to 0 for automatic 100 replies (0 is default) */ };/** * Structure for NON-INVITE SERVER TRANSACTION (incoming SERVER transaction). * @defvar nist_t */ typedef struct nist_t nist_t; struct nist_t { int timer_j_length; /* J = 64*T1 (else 0) */ time_t timer_j_start; };/** * Structure for transaction handling. * @defvar transaction_t */ typedef struct transaction_t transaction_t; struct transaction_t { void *your_instance; /* add whatever you want here. */ int transactionid; /* simple id used to identify the tr. */ fifo_t *transactionff; /* events must be added in this fifo */ via_t *topvia; /* CALL-LEG definition */ from_t *from; /* CALL-LEG definition */ to_t *to; call_id_t *callid; cseq_t *cseq; sip_t *orig_request; /* last request sent */ sip_t *last_response; /* last response received */ sip_t *ack; /* ack request sent */ state_t state; /* state of transaction */ time_t birth_time; /* birth_date of transaction */ time_t completed_time; /* end date of transaction */ /* RESPONSE are received on this socket */ int in_socket; /* REQUESTS are sent on this socket */ int out_socket; void *config; /* transaction is managed by config */ context_type_t ctx_type; ict_t *ict_context; ist_t *ist_context; nict_t *nict_context; nist_t *nist_context; };/** * Structure for osip handling. * In order to use osip, you have to manage at least one global instance * of an osip_t element. Then, you'll register a set of required callbacks * and a set of optional ones. * @defvar osip_t */ typedef struct osip_t osip_t; struct osip_t { void *application_context; /* a pointer for your personnal usage */ /* list of transactions for ict, ist, nict, nist */ list_t *ict_transactions; list_t *ist_transactions; list_t *nict_transactions; list_t *nist_transactions; /* callbacks for sending messages */ int (*cb_send_message) (transaction_t *, sip_t *, char *, int, int); /* callbacks for ict */ void (*cb_ict_kill_transaction) (transaction_t *); void (*cb_ict_invite_sent) (transaction_t *, sip_t *); void (*cb_ict_invite_sent2) (transaction_t *, sip_t *); void (*cb_ict_ack_sent) (transaction_t *, sip_t *); void (*cb_ict_ack_sent2) (transaction_t *, sip_t *); void (*cb_ict_1xx_received) (transaction_t *, sip_t *); void (*cb_ict_2xx_received) (transaction_t *, sip_t *); void (*cb_ict_2xx_received2) (transaction_t *, sip_t *); void (*cb_ict_3xx_received) (transaction_t *, sip_t *); void (*cb_ict_4xx_received) (transaction_t *, sip_t *); void (*cb_ict_5xx_received) (transaction_t *, sip_t *); void (*cb_ict_6xx_received) (transaction_t *, sip_t *); void (*cb_ict_3456xx_received2) (transaction_t *, sip_t *); void (*cb_ict_transport_error) (transaction_t *, int error); /* callbacks for ist */ void (*cb_ist_kill_transaction) (transaction_t *); void (*cb_ist_invite_received) (transaction_t *, sip_t *); void (*cb_ist_invite_received2) (transaction_t *, sip_t *); void (*cb_ist_ack_received) (transaction_t *, sip_t *); void (*cb_ist_ack_received2) (transaction_t *, sip_t *); void (*cb_ist_1xx_sent) (transaction_t *, sip_t *); void (*cb_ist_2xx_sent) (transaction_t *, sip_t *); void (*cb_ist_2xx_sent2) (transaction_t *, sip_t *); void (*cb_ist_3xx_sent) (transaction_t *, sip_t *); void (*cb_ist_4xx_sent) (transaction_t *, sip_t *); void (*cb_ist_5xx_sent) (transaction_t *, sip_t *); void (*cb_ist_6xx_sent) (transaction_t *, sip_t *); void (*cb_ist_3456xx_sent2) (transaction_t *, sip_t *); void (*cb_ist_transport_error) (transaction_t *, int error); /* callbacks for nict */ void (*cb_nict_kill_transaction) (transaction_t *); void (*cb_nict_register_sent) (transaction_t *, sip_t *); void (*cb_nict_bye_sent) (transaction_t *, sip_t *); void (*cb_nict_options_sent) (transaction_t *, sip_t *); void (*cb_nict_info_sent) (transaction_t *, sip_t *); void (*cb_nict_cancel_sent) (transaction_t *, sip_t *); void (*cb_nict_notify_sent) (transaction_t *, sip_t *); void (*cb_nict_subscribe_sent) (transaction_t *, sip_t *); void (*cb_nict_unknown_sent) (transaction_t *, sip_t *); void (*cb_nict_request_sent2) (transaction_t *, sip_t *); void (*cb_nict_1xx_received) (transaction_t *, sip_t *); void (*cb_nict_2xx_received) (transaction_t *, sip_t *); void (*cb_nict_2xx_received2) (transaction_t *, sip_t *); void (*cb_nict_3xx_received) (transaction_t *, sip_t *); void (*cb_nict_4xx_received) (transaction_t *, sip_t *); void (*cb_nict_5xx_received) (transaction_t *, sip_t *); void (*cb_nict_6xx_received) (transaction_t *, sip_t *); void (*cb_nict_3456xx_received2) (transaction_t *, sip_t *); void (*cb_nict_transport_error) (transaction_t *, int error); /* callbacks for nist */ void (*cb_nist_kill_transaction) (transaction_t *); void (*cb_nist_register_received) (transaction_t *, sip_t *); void (*cb_nist_bye_received) (transaction_t *, sip_t *); void (*cb_nist_options_received) (transaction_t *, sip_t *); void (*cb_nist_info_received) (transaction_t *, sip_t *); void (*cb_nist_cancel_received) (transaction_t *, sip_t *); void (*cb_nist_notify_received) (transaction_t *, sip_t *); void (*cb_nist_subscribe_received) (transaction_t *, sip_t *); /* ... TO BE ADDED: All known and used method extensions */ void (*cb_nist_unknown_received) (transaction_t *, sip_t *); void (*cb_nist_request_received2) (transaction_t *, sip_t *); void (*cb_nist_1xx_sent) (transaction_t *, sip_t *); void (*cb_nist_2xx_sent) (transaction_t *, sip_t *); void (*cb_nist_2xx_sent2) (transaction_t *, sip_t *); void (*cb_nist_3xx_sent) (transaction_t *, sip_t *); void (*cb_nist_4xx_sent) (transaction_t *, sip_t *); void (*cb_nist_5xx_sent) (transaction_t *, sip_t *); void (*cb_nist_6xx_sent) (transaction_t *, sip_t *); void (*cb_nist_3456xx_sent2) (transaction_t *, sip_t *); void (*cb_nist_transport_error) (transaction_t *, int error); };/** * Structure for sipevent handling. * A sipevent_t element will have a type and will be related * to a transaction. In the general case, it is used by the * application layer to give SIP messages to the oSIP finite * state machine. * @defvar sipevent_t */ typedef struct sipevent_t sipevent_t; struct sipevent_t { type_t type; int transactionid; sip_t *sip; };#ifndef DOXYGEN/** * Allocate an ict_t element. (for outgoing INVITE transaction) * NOTE: THIS IS AN INTERNAL METHOD ONLY * @param ict The element to allocate. * @param osip The global instance of oSIP. * @param invite The SIP request that initiate the transaction. */ int ict_init (ict_t ** ict, osip_t * osip, sip_t * invite);/** * Free all resource in a ict_t element. * NOTE: THIS IS AN INTERNAL METHOD ONLY * @param ict The element to free. */ int ict_free (ict_t * ict);#endif/** * Set the host and port destination used for sending the SIP message. * This can be useful for an application with 'DIRECT ROOTING MODE' * NOTE: Instead, you should use the 'Route' header facility which * leads to the same behaviour. * @param ict The element to work on. * @param destination The destination host. * @param port The destination port. */ int ict_set_destination (ict_t * ict, char *destination, int port);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -