1N/A/************************************************************************
1N/A * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
1N/A * Copyright (C) 2001-2003 Optical Access
1N/A * Author: Alex Rozin
1N/A *
1N/A * This file is part of RSTP library.
1N/A *
1N/A * RSTP library is free software; you can redistribute it and/or modify it
1N/A * under the terms of the GNU Lesser General Public License as published by the
1N/A * Free Software Foundation; version 2.1
1N/A *
1N/A * RSTP library is distributed in the hope that it will be useful, but
1N/A * WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
1N/A * General Public License for more details.
1N/A *
1N/A * You should have received a copy of the GNU Lesser General Public License
1N/A * along with RSTP library; see the file COPYING. If not, write to the Free
1N/A * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1N/A * 02111-1307, USA.
1N/A **********************************************************************/
1N/A
1N/A/* Generic (abstract state machine) state machine : 17.13, 17.14 */
1N/A
1N/A#ifndef _STP_STATER_H__
1N/A#define _STP_STATER_H__
1N/A
1N/A#define BEGIN 9999 /* distinct from any valid state */
1N/A
1N/A#define STP_DBG 1
1N/A
1N/Atypedef struct state_mach_t {
1N/A struct state_mach_t* next;
1N/A
1N/A char* name; /* for debugging */
1N/A#ifdef STP_DBG
1N/A char debug; /* 0- no dbg, 1 - port, 2 - stpm */
1N/A unsigned int ignoreHop2State;
1N/A#endif
1N/A
1N/A Bool changeState;
1N/A unsigned int State;
1N/A
1N/A void (* concreteEnterState) (struct state_mach_t * );
1N/A Bool (* concreteCheckCondition) (struct state_mach_t * );
1N/A char* (* concreteGetStatName) (int);
1N/A union {
1N/A struct stpm_t* stpm;
1N/A struct port_t* port;
1N/A void * owner;
1N/A } owner;
1N/A
1N/A} STATE_MACH_T;
1N/A
1N/A#define STP_STATE_MACH_IN_LIST(WHAT) \
1N/A { \
1N/A STATE_MACH_T* abstr; \
1N/A \
1N/A abstr = STP_state_mach_create (STP_##WHAT##_enter_state, \
1N/A STP_##WHAT##_check_conditions, \
1N/A STP_##WHAT##_get_state_name, \
1N/A this, \
1N/A #WHAT); \
1N/A abstr->next = this->machines; \
1N/A this->machines = abstr; \
1N/A this->WHAT = abstr; \
1N/A }
1N/A
1N/A
1N/ASTATE_MACH_T *
1N/ASTP_state_mach_create (void (* concreteEnterState) (STATE_MACH_T*),
1N/A Bool (* concreteCheckCondition) (STATE_MACH_T*),
1N/A char * (* concreteGetStatName) (int),
1N/A void* owner, char* name);
1N/A
1N/Avoid
1N/ASTP_state_mach_delete (STATE_MACH_T* this);
1N/A
1N/ABool
1N/ASTP_check_condition (STATE_MACH_T* this);
1N/A
1N/ABool
1N/ASTP_change_state (STATE_MACH_T* this);
1N/A
1N/ABool
1N/ASTP_hop_2_state (STATE_MACH_T* this, unsigned int new_state);
1N/A
1N/A#endif /* _STP_STATER_H__ */
1N/A