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/* Port Protocol Migration state machine : 17.26 */
1N/A
1N/A#include "base.h"
1N/A#include "stpm.h"
1N/A
1N/A#define STATES { \
1N/A CHOOSE(INIT), \
1N/A CHOOSE(SEND_RSTP), \
1N/A CHOOSE(SENDING_RSTP), \
1N/A CHOOSE(SEND_STP), \
1N/A CHOOSE(SENDING_STP) \
1N/A}
1N/A
1N/A#define GET_STATE_NAME STP_migrate_get_state_name
1N/A#include "choose.h"
1N/A
1N/A#define MigrateTime 3 /* 17,16.4 */
1N/A
1N/Avoid
1N/ASTP_migrate_enter_state (STATE_MACH_T* this)
1N/A{
1N/A register PORT_T* port = this->owner.port;
1N/A
1N/A switch (this->State) {
1N/A case BEGIN:
1N/A case INIT:
1N/A port->initPm = True;
1N/A port->mcheck = False;
1N/A break;
1N/A case SEND_RSTP:
1N/A port->mdelayWhile = MigrateTime;
1N/A port->mcheck = port->initPm = False;
1N/A port->sendRSTP = True;
1N/A break;
1N/A case SENDING_RSTP:
1N/A port->rcvdRSTP = port->rcvdSTP = False;
1N/A break;
1N/A case SEND_STP:
1N/A port->mdelayWhile = MigrateTime;
1N/A port->sendRSTP = False;
1N/A port->initPm = False;
1N/A break;
1N/A case SENDING_STP:
1N/A port->rcvdRSTP = port->rcvdSTP = False;
1N/A break;
1N/A }
1N/A}
1N/A
1N/ABool
1N/ASTP_migrate_check_conditions (STATE_MACH_T* this)
1N/A{
1N/A register PORT_T* port = this->owner.port;
1N/A
1N/A if ((!port->portEnabled && !port->initPm) || BEGIN == this->State)
1N/A return STP_hop_2_state (this, INIT);
1N/A
1N/A switch (this->State) {
1N/A case INIT:
1N/A if (port->portEnabled) {
1N/A return STP_hop_2_state (this, (port->owner->ForceVersion >= 2) ?
1N/A SEND_RSTP : SEND_STP);
1N/A }
1N/A break;
1N/A case SEND_RSTP:
1N/A return STP_hop_2_state (this, SENDING_RSTP);
1N/A case SENDING_RSTP:
1N/A if (port->mcheck)
1N/A return STP_hop_2_state (this, SEND_RSTP);
1N/A if (port->mdelayWhile &&
1N/A (port->rcvdSTP || port->rcvdRSTP)) {
1N/A return STP_hop_2_state (this, SENDING_RSTP);
1N/A }
1N/A
1N/A if (!port->mdelayWhile && port->rcvdSTP) {
1N/A return STP_hop_2_state (this, SEND_STP);
1N/A }
1N/A
1N/A if (port->owner->ForceVersion < 2) {
1N/A return STP_hop_2_state (this, SEND_STP);
1N/A }
1N/A
1N/A break;
1N/A case SEND_STP:
1N/A return STP_hop_2_state (this, SENDING_STP);
1N/A case SENDING_STP:
1N/A if (port->mcheck)
1N/A return STP_hop_2_state (this, SEND_RSTP);
1N/A if (port->mdelayWhile &&
1N/A (port->rcvdSTP || port->rcvdRSTP))
1N/A return STP_hop_2_state (this, SENDING_STP);
1N/A if (!port->mdelayWhile && port->rcvdRSTP)
1N/A return STP_hop_2_state (this, SEND_RSTP);
1N/A break;
1N/A }
1N/A return False;
1N/A}
1N/A