rstp.h
Go to the documentation of this file.
1 /**
2  * @file rstp.h
3  * @brief RSTP (Rapid Spanning Tree Protocol)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSTP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _RSTP_H
32 #define _RSTP_H
33 
34 //Forward declaration of RstpBridgeContext structure
35 struct _RstpBridgeContext;
36 #define RstpBridgeContext struct _RstpBridgeContext
37 
38 //Forward declaration of RstpBridgePort structure
39 struct _RstpBridgePort;
40 #define RstpBridgePort struct _RstpBridgePort
41 
42 //Dependencies
43 #include "stp/stp_common.h"
44 #include "rstp/rstp_pti.h"
45 #include "rstp/rstp_prx.h"
46 #include "rstp/rstp_ppm.h"
47 #include "rstp/rstp_bdm.h"
48 #include "rstp/rstp_ptx.h"
49 #include "rstp/rstp_pim.h"
50 #include "rstp/rstp_prs.h"
51 #include "rstp/rstp_prt.h"
52 #include "rstp/rstp_pst.h"
53 #include "rstp/rstp_tcm.h"
54 #include "rstp/rstp_bpdu.h"
55 
56 //RSTP bridge support
57 #ifndef RSTP_SUPPORT
58  #define RSTP_SUPPORT DISABLED
59 #elif (RSTP_SUPPORT != ENABLED && RSTP_SUPPORT != DISABLED)
60  #error RSTP_SUPPORT parameter is not valid
61 #endif
62 
63 //RSTP tick interval (in milliseconds)
64 #ifndef RSTP_TICK_INTERVAL
65  #define RSTP_TICK_INTERVAL 1000
66 #elif (RSTP_TICK_INTERVAL < 10)
67  #error RSTP_TICK_INTERVAL parameter is not valid
68 #endif
69 
70 //Default Bridge Priority Value
71 #ifndef RSTP_DEFAULT_BRIDGE_PRIORITY
72  #define RSTP_DEFAULT_BRIDGE_PRIORITY 32768
73 #elif (RSTP_DEFAULT_BRIDGE_PRIORITY < 0 || RSTP_DEFAULT_BRIDGE_PRIORITY > 61440)
74  #error RSTP_DEFAULT_BRIDGE_PRIORITY parameter is not valid
75 #endif
76 
77 //Default Port Priority Value
78 #ifndef RSTP_DEFAULT_PORT_PRIORITY
79  #define RSTP_DEFAULT_PORT_PRIORITY 128
80 #elif (RSTP_DEFAULT_PORT_PRIORITY < 0 || RSTP_DEFAULT_PORT_PRIORITY > 240)
81  #error RSTP_DEFAULT_PORT_PRIORITY parameter is not valid
82 #endif
83 
84 //Default Migrate Time value
85 #ifndef RSTP_DEFAULT_MIGRATE_TIME
86  #define RSTP_DEFAULT_MIGRATE_TIME 3
87 #elif (RSTP_DEFAULT_MIGRATE_TIME < 0)
88  #error RSTP_DEFAULT_MIGRATE_TIME parameter is not valid
89 #endif
90 
91 //Minimum Bridge Max Age value
92 #ifndef RSTP_MIN_BRIDGE_MAX_AGE
93  #define RSTP_MIN_BRIDGE_MAX_AGE 6
94 #elif (RSTP_MIN_BRIDGE_MAX_AGE < 0)
95  #error RSTP_MIN_BRIDGE_MAX_AGE parameter is not valid
96 #endif
97 
98 //Default Bridge Max Age value
99 #ifndef RSTP_DEFAULT_BRIDGE_MAX_AGE
100  #define RSTP_DEFAULT_BRIDGE_MAX_AGE 20
101 #elif (RSTP_DEFAULT_BRIDGE_MAX_AGE < RSTP_MIN_BRIDGE_MAX_AGE)
102  #error RSTP_DEFAULT_BRIDGE_MAX_AGE parameter is not valid
103 #endif
104 
105 //Maximum Bridge Max Age value
106 #ifndef RSTP_MAX_BRIDGE_MAX_AGE
107  #define RSTP_MAX_BRIDGE_MAX_AGE 40
108 #elif (RSTP_MAX_BRIDGE_MAX_AGE < RSTP_DEFAULT_BRIDGE_MAX_AGE)
109  #error RSTP_MAX_BRIDGE_MAX_AGE parameter is not valid
110 #endif
111 
112 //Minimum Bridge Hello Time value
113 #ifndef RSTP_MIN_BRIDGE_HELLO_TIME
114  #define RSTP_MIN_BRIDGE_HELLO_TIME 1
115 #elif (RSTP_MIN_BRIDGE_HELLO_TIME < 0)
116  #error RSTP_MIN_BRIDGE_HELLO_TIME parameter is not valid
117 #endif
118 
119 //Default Bridge Hello Time value
120 #ifndef RSTP_DEFAULT_BRIDGE_HELLO_TIME
121  #define RSTP_DEFAULT_BRIDGE_HELLO_TIME 2
122 #elif (RSTP_DEFAULT_BRIDGE_HELLO_TIME < RSTP_MIN_BRIDGE_HELLO_TIME)
123  #error RSTP_DEFAULT_BRIDGE_HELLO_TIME parameter is not valid
124 #endif
125 
126 //Maximum Bridge Hello Time value
127 #ifndef RSTP_MAX_BRIDGE_HELLO_TIME
128  #define RSTP_MAX_BRIDGE_HELLO_TIME 10
129 #elif (RSTP_MAX_BRIDGE_HELLO_TIME < RSTP_DEFAULT_BRIDGE_HELLO_TIME)
130  #error RSTP_MAX_BRIDGE_HELLO_TIME parameter is not valid
131 #endif
132 
133 //Minimum Bridge Forward Delay value
134 #ifndef RSTP_MIN_BRIDGE_FORWARD_DELAY
135  #define RSTP_MIN_BRIDGE_FORWARD_DELAY 4
136 #elif (RSTP_MIN_BRIDGE_FORWARD_DELAY < 0)
137  #error RSTP_MIN_BRIDGE_FORWARD_DELAY parameter is not valid
138 #endif
139 
140 //Default Bridge Forward Delay value
141 #ifndef RSTP_DEFAULT_BRIDGE_FORWARD_DELAY
142  #define RSTP_DEFAULT_BRIDGE_FORWARD_DELAY 15
143 #elif (RSTP_DEFAULT_BRIDGE_FORWARD_DELAY < RSTP_MIN_BRIDGE_FORWARD_DELAY)
144  #error RSTP_DEFAULT_BRIDGE_FORWARD_DELAY parameter is not valid
145 #endif
146 
147 //Maximum Bridge Forward Delay value
148 #ifndef RSTP_MAX_BRIDGE_FORWARD_DELAY
149  #define RSTP_MAX_BRIDGE_FORWARD_DELAY 30
150 #elif (RSTP_MAX_BRIDGE_FORWARD_DELAY < RSTP_DEFAULT_BRIDGE_FORWARD_DELAY)
151  #error RSTP_MAX_BRIDGE_FORWARD_DELAY parameter is not valid
152 #endif
153 
154 //Minimum Transmit Hold Count value
155 #ifndef RSTP_MIN_TRANSMIT_HOLD_COUNT
156  #define RSTP_MIN_TRANSMIT_HOLD_COUNT 1
157 #elif (RSTP_MIN_TRANSMIT_HOLD_COUNT < 0)
158  #error RSTP_MIN_TRANSMIT_HOLD_COUNT parameter is not valid
159 #endif
160 
161 //Default Transmit Hold Count value
162 #ifndef RSTP_DEFAULT_TRANSMIT_HOLD_COUNT
163  #define RSTP_DEFAULT_TRANSMIT_HOLD_COUNT 6
164 #elif (RSTP_DEFAULT_TRANSMIT_HOLD_COUNT < RSTP_MIN_TRANSMIT_HOLD_COUNT)
165  #error RSTP_DEFAULT_TRANSMIT_HOLD_COUNT parameter is not valid
166 #endif
167 
168 //Maximum Transmit Hold Count value
169 #ifndef RSTP_MAX_TRANSMIT_HOLD_COUNT
170  #define RSTP_MAX_TRANSMIT_HOLD_COUNT 10
171 #elif (RSTP_MAX_TRANSMIT_HOLD_COUNT < RSTP_DEFAULT_TRANSMIT_HOLD_COUNT)
172  #error RSTP_MAX_TRANSMIT_HOLD_COUNT parameter is not valid
173 #endif
174 
175 //Minimum Ageing Time value
176 #ifndef RSTP_MIN_AGEING_TIME
177  #define RSTP_MIN_AGEING_TIME 10
178 #elif (RSTP_MIN_AGEING_TIME < 0)
179  #error RSTP_MIN_AGEING_TIME parameter is not valid
180 #endif
181 
182 //Default Ageing Time value
183 #ifndef RSTP_DEFAULT_AGEING_TIME
184  #define RSTP_DEFAULT_AGEING_TIME 300
185 #elif (RSTP_DEFAULT_AGEING_TIME < RSTP_MIN_AGEING_TIME)
186  #error RSTP_DEFAULT_AGEING_TIME parameter is not valid
187 #endif
188 
189 //Maximum Ageing Time value
190 #ifndef RSTP_MAX_AGEING_TIME
191  #define RSTP_MAX_AGEING_TIME 1000000
192 #elif (RSTP_MAX_AGEING_TIME < RSTP_DEFAULT_AGEING_TIME)
193  #error RSTP_MAX_AGEING_TIME parameter is not valid
194 #endif
195 
196 //Minimum Port Path Cost value
197 #ifndef RSTP_MIN_PORT_PATH_COST
198  #define RSTP_MIN_PORT_PATH_COST 1
199 #elif (RSTP_MIN_PORT_PATH_COST < 0)
200  #error RSTP_MIN_PORT_PATH_COST parameter is not valid
201 #endif
202 
203 //Default Port Path Cost value
204 #ifndef RSTP_DEFAULT_PORT_PATH_COST
205  #define RSTP_DEFAULT_PORT_PATH_COST 200000
206 #elif (RSTP_DEFAULT_PORT_PATH_COST < RSTP_MIN_PORT_PATH_COST)
207  #error RSTP_DEFAULT_PORT_PATH_COST parameter is not valid
208 #endif
209 
210 //Maximum Port Path Cost value
211 #ifndef RSTP_MAX_PORT_PATH_COST
212  #define RSTP_MAX_PORT_PATH_COST 200000000
213 #elif (RSTP_MAX_PORT_PATH_COST < RSTP_DEFAULT_PORT_PATH_COST)
214  #error RSTP_MAX_PORT_PATH_COST parameter is not valid
215 #endif
216 
217 //C++ guard
218 #ifdef __cplusplus
219 extern "C" {
220 #endif
221 
222 
223 /**
224  * @brief State of the received Spanning Tree information
225  **/
226 
227 typedef enum
228 {
235 
236 
237 /**
238  * @brief Origin/state of the port's Spanning Tree information
239  **/
240 
241 typedef enum
242 {
248 
249 
250 /**
251  * @brief Administrative state of the point-to-point status
252  **/
253 
254 typedef enum
255 {
260 
261 
262 /**
263  * @brief RSTP timer parameter values
264  **/
265 
266 typedef struct
267 {
272 } RstpTimes;
273 
274 
275 /**
276  * @brief Spanning Tree priority vector
277  **/
278 
279 typedef struct
280 {
282  uint32_t rootPathCost;
285  uint16_t bridgePortId;
286 } RstpPriority;
287 
288 
289 /**
290  * @brief RSTP bridge parameters
291  **/
292 
293 typedef struct
294 {
295  uint_t ageingTime; ///<Ageing Time parameter for the bridge (17.13.2)
296  uint_t forceProtocolVersion; ///<Force Protocol Version parameter for the bridge (17.13.4)
297  uint_t bridgeForwardDelay; ///<Delay used by STP bridges to transition Root and Designated ports to Forwarding (17.13.5)
298  uint_t bridgeHelloTime; ///<Interval between periodic transmissions of Configuration messages by Designated ports (17.13.6)
299  uint_t bridgeMaxAge; ///<Maximum age of the information transmitted by the bridge when it is the Root bridge (17.13.8)
300  uint_t migrateTime; ///<Initial value of the mdelayWhile and edgeDelayWhile timers (17.13.9)
301  uint_t transmitHoldCount; ///<Value used to limit the maximum transmission rate (17.13.12)
303 
304 
305 /**
306  * @brief Bridge port parameters
307  **/
308 
309 typedef struct
310 {
311  bool_t adminPortState; ///<Administrative bridge port state (14.8.2.2)
312  uint32_t adminPathCost; ///<Contribution of this port to the path cost
313  RstpAdminPointToPointMac adminPointToPointMac; ///<Administrative state of the point-to-point status (6.4.3)
314  bool_t adminEdgePort; ///<AdminEdgePort parameter for the port (17.13.1)
315  bool_t autoEdgePort; ///<AutoEdgePort parameter for the port (17.13.3)
317 
318 
319 /**
320  * @brief Bridge port
321  **/
322 
324 {
325  RstpBridgeContext *context; ///<RSTP bridge context
326 
327  uint8_t portIndex; ///<Port index
328  MacAddr macAddr; ///<MAC address of the port
329 
330  RstpPortParams params; ///<Port parameters
331 
332  uint32_t linkSpeed; ///<Link speed
333  NicDuplexMode duplexMode; ///<Duplex mode
334  bool_t macOperState; ///<The MAC entity is in a functioning state (6.4.2)
335  bool_t operPointToPointMac; ///<The MAC is connected to a point-to-point LAN (6.4.3)
336  uint_t forwardTransitions; ///<Number of times the port has transitioned to Forwarding state
337 
338  RstpPtiState ptiState; ///<Port Timers state machine (17.22)
339  RstpPrxState prxState; ///<Port Receive state machine (17.23)
340  RstpPpmState ppmState; ///<Port Protocol Migration state machine (17.24)
341  RstpBdmState bdmState; ///<Bridge Detection state machine (17.25)
342  RstpPtxState ptxState; ///<Port Transmit state machine (17.26)
343  RstpPimState pimState; ///<Port Information state machine (17.27)
344  RstpPrtState prtState; ///<Port Role Transition state machine (17.29)
345  RstpPstState pstState; ///<Port State Transition state machine (17.30)
346  RstpTcmState tcmState; ///<Topology Change state machine (17.31)
347 
348  uint_t edgeDelayWhile; ///<Edge Delay timer (17.17.1)
349  uint_t fdWhile; ///<Forward Delay timer (17.17.2)
350  uint_t helloWhen; ///<Hello timer (17.17.3)
351  uint_t mdelayWhile; ///<Migration Delay timer (17.17.4)
352  uint_t rbWhile; ///<Recent Backup timer (17.17.5)
353  uint_t rcvdInfoWhile; ///<Received Info timer (17.17.6)
354  uint_t rrWhile; ///<Recent Root timer (17.17.7)
355  uint_t tcWhile; ///<Topology Change timer (17.17.8)
356 
357  bool_t agree; ///<Boolean (17.19.2)
358  bool_t agreed; ///<Boolean (17.19.3)
359  RstpPriority designatedPriority; ///<First four components of the designated priority vector value (17.19.4)
360  RstpTimes designatedTimes; ///<Set of timer parameter values used to update Port Times (17.19.5)
361  bool_t disputed; ///<Boolean (17.19.6)
362  bool_t fdbFlush; ///<Instruct the filtering database to remove all entries for this port (17.19.7)
363  bool_t forward; ///<Boolean (17.19.8)
364  bool_t forwarding; ///<Boolean (17.19.9)
365  RstpInfoIs infoIs; ///<Origin/state of the port's Spanning Tree information held for the port (17.19.10)
366  bool_t learn; ///<Boolean (17.19.11)
367  bool_t learning; ///<Boolean (17.19.12)
368  bool_t mcheck; ///<Force PPM state machine to transmit RST BPDUs for a MigrateTime period (17.19.13)
369  RstpPriority msgPriority; ///<First four components of the message priority vector (17.19.14)
370  RstpTimes msgTimes; ///<Set of timer parameter values conveyed in a received BPDU (17.19.15)
371  bool_t newInfo; ///<Set if a BPDU is to be transmitted (17.19.16)
372  bool_t operEdge; ///<Boolean (17.19.17)
373  bool_t portEnabled; ///<Set if the port can be used transmit and receive frames (17.19.18)
374  uint16_t portId; ///<Port identifier (17.19.19)
375  uint32_t portPathCost; ///<Port's contribution to the root path cost (17.19.20)
376  RstpPriority portPriority; ///<First four components of the port priority vector value (17.19.21)
377  RstpTimes portTimes; ///<Set of timer parameter values used in transmitted BPDUs (17.19.22)
378  bool_t proposed; ///<Boolean (17.19.23)
379  bool_t proposing; ///<Boolean (17.19.24)
380  bool_t rcvdBpdu; ///<A valid Configuration, TCN or RST BPDU is received on the port (17.19.25)
381  RstpRcvdInfo rcvdInfo; ///<State of the received Spanning Tree information (17.19.26)
382  bool_t rcvdMsg; ///<Boolean (17.19.27)
383  bool_t rcvdRstp; ///<Boolean (17.19.28)
384  bool_t rcvdStp; ///<Boolean (17.19.29)
385  bool_t rcvdTc; ///<Boolean (17.19.30)
386  bool_t rcvdTcAck; ///<Boolean (17.19.31)
387  bool_t rcvdTcn; ///<Boolean (17.19.32)
388  bool_t reRoot; ///<Boolean (17.19.33)
389  bool_t reselect; ///<Boolean (17.19.34)
390  StpPortRole role; ///<Assigned Port Role (17.19.35)
391  bool_t selected; ///<Boolean (17.19.36)
392  StpPortRole selectedRole; ///<Newly computed role for the port (17.19.37)
393  bool_t sendRstp; ///<Set if an RSTP BPDU is to be transmitted (17.19.38)
394  bool_t sync; ///<Boolean (17.19.39)
395  bool_t synced; ///<Boolean (17.19.40)
396  bool_t tcAck; ///<Set if a Configuration message with a TC ACK flag is to be transmitted (17.19.41)
397  bool_t tcProp; ///<Set if a topology change should be propagated through this port (17.19.42)
398  bool_t tick; ///<Tick signal (17.19.43)
399  uint_t txCount; ///<Counter incremented on every BPDU transmission (17.19.44)
400  bool_t updtInfo; ///<Set to tell that portPriority and portTimes should be updated (17.19.45)
401 };
402 
403 
404 /**
405  * @brief RSTP bridge settings
406  **/
407 
408 typedef struct
409 {
410  NetInterface *interface; ///<Underlying network interface
411  uint_t numPorts; ///<Number of ports
412  RstpBridgePort *ports; ///<Bridge's ports
414 
415 
416 /**
417  * @brief RSTP bridge context
418  **/
419 
421 {
422  NetInterface *interface; ///<Underlying network interface
423  uint_t numPorts; ///<Number of ports
424  RstpBridgePort *ports; ///<Bridge's ports
425  bool_t running; ///<RSTP bridge operation state
426 
427  RstpBridgeParams params; ///<RSTP bridge parameters (17.13)
428 
429  StpBridgeId bridgeId; ///<Unique identifier assigned to the bridge (17.18.2)
430  RstpPriority bridgePriority; ///<Bridge priority vector (17.18.3)
431  RstpTimes bridgeTimes; ///<Bridge's timer parameter values (17.18.4)
432  uint16_t rootPortId; ///<Port Identifier of the Root port (17.18.5)
433  RstpPriority rootPriority; ///<First four components of the bridge's root priority vector (17.18.6)
434  RstpTimes rootTimes; ///<Bridge's operational timer parameter values (7.18.7)
435 
436  RstpPrsState prsState; ///<Port Role Selection state machine (17.28)
437 
438  uint_t ageingTime; ///<Ageing time for filtering database entries (17.19.1)
439  uint_t rapidAgeingWhile; ///<Rapid ageing timer
440 
441  uint_t timeSinceTopologyChange; ///<Time since the last topology change
442  uint_t topologyChangeCount; ///<Number of topology changes
443  RstpBpdu bpdu; ///<Received BPDU
444  bool_t busy; ///<Busy flag
445 };
446 
447 
448 //RSTP related functions
451 
454 
462 
474 error_t rstpGetRootPort(RstpBridgeContext *context, uint16_t *value);
479 
481  uint_t *value);
482 
483 error_t rstpSetPortNum(RstpBridgeContext *context, uint_t portIndex,
484  uint16_t value);
485 
486 error_t rstpSetPortAddr(RstpBridgeContext *context, uint_t portIndex,
487  const MacAddr *value);
488 
490  uint8_t value);
491 
493  bool_t value);
494 
496  uint32_t value);
497 
500 
502  bool_t value);
503 
505  bool_t value);
506 
508  bool_t value);
509 
510 error_t rstpGetPortNum(RstpBridgeContext *context, uint_t portIndex,
511  uint16_t *value);
512 
513 error_t rstpGetPortAddr(RstpBridgeContext *context, uint_t portIndex,
514  MacAddr *value);
515 
517  uint8_t *value);
518 
520  bool_t *value);
521 
523  bool_t *value);
524 
526  uint32_t *value);
527 
529  uint32_t *value);
530 
533 
535  uint_t portIndex, bool_t *value);
536 
538  bool_t *value);
539 
541  bool_t *value);
542 
544  bool_t *value);
545 
548 
549 error_t rstpGetPortRole(RstpBridgeContext *context, uint_t portIndex,
550  StpPortRole *value);
551 
553  StpBridgeId *value);
554 
556  uint32_t *value);
557 
559  uint_t portIndex, StpBridgeId *value);
560 
562  uint16_t *value);
563 
565  uint_t *value);
566 
567 void rstpDeinit(RstpBridgeContext *context);
568 
569 //C++ guard
570 #ifdef __cplusplus
571 }
572 #endif
573 
574 #endif
unsigned int uint_t
Definition: compiler_port.h:50
int bool_t
Definition: compiler_port.h:53
error_t
Error codes.
Definition: error.h:43
MacAddr
Definition: ethernet.h:195
#define NetInterface
Definition: net.h:36
NicDuplexMode
Duplex mode.
Definition: nic.h:122
error_t rstpSetBridgePriority(RstpBridgeContext *context, uint16_t value)
Set bridge priority.
Definition: rstp.c:349
error_t rstpGetTopologyChanges(RstpBridgeContext *context, uint_t *value)
Get the number of topology changes.
Definition: rstp.c:1020
error_t rstpStop(RstpBridgeContext *context)
Stop RSTP bridge operation.
Definition: rstp.c:257
error_t rstpGetBridgePriority(RstpBridgeContext *context, uint16_t *value)
Get the assigned bridge priority.
Definition: rstp.c:637
error_t rstpGetTxHoldCount(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Transmit Hold Count parameter.
Definition: rstp.c:765
error_t rstpGetVersion(RstpBridgeContext *context, uint_t *value)
Get assigned protocol version.
Definition: rstp.c:573
error_t rstpGetAdminPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the administrative port path cost.
Definition: rstp.c:1621
error_t rstpGetRootPort(RstpBridgeContext *context, uint16_t *value)
Get the current root port.
Definition: rstp.c:893
error_t rstpGetPortDesignatedBridge(RstpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
Get the bridge identifier of the designated bridge.
Definition: rstp.c:1997
error_t rstpGetPortDesignatedPort(RstpBridgeContext *context, uint_t portIndex, uint16_t *value)
Get the port identifier of the designated bridge.
Definition: rstp.c:2031
RstpInfoIs
Origin/state of the port's Spanning Tree information.
Definition: rstp.h:242
@ RSTP_INFO_IS_MINE
Definition: rstp.h:245
@ RSTP_INFO_IS_RECEIVED
Definition: rstp.h:244
@ RSTP_INFO_IS_DISABLED
Definition: rstp.h:243
@ RSTP_INFO_IS_AGED
Definition: rstp.h:246
error_t rstpSetAdminPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t value)
Set administrative port path cost.
Definition: rstp.c:1266
error_t rstpSetAutoEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t value)
Set AutoEdgePort parameter.
Definition: rstp.c:1368
error_t rstpGetOperPointToPointMac(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the operational point-to-point status of the LAN segment.
Definition: rstp.c:1725
error_t rstpGetBridgeForwardDelay(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Forward Delay parameter.
Definition: rstp.c:733
error_t rstpGetDesignatedRoot(RstpBridgeContext *context, StpBridgeId *value)
Get the bridge identifier of the root of the spanning tree.
Definition: rstp.c:829
error_t rstpGetPortDesignatedRoot(RstpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
Get the bridge identifier of the designated root bridge.
Definition: rstp.c:1929
error_t rstpGetPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the current value of the port path cost.
Definition: rstp.c:1655
error_t rstpSetAdminPointToPointMac(RstpBridgeContext *context, uint_t portIndex, RstpAdminPointToPointMac value)
Set administrative point-to-point status of the LAN segment.
Definition: rstp.c:1301
error_t rstpGetPortDesignatedCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the designated cost of the port.
Definition: rstp.c:1963
error_t rstpGetAdminPointToPointMac(RstpBridgeContext *context, uint_t portIndex, RstpAdminPointToPointMac *value)
Get the administrative point-to-point status of the LAN segment.
Definition: rstp.c:1690
error_t rstpSetProtocolMigration(RstpBridgeContext *context, uint_t portIndex, bool_t value)
Force protocol migration.
Definition: rstp.c:1403
error_t rstpGetForwardDelay(RstpBridgeContext *context, uint_t *value)
Get the current Forward Delay value.
Definition: rstp.c:988
error_t rstpGetPortAddr(RstpBridgeContext *context, uint_t portIndex, MacAddr *value)
Get the MAC address assigned to the port.
Definition: rstp.c:1485
error_t rstpSetVersion(RstpBridgeContext *context, uint_t value)
Set protocol version.
Definition: rstp.c:317
error_t rstpGetNumPorts(RstpBridgeContext *context, uint_t *value)
Get the number of ports.
Definition: rstp.c:541
error_t rstpGetTimeSinceTopologyChange(RstpBridgeContext *context, uint_t *value)
Get the time since a topology change was last detected.
Definition: rstp.c:1052
error_t rstpGetOperEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the operational value of the Edge Port parameter.
Definition: rstp.c:1827
error_t rstpGetForwardTransitions(RstpBridgeContext *context, uint_t portIndex, uint_t *value)
Get the number of times the port has transitioned to Forwarding state.
Definition: rstp.c:2065
error_t rstpGetBridgeHelloTime(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Hello Time parameter.
Definition: rstp.c:701
error_t rstpGetAdminPortState(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the administrative port state.
Definition: rstp.c:1553
error_t rstpGetBridgeAddr(RstpBridgeContext *context, MacAddr *value)
Get the MAC address assigned to the bridge.
Definition: rstp.c:605
error_t rstpSetBridgeMaxAge(RstpBridgeContext *context, uint_t value)
Set Bridge Max Age parameter.
Definition: rstp.c:381
error_t rstpSetPortNum(RstpBridgeContext *context, uint_t portIndex, uint16_t value)
Set port number.
Definition: rstp.c:1086
error_t rstpGetBridgeMaxAge(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Max Age parameter.
Definition: rstp.c:669
error_t rstpSetPortPriority(RstpBridgeContext *context, uint_t portIndex, uint8_t value)
Set port priority.
Definition: rstp.c:1198
error_t rstpGetHelloTime(RstpBridgeContext *context, uint_t *value)
Get the current Hello Time value.
Definition: rstp.c:957
void rstpDeinit(RstpBridgeContext *context)
Release RSTP bridge context.
Definition: rstp.c:2096
error_t rstpSetAdminEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t value)
Set administrative value of the Edge Port parameter.
Definition: rstp.c:1335
error_t rstpGetPortRole(RstpBridgeContext *context, uint_t portIndex, StpPortRole *value)
Get the assigned role of the port.
Definition: rstp.c:1895
RstpAdminPointToPointMac
Administrative state of the point-to-point status.
Definition: rstp.h:255
@ RSTP_ADMIN_P2P_MAC_FORCE_FALSE
Definition: rstp.h:256
@ RSTP_ADMIN_P2P_MAC_AUTO
Definition: rstp.h:258
@ RSTP_ADMIN_P2P_MAC_FORCE_TRUE
Definition: rstp.h:257
#define RstpBridgeContext
Definition: rstp.h:36
#define RstpBridgePort
Definition: rstp.h:40
error_t rstpGetAutoEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the value of the AutoEdgePort parameter.
Definition: rstp.c:1793
error_t rstpGetMacOperState(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the current MAC operational state.
Definition: rstp.c:1587
error_t rstpSetAgeingTime(RstpBridgeContext *context, uint_t value)
Set Ageing Time parameter.
Definition: rstp.c:509
error_t rstpInit(RstpBridgeContext *context, RstpBridgeSettings *settings)
Initialize RSTP bridge context.
Definition: rstp.c:70
error_t rstpSetPortAddr(RstpBridgeContext *context, uint_t portIndex, const MacAddr *value)
Set port address.
Definition: rstp.c:1147
RstpRcvdInfo
State of the received Spanning Tree information.
Definition: rstp.h:228
@ RSTP_RCVD_INFO_SUPERIOR_DESIGNATED
Definition: rstp.h:229
@ RSTP_RCVD_INFO_INFERIOR_ROOT_ALTERNATE
Definition: rstp.h:232
@ RSTP_RCVD_INFO_OTHER
Definition: rstp.h:233
@ RSTP_RCVD_INFO_INFERIOR_DESIGNATED
Definition: rstp.h:231
@ RSTP_RCVD_INFO_REPEATED_DESIGNATED
Definition: rstp.h:230
error_t rstpSetBridgeHelloTime(RstpBridgeContext *context, uint_t value)
Set Bridge Hello Time parameter.
Definition: rstp.c:413
error_t rstpStart(RstpBridgeContext *context)
Start RSTP bridge operation.
Definition: rstp.c:168
error_t rstpSetTxHoldCount(RstpBridgeContext *context, uint_t value)
Set Transmit Hold Count parameter.
Definition: rstp.c:477
error_t rstpGetPortPriority(RstpBridgeContext *context, uint_t portIndex, uint8_t *value)
Get the priority assigned to the port.
Definition: rstp.c:1519
void rstpGetDefaultSettings(RstpBridgeSettings *settings)
Initialize settings with default values.
Definition: rstp.c:51
error_t rstpGetAdminEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the administrative value of the Edge Port parameter.
Definition: rstp.c:1759
error_t rstpSetAdminPortState(RstpBridgeContext *context, uint_t portIndex, bool_t value)
Set administrative bridge port state.
Definition: rstp.c:1232
error_t rstpGetPortState(RstpBridgeContext *context, uint_t portIndex, StpPortState *value)
Get the current state of the port.
Definition: rstp.c:1861
error_t rstpGetRootPathCost(RstpBridgeContext *context, uint32_t *value)
Get the current cost of the path to the root.
Definition: rstp.c:861
error_t rstpGetAgeingTime(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Ageing Time parameter.
Definition: rstp.c:797
error_t rstpGetMaxAge(RstpBridgeContext *context, uint_t *value)
Get the current Max Age value.
Definition: rstp.c:925
error_t rstpSetBridgeForwardDelay(RstpBridgeContext *context, uint_t value)
Set Bridge Forward Delay parameter.
Definition: rstp.c:445
error_t rstpGetPortNum(RstpBridgeContext *context, uint_t portIndex, uint16_t *value)
Get the port number assigned to the port.
Definition: rstp.c:1437
Bridge Detection state machine (BDM)
RstpBdmState
Bridge Detection machine states.
Definition: rstp_bdm.h:48
BPDU processing.
RstpBpdu
Definition: rstp_bpdu.h:111
Port Information state machine (PIM)
RstpPimState
Port Information machine states.
Definition: rstp_pim.h:48
Port Protocol Migration state machine (PPM)
RstpPpmState
Port Protocol Migration states.
Definition: rstp_ppm.h:48
Port Role Selection state machine (PRS)
RstpPrsState
Port Role Selection machine states.
Definition: rstp_prs.h:48
Port Role Transition state machine (PRT)
RstpPrtState
Port Role Transition machine states.
Definition: rstp_prt.h:48
Port Receive state machine (PRX)
RstpPrxState
Port Receive machine states.
Definition: rstp_prx.h:48
Port State Transition state machine (PST)
RstpPstState
Port State Transition machine states.
Definition: rstp_pst.h:48
Port Timers state machine (PTI)
RstpPtiState
Port Timers machine states.
Definition: rstp_pti.h:48
Port Transmit state machine (PTX)
RstpPtxState
Port Transmit machine states.
Definition: rstp_ptx.h:48
Topology change state machine (TCM)
RstpTcmState
Topology Change machine states.
Definition: rstp_tcm.h:48
STP common definitions.
StpBridgeId
Definition: stp_common.h:148
StpPortRole
Port role values.
Definition: stp_common.h:123
StpPortState
Port states.
Definition: stp_common.h:108
RSTP bridge context.
Definition: rstp.h:421
RstpPrsState prsState
Port Role Selection state machine (17.28)
Definition: rstp.h:436
RstpPriority rootPriority
First four components of the bridge's root priority vector (17.18.6)
Definition: rstp.h:433
uint_t rapidAgeingWhile
Rapid ageing timer.
Definition: rstp.h:439
uint_t timeSinceTopologyChange
Time since the last topology change.
Definition: rstp.h:441
RstpBpdu bpdu
Received BPDU.
Definition: rstp.h:443
RstpBridgeParams params
RSTP bridge parameters (17.13)
Definition: rstp.h:427
uint_t numPorts
Number of ports.
Definition: rstp.h:423
bool_t running
RSTP bridge operation state.
Definition: rstp.h:425
uint_t ageingTime
Ageing time for filtering database entries (17.19.1)
Definition: rstp.h:438
bool_t busy
Busy flag.
Definition: rstp.h:444
RstpBridgePort * ports
Bridge's ports.
Definition: rstp.h:424
uint_t topologyChangeCount
Number of topology changes.
Definition: rstp.h:442
RstpTimes bridgeTimes
Bridge's timer parameter values (17.18.4)
Definition: rstp.h:431
uint16_t rootPortId
Port Identifier of the Root port (17.18.5)
Definition: rstp.h:432
RstpPriority bridgePriority
Bridge priority vector (17.18.3)
Definition: rstp.h:430
NetInterface * interface
Underlying network interface.
Definition: rstp.h:422
RstpTimes rootTimes
Bridge's operational timer parameter values (7.18.7)
Definition: rstp.h:434
StpBridgeId bridgeId
Unique identifier assigned to the bridge (17.18.2)
Definition: rstp.h:429
Bridge port.
Definition: rstp.h:324
bool_t proposed
Boolean (17.19.23)
Definition: rstp.h:378
uint8_t portIndex
Port index.
Definition: rstp.h:327
bool_t proposing
Boolean (17.19.24)
Definition: rstp.h:379
RstpInfoIs infoIs
Origin/state of the port's Spanning Tree information held for the port (17.19.10)
Definition: rstp.h:365
StpPortRole role
Assigned Port Role (17.19.35)
Definition: rstp.h:390
bool_t tcAck
Set if a Configuration message with a TC ACK flag is to be transmitted (17.19.41)
Definition: rstp.h:396
RstpPriority msgPriority
First four components of the message priority vector (17.19.14)
Definition: rstp.h:369
bool_t disputed
Boolean (17.19.6)
Definition: rstp.h:361
bool_t newInfo
Set if a BPDU is to be transmitted (17.19.16)
Definition: rstp.h:371
bool_t forward
Boolean (17.19.8)
Definition: rstp.h:363
bool_t rcvdTc
Boolean (17.19.30)
Definition: rstp.h:385
RstpPimState pimState
Port Information state machine (17.27)
Definition: rstp.h:343
RstpTimes msgTimes
Set of timer parameter values conveyed in a received BPDU (17.19.15)
Definition: rstp.h:370
bool_t updtInfo
Set to tell that portPriority and portTimes should be updated (17.19.45)
Definition: rstp.h:400
uint_t rcvdInfoWhile
Received Info timer (17.17.6)
Definition: rstp.h:353
StpPortRole selectedRole
Newly computed role for the port (17.19.37)
Definition: rstp.h:392
uint_t tcWhile
Topology Change timer (17.17.8)
Definition: rstp.h:355
uint_t fdWhile
Forward Delay timer (17.17.2)
Definition: rstp.h:349
RstpPtxState ptxState
Port Transmit state machine (17.26)
Definition: rstp.h:342
bool_t sendRstp
Set if an RSTP BPDU is to be transmitted (17.19.38)
Definition: rstp.h:393
bool_t learning
Boolean (17.19.12)
Definition: rstp.h:367
uint32_t portPathCost
Port's contribution to the root path cost (17.19.20)
Definition: rstp.h:375
bool_t rcvdBpdu
A valid Configuration, TCN or RST BPDU is received on the port (17.19.25)
Definition: rstp.h:380
uint_t helloWhen
Hello timer (17.17.3)
Definition: rstp.h:350
RstpPpmState ppmState
Port Protocol Migration state machine (17.24)
Definition: rstp.h:340
MacAddr macAddr
MAC address of the port.
Definition: rstp.h:328
RstpPriority portPriority
First four components of the port priority vector value (17.19.21)
Definition: rstp.h:376
bool_t rcvdTcn
Boolean (17.19.32)
Definition: rstp.h:387
RstpPtiState ptiState
Port Timers state machine (17.22)
Definition: rstp.h:338
bool_t rcvdMsg
Boolean (17.19.27)
Definition: rstp.h:382
bool_t agreed
Boolean (17.19.3)
Definition: rstp.h:358
bool_t tick
Tick signal (17.19.43)
Definition: rstp.h:398
bool_t sync
Boolean (17.19.39)
Definition: rstp.h:394
uint_t rrWhile
Recent Root timer (17.17.7)
Definition: rstp.h:354
uint_t edgeDelayWhile
Edge Delay timer (17.17.1)
Definition: rstp.h:348
RstpTcmState tcmState
Topology Change state machine (17.31)
Definition: rstp.h:346
bool_t operEdge
Boolean (17.19.17)
Definition: rstp.h:372
uint_t forwardTransitions
Number of times the port has transitioned to Forwarding state.
Definition: rstp.h:336
bool_t forwarding
Boolean (17.19.9)
Definition: rstp.h:364
RstpPrxState prxState
Port Receive state machine (17.23)
Definition: rstp.h:339
bool_t rcvdTcAck
Boolean (17.19.31)
Definition: rstp.h:386
uint32_t linkSpeed
Link speed.
Definition: rstp.h:332
RstpTimes designatedTimes
Set of timer parameter values used to update Port Times (17.19.5)
Definition: rstp.h:360
bool_t rcvdStp
Boolean (17.19.29)
Definition: rstp.h:384
RstpPriority designatedPriority
First four components of the designated priority vector value (17.19.4)
Definition: rstp.h:359
bool_t synced
Boolean (17.19.40)
Definition: rstp.h:395
RstpPstState pstState
Port State Transition state machine (17.30)
Definition: rstp.h:345
RstpBridgeContext * context
RSTP bridge context.
Definition: rstp.h:325
bool_t fdbFlush
Instruct the filtering database to remove all entries for this port (17.19.7)
Definition: rstp.h:362
uint_t mdelayWhile
Migration Delay timer (17.17.4)
Definition: rstp.h:351
bool_t reselect
Boolean (17.19.34)
Definition: rstp.h:389
RstpPortParams params
Port parameters.
Definition: rstp.h:330
bool_t mcheck
Force PPM state machine to transmit RST BPDUs for a MigrateTime period (17.19.13)
Definition: rstp.h:368
bool_t tcProp
Set if a topology change should be propagated through this port (17.19.42)
Definition: rstp.h:397
RstpPrtState prtState
Port Role Transition state machine (17.29)
Definition: rstp.h:344
bool_t portEnabled
Set if the port can be used transmit and receive frames (17.19.18)
Definition: rstp.h:373
RstpRcvdInfo rcvdInfo
State of the received Spanning Tree information (17.19.26)
Definition: rstp.h:381
bool_t rcvdRstp
Boolean (17.19.28)
Definition: rstp.h:383
bool_t selected
Boolean (17.19.36)
Definition: rstp.h:391
RstpBdmState bdmState
Bridge Detection state machine (17.25)
Definition: rstp.h:341
bool_t operPointToPointMac
The MAC is connected to a point-to-point LAN (6.4.3)
Definition: rstp.h:335
bool_t agree
Boolean (17.19.2)
Definition: rstp.h:357
bool_t reRoot
Boolean (17.19.33)
Definition: rstp.h:388
uint16_t portId
Port identifier (17.19.19)
Definition: rstp.h:374
NicDuplexMode duplexMode
Duplex mode.
Definition: rstp.h:333
uint_t rbWhile
Recent Backup timer (17.17.5)
Definition: rstp.h:352
RstpTimes portTimes
Set of timer parameter values used in transmitted BPDUs (17.19.22)
Definition: rstp.h:377
bool_t learn
Boolean (17.19.11)
Definition: rstp.h:366
uint_t txCount
Counter incremented on every BPDU transmission (17.19.44)
Definition: rstp.h:399
bool_t macOperState
The MAC entity is in a functioning state (6.4.2)
Definition: rstp.h:334
RSTP bridge parameters.
Definition: rstp.h:294
uint_t migrateTime
Initial value of the mdelayWhile and edgeDelayWhile timers (17.13.9)
Definition: rstp.h:300
uint_t bridgeMaxAge
Maximum age of the information transmitted by the bridge when it is the Root bridge (17....
Definition: rstp.h:299
uint_t forceProtocolVersion
Force Protocol Version parameter for the bridge (17.13.4)
Definition: rstp.h:296
uint_t transmitHoldCount
Value used to limit the maximum transmission rate (17.13.12)
Definition: rstp.h:301
uint_t bridgeForwardDelay
Delay used by STP bridges to transition Root and Designated ports to Forwarding (17....
Definition: rstp.h:297
uint_t bridgeHelloTime
Interval between periodic transmissions of Configuration messages by Designated ports (17....
Definition: rstp.h:298
uint_t ageingTime
Ageing Time parameter for the bridge (17.13.2)
Definition: rstp.h:295
RSTP bridge settings.
Definition: rstp.h:409
uint_t numPorts
Number of ports.
Definition: rstp.h:411
RstpBridgePort * ports
Bridge's ports.
Definition: rstp.h:412
NetInterface * interface
Underlying network interface.
Definition: rstp.h:410
Bridge port parameters.
Definition: rstp.h:310
bool_t adminPortState
Administrative bridge port state (14.8.2.2)
Definition: rstp.h:311
bool_t adminEdgePort
AdminEdgePort parameter for the port (17.13.1)
Definition: rstp.h:314
RstpAdminPointToPointMac adminPointToPointMac
Administrative state of the point-to-point status (6.4.3)
Definition: rstp.h:313
uint32_t adminPathCost
Contribution of this port to the path cost.
Definition: rstp.h:312
bool_t autoEdgePort
AutoEdgePort parameter for the port (17.13.3)
Definition: rstp.h:315
Spanning Tree priority vector.
Definition: rstp.h:280
uint16_t designatedPortId
Definition: rstp.h:284
StpBridgeId rootBridgeId
Definition: rstp.h:281
uint16_t bridgePortId
Definition: rstp.h:285
StpBridgeId designatedBridgeId
Definition: rstp.h:283
uint32_t rootPathCost
Definition: rstp.h:282
RSTP timer parameter values.
Definition: rstp.h:267
uint_t helloTime
Definition: rstp.h:271
uint_t messageAge
Definition: rstp.h:268
uint_t maxAge
Definition: rstp.h:269
uint_t forwardDelay
Definition: rstp.h:270
uint8_t value[]
Definition: tcp.h:369