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/* Note: this state mashine distinkts from described in P802.1t Clause 18. */
1N/A/* I am ready to discuss it */
1N/A
1N/A#include "base.h"
1N/A#include "stpm.h"
1N/A#include "stp_vectors.h"
1N/A
1N/A#define STATES { \
1N/A CHOOSE(DISABLED), \
1N/A CHOOSE(DETECTED), \
1N/A CHOOSE(DELAYED), \
1N/A CHOOSE(RESOLVED) \
1N/A}
1N/A
1N/A#define GET_STATE_NAME STP_edge_get_state_name
1N/A#include "choose.h"
1N/A
1N/A#define DEFAULT_LINK_DELAY 3
1N/A
1N/Avoid
1N/ASTP_edge_enter_state (STATE_MACH_T *s)
1N/A{
1N/A register PORT_T *port = s->owner.port;
1N/A
1N/A switch (s->State) {
1N/A case BEGIN:
1N/A break;
1N/A case DISABLED:
1N/A port->operEdge = port->adminEdge;
1N/A port->wasInitBpdu = False;
1N/A port->lnkWhile = 0;
1N/A port->portEnabled = False;
1N/A break;
1N/A case DETECTED:
1N/A port->portEnabled = True;
1N/A port->lnkWhile = port->LinkDelay;
1N/A port->operEdge = False;
1N/A break;
1N/A case DELAYED:
1N/A break;
1N/A case RESOLVED:
1N/A if (! port->wasInitBpdu) {
1N/A port->operEdge = port->adminEdge;
1N/A }
1N/A break;
1N/A }
1N/A}
1N/A
1N/ABool
1N/ASTP_edge_check_conditions (STATE_MACH_T *s)
1N/A{
1N/A register PORT_T *port = s->owner.port;
1N/A
1N/A /* If we're disabled, then stay that way. */
1N/A if (!port->adminEnable) {
1N/A if (s->State == DISABLED)
1N/A return False;
1N/A else
1N/A return STP_hop_2_state (s, DISABLED);
1N/A }
1N/A
1N/A switch (s->State) {
1N/A case BEGIN:
1N/A return STP_hop_2_state (s, DISABLED);
1N/A case DISABLED:
1N/A if (port->adminEnable) {
1N/A return STP_hop_2_state (s, DETECTED);
1N/A }
1N/A break;
1N/A case DETECTED:
1N/A return STP_hop_2_state (s, DELAYED);
1N/A case DELAYED:
1N/A if (port->wasInitBpdu) {
1N/A#ifdef STP_DBG
1N/A if (s->debug)
1N/A stp_trace ("port %s 'edge' resolved by BPDU", port->port_name);
1N/A#endif
1N/A return STP_hop_2_state (s, RESOLVED);
1N/A }
1N/A
1N/A if (! port->lnkWhile) {
1N/A#ifdef STP_DBG
1N/A if (s->debug)
1N/A stp_trace ("port %s 'edge' resolved by timer", port->port_name);
1N/A#endif
1N/A return STP_hop_2_state (s, RESOLVED);
1N/A }
1N/A break;
1N/A case RESOLVED:
1N/A break;
1N/A }
1N/A return False;
1N/A}