libosip 3.6.0

fsm.h

00001 /*
00002   The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
00003   Copyright (C) 2001,2002,2003  Aymeric MOIZARD jack@atosc.org
00004   
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _FSM_H_
00021 #define _FSM_H_
00022 
00023 #include <osipparser2/osip_message.h>
00024 #include <osip2/osip.h>
00025 
00026 #include "xixt.h"
00027 
00028 #ifndef DOXYGEN
00029 
00030 typedef struct osip_statemachine osip_statemachine_t;
00031 
00032 struct osip_statemachine {
00033         struct _transition_t *transitions;
00034 };
00035 
00042 osip_event_t *__osip_event_new(type_t type, int transactionid);
00043 
00044 
00045 /* This is for internal use only.                      */
00046 type_t evt_set_type_incoming_sipmessage(osip_message_t * sip);
00047 type_t evt_set_type_outgoing_sipmessage(osip_message_t * sip);
00048 
00049 
00050 #ifndef MINISIZE
00051 void __ict_load_fsm(void);
00052 void __ist_load_fsm(void);
00053 void __nict_load_fsm(void);
00054 void __nist_load_fsm(void);
00055 
00056 void __ict_unload_fsm(void);
00057 void __ist_unload_fsm(void);
00058 void __nict_unload_fsm(void);
00059 void __nist_unload_fsm(void);
00060 
00061 /* load state machine structure for (UAC || UAS) for (INVITE || REQUEST) */
00062 osip_statemachine_t *__ict_get_fsm(void);
00063 osip_statemachine_t *__ist_get_fsm(void);
00064 
00065 osip_statemachine_t *__nict_get_fsm(void);
00066 osip_statemachine_t *__nist_get_fsm(void);
00067 #endif
00068 
00069 typedef struct _transition_t transition_t;
00070 
00071 struct _transition_t {
00072         state_t state;
00073         type_t type;
00074         void (*method) (void *, void *);
00075         struct _transition_t *next;
00076         struct _transition_t *parent;
00077 };
00078 
00079 int fsm_callmethod(type_t type, state_t state,
00080                                    osip_statemachine_t * statemachine,
00081                                    void *sipevent, void *transaction);
00082 
00083 
00085 /* These methods are the "exection method" for the finite */
00086 /* state machine.                                         */
00087 
00088 /************************/
00089 /* FSM  ---- > ICT      */
00090 /************************/
00091 
00092 void ict_snd_invite(osip_transaction_t * ict, osip_event_t * evt);
00093 void osip_ict_timeout_a_event(osip_transaction_t * ict, osip_event_t * evt);
00094 void osip_ict_timeout_b_event(osip_transaction_t * ict, osip_event_t * evt);
00095 void osip_ict_timeout_d_event(osip_transaction_t * ict, osip_event_t * evt);
00096 void ict_rcv_1xx(osip_transaction_t * ict, osip_event_t * evt);
00097 void ict_rcv_2xx(osip_transaction_t * ict, osip_event_t * evt);
00098 osip_message_t *ict_create_ack(osip_transaction_t * ict,
00099                                                            osip_message_t * response);
00100 void ict_rcv_3456xx(osip_transaction_t * ict, osip_event_t * evt);
00101 void ict_retransmit_ack(osip_transaction_t * ict, osip_event_t * evt);
00102 
00103 /************************/
00104 /* FSM  ---- > IST      */
00105 /************************/
00106 
00107 void ist_rcv_invite(osip_transaction_t * ist, osip_event_t * evt);
00108 void osip_ist_timeout_g_event(osip_transaction_t * ist, osip_event_t * evt);
00109 void osip_ist_timeout_h_event(osip_transaction_t * ist, osip_event_t * evt);
00110 void osip_ist_timeout_i_event(osip_transaction_t * ist, osip_event_t * evt);
00111 void ist_snd_1xx(osip_transaction_t * ist, osip_event_t * evt);
00112 void ist_snd_2xx(osip_transaction_t * ist, osip_event_t * evt);
00113 void ist_snd_3456xx(osip_transaction_t * ist, osip_event_t * evt);
00114 void ist_rcv_ack(osip_transaction_t * ist, osip_event_t * evt);
00115 
00116 /***********************/
00117 /* FSM  ---- > NICT    */
00118 /***********************/
00119 
00120 void nict_snd_request(osip_transaction_t * nict, osip_event_t * evt);
00121 void osip_nict_timeout_e_event(osip_transaction_t * nict, osip_event_t * evt);
00122 void osip_nict_timeout_f_event(osip_transaction_t * nict, osip_event_t * evt);
00123 void osip_nict_timeout_k_event(osip_transaction_t * nict, osip_event_t * evt);
00124 void nict_rcv_1xx(osip_transaction_t * nict, osip_event_t * evt);
00125 void nict_rcv_23456xx(osip_transaction_t * nict, osip_event_t * evt);
00126 
00127 /* void nict_rcv_23456xx2(osip_transaction_t *nict, osip_event_t *evt); */
00128 
00129 /************************/
00130 /* FSM  ---- > NIST     */
00131 /************************/
00132 
00133 void nist_rcv_request(osip_transaction_t * nist, osip_event_t * evt);
00134 void nist_snd_1xx(osip_transaction_t * nist, osip_event_t * evt);
00135 void nist_snd_23456xx(osip_transaction_t * nist, osip_event_t * evt);
00136 void osip_nist_timeout_j_event(osip_transaction_t * nist, osip_event_t * evt);
00137 
00138 /************************/
00139 /* Internal Methods     */
00140 /************************/
00141 
00142 
00143 void __osip_message_callback(int type, osip_transaction_t *, osip_message_t *);
00144 void __osip_kill_transaction_callback(int type, osip_transaction_t *);
00145 void __osip_transport_error_callback(int type, osip_transaction_t *, int error);
00146 
00153 int __osip_transaction_set_state(osip_transaction_t * transaction, state_t state);
00154 
00161 int
00162 __osip_transaction_matching_response_osip_to_xict_17_1_3(osip_transaction_t *
00163                                                                                                                  tr,
00164                                                                                                                  osip_message_t * resp);
00165 
00172 int
00173 __osip_transaction_matching_request_osip_to_xist_17_2_3(osip_transaction_t *
00174                                                                                                                 tr,
00175                                                                                                                 osip_message_t * request);
00176 
00177 osip_event_t *__osip_transaction_need_timer_x_event(void *xixt,
00178                                                                                                         struct timeval *timer,
00179                                                                                                         int cond_state,
00180                                                                                                         int transactionid,
00181                                                                                                         int TIMER_VAL);
00182 
00183 int __osip_transaction_snd_xxx(osip_transaction_t * ist, osip_message_t * msg);
00184 
00185 #endif
00186 
00187 #endif