📄 ospf_mib_helper_update.c
字号:
#include <stdlib.h>#include <semLib.h>#include <lstLib.h>#include <avlLib.h>/* WindNet OSPF includes */#include "ospf.h"#include "ospf_enums.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//* management interface includes */#include "rowStatusLib.h"#include "mibApi.h"#include "ospf_mib_helper.h"#include "ospf_mib_helper_update.h"#include "ospf_mib_api.h"#include "ospf_mib_wrn_helper.h"/* public data *//* private data */LOCAL BOOL ospf2MapiInitDone = FALSE; /* flag to check if ospf2Mapi is initialized */LOCAL BOOL ospfStartupInvoked = FALSE; /* if true, ospf_startup is invoked by MIB API */LOCAL BOOL ospfMapiShutdownInProgress = FALSE; /* shutdown process in progress */LOCAL int ospfRestartCnt = 0; /* counter to keep track ospf startup/restart *//* the priority for the "tOspf2Mapi" task. This priority must be somewhat higher than * the ospf receive task in order to allow the "tOspf2Mapi" to be always ahead of * ospf when processing the operational status and statistical updates so that there * will always be free buffer available in the ospf2Mapi memory pool. */#define OSPF2MAPI_TASK_PRIORITY 150/* stack size allocated for the tOspf2Mapi task. * SPR#87023 - increases the stack size allocated from 4K to 8K */#define OSPF2MAPI_TASK_STACK_SIZE 8 * 1024typedef struct ospf2MapiRequest{ SEM_ID ospf2MapiBSemId; /* binary semaphore to ensure mutual exclusion */ SEM_ID ospf2MapiCntSemId; /* couting semaphore */ ulong_t ospf2MapiMaxNodeCnt; /* number of ospf2MapiReqBuf_t nodes to allocate */ ulong_t ospf2MapiCurrNodeCnt; /* number of ospf2MapiReqBuf_t nodes used */ LIST ospf2MapiFreePoolList; /* free ospf2MapiReqBuf_t pool list */ LIST ospf2MapiRecvList; /* linked list used by tOspf2Mapi task and OSPF */ int ospf2MapiTaskId; /* task id for tOspf2Mapi */ ulong_t ospf2MapiReqCnt; /* number of requests from ospf */ ulong_t ospf2MapiReqProcessed; /* number of request tOspf2Mapi task processed */ ulong_t ospf2MapiFailedCnt; /* number of times we failed to allocate memory */ BOOL ospf2MapiFreePoolListInited; /* free pool list is inited */ BOOL ospf2MapiRecvListInited; /* recv list is inited */} ospf2MapiRequest_t;LOCAL ospf2MapiRequest_t *pOspf2MapiReq;/***** private management misc method routines used by MIB API and OSPF *****//**************************************************************************************** ospf2Mapi_bool2StatusGet - convert boolean to mApiOspfStatus_t status value** This routine converts the boolean flag used by OSPF to the mApiOspfStatus_t as defined* in the RFC1850 MIB** RETURNS: mApiOspfStatus_t** NOMANUAL*/LOCAL mApiOspfStatus_t ospf2Mapi_bool2StatusGet( BYTE_ENUM (BOOLEAN) flag ){ return ( flag == TRUE ? EmApiOspf_enabled : EmApiOspf_disabled );}/**************************************************************************************** mApi2Ospf_status2BoolGet - convert mApiOspfStatus_t status value to boolean flag** This routine converts the mApiOspfStatus_t as defined in the RFC1850 MIB to boolean* flag used by OSPF** RETURNS: mApiOspfStatus_t** NOMANUAL*/LOCAL enum BOOLEAN mApi2Ospf_status2BoolGet( mApiOspfStatus_t status ){ return ( status == EmApiOspf_enabled ? TRUE : FALSE );}/**************************************************************************************** mApi2Ospf_trueValue2BoolGet - convert mApiOspfStatus_t status value to boolean** This routine converts the mApiOspfStatus_t status value to the boolean flag used* by OSPF** RETURNS: TRUE or FALSE** NOMANUAL*/LOCAL enum BOOLEAN mApi2Ospf_trueValue2BoolGet( mApiOspfTrueValue_t status ){ return ( status == EmApiOspf_true ? TRUE : FALSE );}/***************************************************************************************** ospf2Mapi_getNbrPermanence - get MIB API nbmaNbrPermanence option** This routine convert the OSPF nbmaNbrPermanence boolean to the MIB API* nbmaNbrPermanence option.** RETURNS: mApiOspfNbmaNbrPermanence_t** NOMANUAL*/LOCAL mApiOspfNbmaNbrPermanence_t ospf2Mapi_getNbrPermanence( BOOL ospfNbmaNbrPermanence ){ return ( ospfNbmaNbrPermanence == TRUE ? EmApiOspfNbmaNbrPermanence_permanent : EmApiOspfNbmaNbrPermanence_dynamic );}/***************************************************************************************** ospf2Mapi_bool2AggregateEffectGet - convert boolean to mApiOspfAggregateEffect_t value** This routine converts the boolean flag used by OSPF to the MIB API* mApiOspfAggregateEffect_t enumeration value.** RETURNS: mApiOspfAggregateEffect_t** NOMANUAL*/LOCAL mApiOspfAggregateEffect_t ospf2Mapi_bool2AggregateEffectGet( enum BOOLEAN advertised ){ return ( advertised == TRUE ? EmApiOspfAggregateEffect_advertiseMatching: EmApiOspfAggregateEffect_doNotAdvertiseMatching );}/**************************************************************************************** mApi2Ospf_aggregateEffect2BoolGet - convert mApiOspfAggregateEffect_t value to boolean** This routine converts the mApiOspfAggregateEffect_t value to the boolean flag used* by OSPF** RETURNS: TRUE or FALSE** NOMANUAL*/LOCAL enum BOOLEAN mApi2Ospf_aggregateEffect2BoolGet( mApiOspfAggregateEffect_t effect ){ return (effect == EmApiOspfAggregateEffect_advertiseMatching ? TRUE : FALSE );}/**************************************************************************************** mApi2Ospf_ifTypeGet - convert mApiOspfIfType_t to OSPF Interface enum value** This routine converts the mApiOspfIfType_t used by MIB API to the OSPF Interface* enumeration value defined by OSPF Protocol.** RETURNS: OSPF_INTERFACE_TYPE enum** NOMANUAL*/LOCAL enum OSPF_INTERFACE_TYPE mApi2Ospf_ifTypeGet( mApiOspfIfType_t ifType ){ enum OSPF_INTERFACE_TYPE ospfIfType; switch( ifType ) { case EmApiOspfIfType_broadcast: ospfIfType = OSPF_BROADCAST; break; case EmApiOspfIfType_nbma: ospfIfType = OSPF_NBMA; break; case EmApiOspfIfType_pointToPoint: ospfIfType = OSPF_POINT_TO_POINT; break; case EmApiOspfIfType_pointToMultipoint: ospfIfType = OSPF_POINT_TO_MULTIPOINT; default: ospfIfType = 0; break; } return ospfIfType;}/***************************************************************************************** ospf2Mapi_ifStateGet - convert OSPF Interface State enum value to mApiOspfIfState_t** This routine converts the OSPF Interface State enumberation value to the* mApiOspfIfState_t used by MIB API** RETURNS: mApiOspfIfState_t or 0 (if interface state is invalid)** NOMANUAL*/LOCAL mApiOspfIfState_t ospf2Mapi_ifStateGet( enum OSPF_INTERFACE_STATE ospfIfState ){ mApiOspfIfState_t ifState; switch( ospfIfState ) { case OSPF_INTERFACE_IS_DOWN: ifState = EmApiOspfIfState_down; break; case OSPF_INTERFACE_LOOPBACK: ifState = EmApiOspfIfState_loopback; break; case OSPF_INTERFACE_WAITING: ifState = EmApiOspfIfState_waiting; break; case OSPF_INTERFACE_POINT_TO_POINT: ifState = EmApiOspfIfState_pointToPoint; break; case OSPF_INTERFACE_DESIGNATED_ROUTER_OTHER: ifState = EmApiOspfIfState_otherDesignatedRouter; break; case OSPF_INTERFACE_BACKUP_DESIGNATED_ROUTER: ifState = EmApiOspfIfState_backupDesignatedRouter; break; case OSPF_INTERFACE_DESIGNATED_ROUTER: ifState = EmApiOspfIfState_designatedRouter; break; default: ifState = 0; break; } return ifState;}/**************************************************************************************** ospf2Mapi_nbrStateGet - convert OSPF Neighbor State enum value to mApiOspfNbrState_t** This routine converts the OSPF Neighbor State enumeration value to the* mApiOspfNbrState_t used by MIB API** RETURNS: mApiOspfNbrState_t or 0 (if neighbor state is invalid)** NOMANUAL*/LOCAL mApiOspfNbrState_t ospf2Mapi_nbrStateGet( enum OSPF_NEIGHBOR_STATE ospfNbrState ){ mApiOspfNbrState_t nbrState; switch( ospfNbrState ) { case OSPF_NEIGHBOR_DOWN: nbrState = EmApiOspfNbrState_down; break; case OSPF_NEIGHBOR_ATTEMPT: nbrState = EmApiOspfNbrState_attempt; break; case OSPF_NEIGHBOR_INITIALIZING: nbrState = EmApiOspfNbrState_init; break; case OSPF_NEIGHBOR_2_WAY: nbrState = EmApiOspfNbrState_twoWay; break; case OSPF_NEIGHBOR_EXCHANGE_START: nbrState = EmApiOspfNbrState_exchangeStart; break; case OSPF_NEIGHBOR_EXCHANGE: nbrState = EmApiOspfNbrState_exchange; break; case OSPF_NEIGHBOR_LOADING: nbrState = EmApiOspfNbrState_loading; break; case OSPF_NEIGHBOR_FULL: nbrState = EmApiOspfNbrState_full; break; default: nbrState = 0; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -