libosip  5.3.0
fsm.h
1 /*
2  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3  Copyright (C) 2001-2020 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 /* This is for internal use only. */
45 type_t evt_set_type_incoming_sipmessage(osip_message_t *sip);
46 type_t evt_set_type_outgoing_sipmessage(osip_message_t *sip);
47 
48 typedef struct _transition_t transition_t;
49 
50 struct _transition_t {
51  state_t state;
52  type_t type;
53  void (*method)(void *, void *);
54  struct _transition_t *next;
55  struct _transition_t *parent;
56 };
57 
58 int fsm_callmethod(type_t type, state_t state, osip_statemachine_t *statemachine, void *sipevent, void *transaction);
59 
61 /* These methods are the "exection method" for the finite */
62 /* state machine. */
63 
64 /************************/
65 /* FSM ---- > ICT */
66 /************************/
67 
68 void ict_snd_invite(osip_transaction_t *ict, osip_event_t *evt);
69 void osip_ict_timeout_a_event(osip_transaction_t *ict, osip_event_t *evt);
70 void osip_ict_timeout_b_event(osip_transaction_t *ict, osip_event_t *evt);
71 void osip_ict_timeout_d_event(osip_transaction_t *ict, osip_event_t *evt);
72 void ict_rcv_1xx(osip_transaction_t *ict, osip_event_t *evt);
73 void ict_rcv_2xx(osip_transaction_t *ict, osip_event_t *evt);
74 osip_message_t *ict_create_ack(osip_transaction_t *ict, osip_message_t *response);
75 void ict_rcv_3456xx(osip_transaction_t *ict, osip_event_t *evt);
76 void ict_retransmit_ack(osip_transaction_t *ict, osip_event_t *evt);
77 
78 /************************/
79 /* FSM ---- > IST */
80 /************************/
81 
82 void ist_rcv_invite(osip_transaction_t *ist, osip_event_t *evt);
83 void osip_ist_timeout_g_event(osip_transaction_t *ist, osip_event_t *evt);
84 void osip_ist_timeout_h_event(osip_transaction_t *ist, osip_event_t *evt);
85 void osip_ist_timeout_i_event(osip_transaction_t *ist, osip_event_t *evt);
86 void ist_snd_1xx(osip_transaction_t *ist, osip_event_t *evt);
87 void ist_snd_2xx(osip_transaction_t *ist, osip_event_t *evt);
88 void ist_snd_3456xx(osip_transaction_t *ist, osip_event_t *evt);
89 void ist_rcv_ack(osip_transaction_t *ist, osip_event_t *evt);
90 
91 /***********************/
92 /* FSM ---- > NICT */
93 /***********************/
94 
95 void nict_snd_request(osip_transaction_t *nict, osip_event_t *evt);
96 void osip_nict_timeout_e_event(osip_transaction_t *nict, osip_event_t *evt);
97 void osip_nict_timeout_f_event(osip_transaction_t *nict, osip_event_t *evt);
98 void osip_nict_timeout_k_event(osip_transaction_t *nict, osip_event_t *evt);
99 void nict_rcv_1xx(osip_transaction_t *nict, osip_event_t *evt);
100 void nict_rcv_23456xx(osip_transaction_t *nict, osip_event_t *evt);
101 
102 /* void nict_rcv_23456xx2(osip_transaction_t *nict, osip_event_t *evt); */
103 
104 /************************/
105 /* FSM ---- > NIST */
106 /************************/
107 
108 void nist_rcv_request(osip_transaction_t *nist, osip_event_t *evt);
109 void nist_snd_1xx(osip_transaction_t *nist, osip_event_t *evt);
110 void nist_snd_23456xx(osip_transaction_t *nist, osip_event_t *evt);
111 void osip_nist_timeout_j_event(osip_transaction_t *nist, osip_event_t *evt);
112 
113 /************************/
114 /* Internal Methods */
115 /************************/
116 
117 void __osip_message_callback(int type, osip_transaction_t *, osip_message_t *);
118 void __osip_kill_transaction_callback(int type, osip_transaction_t *);
119 void __osip_transport_error_callback(int type, osip_transaction_t *, int error);
120 
127 int __osip_transaction_set_state(osip_transaction_t *transaction, state_t state);
128 
135 int __osip_transaction_matching_response_osip_to_xict_17_1_3(osip_transaction_t *tr, osip_message_t *resp);
136 
143 int __osip_transaction_matching_request_osip_to_xist_17_2_3(osip_transaction_t *tr, osip_message_t *request);
144 
145 osip_event_t *__osip_transaction_need_timer_x_event(void *xixt, struct timeval *timer, int cond_state, int transactionid, int TIMER_VAL);
146 
147 int __osip_transaction_snd_xxx(osip_transaction_t *ist, osip_message_t *msg);
148 
149 #endif
150 
151 #endif
enum _state_t state_t
type_t
Definition: osip.h:109
oSIP fsm Routines
oSIP SIP Message Accessor Routines
Definition: osip.h:627
Definition: osip_message.h:54
Definition: osip.h:364