📄 spanutil.c
字号:
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_port_enable
(
ulong_t port
)
{
ulong_t Rc = (port_info[port].state == Disabled) ?
False: True;
return Rc;
}
/******************************************************************************
* get_stp_port_designated_root - dot1dStpPortDesignatedRoot (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
const uchar_t * get_stp_port_designated_root
(
ulong_t port
)
{
const uchar_t *Rc = (const uchar_t *) &port_info[port].designated_root;
return Rc;
}
/******************************************************************************
* get_stp_port_designated_cost - dot1dStpPortDesignatedCost (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_port_designated_cost
(
ulong_t port
)
{
ulong_t Rc = (ulong_t) port_info[port].designated_cost;
return Rc;
}
/******************************************************************************
* get_stp_port_designated_bridge - dot1dStpPortDesignatedBridge (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
const uchar_t * get_stp_port_designated_bridge
(
ulong_t port
)
{
const uchar_t *Rc = (const uchar_t *) &port_info[port].designated_bridge;
return Rc;
}
/******************************************************************************
* get_stp_port_designated_port - dot1dStpPortDesignatedPort (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
const uchar_t * get_stp_port_designated_port
(
ulong_t port
)
{
const uchar_t *Rc = (const uchar_t *) &port_info[port].designated_port;
return Rc;
}
/******************************************************************************
* get_stp_port_forward_transitions - dot1dStpPortForwardTransitions (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_port_forward_transitions
(
ulong_t port
)
{
stp_init_ports();
return forwarding_transition_count[port];
}
/******************************************************************************
* count_forward_transitions - <one-line description of subroutine's purpose>
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void count_forward_transitions
(
ulong_t port
)
{
stp_init_ports();
forwarding_transition_count[port]++;
}
/******************************************************************************
* get_span_tree_enable - This is the RW global spanning tree enable/disable
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_span_tree_enable
(
void
)
{
ulong_t Rc;
Rc = (get_stp_global_enable() == True) ?
True : False;
return Rc;
}
/******************************************************************************
* set_span_tree_enable - <one-line description of subroutine's purpose>
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void set_span_tree_enable
(
ulong_t state
)
{
set_stp_global_enable(state);
}
/******************************************************************************
* get_stp_protocol_state - <one-line description of subroutine's purpose>
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_protocol_state
(
ulong_t port
)
{
#if 0
ulong_t Rc = (port_info[port].protocol_enabled == False) ?
Edot1dStpPortEnable_disabled : Edot1dStpPortEnable_enabled;
return Rc; aaaa
#endif
}
/******************************************************************************
* spanTreeNumPorts - <one-line description of subroutine's purpose>
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
extern int totalPort;
ulong_t spanTreeNumPorts
(
void
)
{
ulong_t Rc = totalPort;
return Rc;
}
/******************************************************************************
* isRootPort - returns true if the port is the root port.
*
* INPUTS:
*
* RETURNS: TRUE if port is the root port.
*/
ulong_t isRootPort
(
ulong_t port
)
{
return (bridge_info.root_port == port);
}
/******************************************************************************
* stGetUplinkFast - check whether the UplinkFast is enabled or not.
*
* INPUTS: port number
*
* RETURNS: stFastON/stFastOFF
*
* ERRORS: none
*
* ERRNO: none
*
* SEE_ALSO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t stGetUplinkFast
(
void
)
{
return (stUplinkFastState);
}
/******************************************************************************
* stSetUplinkFast - sets the UplinkFast
*
* INPUTS: state (stFastON/stFastOFF)
*
* RETURNS: state (stFastON/stFastOFF)
*
* ERRORS: none
*
* ERRNO: none
*
* SEE_ALSO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t stSetUplinkFast
(
ulong_t state
)
{
stUplinkFastState = state;
return (stUplinkFastState);
}
/******************************************************************************
* stPortFastInit - Initialize the FastPort settings
*
* INPUTS: none
*
* RETURNS: OK/ERROR
*
* ERRORS: none
*
* ERRNO: none
*
* SEE_ALSO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t stPortFastInit
(
void
)
{
int i;
if (stPortFastInitDone)
return (OK);
stPortFastState = (ulong_t *)malloc ((No_of_ports+1) * sizeof (ulong_t));
for (i = 0; i < (No_of_ports+1); i++)
stPortFastState [i] = stFastOFF;
stPortFastInitDone = 1;
return (OK);
}
/******************************************************************************
* stUplinkFastInit - Initialize the UplinkFast settings
*
* INPUTS: none
*
* RETURNS: OK/ERROR
*
* ERRORS: none
*
* ERRNO: none
*
* SEE_ALSO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t stUplinkFastInit
(
void
)
{
return (OK);
}
/******************************************************************************
* stGetPortFast - check whether the PortFast is enabled or not.
*
* INPUTS: port number
*
* RETURNS: OFF/ ON
*
* ERRORS: none
*
* ERRNO: none
*
* SEE_ALSO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t stGetPortFast
(
ulong_t port
)
{
return (stPortFastState [port]);
}
/******************************************************************************
* stSetPortFast - Set the PortFast ON or OFF
*
* INPUTS: port number, state
*
* RETURNS: stFastOFF/ stFastON
*
* ERRORS: none
*
* ERRNO: none
*
* SEE_ALSO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t stSetPortFast
(
ulong_t port,
ulong_t state /* stFastOFF/ stFastON */
)
{
stPortFastState [port] = state;
return (stPortFastState [port]);
}
char * SHOW_STA_STATE[] = {
"DISABLED ", "LISTENING ", "LEARNING ",
"FORWARDING", "BLOCKING ", "DISABLED ", "BROKEN "
};
void stShow ()
{
int i; /* a logical port number */
int iPortFast;
unsigned char *u8p;
/* can't printf a string of '*', confuses mangen */
printf ("\n");
for(i=0; i<68; i++)
printf("*");
u8p = (unsigned char *)get_stp_designated_root ();
printf ("\n RootID: %02x%02x%02x%02x%02x%02x%02x%02x",
u8p [0] & 0xff, u8p [1] & 0xff,
u8p [2] & 0xff, u8p [3] & 0xff,
u8p [4] & 0xff, u8p [5] & 0xff,
u8p [6] & 0xff, u8p [7] & 0xff
);
printf (" BridgeID: %02x%02x%02x%02x%02x%02x%02x%02x",
(unsigned int)((bridge_info.bridge_id.priority >> 8) & 0x00ff),
(unsigned int)(bridge_info.bridge_id.priority & 0x00ff),
(unsigned int)(bridge_info.bridge_id.mac[0] & 0x00ff),
(unsigned int)(bridge_info.bridge_id.mac[1] & 0x00ff),
(unsigned int)(bridge_info.bridge_id.mac[2] & 0x00ff),
(unsigned int)(bridge_info.bridge_id.mac[3] & 0x00ff),
(unsigned int)(bridge_info.bridge_id.mac[4] & 0x00ff),
(unsigned int)(bridge_info.bridge_id.mac[5] & 0x00ff));
printf (" RPC = %d", (int) get_stp_root_cost ());
if (get_stp_global_enable () == True)
{
printf ("\n Spanning Tree ENABLED");
#ifdef ST_FAST
if (stGetUplinkFast () == stFastON)
printf (" fastUplink ENABLED");
else
printf (" fastUplink DISABLED");
#else
printf (" UplinkFast NA ");
#endif /* ST_FAST */
}
else
printf ("\n Spanning Tree DISABLED");
printf (" Top. Change = %d", (int) bridge_info.topology_change);
printf ("\n Max Age = %d, Forw. Del = %d, Hold Time = %d",
bridge_info.max_age, bridge_info.forward_delay,
bridge_info.hold_time);
printf ("\n--------------------------------------------------------------------");
printf ("\n port portState state Pcost Dcost Priority portF Protocol ATime");
printf ("\n--------------------------------------------------------------------");
for (i = 1; i <= No_of_ports; i++)
{
printf ("\n %-3d %-10s ", i,
SHOW_STA_STATE[port_info[i].state]);
if (isRootPort (i))
printf ("R ");
else if (designated_port (i))
printf ("D ");
else
printf ("B ");
printf ("%-5d %-5d", (int)get_stp_port_path_cost (i),
(int)get_stp_port_designated_cost (i));
printf (" %-6d ", (int)get_stp_port_priority (i));
iPortFast = stGetPortFast (i);
#ifdef ST_FAST
if (iPortFast == stFastOFF)
printf (" %-4s", "OFF");
else if (iPortFast == stFastON)
printf (" %-4s", "ON ");
else
printf (" %-4s", "? ");
#else
printf (" %-4s", "NA ");
#endif /* ST_FAST */
if (port_info [i].protocol_enabled == True)
printf (" Enabled ");
else
printf (" Disabled ");
if (message_age_timer[i].active)
{
printf ("A ");
printf ("%d", message_age_timer[i].value);
}
else
printf ("N ");
}
printf ("\n--------------------------------------------------------------------\n");
}
/*lint -e(766) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -