Go to the documentation of this file.
32 #define TRACE_LEVEL RSTP_TRACE_LEVEL
43 #if (RSTP_SUPPORT == ENABLED)
107 for(i = 0; i < context->numPorts; i++)
110 context->ports[i].reselect =
FALSE;
123 TRACE_INFO(
"Port %" PRIu8
": Disable forwarding...\r\n",
port->portIndex);
135 TRACE_INFO(
"Port %" PRIu8
": Disable learning...\r\n",
port->portIndex);
150 TRACE_INFO(
"Port %" PRIu8
": Enable forwarding...\r\n",
port->portIndex);
157 port->forwardTransitions++;
169 TRACE_INFO(
"Port %" PRIu8
": Enable learning...\r\n",
port->portIndex);
184 if(
port->tcWhile == 0)
203 port->tcWhile =
port->context->rootTimes.maxAge +
204 port->context->rootTimes.forwardDelay;
228 bpdu = &
port->context->bpdu;
239 port->msgPriority.rootBridgeId.priority =
ntohs(bpdu->rootId.priority);
240 port->msgPriority.rootBridgeId.addr = bpdu->rootId.addr;
241 port->msgPriority.rootPathCost =
ntohl(bpdu->rootPathCost);
242 port->msgPriority.designatedBridgeId.priority =
ntohs(bpdu->bridgeId.priority);
243 port->msgPriority.designatedBridgeId.addr = bpdu->bridgeId.addr;
244 port->msgPriority.designatedPortId =
ntohs(bpdu->portId);
248 port->msgPriority.bridgePortId =
port->portId;
252 port->msgTimes.messageAge =
ntohs(bpdu->messageAge) / 256;
253 port->msgTimes.maxAge =
ntohs(bpdu->maxAge) / 256;
254 port->msgTimes.forwardDelay =
ntohs(bpdu->forwardDelay) / 256;
255 port->msgTimes.helloTime =
ntohs(bpdu->helloTime) / 256;
289 &
port->portPriority.designatedBridgeId.addr) == 0 &&
291 port->portPriority.designatedPortId) == 0)
369 bpdu = &
port->context->bpdu;
397 bpdu = &
port->context->bpdu;
421 bpdu = &
port->context->bpdu;
448 port->portPriority =
port->msgPriority;
461 port->portTimes.messageAge =
port->msgTimes.messageAge;
462 port->portTimes.maxAge =
port->msgTimes.maxAge;
463 port->portTimes.forwardDelay =
port->msgTimes.forwardDelay;
469 port->portTimes.helloTime =
port->msgTimes.helloTime;
488 for(i = 0; i < context->numPorts; i++)
491 context->ports[i].sync =
TRUE;
506 for(i = 0; i < context->numPorts; i++)
509 context->ports[i].reRoot =
TRUE;
525 for(reselect =
FALSE, i = 0; i < context->numPorts; i++)
527 reselect |= context->ports[i].reselect;
536 for(i = 0; i < context->numPorts; i++)
539 context->ports[i].selected =
TRUE;
555 bpdu = &
port->context->bpdu;
597 context =
port->context;
600 for(i = 0; i < context->numPorts; i++)
603 if(&context->ports[i] !=
port)
605 context->ports[i].tcProp =
TRUE;
627 if(
port->tcWhile != 0)
641 bpdu.rootId.priority =
htons(
port->designatedPriority.rootBridgeId.priority);
642 bpdu.rootId.addr =
port->designatedPriority.rootBridgeId.addr;
643 bpdu.rootPathCost =
htonl(
port->designatedPriority.rootPathCost);
644 bpdu.bridgeId.priority =
htons(
port->designatedPriority.designatedBridgeId.priority);
645 bpdu.bridgeId.addr =
port->designatedPriority.designatedBridgeId.addr;
646 bpdu.portId =
htons(
port->designatedPriority.designatedPortId);
651 bpdu.messageAge =
htons(
port->designatedTimes.messageAge * 256);
652 bpdu.maxAge =
htons(
port->designatedTimes.maxAge * 256);
653 bpdu.helloTime =
htons(
port->designatedTimes.helloTime * 256);
654 bpdu.forwardDelay =
htons(
port->designatedTimes.forwardDelay * 256);
716 if(
port->tcWhile != 0)
735 bpdu.rootId.priority =
htons(
port->designatedPriority.rootBridgeId.priority);
736 bpdu.rootId.addr =
port->designatedPriority.rootBridgeId.addr;
737 bpdu.rootPathCost =
htonl(
port->designatedPriority.rootPathCost);
738 bpdu.bridgeId.priority =
htons(
port->designatedPriority.designatedBridgeId.priority);
739 bpdu.bridgeId.addr =
port->designatedPriority.designatedBridgeId.addr;
740 bpdu.portId =
htons(
port->designatedPriority.designatedPortId);
745 bpdu.messageAge =
htons(
port->designatedTimes.messageAge * 256);
746 bpdu.maxAge =
htons(
port->designatedTimes.maxAge * 256);
747 bpdu.helloTime =
htons(
port->designatedTimes.helloTime * 256);
748 bpdu.forwardDelay =
htons(
port->designatedTimes.forwardDelay * 256);
752 bpdu.version1Length = 0;
788 bpdu = &
port->context->bpdu;
822 if((
port->portTimes.messageAge + 1) <=
port->portTimes.maxAge)
824 port->rcvdInfoWhile = (3 *
port->portTimes.helloTime) + 1;
828 port->rcvdInfoWhile = 0;
843 for(i = 0; i < context->numPorts; i++)
864 context->rootPriority = context->bridgePriority;
865 context->rootPortId = context->bridgePriority.
bridgePortId;
868 context->rootTimes = context->bridgeTimes;
874 for(i = 0; i < context->numPorts; i++)
877 port = &context->ports[i];
887 rootPathPriority =
port->portPriority;
897 &context->bridgePriority.designatedBridgeId.addr) != 0)
903 context->rootPriority = rootPathPriority;
913 context->rootTimes =
port->portTimes;
914 context->rootTimes.messageAge++;
921 for(i = 0; i < context->numPorts; i++)
924 port = &context->ports[i];
930 port->designatedPriority.rootBridgeId = context->rootPriority.rootBridgeId;
931 port->designatedPriority.rootPathCost = context->rootPriority.rootPathCost;
932 port->designatedPriority.designatedBridgeId = context->bridgeId;
933 port->designatedPriority.designatedPortId =
port->portId;
934 port->designatedPriority.bridgePortId =
port->portId;
939 port->designatedTimes = context->rootTimes;
940 port->designatedTimes.helloTime = context->bridgeTimes.helloTime;
945 for(i = 0; i < context->numPorts; i++)
948 port = &context->ports[i];
1009 addr = &
port->portPriority.designatedBridgeId.addr;
1010 portId =
port->portPriority.designatedPortId;
1038 for(i = 0; i < context->numPorts; i++)
1041 port = &context->ports[i];
1044 TRACE_DEBUG(
"Port %" PRIu8
": Selected role is %s\r\n",
port->portIndex,
void rstpEnableLearning(RstpBridgePort *port)
Start learning from frames received on the port (17.21.6)
void rstpRecordTimes(RstpBridgePort *port)
Set portTimes variable (17.21.13)
#define RSTP_RST_BPDU_SIZE
void rstpDisableLearning(RstpBridgePort *port)
Stop learning from frames received on the port (17.21.4)
#define RSTP_TCN_BPDU_SIZE
@ RSTP_BPDU_FLAG_FORWARDING
RstpRcvdInfo rstpRcvInfo(RstpBridgePort *port)
Decode message priority and timer values from the received BPDU (17.21.8)
void rstpDisableForwarding(RstpBridgePort *port)
Stop forwarding frames through the port (17.21.3)
void rstpUpdateTopologyChangeCount(RstpBridgeContext *context)
Update the number of topology changes.
RSTP state machine conditions.
void rstpEnableForwarding(RstpBridgePort *port)
Start forwarding frames through the port (17.21.5)
@ SWITCH_PORT_STATE_LEARNING
void rstpClearReselectTree(RstpBridgeContext *context)
Clear reselect for all ports of the bridge (17.21.2)
int_t rstpCompareBridgeAddr(const MacAddr *addr1, const MacAddr *addr2)
Compare bridge addresses.
Spanning Tree priority vector.
error_t rstpSendBpdu(RstpBridgePort *port, const RstpBpdu *bpdu, size_t length)
Send bridge protocol data unit.
@ RSTP_RCVD_INFO_INFERIOR_ROOT_ALTERNATE
#define RSTP_CONFIG_BPDU_SIZE
void rstpRecordProposal(RstpBridgePort *port)
Record proposal (17.21.11)
#define RstpBridgeContext
void rstpUpdtBpduVersion(RstpBridgePort *port)
Update rcvdSTP and rcvdRSTP variables depending on BPDU version (17.21.22)
void rstpRecordPriority(RstpBridgePort *port)
Record priority (17.21.12)
@ STP_PROTOCOL_VERSION
STP version.
bool_t rstpBetterOrSameInfo(RstpBridgePort *port, RstpInfoIs newInfoIs)
Compare Spanning Tree information (17.21.1)
@ STP_PORT_ROLE_ALTERNATE
void rstpSetReRootTree(RstpBridgeContext *context)
Set reRoot for all ports of the bridge (17.21.15)
StpBridgeId designatedBridgeId
RSTP (Rapid Spanning Tree Protocol)
@ RSTP_RCVD_INFO_SUPERIOR_DESIGNATED
void rstpTxConfig(RstpBridgePort *port)
Transmit a Configuration BPDU (17.21.19)
RstpRcvdInfo
State of the received Spanning Tree information.
@ RSTP_BPDU_FLAG_PORT_ROLE_DESIGNATED
void rstpRecordDispute(RstpBridgePort *port)
Record dispute (17.21.10)
void rstpNewTcWhile(RstpBridgePort *port)
Update the value of tcWhile (17.21.7)
@ RSTP_BPDU_FLAG_AGREEMENT
@ RSTP_BPDU_FLAG_PORT_ROLE_ALT_BACKUP
void rstpSetSelectedTree(RstpBridgeContext *context)
Set the selected variable for all ports of the bridge (17.21.16)
@ RSTP_RCVD_INFO_REPEATED_DESIGNATED
uint_t rstpHelloTime(RstpBridgePort *port)
HelloTime variable evaluation (17.20.7)
@ SWITCH_PORT_STATE_BLOCKING
void rstpUpdtRoleDisabledTree(RstpBridgeContext *context)
Set the selectedRole to DisabledPort for all ports of the bridge (17.21.24)
@ SWITCH_PORT_STATE_FORWARDING
@ STP_PORT_ROLE_DESIGNATED
void rstpTxRstp(RstpBridgePort *port)
Transmit a Rapid Spanning Tree BPDU (17.21.20)
RstpInfoIs
Origin/state of the port's Spanning Tree information.
int_t rstpComparePortNum(uint16_t portId1, uint16_t portId2)
Compare port numbers.
@ RSTP_RCVD_INFO_INFERIOR_DESIGNATED
RSTP state machine procedures.
@ RSTP_BPDU_FLAG_LEARNING
RstpBridgePort * rstpGetBridgePort(RstpBridgeContext *context, uint16_t portId)
Retrieve the port that matches the specified port number.
void rstpUpdatePortState(RstpBridgePort *port, SwitchPortState state)
Set port state.
bool_t rstpVersion(RstpBridgeContext *context)
rstpVersion condition (17.20.11)
void rstpTxTcn(RstpBridgePort *port)
Transmit a Topology Change Notification BPDU (17.21.21)
void rstpRecordAgreement(RstpBridgePort *port)
Record agreement (17.21.9)
@ RSTP_BPDU_FLAG_PORT_ROLE_ROOT
void rstpSetSyncTree(RstpBridgeContext *context)
Set sync for all ports of the bridge (17.21.14)
void rstpSetTcFlags(RstpBridgePort *port)
Update rcvdTc, rcvdTcAck and rcvdTcn flags (17.21.17)
@ RSTP_BPDU_FLAG_PORT_ROLE_UNKNOWN
Parameter value/name binding.
const RstpParamName rstpPortRoles[]
@ RSTP_PROTOCOL_VERSION
RSTP version.
@ RSTP_BPDU_FLAG_PROPOSAL
int_t rstpCompareTimes(const RstpTimes *t1, const RstpTimes *t2)
Compare timer parameter values.
#define RSTP_MIN_BRIDGE_HELLO_TIME
int_t rstpComparePriority(const RstpPriority *p1, const RstpPriority *p2)
Compare priority vectors.
void rstpUpdtRolesTree(RstpBridgeContext *context)
Update spanning tree information and port roles (17.21.25)
void rstpUpdtRcvdInfoWhile(RstpBridgePort *port)
Update the Received Info timer (17.21.23)
const char_t * rstpGetParamName(uint_t value, const RstpParamName *paramList, size_t paramListLen)
Convert a parameter to string representation.
@ RSTP_BPDU_FLAG_PORT_ROLE
void rstpSetTcPropTree(RstpBridgePort *port)
Set tcProp for all ports except the port that called the procedure (17.21.18)