libosip  4.0.0
fsm.h
1 /*
2  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3  Copyright (C) 2001-2012 Aymeric MOIZARD amoizard@antisip.com
4 
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.
9 
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.
14 
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
18 */
19 
20 #ifndef _FSM_H_
21 #define _FSM_H_
22 
24 #include <osip2/osip.h>
25 
26 #include "xixt.h"
27 
28 #ifndef DOXYGEN
29 
30 typedef struct osip_statemachine osip_statemachine_t;
31 
32 struct osip_statemachine {
33  struct _transition_t *transitions;
34 };
35 
42 osip_event_t *__osip_event_new (type_t type, int transactionid);
43 
44 
45 /* This is for internal use only. */
46 type_t evt_set_type_incoming_sipmessage (osip_message_t * sip);
47 type_t evt_set_type_outgoing_sipmessage (osip_message_t * sip);
48 
49 typedef struct _transition_t transition_t;
50 
51 struct _transition_t {
52  state_t state;
53  type_t type;
54  void (*method) (void *, void *);
55  struct _transition_t *next;
56  struct _transition_t *parent;
57 };
58 
59 int fsm_callmethod (type_t type, state_t state, osip_statemachine_t * statemachine, void *sipevent, void *transaction);
60 
61 
63 /* These methods are the "exection method" for the finite */
64 /* state machine. */
65 
66 /************************/
67 /* FSM ---- > ICT */
68 /************************/
69 
70 void ict_snd_invite (osip_transaction_t * ict, osip_event_t * evt);
71 void osip_ict_timeout_a_event (osip_transaction_t * ict, osip_event_t * evt);
72 void osip_ict_timeout_b_event (osip_transaction_t * ict, osip_event_t * evt);
73 void osip_ict_timeout_d_event (osip_transaction_t * ict, osip_event_t * evt);
74 void ict_rcv_1xx (osip_transaction_t * ict, osip_event_t * evt);
75 void ict_rcv_2xx (osip_transaction_t * ict, osip_event_t * evt);
76 osip_message_t *ict_create_ack (osip_transaction_t * ict, osip_message_t * response);
77 void ict_rcv_3456xx (osip_transaction_t * ict, osip_event_t * evt);
78 void ict_retransmit_ack (osip_transaction_t * ict, osip_event_t * evt);
79 
80 /************************/
81 /* FSM ---- > IST */
82 /************************/
83 
84 void ist_rcv_invite (osip_transaction_t * ist, osip_event_t * evt);
85 void osip_ist_timeout_g_event (osip_transaction_t * ist, osip_event_t * evt);
86 void osip_ist_timeout_h_event (osip_transaction_t * ist, osip_event_t * evt);
87 void osip_ist_timeout_i_event (osip_transaction_t * ist, osip_event_t * evt);
88 void ist_snd_1xx (osip_transaction_t * ist, osip_event_t * evt);
89 void ist_snd_2xx (osip_transaction_t * ist, osip_event_t * evt);
90 void ist_snd_3456xx (osip_transaction_t * ist, osip_event_t * evt);
91 void ist_rcv_ack (osip_transaction_t * ist, osip_event_t * evt);
92 
93 /***********************/
94 /* FSM ---- > NICT */
95 /***********************/
96 
97 void nict_snd_request (osip_transaction_t * nict, osip_event_t * evt);
98 void osip_nict_timeout_e_event (osip_transaction_t * nict, osip_event_t * evt);
99 void osip_nict_timeout_f_event (osip_transaction_t * nict, osip_event_t * evt);
100 void osip_nict_timeout_k_event (osip_transaction_t * nict, osip_event_t * evt);
101 void nict_rcv_1xx (osip_transaction_t * nict, osip_event_t * evt);
102 void nict_rcv_23456xx (osip_transaction_t * nict, osip_event_t * evt);
103 
104 /* void nict_rcv_23456xx2(osip_transaction_t *nict, osip_event_t *evt); */
105 
106 /************************/
107 /* FSM ---- > NIST */
108 /************************/
109 
110 void nist_rcv_request (osip_transaction_t * nist, osip_event_t * evt);
111 void nist_snd_1xx (osip_transaction_t * nist, osip_event_t * evt);
112 void nist_snd_23456xx (osip_transaction_t * nist, osip_event_t * evt);
113 void osip_nist_timeout_j_event (osip_transaction_t * nist, osip_event_t * evt);
114 
115 /************************/
116 /* Internal Methods */
117 /************************/
118 
119 
120 void __osip_message_callback (int type, osip_transaction_t *, osip_message_t *);
121 void __osip_kill_transaction_callback (int type, osip_transaction_t *);
122 void __osip_transport_error_callback (int type, osip_transaction_t *, int error);
123 
130 int __osip_transaction_set_state (osip_transaction_t * transaction, state_t state);
131 
138 int
139  __osip_transaction_matching_response_osip_to_xict_17_1_3 (osip_transaction_t * tr, osip_message_t * resp);
140 
147 int
148  __osip_transaction_matching_request_osip_to_xist_17_2_3 (osip_transaction_t * tr, osip_message_t * request);
149 
150 osip_event_t *__osip_transaction_need_timer_x_event (void *xixt, struct timeval *timer, int cond_state, int transactionid, int TIMER_VAL);
151 
152 int __osip_transaction_snd_xxx (osip_transaction_t * ist, osip_message_t * msg);
153 
154 #endif
155 
156 #endif