1 /************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
6 * This file is part of RSTP library.
8 * RSTP library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; version 2.1
12 * RSTP library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15 * General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with RSTP library; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 **********************************************************************/
23 /* Generic (abstract state machine) state machine : 17.13, 17.14 */
25 #ifndef _STP_STATER_H__
26 #define _STP_STATER_H__
28 #define BEGIN 9999 /* distinct from any valid state */
32 typedef struct state_mach_t
{
33 struct state_mach_t
* next
;
35 char* name
; /* for debugging */
37 char debug
; /* 0- no dbg, 1 - port, 2 - stpm */
38 unsigned int ignoreHop2State
;
44 void (* concreteEnterState
) (struct state_mach_t
* );
45 Bool (* concreteCheckCondition
) (struct state_mach_t
* );
46 char* (* concreteGetStatName
) (int);
55 #define STP_STATE_MACH_IN_LIST(WHAT) \
57 STATE_MACH_T* abstr; \
59 abstr = STP_state_mach_create (STP_##WHAT##_enter_state, \
60 STP_##WHAT##_check_conditions, \
61 STP_##WHAT##_get_state_name, \
64 abstr->next = this->machines; \
65 this->machines = abstr; \
71 STP_state_mach_create (void (* concreteEnterState
) (STATE_MACH_T
*),
72 Bool (* concreteCheckCondition
) (STATE_MACH_T
*),
73 char * (* concreteGetStatName
) (int),
74 void* owner
, char* name
);
77 STP_state_mach_delete (STATE_MACH_T
* this);
80 STP_check_condition (STATE_MACH_T
* this);
83 STP_change_state (STATE_MACH_T
* this);
86 STP_hop_2_state (STATE_MACH_T
* this, unsigned int new_state
);
88 #endif /* _STP_STATER_H__ */