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 State Transition state machine : 17.24 */
1N/A
1N/A#include "base.h"
1N/A#include "stpm.h"
1N/A#include "stp_to.h"
1N/A
1N/A#define STATES { \
1N/A CHOOSE(DISCARDING), \
1N/A CHOOSE(LEARNING), \
1N/A CHOOSE(FORWARDING) \
1N/A}
1N/A
1N/A#define GET_STATE_NAME STP_sttrans_get_state_name
1N/A#include "choose.h"
1N/A
1N/A
1N/A#ifdef STRONGLY_SPEC_802_1W
1N/Astatic Bool
1N/AdisableLearning (STATE_MACH_T *this)
1N/A{
1N/A register PORT_T *port = this->owner.port;
1N/A
1N/A return STP_OUT_set_learning (port->port_index, port->owner->vlan_id, False);
1N/A}
1N/A
1N/Astatic Bool
1N/AenableLearning (STATE_MACH_T *this)
1N/A{
1N/A register PORT_T *port = this->owner.port;
1N/A
1N/A return STP_OUT_set_learning (port->port_index, port->owner->vlan_id, True);
1N/A}
1N/A
1N/Astatic Bool
1N/AdisableForwarding (STATE_MACH_T *this)
1N/A{
1N/A register PORT_T *port = this->owner.port;
1N/A
1N/A return STP_OUT_set_forwarding (port->port_index, port->owner->vlan_id, False);
1N/A}
1N/A
1N/Astatic Bool
1N/AenableForwarding (STATE_MACH_T *this)
1N/A{
1N/A register PORT_T *port = this->owner.port;
1N/A
1N/A return STP_OUT_set_forwarding (port->port_index, port->owner->vlan_id, True);
1N/A}
1N/A#endif
1N/A
1N/Avoid
1N/ASTP_sttrans_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 DISCARDING:
1N/A port->learning = False;
1N/A port->forwarding = False;
1N/A#ifdef STRONGLY_SPEC_802_1W
1N/A disableLearning (this);
1N/A disableForwarding (this);
1N/A#else
1N/A STP_OUT_set_port_state (port->port_index, port->owner->vlan_id, UID_PORT_DISCARDING);
1N/A#endif
1N/A break;
1N/A case LEARNING:
1N/A port->learning = True;
1N/A#ifdef STRONGLY_SPEC_802_1W
1N/A enableLearning (this);
1N/A#else
1N/A STP_OUT_set_port_state (port->port_index, port->owner->vlan_id, UID_PORT_LEARNING);
1N/A#endif
1N/A break;
1N/A case FORWARDING:
1N/A port->tc = !port->operEdge;
1N/A port->forwarding = True;
1N/A#ifdef STRONGLY_SPEC_802_1W
1N/A enableForwarding (this);
1N/A#else
1N/A STP_OUT_set_port_state (port->port_index, port->owner->vlan_id, UID_PORT_FORWARDING);
1N/A#endif
1N/A break;
1N/A }
1N/A
1N/A}
1N/A
1N/ABool
1N/ASTP_sttrans_check_conditions (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 return STP_hop_2_state (this, DISCARDING);
1N/A case DISCARDING:
1N/A if (port->learn) {
1N/A return STP_hop_2_state (this, LEARNING);
1N/A }
1N/A break;
1N/A case LEARNING:
1N/A if (port->forward) {
1N/A return STP_hop_2_state (this, FORWARDING);
1N/A }
1N/A if (!port->learn) {
1N/A return STP_hop_2_state (this, DISCARDING);
1N/A }
1N/A break;
1N/A case FORWARDING:
1N/A if (!port->forward) {
1N/A return STP_hop_2_state (this, DISCARDING);
1N/A }
1N/A break;
1N/A }
1N/A
1N/A return False;
1N/A}