4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai/************************************************************************
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * Copyright (C) 2001-2003 Optical Access
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * Author: Alex Rozin
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * This file is part of RSTP library.
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * RSTP library is free software; you can redistribute it and/or modify it
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * under the terms of the GNU Lesser General Public License as published by the
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * Free Software Foundation; version 2.1
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * RSTP library is distributed in the hope that it will be useful, but
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * WITHOUT ANY WARRANTY; without even the implied warranty of
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * General Public License for more details.
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * You should have received a copy of the GNU Lesser General Public License
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * along with RSTP library; see the file COPYING. If not, write to the Free
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * 02111-1307, USA.
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai **********************************************************************/
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai/* Generic (abstract) state machine : 17.13, 17.14 */
4eaa471005973e11a6110b69fe990530b3b95a38Rishi SrivatsavaiSTP_state_mach_create (void (*concreteEnterState) (STATE_MACH_T*),
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai Bool (*concreteCheckCondition) (STATE_MACH_T*),
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai STP_MALLOC(this, STATE_MACH_T, "state machine");
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai this->concreteEnterState = concreteEnterState;
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai this->concreteCheckCondition = concreteCheckCondition;
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai this->concreteGetStatName = concreteGetStatName;
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai bret = (*(this->concreteCheckCondition)) (this);
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai for (number_of_loops = 0; ; number_of_loops++) {
4eaa471005973e11a6110b69fe990530b3b95a38Rishi SrivatsavaiSTP_hop_2_state (STATE_MACH_T* this, unsigned int new_state)
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai case 0: break;
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai if (new_state == this->State || new_state == this->ignoreHop2State) break;
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai *this->owner.port->owner->name ? this->owner.port->owner->name : "Glbl",
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai (*(this->concreteGetStatName)) (this->State),
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai (*(this->concreteGetStatName)) (new_state));
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai *this->owner.stpm->name ? this->owner.stpm->name : "Glbl",
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai (*(this->concreteGetStatName)) (this->State),