]> git.ipfire.org Git - people/ms/rstp.git/blame - rstplib/edge.c
remove ifdef'd code
[people/ms/rstp.git] / rstplib / edge.c
CommitLineData
ad02a0eb
SH
1/************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
4 * Author: Alex Rozin
5 *
6 * This file is part of RSTP library.
7 *
8 * RSTP library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; version 2.1
11 *
12 * RSTP library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with RSTP library; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 **********************************************************************/
22
23/* Note: this state mashine distinkts from described in P802.1t Clause 18. */
24/* I am ready to discuss it */
25
26#include "base.h"
27#include "stpm.h"
28
29#define STATES { \
30 CHOOSE(DISABLED), \
31 CHOOSE(DETECTED), \
32 CHOOSE(DELEAYED), \
33 CHOOSE(RESOLVED), \
34}
35
36#define GET_STATE_NAME STP_edge_get_state_name
37#include "choose.h"
38
39#define DEFAULT_LINK_DELAY 3
40
41void
42STP_edge_enter_state (STATE_MACH_T *s)
43{
44 register PORT_T *port = s->owner.port;
45
46 switch (s->State) {
47 case BEGIN:
48 break;
49 case DISABLED:
50 port->operEdge = port->adminEdge;
51 port->wasInitBpdu = False;
52 port->lnkWhile = 0;
53 port->portEnabled = False;
54 break;
55 case DETECTED:
56 port->portEnabled = True;
57 port->lnkWhile = port->LinkDelay;
58 port->operEdge = False;
59 break;
60 case DELEAYED:
61 break;
62 case RESOLVED:
63 if (! port->wasInitBpdu) {
64 port->operEdge = port->adminEdge;
65 }
66 break;
67 }
68}
69
70Bool
71STP_edge_check_conditions (STATE_MACH_T *s)
72{
73 register PORT_T *port = s->owner.port;
74
75 switch (s->State) {
76 case BEGIN:
77 return STP_hop_2_state (s, DISABLED);
78 case DISABLED:
79 if (port->adminEnable) {
80 return STP_hop_2_state (s, DETECTED);
81 }
82 break;
83 case DETECTED:
84 return STP_hop_2_state (s, DELEAYED);
85 case DELEAYED:
86 if (port->wasInitBpdu) {
87#ifdef STP_DBG
88 if (s->debug)
89 stp_trace ("port %s 'edge' resolved by BPDU", port->port_name);
90#endif
91 return STP_hop_2_state (s, RESOLVED);
92 }
93
94 if (! port->lnkWhile) {
95#ifdef STP_DBG
96 if (s->debug)
97 stp_trace ("port %s 'edge' resolved by timer", port->port_name);
98#endif
99 return STP_hop_2_state (s, RESOLVED);
100 }
101
102 if (! port->adminEnable) {
103 return STP_hop_2_state (s, DISABLED);
104 }
105 break;
106 case RESOLVED:
107 if (! port->adminEnable) {
108 return STP_hop_2_state (s, DISABLED);
109 }
110 break;
111 }
112 return False;
113}
114