📄 osip.h
字号:
OSIP_NIST_STATUS_3XX_SENT, /**< 3XX FOR MESSAGE SENT */ OSIP_NIST_STATUS_4XX_SENT, /**< 4XX FOR MESSAGE SENT */ OSIP_NIST_STATUS_5XX_SENT, /**< 5XX FOR MESSAGE SENT */ OSIP_NIST_STATUS_6XX_SENT, /**< 6XX FOR MESSAGE SENT */ OSIP_NIST_STATUS_3456XX_SENT_AGAIN, /**< RESPONSE RETRANSMITTED */ OSIP_MESSAGE_CALLBACK_COUNT /**< END OF ENUM */ } osip_message_callback_type_t;/** * Enumeration for callback type used when transaction is over. */ typedef enum osip_kill_callback_type { OSIP_ICT_KILL_TRANSACTION, /**< end of Client INVITE transaction */ OSIP_IST_KILL_TRANSACTION, /**< end of Server INVITE transaction */ OSIP_NICT_KILL_TRANSACTION, /**< end of Client Non-INVITE transaction */ OSIP_NIST_KILL_TRANSACTION, /**< end of Server Non-INVITE transaction */ OSIP_KILL_CALLBACK_COUNT /**< END OF ENUM */ } osip_kill_callback_type_t;/** * Enumeration for callback type used when a transport error is detected. */ typedef enum osip_transport_error_callback_type { OSIP_ICT_TRANSPORT_ERROR, /**< transport error for ICT */ OSIP_IST_TRANSPORT_ERROR, /**< transport error for IST */ OSIP_NICT_TRANSPORT_ERROR, /**< transport error for NICT */ OSIP_NIST_TRANSPORT_ERROR, /**< transport error for NIST */ OSIP_TRANSPORT_ERROR_CALLBACK_COUNT /**< END OF ENUM */ } 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); };/** * Set a callback for each transaction operation. * @param osip The element to work on. * @param type The event type to hook on. * @param cb The method to be called upon the event. */ int osip_set_message_callback (osip_t *osip, int type, osip_message_cb_t cb);/** * Set a callback for transaction operation related to the end of transactions. * @param osip The element to work on. * @param type The event type to hook on. * @param cb The method to be called upon the event. */ int osip_set_kill_transaction_callback (osip_t *osip, int type, osip_kill_transaction_cb_t cb);/** * Set a callback for each transaction operation related to network error. * @param osip The element to work on. * @param type The event type to hook on. * @param cb The method to be called upon the event. */ int osip_set_transport_error_callback (osip_t *osip, 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. * NOTE: This method MUST NEVER be called within another call * of this method. (For example, you can't call osip_transaction_execute() * in a callback registered in the osip_t element.) * @param transaction The element to free. * @param evt The element to consume. */ int osip_transaction_execute (osip_transaction_t * transaction, osip_event_t * evt);/** * Set a pointer to your personal context associated with this transaction. * NOTE: this is a very useful method that allow you to avoid searching * for your personal context inside the registered callbacks. * You can initialise this pointer to your context right after * the creation of the osip_transaction_t element. Then, you'll be * able to get the address of your context by calling * osip_transaction_get_your_instance(). * @param transaction The element to work on. * @param instance The address of your context. */ int osip_transaction_set_your_instance (osip_transaction_t * transaction, void *instance);/** * Get a pointer to your personal context associated with this transaction. * @param transaction The element to work on. */ void *osip_transaction_get_your_instance (osip_transaction_t * transaction);/** * Get target ip and port for this request. * (automaticly set by osip_transaction_init() for ict and nict) * @param transaction The element to work on. * @param ip The ip of host where to send initial request. * @param port The port where to send initial request. */ int osip_transaction_get_destination (osip_transaction_t * transaction, char **ip, int *port);#ifndef DOXYGEN/** * Set the socket for incoming message. * NOTE: THIS HAS NEVER TESTED! Please send feedback. * @param transaction The element to work on. * @param sock The socket for incoming message. */ int osip_transaction_set_in_socket (osip_transaction_t * transaction, int sock);/** * Set the socket for outgoing message. * NOTE: THIS HAS NEVER TESTED! Please send feedback. * @param transaction The element to work on. * @param sock The socket for outgoing message. */ int osip_transaction_set_out_socket (osip_transaction_t * transaction, int sock);#if 0/** * Check if the first 2 parameters match the other ones. * NOTE: THIS IS AN INTERNAL METHOD ONLY * @param to1 The initial to header. * @param from1 The initial from header. * @param to2 The new to header. * @param from2 The new from header. */ int callleg_match (osip_to_t * to1, osip_from_t * from1, osip_to_t * to2, osip_from_t * from2);#endif#endif /* endif DOXYGEN *//** * Allocate an osip_t element. * @param osip the element to allocate. */ int osip_init (osip_t ** osip);/** * Free all resource in a osip_t element. * @param osip The element to release. */ void osip_release (osip_t * osip);/** * Set a pointer in a osip_t element. * This help to find your application layer in callbacks. * @param osip The element to work on. * @param pointer The element to set. */ void osip_set_application_context (osip_t * osip, void *pointer);/** * Get a pointer in a osip_t element. * This help to find your application layer in callbacks. * @param osip The element to work on. */ void *osip_get_application_context (osip_t * osip);/** * Remove a transaction from the osip stack. * @param osip The element to work on. * @param ict The transaction to add.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -