📄 osip.h
字号:
/* The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-) Copyright (C) 2001,2002,2003,2004 Aymeric MOIZARD jack@atosc.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#ifndef _OSIP_H_#define _OSIP_H_#if defined(HAVE_DICT_DICT_H)#include <dict/dict.h>#endif#include <osipparser2/osip_const.h>/* Time-related functions and data types */#include <osip2/osip_time.h>#ifdef __sun#include <sys/types.h>#endif#include <osipparser2/osip_parser.h>#include <osip2/osip_fifo.h>/** * @file osip.h * @brief oSIP fsm Routines * *//** * @defgroup oSIP_FSM oSIP fsm Handling * @ingroup osip2_fsm * @{ */#ifdef __cplusplusextern "C"{#endif/** * Enumeration for transaction state. * Those states are extracted from the diagram found in rfc3261.txt * */ typedef enum _state_t { /* STATES for invite client transaction */ ICT_PRE_CALLING, ICT_CALLING, ICT_PROCEEDING, ICT_COMPLETED, ICT_TERMINATED, /* STATES for invite server transaction */ IST_PRE_PROCEEDING, IST_PROCEEDING, IST_COMPLETED, IST_CONFIRMED, IST_TERMINATED, /* STATES for NON-invite client transaction */ NICT_PRE_TRYING, NICT_TRYING, NICT_PROCEEDING, NICT_COMPLETED, NICT_TERMINATED, /* STATES for NON-invite server transaction */ NIST_PRE_TRYING, NIST_TRYING, NIST_PROCEEDING, NIST_COMPLETED, NIST_TERMINATED,#ifndef DOXYGEN DIALOG_EARLY, DIALOG_CONFIRMED, DIALOG_CLOSE /* ?? */#endif } state_t;/** * Enumeration for event type. * <BR>The list of values that you need to know is reduced to this: * <BR> RCV_REQINVITE, * <BR> RCV_REQACK, * <BR> RCV_REQUEST, * <BR> RCV_STATUS_1XX, * <BR> RCV_STATUS_2XX, * <BR> RCV_STATUS_3456XX, *<BR> * <BR> SND_REQINVITE, * <BR> SND_REQACK, * <BR> SND_REQUEST, * <BR> SND_STATUS_1XX, * <BR> SND_STATUS_2XX, * <BR> SND_STATUS_3456XX, */ typedef enum type_t { /* 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;/** * 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). * @var osip_ict_t */ typedef struct osip_ict osip_ict_t;/** * Structure for INVITE CLIENT TRANSACTION. * @struct osip_ict */ struct osip_ict { int timer_a_length; /**@internal A=T1, A=2xT1... (unreliable only) */ struct timeval timer_a_start; /**@internal */ int timer_b_length; /**@internal B = 64* T1 */ struct timeval timer_b_start; /**@internal fire when transaction timeouts */ int timer_d_length; /**@internal D >= 32s for unreliable tr (or 0) */ struct timeval timer_d_start; /**@internal should be equal to timer H */ char *destination; /**@internal url used to send requests */ int port; /**@internal port of next hop */ };/** * Structure for NON-INVITE CLIENT TRANSACTION (outgoing NON-INVITE transaction). * @var osip_nict_t */ typedef struct osip_nict osip_nict_t;/** * Structure for NON-INVITE CLIENT TRANSACTION. * @struct osip_nict */ struct osip_nict { int timer_e_length; /**@internal A=T1, A=2xT1... (unreliable only) */ struct timeval timer_e_start; /**@internal */ int timer_f_length; /**@internal B = 64* T1 */ struct timeval timer_f_start; /**@internal fire when transaction timeouts */ int timer_k_length; /**@internal K = T4 (else = 0) */ struct timeval timer_k_start; /**@internal */ char *destination; /**@internal url used to send requests */ int port; /**@internal port of next hop */ };/** * Structure for INVITE SERVER TRANSACTION (incoming INVITE transaction). * @var osip_ist_t */ typedef struct osip_ist osip_ist_t;/** * Structure for INVITE SERVER TRANSACTION. * @struct osip_ist */ struct osip_ist { int timer_g_length; /**@internal G=MIN(T1*2,T2) for unreliable trans. */ struct timeval timer_g_start; /**@internal 0 when reliable transport is used */ int timer_h_length; /**@internal H = 64* T1 */ struct timeval timer_h_start; /**@internal fire when if no ACK is received */ int timer_i_length; /**@internal I = T4 for unreliable (or 0) */ struct timeval timer_i_start; /**@internal absorb all ACK */ };/** * Structure for NON-INVITE SERVER TRANSACTION (incoming SERVER transaction). * @var osip_nist_t */ typedef struct osip_nist osip_nist_t;/** * Structure for NON-INVITE SERVER TRANSACTION. * @struct osip_nist */ struct osip_nist { int timer_j_length; /**@internal J = 64*T1 (else 0) */ struct timeval timer_j_start; /**@internal */ };/** * Structure for transaction handling. * @var osip_transaction_t */ typedef struct osip_transaction osip_transaction_t;/** * Structure for transaction handling * @struct osip_transaction */ struct osip_transaction { void *your_instance; /**< User Defined Pointer. */ int transactionid; /**< Internal Transaction Identifier. */ osip_fifo_t *transactionff; /**< events must be added in this fifo */ osip_via_t *topvia; /**< CALL-LEG definition (Top Via) */ osip_from_t *from; /**< CALL-LEG definition (From) */ osip_to_t *to; /**< CALL-LEG definition (To) */ osip_call_id_t *callid; /**< CALL-LEG definition (Call-ID) */ osip_cseq_t *cseq; /**< CALL-LEG definition (CSeq) */ osip_message_t *orig_request; /**< Initial request */ osip_message_t *last_response; /**< Last response */ osip_message_t *ack; /**< ack request sent */ state_t state; /**< Current state of the transaction */ time_t birth_time; /**< birth date of transaction */ time_t completed_time; /**< end date of transaction */ int in_socket; /**< Optional socket for incoming message */ int out_socket; /**< Optional place for outgoing message */ void *config; /**@internal transaction is managed by osip_t */ osip_fsm_type_t ctx_type; /**< Type of the transaction */ osip_ict_t *ict_context; /**@internal */ osip_ist_t *ist_context; /**@internal */ osip_nict_t *nict_context; /**@internal */ osip_nist_t *nist_context; /**@internal */ };/** * Enumeration for callback type. */ typedef enum osip_message_callback_type { OSIP_ICT_INVITE_SENT = 0, /**< INVITE MESSAGE SENT */ OSIP_ICT_INVITE_SENT_AGAIN, /**< INVITE MESSAGE RETRANSMITTED */ OSIP_ICT_ACK_SENT, /**< ACK MESSAGE SENT */ OSIP_ICT_ACK_SENT_AGAIN, /**< ACK MESSAGE RETRANSMITTED */ OSIP_ICT_STATUS_1XX_RECEIVED, /**< 1XX FOR INVITE RECEIVED */ OSIP_ICT_STATUS_2XX_RECEIVED, /**< 2XX FOR INVITE RECEIVED */ OSIP_ICT_STATUS_2XX_RECEIVED_AGAIN, /**< 2XX FOR INVITE RECEIVED AGAIN */ OSIP_ICT_STATUS_3XX_RECEIVED, /**< 3XX FOR INVITE RECEIVED */ OSIP_ICT_STATUS_4XX_RECEIVED, /**< 4XX FOR INVITE RECEIVED */ OSIP_ICT_STATUS_5XX_RECEIVED, /**< 5XX FOR INVITE RECEIVED */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -