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 {
00034   struct _transition_t *transitions;
00035 };
00036 
00043 osip_event_t *__osip_event_new (type_t type, int transactionid);
00044 
00045 
00046 /* This is for internal use only.                      */
00047 type_t evt_set_type_incoming_sipmessage (osip_message_t * sip);
00048 type_t evt_set_type_outgoing_sipmessage (osip_message_t * sip);
00049 
00050 
00051 #ifndef MINISIZE
00052 void __ict_load_fsm (void);
00053 void __ist_load_fsm (void);
00054 void __nict_load_fsm (void);
00055 void __nist_load_fsm (void);
00056 
00057 void __ict_unload_fsm (void);
00058 void __ist_unload_fsm (void);
00059 void __nict_unload_fsm (void);
00060 void __nist_unload_fsm (void);
00061 
00062 /* load state machine structure for (UAC || UAS) for (INVITE || REQUEST) */
00063 osip_statemachine_t *__ict_get_fsm (void);
00064 osip_statemachine_t *__ist_get_fsm (void);
00065 
00066 osip_statemachine_t *__nict_get_fsm (void);
00067 osip_statemachine_t *__nist_get_fsm (void);
00068 #endif
00069 
00070 typedef struct _transition_t transition_t;
00071 
00072 struct _transition_t
00073 {
00074   state_t state;
00075   type_t type;
00076   void (*method) (void *, void *);
00077   struct _transition_t *next;
00078   struct _transition_t *parent;
00079 };
00080 
00081 int fsm_callmethod (type_t type, state_t state,
00082                     osip_statemachine_t * statemachine,
00083                     void *sipevent, void *transaction);
00084 
00085 
00087 /* These methods are the "exection method" for the finite */
00088 /* state machine.                                         */
00089 
00090 /************************/
00091 /* FSM  ---- > ICT      */
00092 /************************/
00093 
00094 void ict_snd_invite (osip_transaction_t * ict, osip_event_t * evt);
00095 void osip_ict_timeout_a_event (osip_transaction_t * ict, osip_event_t * evt);
00096 void osip_ict_timeout_b_event (osip_transaction_t * ict, osip_event_t * evt);
00097 void osip_ict_timeout_d_event (osip_transaction_t * ict, osip_event_t * evt);
00098 void ict_rcv_1xx (osip_transaction_t * ict, osip_event_t * evt);
00099 void ict_rcv_2xx (osip_transaction_t * ict, osip_event_t * evt);
00100 osip_message_t *ict_create_ack (osip_transaction_t * ict,
00101                                 osip_message_t * response);
00102 void ict_rcv_3456xx (osip_transaction_t * ict, osip_event_t * evt);
00103 void ict_retransmit_ack (osip_transaction_t * ict, osip_event_t * evt);
00104 
00105 /************************/
00106 /* FSM  ---- > IST      */
00107 /************************/
00108 
00109 void ist_rcv_invite (osip_transaction_t * ist, osip_event_t * evt);
00110 void osip_ist_timeout_g_event (osip_transaction_t * ist, osip_event_t * evt);
00111 void osip_ist_timeout_h_event (osip_transaction_t * ist, osip_event_t * evt);
00112 void osip_ist_timeout_i_event (osip_transaction_t * ist, osip_event_t * evt);
00113 void ist_snd_1xx (osip_transaction_t * ist, osip_event_t * evt);
00114 void ist_snd_2xx (osip_transaction_t * ist, osip_event_t * evt);
00115 void ist_snd_3456xx (osip_transaction_t * ist, osip_event_t * evt);
00116 void ist_rcv_ack (osip_transaction_t * ist, osip_event_t * evt);
00117 
00118 /***********************/
00119 /* FSM  ---- > NICT    */
00120 /***********************/
00121 
00122 void nict_snd_request (osip_transaction_t * nict, osip_event_t * evt);
00123 void osip_nict_timeout_e_event (osip_transaction_t * nict, osip_event_t * evt);
00124 void osip_nict_timeout_f_event (osip_transaction_t * nict, osip_event_t * evt);
00125 void osip_nict_timeout_k_event (osip_transaction_t * nict, osip_event_t * evt);
00126 void nict_rcv_1xx (osip_transaction_t * nict, osip_event_t * evt);
00127 void nict_rcv_23456xx (osip_transaction_t * nict, osip_event_t * evt);
00128 
00129 /* void nict_rcv_23456xx2(osip_transaction_t *nict, osip_event_t *evt); */
00130 
00131 /************************/
00132 /* FSM  ---- > NIST     */
00133 /************************/
00134 
00135 void nist_rcv_request (osip_transaction_t * nist, osip_event_t * evt);
00136 void nist_snd_1xx (osip_transaction_t * nist, osip_event_t * evt);
00137 void nist_snd_23456xx (osip_transaction_t * nist, osip_event_t * evt);
00138 void osip_nist_timeout_j_event (osip_transaction_t * nist, osip_event_t * evt);
00139 
00140 /************************/
00141 /* Internal Methods     */
00142 /************************/
00143 
00144 
00145 void __osip_message_callback (int type, osip_transaction_t *, osip_message_t *);
00146 void __osip_kill_transaction_callback (int type, osip_transaction_t *);
00147 void __osip_transport_error_callback (int type, osip_transaction_t *, int error);
00148 
00155 int __osip_transaction_set_state (osip_transaction_t * transaction, state_t state);
00156 
00163 int
00164 __osip_transaction_matching_response_osip_to_xict_17_1_3 (osip_transaction_t *
00165                                                           tr,
00166                                                           osip_message_t * resp);
00167 
00174 int
00175 __osip_transaction_matching_request_osip_to_xist_17_2_3 (osip_transaction_t *
00176                                                          tr,
00177                                                          osip_message_t * request);
00178 
00179 osip_event_t *
00180 __osip_transaction_need_timer_x_event (void *xixt, struct timeval *timer,
00181                                        int cond_state,
00182                                        int transactionid,
00183                                        int TIMER_VAL);
00184 
00185 int
00186 __osip_transaction_snd_xxx (osip_transaction_t * ist, osip_message_t * msg);
00187 
00188 #endif
00189 
00190 #endif

Generated on Wed Feb 13 01:03:28 2008 for libosip by  doxygen 1.5.4