Go to the documentation of this file.
32 #define TRACE_LEVEL STP_TRACE_LEVEL
43 #if (STP_SUPPORT == ENABLED)
59 context->designatedRoot = context->bridgeId;
60 context->rootPathCost = 0;
61 context->rootPort = 0;
66 context->maxAge = context->bridgeMaxAge;
67 context->helloTime = context->bridgeHelloTime;
68 context->forwardDelay = context->bridgeForwardDelay;
73 context->topologyChangeDetected =
FALSE;
74 context->topologyChange =
FALSE;
84 for(i = 0; i < context->numPorts; i++)
87 port = &context->ports[i];
116 port->changeDetectionEnabled =
TRUE;
143 context =
port->context;
146 if(
port->holdTimer.active)
163 bpdu.rootId.priority =
htons(context->designatedRoot.priority);
164 bpdu.rootId.addr = context->designatedRoot.addr;
168 bpdu.rootPathCost =
htonl(context->rootPathCost);
172 bpdu.bridgeId.priority =
htons(context->bridgeId.priority);
173 bpdu.bridgeId.addr = context->bridgeId.addr;
195 messageAge = (rootPort != NULL) ? rootPort->messageAgeTimer.value : 0;
205 bpdu.maxAge =
htons(context->maxAge * 256);
206 bpdu.helloTime =
htons(context->helloTime * 256);
207 bpdu.forwardDelay =
htons(context->forwardDelay * 256);
211 if(
port->topologyChangeAck)
218 if(context->topologyChange)
225 if(messageAge < context->
maxAge)
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);
281 context->maxAge =
ntohs(bpdu->maxAge) / 256;
282 context->helloTime =
ntohs(bpdu->helloTime) / 256;
283 context->forwardDelay =
ntohs(bpdu->forwardDelay) / 256;
312 for(i = 0; i < context->numPorts; i++)
315 port = &context->ports[i];
407 for(i = 0; i < context->numPorts; i++)
410 port = &context->ports[i];
424 &rootPort->designatedRoot) < 0)
430 &rootPort->designatedRoot) > 0)
433 else if((
port->designatedCost +
port->pathCost) <
434 (rootPort->designatedCost + rootPort->pathCost))
439 else if((
port->designatedCost +
port->pathCost) >
440 (rootPort->designatedCost + rootPort->pathCost))
444 &rootPort->designatedBridge) < 0)
451 &rootPort->designatedBridge) > 0)
454 else if(
port->designatedPort < rootPort->designatedPort)
461 else if(
port->designatedPort > rootPort->designatedPort)
464 else if(
port->portId < rootPort->portId)
480 context->rootPort = 0;
484 context->designatedRoot = context->bridgeId;
488 context->rootPathCost = 0;
494 context->rootPort = rootPort->portId;
498 context->designatedRoot = rootPort->designatedRoot;
502 context->rootPathCost = rootPort->designatedCost + rootPort->pathCost;
518 for(i = 0; i < context->numPorts; i++)
521 port = &context->ports[i];
532 &
port->designatedRoot) != 0)
538 else if(context->rootPathCost <
port->designatedCost)
544 else if(context->rootPathCost ==
port->designatedCost &&
552 else if(context->rootPathCost ==
port->designatedCost &&
554 port->portId <
port->designatedPort)
580 context =
port->context;
584 port->designatedRoot = context->designatedRoot;
588 port->designatedCost = context->rootPathCost;
592 port->designatedBridge = context->bridgeId;
596 port->designatedPort =
port->portId;
611 for(i = 0; i < context->numPorts; i++)
614 port = &context->ports[i];
684 if(
port->changeDetectionEnabled)
716 if(!context->topologyChangeDetected)
726 context->topologyChangeDetected =
TRUE;
738 context->topologyChangeDetected =
FALSE;
void stpBecomeDesignatedPort(StpBridgePort *port)
Become Designated port (8.6.10)
void stpUpdateAgeingTime(StpBridgeContext *context, uint32_t ageingTime)
Set ageing time for dynamic filtering entries.
#define STP_CONFIG_BPDU_SIZE
void stpReplyToConfigBpdu(StpBridgePort *port)
Reply to Configuration BPDU (8.6.5)
void stpUpdateTopologyChange(StpBridgeContext *context, bool_t value)
Set the Topology Change flag.
@ STP_PORT_STATE_LEARNING
void stpTransmitTcnBpdu(StpBridgeContext *context)
Transmit Topology Change Notification BPDU (8.6.6)
void stpUpdatePortState(StpBridgePort *port, StpPortState state)
Set port state.
@ STP_PORT_STATE_DISABLED
@ STP_PORT_STATE_FORWARDING
STP (Spanning Tree Protocol)
bool_t stpRootPort(StpBridgePort *port)
Test whether a given port is the Root port for the bridge.
@ STP_PROTOCOL_VERSION
STP version.
void stpInitProc(StpBridgeContext *context)
Initialization procedure.
void stpMakeBlocking(StpBridgePort *port)
Make blocking (8.6.13)
void stpTransmitConfigBpdu(StpBridgePort *port)
Transmit Configuration BPDU (8.6.1)
void stpTopologyChangeDetection(StpBridgeContext *context)
Topology change detection (8.6.14)
@ STP_PORT_STATE_LISTENING
#define STP_TCN_BPDU_SIZE
void stpAckTopologyChange(StpBridgePort *port)
Acknowledge topology change (8.6.16)
void stpRecordConfigInfo(StpBridgePort *port, const StpBpdu *bpdu)
Record configuration information (8.6.2)
bool_t stpRootBridge(StpBridgeContext *context)
Test whether the bridge is the Root bridge.
void stpRecordConfigTimeoutValues(StpBridgeContext *context, const StpBpdu *bpdu)
Record configuration timeout values (8.6.3)
void stpStartTimer(StpTimer *timer, uint_t value)
Start timer.
STP algorithm conditions.
error_t stpSendBpdu(StpBridgePort *port, const StpBpdu *bpdu, size_t length)
Send bridge protocol data unit.
@ STP_PORT_STATE_BLOCKING
void stpConfigUpdate(StpBridgeContext *context)
Configuration update (8.6.7)
void stpConfigBpduGeneration(StpBridgeContext *context)
Configuration BPDU generation (8.6.4)
void stpMakeForwarding(StpBridgePort *port)
Make forwarding (8.6.12)
void stpDesignatedPortSelection(StpBridgeContext *context)
Designated port selection (8.6.9)
StpBridgePort * stpGetBridgePort(StpBridgeContext *context, uint16_t portId)
Retrieve the port that matches the specified port number.
void stpRootSelection(StpBridgeContext *context)
Root selection (8.6.8)
#define STP_MESSAGE_AGE_INCREMENT
bool_t stpDesignatedPort(StpBridgePort *port)
Test whether a given port is a Designated port.
void stpStopTimer(StpTimer *timer)
Stop timer.
int_t stpCompareBridgeId(const StpBridgeId *id1, const StpBridgeId *id2)
Compare bridge identifiers.
void stpTopologyChangeAcked(StpBridgeContext *context)
Topology change acknowledged (8.6.15)
void stpPortStateSelection(StpBridgeContext *context)
Port state selection (8.6.11)