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
22 #include <osip2/internal.h>
23 #include <osip2/osip_fifo.h>
24 #include <osip2/osip.h>
27 static transition_t *fsm_findmethod (type_t type, state_t state,
28 osip_statemachine_t * statemachine);
30 /* find the transition for state and type in statemachine */
31 /* return NULL; if transition is not found. */
33 fsm_findmethod (type_t type, state_t state,
34 osip_statemachine_t * statemachine)
39 while (!osip_list_eol (statemachine->transitions, pos))
41 transition_t *transition;
44 (transition_t *) osip_list_get (statemachine->transitions, pos);
45 if (transition->type == type && transition->state == state)
53 /* call the right execution method. */
54 /* return -1 when event must be discarded */
56 fsm_callmethod (type_t type, state_t state,
57 osip_statemachine_t * statemachine, void *sipevent,
60 transition_t *transition;
62 transition = fsm_findmethod (type, state, statemachine);
63 if (transition == NULL)
65 /* No transition found for this event */
66 return -1; /* error */
68 transition->method (transaction, sipevent);