stp_procedures.c
Go to the documentation of this file.
1 /**
2  * @file stp_procedures.c
3  * @brief Elements of procedures
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 //Switch to the appropriate trace level
32 #define TRACE_LEVEL STP_TRACE_LEVEL
33 
34 //Dependencies
35 #include "stp/stp.h"
36 #include "stp/stp_procedures.h"
37 #include "stp/stp_conditions.h"
38 #include "stp/stp_bpdu.h"
39 #include "stp/stp_misc.h"
40 #include "debug.h"
41 
42 //Check TCP/IP stack configuration
43 #if (STP_SUPPORT == ENABLED)
44 
45 
46 /**
47  * @brief Initialization procedure
48  * @param[in] context Pointer to the STP bridge context
49  **/
50 
52 {
53  uint_t i;
55 
56  //The Designated Root parameter held for the bridge is set equal to the
57  //value of the Bridge Identifier, and the values of the Root Path Cost and
58  //Root Port parameter held for the Bridge are set to zero
59  context->designatedRoot = context->bridgeId;
60  context->rootPathCost = 0;
61  context->rootPort = 0;
62 
63  //The Max Age, Hello Time, and Forward Delay parameters held by the bridge
64  //are set to the values of the Bridge Max Age, Bridge Hello Time, and Bridge
65  //Forward Delay parameters
66  context->maxAge = context->bridgeMaxAge;
67  context->helloTime = context->bridgeHelloTime;
68  context->forwardDelay = context->bridgeForwardDelay;
69 
70  //The Topology Change Detected and Topology Change flag parameters for the
71  //bridge are reset, and the Topology Change Notification Timer and Topology
72  //Change Timer are stopped, if running
73  context->topologyChangeDetected = FALSE;
74  context->topologyChange = FALSE;
75  stpStopTimer(&context->tcnTimer);
76  stpStopTimer(&context->topologyChangeTimer);
77 
78  //Stop the rapid ageing timer
79  stpStopTimer(&context->rapidAgeingTimer);
80  //Restore default ageing time
81  stpUpdateAgeingTime(context, context->ageingTime);
82 
83  //Loop through the ports of the bridge
84  for(i = 0; i < context->numPorts; i++)
85  {
86  //Point to the current bridge port
87  port = &context->ports[i];
88 
89  //The Become Designated Port procedure is used to assign values to the
90  //Designated Root, Designated Cost, Designated Bridge, and Designated
91  //Port parameters for the port
93 
94  //The Port State is set to Blocking if the port is to be enabled following
95  //initialization. Alternatively, the Port State is set to Disabled
96  if(port->state != STP_PORT_STATE_DISABLED)
97  {
99  }
100  else
101  {
103  }
104 
105  //The Topology Change Acknowledge flag parameter is reset
106  port->topologyChangeAck = FALSE;
107  //The Configuration Pending flag parameter is reset
108  port->configPending = FALSE;
109  //The Message Age Timer is stopped, if running
110  stpStopTimer(&port->messageAgeTimer);
111  //The Forward Delay Timer is stopped, if running
112  stpStopTimer(&port->forwardDelayTimer);
113  //The Hold Timer is stopped, if running
114  stpStopTimer(&port->holdTimer);
115  //The Change Detection Enabled flag is set
116  port->changeDetectionEnabled = TRUE;
117  }
118 
119  //The Port State Selection procedure is used to select the state of each of
120  //the bridge's ports
121  stpPortStateSelection(context);
122 
123  //The Configuration BPDU Generation procedure is invoked and the Hello Timer
124  //is started
125  stpConfigBpduGeneration(context);
126  stpStartTimer(&context->helloTimer, 0);
127 }
128 
129 
130 /**
131  * @brief Transmit Configuration BPDU (8.6.1)
132  * @param[in] port Pointer to the bridge port context
133  **/
134 
136 {
138  StpBpdu bpdu;
139  StpBridgeContext *context;
140  StpBridgePort *rootPort;
141 
142  //Point to the STP bridge context
143  context = port->context;
144 
145  //Check whether the Hold Timer is active
146  if(port->holdTimer.active)
147  {
148  //If the Hold Timer for the port is active then the Configuration Pending
149  //flag parameter for the Port shall be set. This completes the procedure
150  port->configPending = TRUE;
151  }
152  else
153  {
154  //If the Hold Timer for the Port is not active, a Configuration BPDU is
155  //prepared for transmission
156  bpdu.protocolId = HTONS(STP_PROTOCOL_ID);
157  bpdu.protocolVersionId = STP_PROTOCOL_VERSION;
158  bpdu.bpduType = STP_BPDU_TYPE_CONFIG;
159  bpdu.flags = 0;
160 
161  //The Root Identifier shall be set to the value of the Designated Root
162  //parameter held by the Bridge
163  bpdu.rootId.priority = htons(context->designatedRoot.priority);
164  bpdu.rootId.addr = context->designatedRoot.addr;
165 
166  //The Root Path Cost shall be set to the value of the Root Path Cost
167  //parameter held by the bridge
168  bpdu.rootPathCost = htonl(context->rootPathCost);
169 
170  //The Bridge Identifier shall be set to the value of the Bridge Identifier
171  //parameter held by the Bridge
172  bpdu.bridgeId.priority = htons(context->bridgeId.priority);
173  bpdu.bridgeId.addr = context->bridgeId.addr;
174 
175  //The Port Identifier shall be set to the value of the Port Identifier
176  //parameter held for the bridge port through which the Configuration
177  //BPDU is transmitted
178  bpdu.portId = htons(port->portId);
179 
180  //Check if the bridge has been selected as the Root
181  if(stpRootBridge(context))
182  {
183  //If the Bridge has been selected as the Root, the Message Age shall
184  //be set to zero
185  messageAge = 0;
186  }
187  else
188  {
189  //Point to the Root port
190  rootPort = stpGetBridgePort(context, context->rootPort);
191 
192  //The value of the Message Age shall be set such that the transmitted
193  //Configuration BPDU does not convey an underestimate of the age of
194  //the Protocol Message received on the Root port
195  messageAge = (rootPort != NULL) ? rootPort->messageAgeTimer.value : 0;
196 
197  //The value of the parameter shall not exceed its true value by more
198  //than the maximum Message Age increment overestimate
200  }
201 
202  //The Max Age, Hello Time, and Forward Delay shall be set to the values
203  //of the Max Age, Hello Time, and Forward Delay parameters held for the
204  //bridge
205  bpdu.maxAge = htons(context->maxAge * 256);
206  bpdu.helloTime = htons(context->helloTime * 256);
207  bpdu.forwardDelay = htons(context->forwardDelay * 256);
208 
209  //The Topology Change Acknowledgment flag shall be set to the value of the
210  //Topology Change Acknowledge flag parameter for the port
211  if(port->topologyChangeAck)
212  {
213  bpdu.flags |= STP_BPDU_FLAG_TC_ACK;
214  }
215 
216  //The Topology Change flag shall be set to the value of the Topology
217  //Change flag parameter for the bridge
218  if(context->topologyChange)
219  {
220  bpdu.flags |= STP_BPDU_FLAG_TC;
221  }
222 
223  //Check if the value of the Message Age parameter in the Configuration
224  //BPDU is less than that of the Max Age parameter
225  if(messageAge < context->maxAge)
226  {
227  //Set the Message Age
228  bpdu.messageAge = htons(messageAge * 256);
229 
230  //The Topology Change Acknowledge flag parameter for the port is reset
231  port->topologyChangeAck = FALSE;
232  //The Configuration Pending flag parameter for the port is reset
233  port->configPending = FALSE;
234 
235  //The BPDU shall be transmitted through the port within a time maximum
236  //BPDU transmission delay
238 
239  //The Hold Timer for the port is started
240  stpStartTimer(&port->holdTimer, 0);
241  }
242  }
243 }
244 
245 
246 /**
247  * @brief Record configuration information (8.6.2)
248  * @param[in] port Pointer to the bridge port context
249  * @param[in] bpdu Pointer to the received Configuration BPDU
250  **/
251 
253 {
254  //The Designated Root, Designated Cost, Designated Bridge, and Designated
255  //Port parameters held for the port are set to the values of the Root
256  //Identifier, Root Path Cost, Bridge Identifier, and Port Identifier
257  //parameters conveyed in the received Configuration BPDU
258  port->designatedRoot.priority = ntohs(bpdu->rootId.priority);
259  port->designatedRoot.addr = bpdu->rootId.addr;
260  port->designatedCost = ntohl(bpdu->rootPathCost);
261  port->designatedBridge.priority = ntohs(bpdu->bridgeId.priority);
262  port->designatedBridge.addr = bpdu->bridgeId.addr;
263  port->designatedPort = ntohs(bpdu->portId);
264 
265  //The Message Age Timer for the Port is started, to run from the value of
266  //the Message Age parameter conveyed in the received Configuration BPDU
267  stpStartTimer(&port->messageAgeTimer, ntohs(bpdu->messageAge) / 256);
268 }
269 
270 
271 /**
272  * @brief Record configuration timeout values (8.6.3)
273  * @param[in] context Pointer to the STP bridge context
274  * @param[in] bpdu Pointer to the received Configuration BPDU
275  **/
276 
278 {
279  //The Max Age, Hello Time and Forward Delay parameters held by the bridge
280  //are set to the values conveyed in the received Configuration BPDU
281  context->maxAge = ntohs(bpdu->maxAge) / 256;
282  context->helloTime = ntohs(bpdu->helloTime) / 256;
283  context->forwardDelay = ntohs(bpdu->forwardDelay) / 256;
284 
285  //The Topology Change parameter held by the bridge is set to the value of
286  //the Topology Change flag conveyed in the received Configuration BPDU
287  if((bpdu->flags & STP_BPDU_FLAG_TC) != 0)
288  {
289  //The Topology Change flag parameter held for the bridge is set
290  stpUpdateTopologyChange(context, TRUE);
291  }
292  else
293  {
294  //The Topology Change flag parameter held for the bridge is reset
295  stpUpdateTopologyChange(context, FALSE);
296  }
297 }
298 
299 
300 /**
301  * @brief Configuration BPDU generation (8.6.4)
302  * @param[in] context Pointer to the STP bridge context
303  **/
304 
306 {
307  uint_t i;
309 
310  //For each port that is the Designated port for the LAN to which it is
311  //attached, the Transmit Configuration BPDU procedure is used
312  for(i = 0; i < context->numPorts; i++)
313  {
314  //Point to the current bridge port
315  port = &context->ports[i];
316 
317  //Check port state
318  if(port->state != STP_PORT_STATE_DISABLED && port->macOperState)
319  {
320  //Check whether the value of the Designated Bridge and Designated Port
321  //parameters held for the port are the same as that of the Bridge
322  //Identifier and the Port Identifier for that port, respectively
324  {
325  //Send a Configuration BPDU
327  }
328  }
329  }
330 }
331 
332 
333 /**
334  * @brief Reply to Configuration BPDU (8.6.5)
335  * @param[in] port Pointer to the bridge port context
336  **/
337 
339 {
340  //The Transmit Configuration BPDU procedure is used for the port on which
341  //the Configuration BPDU was received
343 }
344 
345 
346 /**
347  * @brief Transmit Topology Change Notification BPDU (8.6.6)
348  * @param[in] context Pointer to the STP bridge context
349  **/
350 
352 {
353  StpBpdu bpdu;
354  StpBridgePort *rootPort;
355 
356  //Point to the Root port
357  rootPort = stpGetBridgePort(context, context->rootPort);
358 
359  //Sanity check
360  if(rootPort != NULL)
361  {
362  //Format Topology Change Notification BPDU
363  bpdu.protocolId = HTONS(STP_PROTOCOL_ID);
364  bpdu.protocolVersionId = STP_PROTOCOL_VERSION;
365  bpdu.bpduType = STP_BPDU_TYPE_TCN;
366 
367  //The Topology Change Notification BPDU shall be transmitted through the
368  //Root port within a time of maximum BPDU transmission delay
369  stpSendBpdu(rootPort, &bpdu, STP_TCN_BPDU_SIZE);
370  }
371 }
372 
373 
374 /**
375  * @brief Configuration update (8.6.7)
376  * @param[in] context Pointer to the STP bridge context
377  **/
378 
380 {
381  //The procedure for Root Selection shall be used to select the Designated
382  //Root and the Root port, and to calculate the Root Path Cost for this bridge
383  stpRootSelection(context);
384 
385  //The procedure for Designated Port Selection shall be used to determine for
386  //each port whether the port should become the Designated port for the LAN
387  //to which it is attached
389 }
390 
391 
392 /**
393  * @brief Root selection (8.6.8)
394  * @param[in] context Pointer to the STP bridge context
395  **/
396 
398 {
399  uint_t i;
401  StpBridgePort *rootPort;
402 
403  //Initialize root port
404  rootPort = NULL;
405 
406  //Loop through the ports of the bridge
407  for(i = 0; i < context->numPorts; i++)
408  {
409  //Point to the current bridge port
410  port = &context->ports[i];
411 
412  //Make sure the port is not the Designated port for the LAN to which it
413  //is attached, is not Disabled, and has a Designated Root parameter of
414  //higher priority than the bridge's Bridge Identifier
416  stpCompareBridgeId(&port->designatedRoot, &context->bridgeId) < 0)
417  {
418  //Select the root port
419  if(rootPort == NULL)
420  {
421  rootPort = port;
422  }
423  else if(stpCompareBridgeId(&port->designatedRoot,
424  &rootPort->designatedRoot) < 0)
425  {
426  //This port has the highest priority Root
427  rootPort = port;
428  }
429  else if(stpCompareBridgeId(&port->designatedRoot,
430  &rootPort->designatedRoot) > 0)
431  {
432  }
433  else if((port->designatedCost + port->pathCost) <
434  (rootPort->designatedCost + rootPort->pathCost))
435  {
436  //This port has the lowest Root Path Cost
437  rootPort = port;
438  }
439  else if((port->designatedCost + port->pathCost) >
440  (rootPort->designatedCost + rootPort->pathCost))
441  {
442  }
443  else if(stpCompareBridgeId(&port->designatedBridge,
444  &rootPort->designatedBridge) < 0)
445  {
446  //This port has the highest priority Bridge Identifier recorded as
447  //the Designated Bridge for the LAN to which the port is attached
448  rootPort = port;
449  }
450  else if(stpCompareBridgeId(&port->designatedBridge,
451  &rootPort->designatedBridge) > 0)
452  {
453  }
454  else if(port->designatedPort < rootPort->designatedPort)
455  {
456  //This port has the has the highest priority Port Identifier
457  //recorded as the Designated port for the LAN to which the port
458  //is attached
459  rootPort = port;
460  }
461  else if(port->designatedPort > rootPort->designatedPort)
462  {
463  }
464  else if(port->portId < rootPort->portId)
465  {
466  //This port has the highest priority Port Identifier
467  rootPort = port;
468  }
469  else
470  {
471  }
472  }
473  }
474 
475  //Check whether one of the bridge ports has been identified as the Root port
476  if(rootPort == NULL)
477  {
478  //If there is no such port, the value of the Root Port parameter is set
479  //to zero
480  context->rootPort = 0;
481 
482  //The Designated Root parameter held by the bridge is set to the Bridge
483  //Identifier parameter held for the bridge
484  context->designatedRoot = context->bridgeId;
485 
486  //The value of the Root Path Cost parameter held by the bridge is set to
487  //zero
488  context->rootPathCost = 0;
489  }
490  else
491  {
492  //Save the Port Identifier of the port that offers the lowest cost path
493  //to the Root
494  context->rootPort = rootPort->portId;
495 
496  //The Designated Root parameter held by the bridge is set to the
497  //Designated Root parameter held for the Root port
498  context->designatedRoot = rootPort->designatedRoot;
499 
500  //The value of the Root Path Cost parameter held by the bridge is set to
501  //the value of the Root Path Cost parameter associated with the Root port
502  context->rootPathCost = rootPort->designatedCost + rootPort->pathCost;
503  }
504 }
505 
506 
507 /**
508  * @brief Designated port selection (8.6.9)
509  * @param[in] context Pointer to the STP bridge context
510  **/
511 
513 {
514  uint_t i;
516 
517  //Loop through the ports of the bridge
518  for(i = 0; i < context->numPorts; i++)
519  {
520  //Point to the current bridge port
521  port = &context->ports[i];
522 
523  //The procedure to Become Designated Port shall be invoked for each port
524  //that meet the following conditions
526  {
527  //The port has already been selected as the Designated port for the
528  //LAN to which it is attached
530  }
531  else if(stpCompareBridgeId(&context->designatedRoot,
532  &port->designatedRoot) != 0)
533  {
534  //The Designated Root parameter recorded for the bridge differs from
535  //that recorded for the port
537  }
538  else if(context->rootPathCost < port->designatedCost)
539  {
540  //The bridge offers a Path of lower cost to the Root for the LAN to
541  //which the port is attached
543  }
544  else if(context->rootPathCost == port->designatedCost &&
545  stpCompareBridgeId(&context->bridgeId, &port->designatedBridge) < 0)
546  {
547  //The bridge offers a Path of equal cost to the Root, and the bridge's
548  //Bridge Identifier denotes a bridge of higher priority than that
549  //recorded as the Designated Bridge for that port
551  }
552  else if(context->rootPathCost == port->designatedCost &&
553  stpCompareBridgeId(&context->bridgeId, &port->designatedBridge) == 0 &&
554  port->portId < port->designatedPort)
555  {
556  //The bridge offers a Path of equal cost to the Root, and the bridge
557  //is the Designated Bridge for the LAN to which the port is attached,
558  //and the Port Identifier of the port is of higher priority than that
559  //recorded as the Designated Port
561  }
562  else
563  {
564  //Just for sanity
565  }
566  }
567 }
568 
569 
570 /**
571  * @brief Become Designated port (8.6.10)
572  * @param[in] port Pointer to the bridge port context
573  **/
574 
576 {
577  StpBridgeContext *context;
578 
579  //Point to the STP bridge context
580  context = port->context;
581 
582  //The Designated Root parameter held for the port is set to the value of the
583  //Designated Root parameter held by the bridge
584  port->designatedRoot = context->designatedRoot;
585 
586  //The Designated Cost parameter held for the port is set to the value of the
587  //Root Path Cost held by the bridge
588  port->designatedCost = context->rootPathCost;
589 
590  //The Designated Bridge parameter held for the port is set to the Bridge
591  //Identifier of the bridge
592  port->designatedBridge = context->bridgeId;
593 
594  //The Designated Port parameter held for the port is set to the Port Identifier
595  //of the port
596  port->designatedPort = port->portId;
597 }
598 
599 
600 /**
601  * @brief Port state selection (8.6.11)
602  * @param[in] context Pointer to the STP bridge context
603  **/
604 
606 {
607  uint_t i;
609 
610  //Loop through the ports of the bridge
611  for(i = 0; i < context->numPorts; i++)
612  {
613  //Point to the current bridge port
614  port = &context->ports[i];
615 
616  //Root, Designated or Alternate port?
617  if(stpRootPort(port))
618  {
619  //The Configuration Pending flag parameter and Topology Change
620  //Acknowledge flag parameter for the port are reset
621  port->configPending = FALSE;
622  port->topologyChangeAck = FALSE;
623 
624  //The Make Forwarding procedure is used for the port
626  }
627  else if(stpDesignatedPort(port))
628  {
629  //The Message Age Timer for the port is stopped, if running
630  stpStopTimer(&port->messageAgeTimer);
631 
632  //The Make Forwarding procedure is used for the port
634  }
635  else
636  {
637  //The Configuration Pending flag parameter and Topology Change
638  //Acknowledge flag parameter for the port are reset
639  port->configPending = FALSE;
640  port->topologyChangeAck = FALSE;
641 
642  //The Make Blocking procedure is used for the port
644  }
645  }
646 }
647 
648 
649 /**
650  * @brief Make forwarding (8.6.12)
651  * @param[in] port Pointer to the bridge port context
652  **/
653 
655 {
656  //Check whether the port state is Blocking
657  if(port->state == STP_PORT_STATE_BLOCKING)
658  {
659  //The port state is set to Listening
661  //The Forward Delay Timer for the port is started
662  stpStartTimer(&port->forwardDelayTimer, 0);
663  }
664 }
665 
666 
667 /**
668  * @brief Make blocking (8.6.13)
669  * @param[in] port Pointer to the bridge port context
670  **/
671 
673 {
674  //Check whether the port is not in the Disabled or the Blocking state
675  if(port->state != STP_PORT_STATE_DISABLED &&
676  port->state != STP_PORT_STATE_BLOCKING)
677  {
678  //If the port is in the Forwarding or Learning State and the Change
679  //Detection Enabled parameter for the port is set, the Topology Change
680  //Detection procedure is invoked
681  if(port->state == STP_PORT_STATE_FORWARDING ||
682  port->state == STP_PORT_STATE_LEARNING)
683  {
684  if(port->changeDetectionEnabled)
685  {
687  }
688  }
689 
690  //The port state is set to Blocking
692  //The Forward Delay Timer for the port is stopped
693  stpStopTimer(&port->forwardDelayTimer);
694  }
695 }
696 
697 
698 /**
699  * @brief Topology change detection (8.6.14)
700  * @param[in] context Pointer to the STP bridge context
701  **/
702 
704 {
705  //Check if the bridge has been selected as the Root
706  if(stpRootBridge(context))
707  {
708  //The Topology Change flag parameter held for the bridge is set
709  stpUpdateTopologyChange(context, TRUE);
710  //The Topology Change Timer for the bridge is started
711  stpStartTimer(&context->topologyChangeTimer, 0);
712  }
713  else
714  {
715  //Topology Change Detected flag parameter not already set?
716  if(!context->topologyChangeDetected)
717  {
718  //The Transmit Topology Change Notification BPDU procedure is invoked
719  stpTransmitTcnBpdu(context);
720  //The Topology Change Notification Timer is started
721  stpStartTimer(&context->tcnTimer, 0);
722  }
723  }
724 
725  //The Topology Change Detected flag parameter for the bridge is set
726  context->topologyChangeDetected = TRUE;
727 }
728 
729 
730 /**
731  * @brief Topology change acknowledged (8.6.15)
732  * @param[in] context Pointer to the STP bridge context
733  **/
734 
736 {
737  //The Topology Change Detected flag parameter held for the bridge is reset
738  context->topologyChangeDetected = FALSE;
739  //The Topology Change Notification Timer is stopped
740  stpStopTimer(&context->tcnTimer);
741 }
742 
743 
744 /**
745  * @brief Acknowledge topology change (8.6.16)
746  * @param[in] port Pointer to the bridge port context
747  **/
748 
750 {
751  //The Topology Change Acknowledge flag parameter for the port is set
752  port->topologyChangeAck = TRUE;
753  //The Transmit Configuration BPDU procedure is used for the port
755 }
756 
757 #endif
unsigned int uint_t
Definition: compiler_port.h:50
#define HTONS(value)
Definition: cpu_endian.h:410
#define ntohl(value)
Definition: cpu_endian.h:422
#define htonl(value)
Definition: cpu_endian.h:414
#define htons(value)
Definition: cpu_endian.h:413
#define ntohs(value)
Definition: cpu_endian.h:421
Debugging facilities.
uint16_t port
Definition: dns_common.h:267
#define TRUE
Definition: os_port.h:50
#define FALSE
Definition: os_port.h:46
uint16_t maxAge
Definition: rstp_bpdu.h:107
uint16_t messageAge
Definition: rstp_bpdu.h:106
STP (Spanning Tree Protocol)
#define STP_MESSAGE_AGE_INCREMENT
Definition: stp.h:76
#define StpBridgeContext
Definition: stp.h:36
#define StpBridgePort
Definition: stp.h:40
error_t stpSendBpdu(StpBridgePort *port, const StpBpdu *bpdu, size_t length)
Send bridge protocol data unit.
Definition: stp_bpdu.c:186
BPDU processing.
@ STP_BPDU_TYPE_CONFIG
Definition: stp_bpdu.h:57
@ STP_BPDU_TYPE_TCN
Definition: stp_bpdu.h:58
StpBpdu
Definition: stp_bpdu.h:99
#define STP_CONFIG_BPDU_SIZE
Definition: stp_bpdu.h:39
#define STP_TCN_BPDU_SIZE
Definition: stp_bpdu.h:38
@ STP_BPDU_FLAG_TC
Definition: stp_bpdu.h:68
@ STP_BPDU_FLAG_TC_ACK
Definition: stp_bpdu.h:69
#define STP_PROTOCOL_ID
Definition: stp_common.h:80
@ STP_PROTOCOL_VERSION
STP version.
Definition: stp_common.h:97
@ STP_PORT_STATE_BLOCKING
Definition: stp_common.h:111
@ STP_PORT_STATE_LEARNING
Definition: stp_common.h:113
@ STP_PORT_STATE_LISTENING
Definition: stp_common.h:112
@ STP_PORT_STATE_FORWARDING
Definition: stp_common.h:114
@ STP_PORT_STATE_DISABLED
Definition: stp_common.h:109
bool_t stpRootPort(StpBridgePort *port)
Test whether a given port is the Root port for the bridge.
bool_t stpDesignatedPort(StpBridgePort *port)
Test whether a given port is a Designated port.
bool_t stpRootBridge(StpBridgeContext *context)
Test whether the bridge is the Root bridge.
STP algorithm conditions.
void stpUpdateTopologyChange(StpBridgeContext *context, bool_t value)
Set the Topology Change flag.
Definition: stp_misc.c:325
void stpUpdateAgeingTime(StpBridgeContext *context, uint32_t ageingTime)
Set ageing time for dynamic filtering entries.
Definition: stp_misc.c:427
void stpStartTimer(StpTimer *timer, uint_t value)
Start timer.
Definition: stp_misc.c:729
void stpStopTimer(StpTimer *timer)
Stop timer.
Definition: stp_misc.c:743
StpBridgePort * stpGetBridgePort(StpBridgeContext *context, uint16_t portId)
Retrieve the port that matches the specified port number.
Definition: stp_misc.c:212
void stpUpdatePortState(StpBridgePort *port, StpPortState state)
Set port state.
Definition: stp_misc.c:358
int_t stpCompareBridgeId(const StpBridgeId *id1, const StpBridgeId *id2)
Compare bridge identifiers.
Definition: stp_misc.c:296
STP helper functions.
void stpAckTopologyChange(StpBridgePort *port)
Acknowledge topology change (8.6.16)
void stpBecomeDesignatedPort(StpBridgePort *port)
Become Designated port (8.6.10)
void stpMakeForwarding(StpBridgePort *port)
Make forwarding (8.6.12)
void stpMakeBlocking(StpBridgePort *port)
Make blocking (8.6.13)
void stpInitProc(StpBridgeContext *context)
Initialization procedure.
void stpTransmitConfigBpdu(StpBridgePort *port)
Transmit Configuration BPDU (8.6.1)
void stpTransmitTcnBpdu(StpBridgeContext *context)
Transmit Topology Change Notification BPDU (8.6.6)
void stpRecordConfigInfo(StpBridgePort *port, const StpBpdu *bpdu)
Record configuration information (8.6.2)
void stpRootSelection(StpBridgeContext *context)
Root selection (8.6.8)
void stpRecordConfigTimeoutValues(StpBridgeContext *context, const StpBpdu *bpdu)
Record configuration timeout values (8.6.3)
void stpReplyToConfigBpdu(StpBridgePort *port)
Reply to Configuration BPDU (8.6.5)
void stpDesignatedPortSelection(StpBridgeContext *context)
Designated port selection (8.6.9)
void stpTopologyChangeDetection(StpBridgeContext *context)
Topology change detection (8.6.14)
void stpConfigUpdate(StpBridgeContext *context)
Configuration update (8.6.7)
void stpPortStateSelection(StpBridgeContext *context)
Port state selection (8.6.11)
void stpConfigBpduGeneration(StpBridgeContext *context)
Configuration BPDU generation (8.6.4)
void stpTopologyChangeAcked(StpBridgeContext *context)
Topology change acknowledged (8.6.15)
Elements of procedures.