?? spanutil.c
字號:
/* spanUtil - Spanning Tree internal utility routines */
/* Copyright 2001 Wind River Systems, Inc. */
/* Copyright 1998-2000 Wind River Systems, Inc. */
/* Copyright 1999 Wind River Systems, Inc. */
/* Copyright 1998-1999 XACT, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01g,18apr01,kc Replaced "extern" with "IMPORT" and "static" with "LOCAL".
01f,22feb01,kw Fixed the STP formalus validation rules.
01e,10dec00,ajw Changes to comments for refgen web pages
01d,16nov00,kw Ran thru lint.
01c,26jul00,kw Convert from zero index base scalars to 1 based index.
01b,18oct99,kw Added a forwarding_transition_counter for each port. PR#872
01a,17sep99,kw added support for BL2 PR#713
*/
/*
DESCRIPTION
The routines in this midule interface the low level Spanning Tree to stpMib.
INCLUDES:
\ml
\m tmsTypes.h
\m spantree.h
\m idbObjectEnums.idb
\me
*/
/* includes */
#include <stp/types.h>
#include <stp/spantree.h>
/*#include <stp/stpMib.h> */
/* defines */
/* typedefs */
/* locals */
LOCAL ulong_t topology_change_count;
LOCAL ulong_t * forwarding_transition_count;
/*
* UplinkFast/PortFast
*/
LOCAL ulong_t stUplinkFastState;
LOCAL ulong_t *stPortFastState;
LOCAL ulong_t stPortFastInitDone = 0;
/* globals */
IMPORT Bridge_data bridge_info; /* (8.5.3) */
IMPORT Port_data *port_info; /* (8.5.5) */
IMPORT Boolean designated_port (Int port_no);
IMPORT Timer* message_age_timer;
/* forward declarations */
extern STATUS No_of_ports;
LOCAL void stp_init_ports()
{
if ( forwarding_transition_count == NULL )
{
topology_change_count = 0;
forwarding_transition_count =
(ulong_t *)calloc( (spanTreeNumPorts() + 1), sizeof(ulong_t) );
}
}
/******************************************************************************
* get_stp_protocol_spec - dot1dStpProtocolSpecification (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_protocol_spec
(
void
)
{
return 3;
}
/******************************************************************************
* get_stp_time_since_topology_change - dot1dStpTimeSinceTopologyChange (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_time_since_topology_change
(
void
)
{
IMPORT Timer since_topology_change;
return since_topology_change.value;
}
/******************************************************************************
* count_topology_change - dot1dStpTopChanges (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void count_topology_change
(
void
)
{
topology_change_count++;
}
/******************************************************************************
* get_stp_topology_change_count -
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_topology_change_count
(
void
)
{
return topology_change_count;
}
/******************************************************************************
* get_stp_designated_root - dot1dStpDesignatedRoot (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
const uchar_t * get_stp_designated_root
(
void
)
{
const uchar_t *Rc = (const uchar_t *) &bridge_info.designated_root;
return Rc;
}
/******************************************************************************
* get_stp_root_cost - dot1dStpRootCost (RO)
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_root_cost
(
void
)
{
ulong_t Rc = (ulong_t) bridge_info.root_path_cost;
return Rc;
}
/******************************************************************************
* get_stp_root_port - dot1dStpRootPort (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_root_port
(
void
)
{
ulong_t Rc = (ulong_t) bridge_info.root_port;
return Rc;
}
/******************************************************************************
* get_stp_max_age - dot1dStpMaxAge (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_max_age
(
void
)
{
ulong_t Rc = (ulong_t) bridge_info.max_age;
return Rc;
}
/******************************************************************************
* get_stp_hello_time - dot1dStpHelloTime (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_hello_time
(
void
)
{
ulong_t Rc = (ulong_t) bridge_info.hello_time;
return Rc;
}
/******************************************************************************
* get_stp_hold_time - dot1dStpHoldTime (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_hold_time
(
void
)
{
return FIXED_HOLD_TIME;
}
/******************************************************************************
* get_stp_forward_delay - dot1dStpForwardDelay (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_forward_delay
(
void
)
{
ulong_t Rc = (ulong_t) bridge_info.forward_delay;
return Rc;
}
/******************************************************************************
* get_stp_bridge_max_age - dot1dStpBridgeMaxAge (RW)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_bridge_max_age
(
void
)
{
ulong_t Rc = (ulong_t) bridge_info.bridge_max_age;
return Rc;
}
/******************************************************************************
* set_stp_bridge_max_age - <one-line description of subroutine's purpose>
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void set_stp_bridge_max_age
(
ulong_t max_age,
Boolean startup
)
{
/* Value must be valid or it gets set to the default. */
if ( max_age >= (2 * (bridge_info.bridge_hello_time + 1)) )
{
bridge_info.bridge_max_age = (Time_t) max_age;
bridge_info.topology_change_time =
bridge_info.bridge_max_age + bridge_info.bridge_forward_delay;
if (startup == False)
{
span_update_bridge_parms();
}
}
}
/******************************************************************************
* get_stp_bridge_hello_time - dot1dStpBridgeHelloTime (RW)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_bridge_hello_time
(
void
)
{
ulong_t Rc = (ulong_t) bridge_info.bridge_hello_time;
return Rc;
}
/******************************************************************************
* set_stp_bridge_hello_time - <one-line description of subroutine's purpose>
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void set_stp_bridge_hello_time
(
ulong_t hello_time,
Boolean startup
)
{
bridge_info.bridge_hello_time = (Time_t) hello_time;
if (startup == False)
{
span_update_bridge_parms();
}
}
/******************************************************************************
* get_stp_bridge_forward_delay - dot1dStpBridgeForwardDelay (RW)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_bridge_forward_delay
(
void
)
{
ulong_t Rc = (ulong_t) bridge_info.bridge_forward_delay;
return Rc;
}
/******************************************************************************
* set_stp_bridge_forward_delay - <one-line description of subroutine's purpose>
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
void set_stp_bridge_forward_delay
(
ulong_t forward_delay,
Boolean startup
)
{
/* forward_delay must be valid to STP formalus */
if ( (2 * (forward_delay - 1)) >= bridge_info.bridge_max_age )
{
bridge_info.bridge_forward_delay = (Time_t) forward_delay;
bridge_info.topology_change_time =
bridge_info.bridge_max_age + bridge_info.bridge_forward_delay;
if (startup == False)
{
span_update_bridge_parms();
}
}
}
/******************************************************************************
* get_stp_port - dot1dStpPort (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_port
(
ulong_t port
)
{
return port; /* This is a 1-1 mapping for now */
}
/******************************************************************************
* get_stp_port_state - dot1dStpPortState (RO)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
* NOMANUAL <this will be removed later>
*/
ulong_t get_stp_port_state
(
ulong_t port
)
{
ulong_t Rc;
Rc=port_info[port].state;
return Rc;
}
/******************************************************************************
* get_stp_port_enable - dot1dStpPortEnable (RW)
*
* INPUTS:
*
* RETURNS:
*
* ERRORS:
*
* ERRNO:
*
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -