1 /************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
6 * This file is part of RSTP library.
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
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.
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
21 **********************************************************************/
23 /* STP PORT instance : 17.18, 17.15 */
30 #define TIMERS_NUMBER 9
31 typedef unsigned int PORT_TIMER_T
;
41 SuperiorDesignatedInfo
,
42 RepeatedDesignatedInfo
,
43 InferiorDesignatedInfo
,
44 InferiorRootAlternateInfo
,
57 typedef struct port_t
{
60 /* per Port state machines */
61 STATE_MACH_T
* info
; /* 17.21 */
62 STATE_MACH_T
* roletrns
; /* 17.23 */
63 STATE_MACH_T
* sttrans
; /* 17.24 */
64 STATE_MACH_T
* topoch
; /* 17.25 */
65 STATE_MACH_T
* migrate
; /* 17.26 */
66 STATE_MACH_T
* transmit
; /* 17.26 */
67 STATE_MACH_T
* p2p
; /* 6.4.3, 6.5.1 */
69 #if 0 /* leu: replaced by brdec state machine */
70 STATE_MACH_T
* edge
; /* */
72 STATE_MACH_T
* pcost
; /* */
73 STATE_MACH_T
* portrec
; /* kd: new in 802.1D */
74 STATE_MACH_T
* brdec
; /* kd: new in 802.1D */
76 STATE_MACH_T
* machines
; /* list of machines */
78 struct stpm_t
* owner
; /* Bridge, that this port belongs to */
81 PORT_TIMER_T edgeDelayWhile
; /* kd: 802.1D page 158 */
82 PORT_TIMER_T fdWhile
; /* 17.15.1 */
83 PORT_TIMER_T helloWhen
; /* 17.15.2 */
84 PORT_TIMER_T mdelayWhile
; /* 17.15.3 */
85 PORT_TIMER_T rbWhile
; /* 17.15.4 */
86 PORT_TIMER_T rcvdInfoWhile
;/* 17.15.5 */
87 PORT_TIMER_T rrWhile
; /* 17.15.6 */
88 PORT_TIMER_T tcWhile
; /* 17.15.7 */
89 PORT_TIMER_T txCount
; /* 17.18.40 */
90 PORT_TIMER_T lnkWhile
;
92 PORT_TIMER_T
* timers
[TIMERS_NUMBER
]; /*list of timers */
94 Bool agreed
; /* 17.18.1 */
96 PRIO_VECTOR_T designPrio
; /* 17.18.2 */
97 TIMEVALUES_T designTimes
; /* 17.18.3 */
99 Bool forward
; /* 17.18.4 */
100 Bool forwarding
; /* 17.18.5 */
102 INFO_IS_T infoIs
; /* 17.18.6 */
103 Bool initPm
; /* 17.18.7 */
104 Bool learn
; /* 17.18.8 */
105 Bool learning
; /* 17.18.9 */
106 Bool mcheck
; /* 17.18.10 */
107 PRIO_VECTOR_T msgPrio
; /* 17.18.11 */
108 TIMEVALUES_T msgTimes
; /* 17.18.12 */
109 Bool newInfo
; /* 17.18.13 */
110 Bool operEdge
; /* 17.18.14 */
112 Bool adminEdge
; /* 17.18.14 */
113 Bool portEnabled
; /* 17.18.15 */
114 PORT_ID port_id
; /* 17.18.16 */
115 PRIO_VECTOR_T portPrio
; /* 17.18.17 */
116 TIMEVALUES_T portTimes
; /* 17.18.18 */
117 Bool proposed
; /* 17.18.19 */
118 Bool proposing
; /* 17.18.20 */
119 Bool rcvdBpdu
; /* 17.18.21 */
120 Bool rcvdMsg
; /* 17.18.22 */ /*izmenim na bool*/
122 Bool rcvdRSTP
; /* 17/18.23 */
123 Bool rcvdSTP
; /* 17.18.24 */
124 Bool rcvdTc
; /* 17.18.25 */
125 Bool rcvdTcAck
; /* 17.18.26 */
126 Bool rcvdTcn
; /* 17.18.27 */
127 Bool reRoot
; /* 17.18.28 */
128 Bool reselect
; /* 17.18.29 */
129 PORT_ROLE_T role
; /* 17.18.30 */
130 Bool selected
; /* 17.18.31 */
131 PORT_ROLE_T selectedRole
; /* 17.18.32 */
132 Bool sendRSTP
; /* 17.18.33 */
133 Bool sync
; /* 17.18.34 */
134 Bool synced
; /* 17.18.35 */
135 Bool tc
; /* 17.18.36 */
136 Bool tcAck
; /* 17.18.37 */
137 Bool tcProp
; /* 17.18.38 */
139 Bool updtInfo
; /* 17.18.41 */
142 /* message information */
143 unsigned char msgBpduVersion
;
144 unsigned char msgBpduType
;
145 unsigned char msgPortRole
;
146 unsigned char msgFlags
;
148 unsigned long adminPCost
; /* may be ADMIN_PORT_PATH_COST_AUTO */
149 unsigned long operPCost
;
150 unsigned long operSpeed
;
151 unsigned long usedSpeed
;
152 int LinkDelay
; /* TBD: LinkDelay may be managed ? */
153 Bool adminEnable
; /* 'has LINK' */
159 Bool operPointToPointMac
;
160 ADMIN_P2P_T adminPointToPointMac
;
163 unsigned long rx_cfg_bpdu_cnt
;
164 unsigned long rx_rstp_bpdu_cnt
;
165 unsigned long rx_tcn_bpdu_cnt
;
167 unsigned long uptime
; /* 14.8.2.1.3.a */
173 unsigned int skip_rx
;
174 unsigned int skip_tx
;
179 Bool
portEnabled(PORT_T
* self
);
180 PORT_T
* STP_port_create (struct stpm_t
* stpm
, int port_index
);
181 void STP_port_delete (PORT_T
* self
);
182 int STP_port_rx_bpdu (PORT_T
* self
, BPDU_T
* bpdu
, size_t len
);
183 void STP_port_init (PORT_T
* self
, struct stpm_t
* stpm
, Bool check_link
);
186 int STP_port_trace_state_machine (PORT_T
* self
, char* mach_name
, int enadis
, int vlan_id
);
187 void STP_port_trace_flags (char* title
, PORT_T
* self
);
190 #endif /* _STP_PORT_H__ */