2 The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3 Copyright (C) 2001,2002,2003 Aymeric MOIZARD jack@atosc.org
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <osipparser2/osip_message.h>
24 #include <osip2/osip.h>
28 void add_gettimeofday (struct timeval *atv, int ms);
29 void min_timercmp (struct timeval *tv1, struct timeval *tv2);
31 int gettimeofday(struct timeval *tp, void *tz);
34 typedef struct osip_statemachine osip_statemachine_t;
36 struct osip_statemachine
38 osip_list_t *transitions;
42 * Allocate a sipevent.
43 * NOTE: THIS IS AN INTERNAL METHOD ONLY
44 * @param type The type of the event.
45 * @param transactionid The transaction id for this event.
47 osip_event_t *__osip_event_new (type_t type, int transactionid);
50 /* This is for internal use only. */
51 type_t evt_set_type_incoming_sipmessage (osip_message_t * sip);
52 type_t evt_set_type_outgoing_sipmessage (osip_message_t * sip);
54 /* send a request on UDP. */
55 int udp_send_request (osip_message_t * request, osip_uri_t * proxy);
57 /* send a response on UDP. */
58 int udp_send_response (osip_message_t * response);
60 void __ict_load_fsm (void);
61 void __ist_load_fsm (void);
62 void __nict_load_fsm (void);
63 void __nist_load_fsm (void);
65 void __ict_unload_fsm (void);
66 void __ist_unload_fsm (void);
67 void __nict_unload_fsm (void);
68 void __nist_unload_fsm (void);
70 /* load state machine structure for (UAC || UAS) for (INVITE || REQUEST) */
71 osip_statemachine_t *__ict_get_fsm (void);
72 osip_statemachine_t *__ist_get_fsm (void);
74 osip_statemachine_t *__nict_get_fsm (void);
75 osip_statemachine_t *__nist_get_fsm (void);
77 typedef struct _transition_t
81 void (*method) (void *, void *);
85 int fsm_callmethod (type_t type, state_t state,
86 osip_statemachine_t * statemachine,
87 void *sipevent, void *transaction);
90 /*!! THESE ARE FOR INTERNAL USE ONLY!! */
91 /* These methods are the "exection method" for the finite */
94 /************************/
96 /************************/
98 void ict_snd_invite (osip_transaction_t * ict, osip_event_t * evt);
99 void osip_ict_timeout_a_event (osip_transaction_t * ict, osip_event_t * evt);
100 void osip_ict_timeout_b_event (osip_transaction_t * ict, osip_event_t * evt);
101 void osip_ict_timeout_d_event (osip_transaction_t * ict, osip_event_t * evt);
102 void ict_rcv_1xx (osip_transaction_t * ict, osip_event_t * evt);
103 void ict_rcv_2xx (osip_transaction_t * ict, osip_event_t * evt);
104 osip_message_t *ict_create_ack (osip_transaction_t * ict,
105 osip_message_t * response);
106 void ict_rcv_3456xx (osip_transaction_t * ict, osip_event_t * evt);
107 void ict_retransmit_ack (osip_transaction_t * ict, osip_event_t * evt);
109 /************************/
111 /************************/
113 osip_message_t *ist_create_resp_100 (osip_transaction_t * ist,
114 osip_message_t * request);
115 void ist_rcv_invite (osip_transaction_t * ist, osip_event_t * evt);
116 void osip_ist_timeout_g_event (osip_transaction_t * ist, osip_event_t * evt);
117 void osip_ist_timeout_h_event (osip_transaction_t * ist, osip_event_t * evt);
118 void osip_ist_timeout_i_event (osip_transaction_t * ist, osip_event_t * evt);
119 void ist_snd_1xx (osip_transaction_t * ist, osip_event_t * evt);
120 void ist_snd_2xx (osip_transaction_t * ist, osip_event_t * evt);
121 void ist_snd_3456xx (osip_transaction_t * ist, osip_event_t * evt);
122 void ist_rcv_ack (osip_transaction_t * ist, osip_event_t * evt);
124 /***********************/
125 /* FSM ---- > NICT */
126 /***********************/
128 void nict_snd_request (osip_transaction_t * nict, osip_event_t * evt);
129 void osip_nict_timeout_e_event (osip_transaction_t * nict,
131 void osip_nict_timeout_f_event (osip_transaction_t * nict,
133 void osip_nict_timeout_k_event (osip_transaction_t * nict,
135 void nict_rcv_1xx (osip_transaction_t * nict, osip_event_t * evt);
136 void nict_rcv_23456xx (osip_transaction_t * nict, osip_event_t * evt);
138 /* void nict_rcv_23456xx2(osip_transaction_t *nict, osip_event_t *evt); */
140 /************************/
141 /* FSM ---- > NIST */
142 /************************/
144 void nist_rcv_request (osip_transaction_t * nist, osip_event_t * evt);
145 void nist_snd_1xx (osip_transaction_t * nist, osip_event_t * evt);
146 void nist_snd_23456xx (osip_transaction_t * nist, osip_event_t * evt);
147 void osip_nist_timeout_j_event (osip_transaction_t * nist,
150 /************************/
151 /* Internal Methods */
152 /************************/
155 void __osip_message_callback (int type, osip_transaction_t *,
157 void __osip_kill_transaction_callback (int type, osip_transaction_t *);
158 void __osip_transport_error_callback (int type, osip_transaction_t *,
162 * Set the state of the transaction.
163 * NOTE: THIS IS AN INTERNAL METHOD ONLY
164 * @param transaction The element to work on.
165 * @param state The new state.
167 int __osip_transaction_set_state (osip_transaction_t * transaction,
171 * Check if the response match a server transaction.
172 * NOTE: THIS IS AN INTERNAL METHOD ONLY
173 * @param tr The transaction.
174 * @param resp The SIP response received.
177 __osip_transaction_matching_response_osip_to_xict_17_1_3 (osip_transaction_t *
183 * Check if the request match a client transaction.
184 * NOTE: THIS IS AN INTERNAL METHOD ONLY
185 * @param tr The transaction.
186 * @param request The SIP request received.
189 __osip_transaction_matching_request_osip_to_xist_17_2_3 (osip_transaction_t *