?? osip.h
字號:
#if 0 typedef struct osip_statemachine osip_statemachine_t; struct osip_statemachine { osip_list_t *transitions; };#endif/** * Enumeration for transaction type. * A transaction can be either of: * ICT, * IST, * NICT, * NIST, */ typedef enum osip_fsm_type_t { ICT, /**< Invite Client (outgoing) Transaction */ IST, /**< Invite Server (incoming) Transaction */ NICT,/**< Non-Invite Client (outgoing) Transaction */ NIST /**< Non-Invite Server (incoming) Transaction */ } osip_fsm_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 osip_ict_t */ typedef struct osip_ict osip_ict_t; struct osip_ict { /* 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 osip_nict_t */ typedef struct osip_nict osip_nict_t; struct osip_nict { /* 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 osip_ist_t */ typedef struct osip_ist osip_ist_t; struct osip_ist { int timer_g_length; /* G=MIN(T1*2,T2) for unreliable transport */ 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 */ };/** * Structure for NON-INVITE SERVER TRANSACTION (incoming SERVER transaction). * @defvar osip_nist_t */ typedef struct osip_nist osip_nist_t; struct osip_nist { int timer_j_length; /* J = 64*T1 (else 0) */ time_t timer_j_start; };/** * Structure for transaction handling. * @defvar osip_transaction_t */ typedef struct osip_transaction osip_transaction_t; struct osip_transaction { void *your_instance; /* add whatever you want here. */ int transactionid; /* simple id used to identify the tr. */ osip_fifo_t *transactionff; /* events must be added in this fifo */ osip_via_t *topvia; /* CALL-LEG definition */ osip_from_t *from; /* CALL-LEG definition */ osip_to_t *to; osip_call_id_t *callid; osip_cseq_t *cseq; osip_message_t *orig_request; /* last request sent */ osip_message_t *last_response; /* last response received */ osip_message_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 */ osip_fsm_type_t ctx_type; osip_ict_t *ict_context; osip_ist_t *ist_context; osip_nict_t *nict_context; osip_nist_t *nist_context; }; typedef 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, /* ... TO BE ADDED: All known and used method extensions */ 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_MESSAGE_CALLBACK_COUNT } osip_message_callback_type_t; typedef 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 } osip_kill_callback_type_t; typedef 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 } osip_transport_error_callback_type_t; typedef void (* osip_message_cb_t) (int type, osip_transaction_t *, osip_message_t *); typedef void (* osip_kill_transaction_cb_t) (int type, osip_transaction_t *); typedef void (* osip_transport_error_cb_t) (int type, osip_transaction_t *, int error);#ifdef OSIP_RETRANSMIT_2XX struct osip_dialog; typedef struct ixt_t ixt_t; struct ixt_t { /* any ACK received that match this context will set counter to -1*/ struct osip_dialog *dialog; osip_message_t *msg2xx; /* copy of string to retransmit */ osip_message_t *ack; /* useless for ist */ time_t start; int interval; /* between each retransmission, in ms */ char *dest; int port; int sock; int counter; /* start at 7 */ };#endif/** * 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 osip_t; struct osip { void *application_context; /* a pointer for your personnal usage */ /* list of transactions for ict, ist, nict, nist */ osip_list_t *osip_ict_transactions; osip_list_t *osip_ist_transactions; osip_list_t *osip_nict_transactions; osip_list_t *osip_nist_transactions; osip_list_t *ixt_retransmissions; /* for retransmission of 2xx & ACK for INVITE */ osip_message_cb_t msg_callbacks[OSIP_MESSAGE_CALLBACK_COUNT]; osip_kill_transaction_cb_t kill_callbacks[OSIP_KILL_CALLBACK_COUNT]; osip_transport_error_cb_t tp_error_callbacks[OSIP_TRANSPORT_ERROR_CALLBACK_COUNT]; /* callbacks for sending messages */ int (*cb_send_message) (osip_transaction_t *, osip_message_t *, char *, int, int); }; int osip_set_message_callback (osip_t *, int type, osip_message_cb_t cb); int osip_set_kill_transaction_callback (osip_t *, int type, osip_kill_transaction_cb_t cb); int osip_set_transport_error_callback (osip_t *, int type, osip_transport_error_cb_t cb);/** * Structure for sipevent handling. * A osip_event_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 osip_event_t */ typedef struct osip_event osip_event_t; struct osip_event { type_t type; int transactionid; osip_message_t *sip; };/** * Allocate an osip_transaction_t element. * @param transaction The element to allocate. * @param ctx_type The type of transaction. (ICT, IST, NICT, NIST) * @param osip The global instance of oSIP. * @param request The SIP request that initiate the transaction. */ int osip_transaction_init (osip_transaction_t ** transaction, osip_fsm_type_t ctx_type, osip_t * osip, osip_message_t * request);/** * Free all resource in a osip_transaction_t element. * @param transaction The element to free. */ int osip_transaction_free (osip_transaction_t * transaction);/** * Free all resource in a osip_transaction_t element. * This method does the same than osip_transaction_free() but it assumes * that the transaction is already removed from the list of transaction * in the osip stack. (to remove it use osip_xixt_remove(osip, transaction); * @param transaction The element to free. */ int osip_transaction_free2 (osip_transaction_t * transaction);/** * 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 osip_ict_set_destination (osip_ict_t * ict, char *destination, int port);/** * 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 nict The element to work on. * @param destination The destination host. * @param port The destination port. */ int osip_nict_set_destination (osip_nict_t * nict, char *destination, int port);/** * Add a SIP event in the fifo of a osip_transaction_t element. * @param transaction The element to work on. * @param evt The event to add. */ int osip_transaction_add_event (osip_transaction_t * transaction, osip_event_t * evt);/** * Consume one osip_event_t element previously added in the fifo.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -