📄 stp-8021d-d17.c
字号:
* NOMANUAL <this will be removed later>
*/
void designated_port_selection
(
void
) /* (8.6.9) */
{
Int port_no;
for (port_no = One; port_no <= No_of_ports; port_no++) /* (8.6.9.3) */
{
if (designated_port(port_no) /* (8.6.9.3.1) */
||
id_neq( port_info[port_no].designated_root,
bridge_info.designated_root) /* (8.6.9.3.2) */
||
(bridge_info.root_path_cost
< port_info[port_no].designated_cost
) /* (8.6.9.3.3) */
||
((bridge_info.root_path_cost
== port_info[port_no].designated_cost
)
&&
/* (8.6.9.3.4) */
(id_lt(bridge_info.bridge_id, port_info[port_no].designated_bridge)
||
(id_eq(bridge_info.bridge_id, port_info[port_no].designated_bridge)
&&
(port_info[port_no].port_id
<= port_info[port_no].designated_port
) /* (8.6.9.3.5) */
))))
{
become_designated_port(port_no); /* (8.6.10.2.2) */
}
}
}
/*******************************************************************************
* become_designated_port -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void become_designated_port
(
Int port_no
) /* (8.6.10) */
{
id_equate(port_info[port_no].designated_root, bridge_info.designated_root);
/* (8.6.10.3.1) */
port_info[port_no].designated_cost = bridge_info.root_path_cost;
/* (8.6.10.3.2) */
id_equate(port_info[port_no].designated_bridge, bridge_info.bridge_id);
/* (8.6.10.3.3) */
port_info[port_no].designated_port = port_info[port_no].port_id;
/* (8.6.10.3.4) */
}
/*******************************************************************************
* port_state_selection -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void port_state_selection
(
void
) /* (8.6.11) */
{
Int port_no;
for (port_no = One; port_no <= No_of_ports; port_no++)
{
if (port_no == bridge_info.root_port) /* (8.6.11.3.1) */
{
port_info[port_no].config_pending = False; /* (8.6.11.3.1(a)) */
port_info[port_no].topology_change_acknowledge = False;
make_forwarding(port_no); /* (8.6.11.3.1(b)) */
}
else if (designated_port(port_no)) /* (8.6.11.3.2) */
{
stop_message_age_timer(port_no); /* (8.6.11.3.2(a)) */
make_forwarding(port_no); /* (8.6.11.3.2(b)) */
}
else
/* (8.6.11.3.3) */
{
port_info[port_no].config_pending = False; /* (8.6.11.3.3(a)) */
port_info[port_no].topology_change_acknowledge = False;
make_blocking(port_no); /* (8.6.11.3.3(b)) */
}
}
}
/*******************************************************************************
* make_forwarding -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void make_forwarding
(
Int port_no
) /* (8.6.12) */
{
if (port_info[port_no].state == Blocking && \
port_info[port_no].portLinkBlockSet != TRUE) /* (8.6.12.3) */
{
#ifdef ST_FAST
if (stGetPortFast (port_no) == stFastON ||
(stGetUplinkFast () == stFastON && isRootPort (port_no)))
{
set_port_state (port_no, Forwarding); /* PortFast/UplinkFast */
topology_change_detection (); /* (8.6.14.2.2) */
}
else
{
/*
* Do not run UplinkFast/PortFast
*/
set_port_state(port_no, Listening); /* (8.6.12.3.1) */
start_forward_delay_timer(port_no); /* (8.6.12.3.2) */
}
#else
set_port_state(port_no, Listening); /* (8.6.12.3.1) */
start_forward_delay_timer(port_no); /* (8.6.12.3.2) */
#endif /* ST_FAST */
}
#ifdef ST_FAST
else
{
if ((stGetPortFast (port_no) == stFastON &&
port_info[port_no].state != Disabled)
||
(stGetUplinkFast () == stFastON && isRootPort (port_no)))
{
set_port_state (port_no, Forwarding); /* UplinkFast/PortFast */
}
}
#endif /* ST_FAST */
}
/*******************************************************************************
* make_blocking -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void make_blocking
(
Int port_no
) /* (8.6.13) */
{
if ((port_info[port_no].state != Disabled)
&&
(port_info[port_no].state != Blocking)
) /* (8.6.13.3) */
{
if ((port_info[port_no].state == Forwarding)
||
(port_info[port_no].state == Learning)
)
{
if (port_info[port_no].change_detection_enabled == True)
/* (8.5.5.10) */
{
topology_change_detection(); /* (8.6.13.3.1) */
}
}
set_port_state(port_no, Blocking); /* (8.6.13.3.2) */
stop_forward_delay_timer(port_no); /* (8.6.13.3.3) */
}
}
/*******************************************************************************
* set_port_state -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void set_port_state
(
Int port_no,
State_t state
)
{
extern void count_forward_transitions(ulong_t);
if ((state == Forwarding) && (port_info[port_no].state != Forwarding))
{
count_forward_transitions( (ulong_t)port_no );
}
if (((state == Forwarding) && (port_info[port_no].state == Learning)) ||
((state == Blocking) && (port_info[port_no].state == Forwarding)))
{
/* aaaaa sysAgentSend1493Trap(SNMP_TRAP_1493_TOPOLOGY); */
}
/*
* LACP/STP/GARP Integration.
* The followint code has beed added to support Event Detector
* and also to implement what used to be done in pollPortTask
* When port transition in and out of Forwarding, an event needs
* to be signaled (for GARP).
* Also the appManager needs to be Set if at least one port is in
* Forwarding and Cleared when thre are no more ports in Forwarding.
*/
if (state == Forwarding)
{
/*aaaa appManagerSet (APP_MANAGER_STPFWD);*/ /* pollPortTask used to do that */
stpPortBitmask (ADD_PORT, port_no);
/* event that port went into Forwarding */
/*aaaa if (ebIsAnyRecipientWaiting (registrationForward))
ebSignalEvent (registrationForward, (const char *)&port_no,
sizeof (port_no), NULL, NULL); */
}
else
{
stpPortBitmask (REMOVE_PORT, port_no);
if (stpPortBitmask (TEST_BITMAP, port_no) == 0)
{}/* aaaa appManagerClr (APP_MANAGER_STPFWD);*/
/* event that port went out of Forwarding */
/* aaaa if (ebIsAnyRecipientWaiting (registrationNoForward))
ebSignalEvent (registrationNoForward, (const char *)&port_no,
sizeof (port_no), NULL, NULL);*/
}
span_set_port_state(port_no, state);
port_info[port_no].state = state;
}
/*******************************************************************************
* topology_change_detection -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void topology_change_detection
(
void
) /* (8.6.14) */
{
if (root_bridge()) /* (8.6.14.3.1) */
{
bridge_info.topology_change = True; /* (8.6.14.3.1(a)) */
start_topology_change_timer(); /* (8.6.14.3.1(b)) */
}
else if (bridge_info.topology_change_detected == False) /* (8.6.14.3.2) */
{
transmit_tcn(); /* (8.6.14.3.2(a)) */
start_tcn_timer(); /* (8.6.14.3.2(b)) */
}
bridge_info.topology_change_detected = True; /* (8.6.14.3.3) */
span_set_aging(ForwardDelayAging);
count_topology_change(); /* WRS addition (GKW) */
}
/*******************************************************************************
* topology_change_acknowledged -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void topology_change_acknowledged
(
void
) /* (8.6.15) */
{
bridge_info.topology_change_detected = False; /* (8.6.15.3.1) */
span_set_aging(FilterDbaseTime);
stop_tcn_timer(); /* (8.6.15.3.2) */
}
/*******************************************************************************
* acknowledge_topology_change -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void acknowledge_topology_change
(
Int port_no
) /* (8.6.16) */
{
port_info[port_no].topology_change_acknowledge = True; /* (8.6.16.3.1) */
transmit_config(port_no); /* (8.6.16.3.2) */
}
/*******************************************************************************
* received_config_bpdu - Operation of the Protocol (8.7)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void received_config_bpdu
(
Int port_no,
Config_bpdu * config
) /* (8.7.1) */
{
Boolean root;
root = root_bridge();
if (port_info[port_no].state != Disabled &&
(port_info[port_no].portLinkBlockSet != TRUE))
{
if (supersedes_port_info(port_no, config)) /* (8.7.1.1) */
{ /* (8.6.2.2) */
record_config_information(port_no, config); /* (8.7.1.1.1) */
/* (8.6.2.2) */
configuration_update(); /* (8.7.1.1.2) */
/* (8.6.7.2.1) */
port_state_selection(); /* (8.7.1.1.3) */
/* (8.6.11.2.1) */
if ((!root_bridge()) && root) /* (8.7.1.1.4) */
{
stop_hello_timer();
if (bridge_info.topology_change_detected) /* (8.7.1.1.5) */
{
stop_topology_change_timer();
transmit_tcn(); /* (8.6.6.1) */
start_tcn_timer();
}
}
if (port_no == bridge_info.root_port)
{
record_config_timeout_values(config); /* (8.7.1.1.6) */
/* (8.6.3.2) */
config_bpdu_generation(); /* (8.6.4.2.1) */
if (config->topology_change_acknowledgment) /* (8.7.1.1.7) */
{
topology_change_acknowledged(); /* (8.6.15.2) */
}
}
}
else if (designated_port(port_no)) /* (8.7.1.2) */
{
reply(port_no); /* (8.7.1.2.1) */
/* (8.6.5.2) */
}
}
}
/*******************************************************************************
* received_tcn_bpdu -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void received_tcn_bpdu
(
Int port_no,
Tcn_bpdu * tcn
) /* (8.7.2) */
{
#ifdef _lint
tcn = tcn;
#endif
if (port_info[port_no].state != Disabled &&
(port_info[port_no].portLinkBlockSet != TRUE))
{
if (designated_port(port_no))
{
topology_change_detection(); /* (8.7.2.1) */
/* (8.6.14.2.1) */
acknowledge_topology_change(port_no); /* (8.7.2.2) */
} /* (8.6.16.2) */
}
}
/*******************************************************************************
* hello_timer_expiry -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void hello_timer_expiry
(
void
) /* (8.7.3) */
{
config_bpdu_generation(); /* (8.6.4.2.2) */
start_hello_timer();
}
/*******************************************************************************
* message_age_timer_expiry -
*
* INPUTS:
* <parameters and functions>
*
* RETURNS:
* <values modified>
*
* ERRORS:
* <values returned and why (do not include VxWorks ERRNO types here)>
*
* ERRNO:
* <comma separated list of errno values, no comments needed>
*
* SEE_ALSO:
* <optional, cross reference to other modules, subroutines or documentation>
*
* NOMANUAL <this will be removed later>
*/
void message_age_timer_expiry
(
Int port_no
) /* (8.7.4) */
{
Boolean root;
root = root_bridge();
become_designated_port(port_no); /* (8.7.4.1) */
/* (8.6.10.2.1) */
configuration_update(); /* (8.7.4.2) */
/* (8.6.7.2.2) */
port_state_selection(); /* (8.7.4.3) */
/* (8.6.11.2.2) */
if ((root_bridge()) && (!root)) /* (8.7.4.4) */
{
bridge_info.max_age = bridge_info.bridge_max_age; /* (8.7.4.4.1) */
bridge_info.hello_time = bridge_info.bridge_hello_time;
bridge_info.forward_delay = bridge_info.bridge_forward_delay;
topology_change_detection(); /* (8.7.4.4.2) */
/* (8.6.14.2.4) */
stop_tcn_timer(); /* (8.7.4.4.3) */
config_bpdu_generation(); /* (8.7.4.4.4) */
start_hello_timer();
}
}
/*******************************************************************************
* forward_delay_timer_expiry -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -