30 #include <sys/types.h>
170 #define DEFAULT_T1 500
172 #ifndef DEFAULT_T1_TCP_PROGRESS
181 #define DEFAULT_T1_TCP_PROGRESS 50
188 #define DEFAULT_T2 4000
195 #define DEFAULT_T4 5000
297 #define OSIP_SRV_STATE_UNKNOWN 0
298 #define OSIP_SRV_STATE_RETRYLATER 2
299 #define OSIP_SRV_STATE_COMPLETED 3
300 #define OSIP_SRV_STATE_NOTSUPPORTED 4
306 typedef struct osip_srv_record osip_srv_record_t;
322 #define OSIP_NAPTR_STATE_UNKNOWN 0
323 #define OSIP_NAPTR_STATE_INPROGRESS 1
324 #define OSIP_NAPTR_STATE_NAPTRDONE 2
325 #define OSIP_NAPTR_STATE_SRVINPROGRESS 3
326 #define OSIP_NAPTR_STATE_SRVDONE 4
327 #define OSIP_NAPTR_STATE_RETRYLATER 5
328 #define OSIP_NAPTR_STATE_NOTSUPPORTED 6
334 typedef struct osip_naptr osip_naptr_t;
960 #ifdef OSIP_MONOTHREAD
1057 #define EVT_IS_RCV_INVITE(event) (event->type==RCV_REQINVITE)
1062 #define EVT_IS_RCV_ACK(event) (event->type==RCV_REQACK)
1067 #define EVT_IS_RCV_REQUEST(event) (event->type==RCV_REQUEST)
1072 #define EVT_IS_RCV_STATUS_1XX(event) (event->type==RCV_STATUS_1XX)
1077 #define EVT_IS_RCV_STATUS_2XX(event) (event->type==RCV_STATUS_2XX)
1082 #define EVT_IS_RCV_STATUS_3456XX(event) (event->type==RCV_STATUS_3456XX)
1090 #define EVT_IS_SND_INVITE(event) (event->type==SND_REQINVITE)
1095 #define EVT_IS_SND_ACK(event) (event->type==SND_REQACK)
1100 #define EVT_IS_SND_REQUEST(event) (event->type==SND_REQUEST)
1105 #define EVT_IS_SND_STATUS_1XX(event) (event->type==SND_STATUS_1XX)
1110 #define EVT_IS_SND_STATUS_2XX(event) (event->type==SND_STATUS_2XX)
1115 #define EVT_IS_SND_STATUS_3456XX(event) (event->type==SND_STATUS_3456XX)
1120 #define EVT_IS_INCOMINGMSG(event) (event->type>=RCV_REQINVITE \
1121 &&event->type<=RCV_STATUS_3456XX)
1126 #define EVT_IS_INCOMINGREQ(event) (EVT_IS_RCV_INVITE(event) \
1127 ||EVT_IS_RCV_ACK(event) \
1128 ||EVT_IS_RCV_REQUEST(event))
1133 #define EVT_IS_INCOMINGRESP(event) (EVT_IS_RCV_STATUS_1XX(event) \
1134 ||EVT_IS_RCV_STATUS_2XX(event) \
1135 ||EVT_IS_RCV_STATUS_3456XX(event))
1140 #define EVT_IS_OUTGOINGMSG(event) (event->type>=SND_REQINVITE \
1141 &&event->type<=SND_STATUS_3456XX)
1146 #define EVT_IS_OUTGOINGREQ(event) (EVT_IS_SND_INVITE(event) \
1147 ||EVT_IS_SND_ACK(event) \
1148 ||EVT_IS_SND_REQUEST(event))
1153 #define EVT_IS_OUTGOINGRESP(event) (EVT_IS_SND_STATUS_1XX(event) \
1154 ||EVT_IS_SND_STATUS_2XX(event) \
1155 ||EVT_IS_SND_STATUS_3456XX(event))
1161 #define EVT_IS_MSG(event) (event->type>=RCV_REQINVITE \
1162 &&event->type<=SND_STATUS_3456XX)
1168 #define EVT_IS_KILL_TRANSACTION(event) (event->type==KILL_TRANSACTION)
Structure for referencing a list of elements.
Structure for SIP Message (REQUEST and RESPONSE).
void * ict_fastmutex
mutex for ICT transaction
struct timeval timer_f_start
Timer F (fire when transaction timeout)
void * osip_transaction_get_reserved3(osip_transaction_t *transaction)
Get a pointer to your personal context associated with this transaction.
int timer_a_length
Timer A A=T1, A=2xT1...
void osip_timers_nict_execute(osip_t *osip)
Check if a nict transactions needs a timer event.
osip_message_t * last_response
Last response.
Event is an incoming NON-INVITE and NON-ACK request.
struct timeval timer_g_start
Timer G (0 when reliable transport is used)
struct timeval timer_d_start
Timer D.
Definition of the CSeq header.
Event is an incoming 2XX response.
time_t completed_time
end date of transaction
void * osip_get_application_context(osip_t *osip)
Get a pointer in a osip_t element.
void * reserved4
User Defined Pointer.
int osip_transaction_free2(osip_transaction_t *transaction)
Free all resource in a osip_transaction_t element.
TIMER F EXPIRATION: NO REMOTE ANSWER.
int osip_transaction_set_reserved3(osip_transaction_t *transaction, void *ptr)
Set a pointer to your personal context associated with this transaction.
int osip_init(osip_t **osip)
Allocate an osip_t element.
osip_transport_error_cb_t tp_error_callbacks[OSIP_TRANSPORT_ERROR_CALLBACK_COUNT]
transport error callback
enum osip_message_callback_type osip_message_callback_type_t
Enumeration for callback type.
end of Server Non-INVITE transaction
void * osip_transaction_get_reserved6(osip_transaction_t *transaction)
Get a pointer to your personal context associated with this transaction.
Structure for NAPTR record entry.
osip_nist_t * nist_context
internal nist context
Structure for referencing a fifo.
int transactionid
previous unique transaction id generation
int in_socket
Optional socket for incoming message.
osip_via_t * topvia
CALL-LEG definition (Top Via)
_state_t
Enumeration for transaction state.
int osip_transaction_set_in_socket(osip_transaction_t *transaction, int sock)
Set the socket for incoming message.
void * reserved3
User Defined Pointer.
int osip_nict_execute(osip_t *osip)
Consume ALL pending osip_event_t previously added in the fifos of nict transactions.
UNKNWON REQUEST RECEIVED.
enum _state_t state_t
Enumeration for transaction state.
osip_ist_t * ist_context
internal ist context
char * destination
IP used to send requests.
osip_kill_transaction_cb_t kill_callbacks[OSIP_KILL_CALLBACK_COUNT]
kill callbacks
2XX FOR MESSAGE RETRANSMITTED
osip_message_callback_type
Enumeration for callback type.
int osip_remove_transaction(osip_t *osip, osip_transaction_t *ict)
Remove a transaction from the osip stack.
void * osip_ict_hastable
htable of ict transactions
void osip_timers_ist_execute(osip_t *osip)
Check if an ist transactions needs a timer event.
Structure for INVITE CLIENT TRANSACTION.
osip_srv_entry_t srventry[10]
result table
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.
enum osip_transport_error_callback_type osip_transport_error_callback_type_t
Enumeration for callback type used when a transport error is detected.
Invite Server (incoming) Transaction.
struct timeval timer_a_start
Timer A (retransmission)
int osip_transaction_set_your_instance(osip_transaction_t *transaction, void *ptr)
Set a pointer to your personal context associated with this transaction.
int osip_transaction_get_destination(osip_transaction_t *transaction, char **ip, int *port)
Get target ip and port for this request.
void osip_set_application_context(osip_t *osip, void *pointer)
Set a pointer in a osip_t element.
Event is an incoming final response (not 2XX)
osip_ict_t * ict_context
internal ict context
char ipaddress[512]
ipaddress result
int naptr_state
naptr state
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.
osip_message_t * ack
ack message if needed
osip_message_cb_t msg_callbacks[OSIP_MESSAGE_CALLBACK_COUNT]
message callbacks
struct timeval timer_k_start
Timer K.
int osip_transaction_execute(osip_transaction_t *transaction, osip_event_t *evt)
Consume one osip_event_t element previously added in the fifo.
Structure for transaction handling.
end of Server INVITE transaction
osip_message_t * sip
SIP message (optional)
void * reserved1
User Defined Pointer.
struct osip_srv_record sipsctp_record
sctp SRV result
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.
struct osip_srv_record sipudp_record
udp SRV result
void * osip_nist_hastable
htable of nist transactions
char protocol[64]
transport protocol
int osip_transaction_set_out_socket(osip_transaction_t *transaction, int sock)
Set the socket for outgoing message.
int osip_transaction_free(osip_transaction_t *transaction)
Free all resource in a osip_transaction_t element.
struct timeval timer_j_start
Timer J.
struct osip_dialog * dialog
related dialog
int transactionid
identifier of the related osip transaction
int osip_set_message_callback(osip_t *osip, int type, osip_message_cb_t cb)
Set a callback for each transaction operation.
struct osip_srv_record sipdtls_record
dtls SRV result
Structure for INVITE SERVER TRANSACTION.
struct timeval srv_is_broken
time when we considered SRV entry broken
osip_kill_callback_type
Enumeration for callback type used when transaction is over.
void * your_instance
User Defined Pointer.
int transactionid
Internal Transaction Identifier.
end of Client Non-INVITE transaction
osip_event_t * osip_parse(const char *buf, size_t length)
Create a sipevent from a SIP message string.
osip_transaction_t * osip_transaction_find(osip_list_t *transactions, osip_event_t *evt)
Search for a transaction that match this event (MUST be a MESSAGE event).
void * reserved2
User Defined Pointer.
osip_srv_record_t record
memory space for SRV record
osip_from_t * from
CALL-LEG definition (From)
char * destination
IP used to send requests.
int osip_transaction_set_reserved5(osip_transaction_t *transaction, void *ptr)
Set a pointer to your personal context associated with this transaction.
int timer_b_length
Timer B B = 64* T1.
struct timeval start
Time of first retransmission.
osip_list_t ixt_retransmissions
list of ixt elements
void(* osip_transport_error_cb_t)(int type, osip_transaction_t *, int error)
Callback definition for transport error announcements.
osip_naptr_t * naptr_record
memory space for NAPTR record
int timer_j_length
Timer J = 64*T1 (else 0)
struct osip_dialog * osip_stop_200ok_retransmissions(osip_t *osip, osip_message_t *ack)
Stop the out of fsm 200 Ok retransmissions matching an incoming ACK.
void(* osip_message_cb_t)(int type, osip_transaction_t *, osip_message_t *)
Callback definition for message announcements.
ACK MESSAGE RETRANSMITTED.
2XX FOR INVITE RECEIVED AGAIN
2XX FOR INVITE RETRANSMITTED
void * osip_transaction_get_reserved1(osip_transaction_t *transaction)
Get a pointer to your personal context associated with this transaction.
void * nist_fastmutex
mutex for NIST transaction
Structure for osip handling.
Non-Invite Server (incoming) Transaction.
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.
void * ist_fastmutex
mutex for IST transaction
int osip_ist_execute(osip_t *osip)
Consume ALL pending osip_event_t previously added in the fifos of ist transactions.
osip_message_t * msg2xx
buffer to retransmit
2XX FOR MESSAGE RECEIVED AGAIN
int out_socket
Optional place for outgoing message.
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.
void * id_mutex
mutex for unique transaction id generation
TIMER B EXPIRATION: NO REMOTE ANSWER.
Event is an incoming ACK request.
osip_list_t osip_ict_transactions
list of ict transactions
Definition of the From header.
Event is an outgoing NON-INVITE and NON-ACK request.
int(* cb_send_message)(osip_transaction_t *, osip_message_t *, char *, int, int)
callback to send message
Event is an outgoing 2XX response.
INVITE MESSAGE RECEIVED AGAN.
struct timeval timer_b_start
Timer B (fire when transaction timeout)
int timer_h_length
Timer H H = 64* T1.
int osip_transaction_set_naptr_record(osip_transaction_t *transaction, osip_naptr_t *record)
Set NAPTR lookup information to be used by state machine.
void * reserved5
User Defined Pointer.
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 tran...
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.
int interval
delay between retransmission, in ms
Event to 'kill' the transaction before termination.
char * dest
destination host
UNKNOWN REQUEST MESSAGE SENT.
int timer_k_length
Timer K K = T4 (else = 0)
osip_fsm_type_t ctx_type
Type of the transaction.
osip_transaction_t * osip_create_transaction(osip_t *osip, osip_event_t *evt)
Create a transaction for this event (MUST be a SIP REQUEST event).
Event is an outgoing ACK request.
state_t state
Current state of the transaction.
osip_list_t osip_nist_transactions
list of nist transactions
int osip_transaction_set_reserved6(osip_transaction_t *transaction, void *ptr)
Set a pointer to your personal context associated with this transaction.
Event is an incoming informational response.
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.
osip_fifo_t * transactionff
events must be added in this fifo
Invite Client (outgoing) Transaction.
osip_transaction_t * __osip_find_transaction(osip_t *osip, osip_event_t *evt, int consume)
Some race conditions can happen in multi threaded applications.
end of Client INVITE transaction
int keep_in_cache
keep in cache value
Definition of the Via header.
osip_fsm_type_t
Enumeration for transaction type.
time_t birth_time
birth date of transaction
int timer_f_length
Timer F B = 64* T1.
struct timeval timer_e_start
Timer E (retransmission)
struct timeval timer_h_start
Timer H (fire if no ACK is received)
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.
ACK MESSAGE RECEIVED AGAIN.
REQUEST MESSAGE RETRANMITTED.
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.
Event is an outgoing final response (not 2XX)
void * osip_transaction_get_reserved5(osip_transaction_t *transaction)
Get a pointer to your personal context associated with this transaction.
INVITE MESSAGE RETRANSMITTED.
void * osip_transaction_get_reserved2(osip_transaction_t *transaction)
Get a pointer to your personal context associated with this transaction.
void osip_event_free(osip_event_t *event)
Free all resource in a sipevent.
osip_call_id_t * callid
CALL-LEG definition (Call-ID)
osip_to_t * to
CALL-LEG definition (To)
Event is an incoming INVITE request.
int timer_e_length
Timer E A=T1, A=2xT1...
void osip_retransmissions_execute(osip_t *osip)
Send required retransmissions.
void osip_timers_ict_execute(osip_t *osip)
Check if an ict transactions needs a timer event.
osip_list_t osip_nict_transactions
list of nict transactions
oSIP SIP Parser additionnal Routines
Structure for referencing a dialog.
osip_message_t * orig_request
Initial request.
int osip_nist_execute(osip_t *osip)
Consume ALL pending osip_event_t previously added in the fifos of nist transactions.
void * reserved6
User Defined Pointer.
Definition of the Call-Id header.
osip_event_t * osip_new_outgoing_sipmessage(osip_message_t *sip)
Allocate a sipevent (we know this message is an OUTGOING SIP message).
osip_cseq_t * cseq
CALL-LEG definition (CSeq)
int osip_transaction_set_reserved4(osip_transaction_t *transaction, void *ptr)
Set a pointer to your personal context associated with this transaction.
Structure for SRV record entry.
void * config
(internal) transaction is managed by osip_t
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...
Structure for 2XX retransmission management.
void * ixt_fastmutex
mutex for IXT transaction
UNKNWON REQUEST RECEIVED AGAIN.
osip_transport_error_callback_type
Enumeration for callback type used when a transport error is detected.
osip_list_t osip_ist_transactions
list of ist transactions
void osip_timers_nist_execute(osip_t *osip)
Check if a nist transactions needs a timer event.
struct osip_srv_record siptls_record
tls SRV result
void(* osip_kill_transaction_cb_t)(int type, osip_transaction_t *)
Callback definition for end of transaction announcements.
void * osip_ist_hastable
htable of ist transactions
int osip_transaction_set_reserved1(osip_transaction_t *transaction, void *ptr)
Set a pointer to your personal context associated with this transaction.
int timer_g_length
Timer G G=MIN(T1*2,T2) for unreliable trans.
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.
void * osip_nict_hastable
htable of nict transactions
void * osip_transaction_get_your_instance(osip_transaction_t *transaction)
Get a pointer to your personal context associated with this transaction.
int osip_transaction_set_reserved2(osip_transaction_t *transaction, void *ptr)
Set a pointer to your personal context associated with this transaction.
osip_nict_t * nict_context
internal nict context
int timer_i_length
Timer I I = T4 for unreliable (or 0)
void * osip_transaction_get_reserved4(osip_transaction_t *transaction)
Get a pointer to your personal context associated with this transaction.
void * application_context
User defined Pointer.
struct osip_srv_record siptcp_record
tcp SRV result
enum osip_kill_callback_type osip_kill_callback_type_t
Enumeration for callback type used when transaction is over.
int timer_d_length
Timer D D >= 32s for unreliable tr (or 0)
void * nict_fastmutex
mutex for NICT transaction
Structure for SRV record entry.
struct timeval timer_i_start
Timer I (absorb all ACK)
Event is an outgoing informational response.
Structure for osip event handling.
Structure for NON-INVITE CLIENT TRANSACTION.
Structure for NON-INVITE SERVER TRANSACTION.
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.
void osip_release(osip_t *osip)
Free all resource in a osip_t element.
int osip_ict_execute(osip_t *osip)
Consume ALL pending osip_event_t previously added in the fifos of ict transactions.
type_t
Enumeration for event type.
Non-Invite Client (outgoing) Transaction.
osip_message_t * ack
ack request sent
Event is an outgoing INVITE request.
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.