📄 stp-8021d-d17.c
字号:
*/
void forward_delay_timer_expiry
(
Int port_no
) /* (8.7.5) */
{
if (port_info[port_no].state == Listening) /* (8.7.5.1) */
{
#ifdef ST_FAST
if (stGetPortFast (port_no) == stFastON ||
(stGetUplinkFast () == stFastON && isRootPort (port_no)))
{
/*
* Run UplinkFast/PortFast
*/
set_port_state (port_no, Forwarding); /* UplinkFast/PortFast */
topology_change_detection (); /* (8.6.14.2.2) */
}
else
{
set_port_state(port_no, Learning); /* (8.7.5.1.1) */
start_forward_delay_timer(port_no); /* (8.7.5.1.2) */
}
#else
set_port_state(port_no, Learning); /* (8.7.5.1.1) */
start_forward_delay_timer(port_no); /* (8.7.5.1.2) */
#endif /* ST_FLAG */
}
else if (port_info[port_no].state == Learning) /* (8.7.5.2) */
{
set_port_state(port_no, Forwarding); /* (8.7.5.2.1) */
if (designated_for_some_port()) /* (8.7.5.2.2) */
{
if (port_info[port_no].change_detection_enabled == True)
/* (8.5.5.10) */
{
topology_change_detection(); /* (8.6.14.2.2) */
return;
}
}
}
}
/*******************************************************************************
* designated_for_some_port -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
Boolean designated_for_some_port
(
void
)
{
Int port_no;
for (port_no = One; port_no <= No_of_ports; port_no++)
{
if (id_eq(port_info[port_no].designated_bridge, bridge_info.bridge_id))
{
return (True);
}
}
return (False);
}
/*******************************************************************************
* tcn_timer_expiry -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void tcn_timer_expiry
(
void
) /* (8.7.6) */
{
transmit_tcn(); /* (8.7.6.1) */
start_tcn_timer(); /* (8.7.6.2) */
}
/*******************************************************************************
* topology_change_timer_expiry -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void topology_change_timer_expiry
(
void
) /* (8.7.7) */
{
bridge_info.topology_change_detected = False; /* (8.7.7.1) */
span_set_aging(FilterDbaseTime);
bridge_info.topology_change = False; /* (8.7.7.2) */
}
/*******************************************************************************
* hold_timer_expiry -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void hold_timer_expiry
(
Int port_no
) /* (8.7.8) */
{
if (port_info[port_no].config_pending)
{
transmit_config(port_no); /* (8.6.1.2.3) */
}
}
/** Management of the Bridge Protocol Entity (8.8) **/
/*******************************************************************************
* span_init - initialize Bridge Protocol Entity management
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void span_init
(
void
) /* initialization() *//* (8.8.1) */
{
Int port_no;
/* (8.8.1.1) */
id_equate(bridge_info.designated_root, bridge_info.bridge_id);
bridge_info.root_path_cost = Zero;
bridge_info.root_port = No_port;
bridge_info.max_age = bridge_info.bridge_max_age; /* (8.8.1.2) */
bridge_info.hello_time = bridge_info.bridge_hello_time;
bridge_info.forward_delay = bridge_info.bridge_forward_delay;
bridge_info.topology_change_detected = False; /* (8.8.1.3) */
span_set_aging(FilterDbaseTime);
bridge_info.topology_change = False;
stop_tcn_timer();
stop_topology_change_timer();
for (port_no = One; port_no <= No_of_ports; port_no++) /* (8.8.1.4) */
{
initialize_port(port_no);
}
port_state_selection(); /* (8.8.1.5) */
config_bpdu_generation(); /* (8.8.1.6) */
start_hello_timer();
}
/*******************************************************************************
* initialize_port -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void initialize_port
(
Int port_no
)
{
ulong_t portEnable = True;
become_designated_port(port_no); /* (8.8.1.4.1) */
portEnable = get_stp_port_enable((ulong_t)port_no);
if (portEnable == False) /* 1 is enabled 2 is disabled */
{
if (get_stp_port_state((ulong_t)port_no) != 0)
{ /* Don't set them if they're already disabled */
set_port_state(port_no, Disabled);
}
}
else if (get_span_tree_enable() == False)
{
set_port_state(port_no, Forwarding);
}
else
{
set_port_state(port_no, Blocking); /* (8.8.1.4.2) */
}
port_info[port_no].topology_change_acknowledge = False;
/* (8.8.1.4.3) */
port_info[port_no].config_pending = False; /* (8.8.1.4.4) */
port_info[port_no].change_detection_enabled = True; /* (8.8.1.4.8) */
stop_message_age_timer(port_no); /* (8.8.1.4.5) */
stop_forward_delay_timer(port_no); /* (8.8.1.4.6) */
stop_hold_timer(port_no); /* (8.8.1.4.7) */
}
/*******************************************************************************
* enable_port -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void enable_port
(
Int port_no
) /* (8.8.2) */
{
initialize_port(port_no);
port_state_selection(); /* (8.8.2.7) */
}
/*******************************************************************************
* disable_port -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void disable_port
(
Int port_no
) /* (8.8.3) */
{
Boolean root;
root = root_bridge();
become_designated_port(port_no); /* (8.8.3.1) */
set_port_state(port_no, Disabled); /* (8.8.3.2) */
port_info[port_no].topology_change_acknowledge = False; /* (8.8.3.3) */
port_info[port_no].config_pending = False; /* (8.8.3.4) */
stop_message_age_timer(port_no); /* (8.8.3.5) */
stop_forward_delay_timer(port_no); /* (8.8.3.6) */
configuration_update(); /* (8.8.3.7) */
port_state_selection(); /* (8.8.3.8) */
if ((root_bridge()) && (!root)) /* (8.8.3.9) */
{
bridge_info.max_age = bridge_info.bridge_max_age; /* (8.8.3.9.1) */
bridge_info.hello_time = bridge_info.bridge_hello_time;
bridge_info.forward_delay = bridge_info.bridge_forward_delay;
topology_change_detection(); /* (8.8.3.9.2) */
stop_tcn_timer(); /* (8.8.3.9.3) */
config_bpdu_generation(); /* (8.8.3.9.4) */
start_hello_timer();
}
}
/*******************************************************************************
* set_bridge_priority -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void set_bridge_priority
(
Identifier new_bridge_id
) /* (8.8.4) */
/* (8.8.4.1) */
{
Boolean root;
Int port_no;
root = root_bridge();
for (port_no = One; port_no <= No_of_ports; port_no++) /* (8.8.4.2) */
{
if (designated_port(port_no))
{
id_equate(port_info[port_no].designated_bridge, new_bridge_id);
}
}
id_equate(bridge_info.bridge_id, new_bridge_id); /* (8.8.4.3) */
configuration_update(); /* (8.8.4.4) */
port_state_selection(); /* (8.8.4.5) */
if ((root_bridge()) && (!root)) /* (8.8.4.6) */
{
bridge_info.max_age = bridge_info.bridge_max_age; /* (8.8.4.6.1) */
bridge_info.hello_time = bridge_info.bridge_hello_time;
bridge_info.forward_delay = bridge_info.bridge_forward_delay;
topology_change_detection(); /* (8.8.4.6.2) */
stop_tcn_timer(); /* (8.8.4.6.3) */
config_bpdu_generation(); /* (8.8.4.6.4) */
start_hello_timer();
}
}
/*******************************************************************************
* set_port_priority -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void set_port_priority
(
Int port_no,
Port_id new_port_id
) /* (8.8.5) */
/* (8.8.5.1) */
{
if (designated_port(port_no)) /* (8.8.5.2) */
{
port_info[port_no].designated_port = new_port_id;
}
port_info[port_no].port_id = new_port_id; /* (8.8.5.3) */
if (id_eq(bridge_info.bridge_id, /* (8.8.5.4) */
port_info[port_no].designated_bridge)
&&
(port_info[port_no].port_id
< port_info[port_no].designated_port
)
)
{
become_designated_port(port_no); /* (8.8.5.4.1) */
port_state_selection(); /* (8.8.5.4.2) */
}
}
/*******************************************************************************
* set_path_cost -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void set_path_cost
(
Int port_no,
Cost_t path_cost
) /* (8.8.6) */
{
port_info[port_no].path_cost = path_cost; /* (8.8.6.1) */
configuration_update(); /* (8.8.6.2) */
port_state_selection(); /* (8.8.6.3) */
}
/*******************************************************************************
* enable_change_detection -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void enable_change_detection
(
Int port_no
) /* (8.8.7) */
{
port_info[port_no].change_detection_enabled = True;
}
/*******************************************************************************
* disable_change_detection -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void disable_change_detection
(
Int port_no
) /* (8.8.8) */
{
port_info[port_no].change_detection_enabled = False;
}
/*******************************************************************************
* span_tick -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void span_tick
(
void
)
{
Int port_no;
/* Called every second, so 100th of a second. */
if ( since_topology_change.active )
since_topology_change.value += 100;
if (hello_timer_expired())
{
hello_timer_expiry();
}
if (tcn_timer_expired())
{
tcn_timer_expiry();
}
if (topology_change_timer_expired())
{
topology_change_timer_expiry();
}
for (port_no = One; port_no <= No_of_ports; port_no++)
{
if (message_age_timer_expired(port_no))
{
message_age_timer_expiry(port_no);
}
}
for (port_no = One; port_no <= No_of_ports; port_no++)
{
if (forward_delay_timer_expired(port_no))
{
forward_delay_timer_expiry(port_no);
}
if (hold_timer_expired(port_no))
{
hold_timer_expiry(port_no);
}
}
}
/*******************************************************************************
* start_hello_timer -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -