]>
git.ipfire.org Git - people/ms/rstp.git/blob - rstplib/statmch.h
4b399c77c8a066856bea599f95f575f0ebe0d8d4
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 */
30 typedef struct state_mach_t
{
31 struct state_mach_t
* next
;
33 char* name
; /* for debugging */
35 char debug
; /* 0- no dbg, 1 - port, 2 - stpm */
36 unsigned int ignoreHop2State
;
42 void (* concreteEnterState
) (struct state_mach_t
* );
43 Bool (* concreteCheckCondition
) (struct state_mach_t
* );
44 char* (* concreteGetStatName
) (int);
53 #define STP_STATE_MACH_IN_LIST(WHAT) \
55 STATE_MACH_T* abstr; \
57 abstr = STP_state_mach_create (STP_##WHAT##_enter_state, \
58 STP_##WHAT##_check_conditions, \
59 STP_##WHAT##_get_state_name, \
62 abstr->next = this->machines; \
63 this->machines = abstr; \
69 STP_state_mach_create (void (* concreteEnterState
) (STATE_MACH_T
*),
70 Bool (* concreteCheckCondition
) (STATE_MACH_T
*),
71 char * (* concreteGetStatName
) (int),
72 void* owner
, char* name
);
75 STP_state_mach_delete (STATE_MACH_T
* this);
78 STP_check_condition (STATE_MACH_T
* this);
81 STP_change_state (STATE_MACH_T
* this);
84 STP_hop_2_state (STATE_MACH_T
* this, unsigned int new_state
);
86 #endif /* _STP_STATER_H__ */