?? ospf_mib_api.c
字號:
/* ospf_mib_api.c - OSPF version 2.0 MIB Management Interface *//* Copyright 1998-2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------03q,04jun03,asr Changed back to use system memory instead of OSPF memory partition03p,02jun03,ram Changed native memory usage to OSPF memory partition03o,23may03,asr Changes to make OSPF virtual stack compatible03n,28feb03,kc Fixed SPR#86505 - modified per new mibApi.h header file updates. Renamed MAPI_COMMIT_NVM and MAPI_GET_NVM mApiReqType_t request type to MAPI_COMMIT_FORCE and MAPI_GET_FORCE respectively.03m,28feb03,kc Fixed SPR#86502 - Added INCLUDE_OSPF_MIB_UTILITIES component init to ospfMapiInit(). Also renamed INCLUDE_OSPF_SHOW_ROUTINES component to INCLUDE_OSPF_MIB_SHOW_ROUTINES.03l,03feb03,kc Fixed SPR#85865 - modified ospfMapiSetGenGroup() to return error immediately if mApi2Ospf_configGenGroup() failed.03k,01feb03,kc Added refgen documentation - describes the usage and provides examples for how to use the ospfMapiSetHelper() routine.03j,31jan03,kc Fixed SPR#86007 - added ospfMapiSetHelper() routine.03i,17jan03,kc Fixed SPR#85806 - modified the for-loop for processing the object(s) from the request list in ospf_mApi_processSetReq() to set the value of the currObjInProcess correctly.03i,12dec02,mwv Fix compiler warning03h,19nov02,mwv Merge TMS code SPR 8428403g,12nov02,kc Added ospfMapiIsInited() routine. Also redefine OSPF_MAPI_INIT_CHECK macro so that it looks like a function call.03f,08oct02,agi Fixed compiler warnings03e,20sep02,kc Fixed SPR#77551 - changed returned status for ospfMapiDestroy() and modified the routine to disallow the mib api to be destroyed if the OSPF protocol is up running.03d,20sep02,kc Modified ospf_mApi_processGetReq() to sanity check the instanceLen for the given index values for the MAPI_GET and MAPI_GET requests.03c,09aug02,kc Fixed wrnOspf_mApi_ifIndexSet() to correctly set the next index value for wrnOspfIfTable. Modified ospf_mApi_processSetReq() to validate the function pointer before using it. 03b,17jun02,kc Modified ospf_mApi_processSetReq() to remember the running count for the current object in the varbind list that is currently processed.03a,21may02,kc Fixed NULL pointer access problem in ospf_mApi_processSetReq(), ospf_mApi_processGetReq(), ospf_rs2mApi_errorGet(), ospfMapixxxGenGroup() and ospfMapixxxWrnGenGroup().02z,15apr02,kc Renamed MAPI_NVM_SET to MAPI_COMMIT_NVM and pCookie pointer to pReqCookie pointer per mibApi.h update. Added support for the MAPI_GET_NVM mApiRequest_t.02y,10apr02,kc Added net/if.h include. Removed ospf2Mapi_destroy() from ospfMapiDestroy().02x,10apr02,kc Remerged changes for unnumbered interface support.02w,26mar02,kc Added ospfMapiDebug and ospfMapiErrorDebug global variables to allow the debug messages to be turn on/off at runtime via command line.02v,24mar02,kc Moved ospf2Mapi_init() call from ospfMapiInit() to ospf2Mapi_proto_register(). The "tOspf2Mapi" task shouldn't be spawned if the ospf protocol is not running.02u,23mar02,kc MIB API no longer automatically create the OSPF backbone area when it is first initialized.02t,22feb02,kc Renamed all public MIB API functions using WRS naming convention.02s,13feb02,kc Modified ospf_mApi_processSetReq() to remember the mib api request type it is currently processed.02r,07feb02,kc Modified ospf_mApi_processSetReq(), ospf_mApi_setGenGroup() and wrnOspf_mApi_setGenGroup() to track the nvm set failure.02q,02feb02,kc Modified ospf_mApi_processSetReq(), ospf_mApi_setGenGroup() and wrnOspf_mApi_setGenGroup() to invoke nvram callback routine only if the request is not intiated by nvram.02p,02feb02,kc Fixed ospf_mApi_setReqCnt() to ignore counters checking if the request is MAPI_NVM_SET.02o,19dec01,kc Modified ospf_mApi_processSetReq() to check if ospf protocol is running before invoking the ospf_mApi_dynConfigRtn() for tabular objects configuration.02n,19dec01,kc Added ospfRfcProto, ospfOpaqueEnable and ospfDbOverflow protocol specific initialization check to ospf_mApi_init().02m.15dec01,kc Reworked ospf_rs2mApi_errorGet() routine.02l,14dec01,kc Localized ospf_mApi_avlTreeErase(). Also fixed callout to ospf_mApi_initGeneralGroup() and wrnOspf_mApi_initGeneralGroup() in ospf_mApi_init().02k,12dec01,kc Fixed ospf_mApi_setReqCnt() out-of-sync problem.02j,11dec01,kc Somewhat simplified ospf_mApi_processSetReq().02i,10dec01,kc Added instanceLen argument to ospf_mApi_processSetReq() and ospf_mApi_processSetReq(). Now also validate the request message.02h,29nov01,kc Added instanceLen assignment to ospf_mApi_areaAggregateIndexSet().02g,29nov01,kc Fixed ospf_mApi_getGenGroup() and wrnOspf_mApi_getGenGroup() to correctly process the varbinds.02f,13nov01,kc Fixed ospf_mApi_processGetReq() to correctly process the varbinds.02e,12nov01,kc Fixed out-of-sync problem in ospf_mApi_setReqCnt() - handle the MAPI_TEST request failures.02d,08nov01,kc Modified ospf_mApi_init() so that it will not initialized the MIB API if ospfMapiInitDone private flag is already set.02c,25oct01,kc Fixed ospf_mApi_getAreaAggregate() routine, called ospf_mApi_processGetReq() with the correct avl node pointer.02b,24oct01,kc Added explict typecast in ospf_mApi_ipAddr2OoctetString().02a,21oct01,kc Added ospf_mApi_avlTreeErase(). Modified ospf_mApi_destroy() to use this new routine.01z,21oct01,kc Invoke the application provided nvram save and delete method routines in ospf_mApi_processSetReq() if necessary.01y,21oct01,kc Initialize ospf protocol information in ospf_mApi_init().01x,20oct01,kc Added Area Aggregation supported routines.01w,18oct01,kc Redefined ospf_mApi_init() function arguments.01v,16oct01,kc Removed __WRN_OSPF_MIB__ preproc.01u,16oct01,kc Added wrnOspf_mApi_getXXX() routines.01t,15oct01,kc Modified ospf_mApi_databaseFree() to free memory used by nodes on the ospfFreePoolList.01s,15oct01,kc Use the max allocation size for external lsdb as argument to ospf2Mapi_init().01r,13oct01,kc Added __WRN_OSPF_MIB__ preproc.01q,12oct01,kc Added ospf_mApi_showInit() import statement.01p,10oct01,kc Added ospf_mApi_setNbr() support.01o,10oct01,kc Also destroy ospfNbrTable row status handler in ospf_mApi_destroy().01n,08oct01,kc Added wrn-ospf mib specific init and destory support.01m,07oct01,kc Need to include ospf_mApi_helper.h before ospf_mib_api.h.01l,07oct01,kc Called ospf2Mapi_destroy() in ospf_mApi_destroy().01k,18sep01,kc Added lots of arguments to ospf_mApi_init() so that the limit for the MIB tables can be configurable via Tornado Project Facility.01j,15sep01,kc Added support for user callback routine for saving and retrieving configuration to and from the nvram.01i,12sep01,kc Installed ospf_mApi_showInit() in ospf_mApi_init().01h,11sep01,kc Moved all show routines to ospf_mApi_show.c01g,04sep01,kc Added show routines for all tables.01f,24aug01,kc Implemented a generic ospf_mApi_processSetReq() to handle MIB API TEST and SET requests.01e,21aug01,kc Implemented ospf_mApi_processGetReq() generic GET routine, thus simplied all previously implemented GET and GET NEXT routines.01d,20aug01,kc Implemented MIB API compliant GET NEXT routines for all tables01c,16aug01,kc Implemented MIB API compliant GET routines for all tables.01b,15aug01,kc Layout the mApiOspfClass_t data structure01a,14aug01,kc Initial file creation.*//*DESCRIPTIONThis module serves as an intermediate layer to facilitate interoperabilitybetween WindNet OSPFv2 and the OSPF MIB. It implements the RFC1850 compliantmanagement interfaces that can be used to configure and monitor the OSPF protocol.The intention of this module is to provide an SNMP MIB abstraction layer that providesinstrumented MIB object/table row access for GET, GET-NEXT and SET operations. Itencapsulates all the MIB access operations and implementation details from theapplication, thus, provides a neutral interface that can be used by any managementtechnology such as Envoy SNMP and TMS IDB+ or any third-party management technologies.This module assumes that the calling routine (e.g. Envoy SNMP or TMS IDB+) willserialize the SET requests to prevent requests from multiple management applications(e.g. SNMP MIB Browser, SnmpTalk) from interrupting a collection of grouped SETrequests (e.g., all requests in a single SNMP PDU) from a specific managementapplication.The management interfaces implemented in this module shall not be invoked directlyfrom the Wind Shell. It must be called by the relevant method routines of an SNMPagent. To simplify processing and to allow fast, direct acccess of the MIB objects,this module maintain an OSPF Management Database that consists of shadow copies of allthe OSPF configurations that are relevant to the OSPF MIBs.It is not necessary to start WindNet OSPF in order to configure the OSPF protocol usingthis module. As long as the management facility is initialized, the OSPF MIBs can beconfigured using an SNMP agent. Explanation for each of the OSPF scalar or tabularobjects may be obtained from the MIB. Since most of the configurable OSPF objects havedefault values, these configuration parameters can be left unchanged. In a basic OSPFconfiguration, one can simply configure the ospfIfTable for interfaces that need to runOSPF, configure the OSPF Router ID and then enable the OSPF protocol. To ensureuniqueness, it is suggested that the OSPF Router ID should default to one of the router'sIP interface addresses. WindNet OSPF will not be started if this is left unspecified. Theimplementation will not automatically assign one of the router's interface IP addresses asthe OSPF Router ID. This is because the OSPF Router ID must be unique to the routing domainand such uniqueness cannot be guarantee if the interface has been deleted/disabled. Inaddition, it is not always necessary to specify the OSPF Area to which each OSPF interfaceconnects since it will default to the backbone OSPF Area (Area ID 0.0.0.0) if leftunspecified.INCLUDE FILES: ospf_mib_api.hSEE ALSO: WindNet OSPF User's Guide*//* This include is here to get rid of the "empty file" compiler warning */#include <vxWorks.h>#if defined (__OSPF_MIB__)/* standard VxWorks includes */#include <stdio.h>#include <stdlib.h>#include <sysLib.h>#include <semLib.h>#include <lstLib.h>#include <avlLib.h>#include <net/if.h>/* 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"#include "ospf.h"/* private data */LOCAL BOOL ospfMapiInitDone = FALSE; /* flag to check mib api initialization *//* SPR#86502 - added prototype for INCLUDE_OSPF_MIB_UTILITIES component */#ifdef INCLUDE_OSPF_MIB_SHOW_ROUTINESIMPORT void ospfMapiShowInit( void );#endif /* INCLUDE_OSPF_MIB_SHOW_ROUTINES */#ifdef INCLUDE_OSPF_MIB_UTILITIESIMPORT STATUS ospfMapiUtilitiesInit( void );#endif /* INCLUDE_OSPF_MIB_UTILITIES *//* the following are the the debug switch that allow the mApi debug message to be turned * on/off at runtime if the corresponding debug macros are defined in ospf_mib_api.h. * Initially these debug variables are all turn off. */int ospfMapiDebug = 0;int ospfMapiErrorDebug = 0;/* MIB API request display strings */char *mApiRequest[] = { "UNKNOWN", "GET", "GET NEXT", "TEST", "COMMIT", "UNDO", "COMPLETE", "TEST FORCE", "COMMIT NVM", "GET NVM" };/* macro to determine if the management facility is initialized */#define OSPF_MAPI_INIT_CHECK() if ( ospfMapiInitDone == FALSE ) \ { \ mApiOspfError(("OSPF MIB API not inited!\n")); \ return ERROR; \ }/***************************************************************************************** ospf_mApi2rs_reqTypeGet - convert mib api request type to rowStatus lib request type** This routine converts the mib api request type to the rowStatus lib request type.* This routine is used in conjuction with the rowStatus library.** RETURNS: rsRequest_t** NOMANUAL*/LOCAL rsRequest_t ospf_mApi2rs_reqTypeGet( mApiReqType_t reqType ){ rsRequest_t rsRequest; switch( reqType ) { case MAPI_GET: case MAPI_GET_NEXT: case MAPI_GET_FORCE: rsRequest = RS_GET_REQUEST; break; case MAPI_TEST: rsRequest = RS_VALIDATE_REQUEST; break; case MAPI_COMMIT: rsRequest = RS_COMMIT_REQUEST; break; case MAPI_COMMIT_FORCE: rsRequest = RS_SET_NVM_REQUEST; break; case MAPI_UNDO: case MAPI_COMPLETE: default: rsRequest = RS_ERROR_REQUEST; break; } return rsRequest;}/***************************************************************************************** ospf_mApi_setReqCnt - set the SNMP Test/Commit/Undo state counter** This routine set the SNMP Test/Commit/Undo state counter. It is assumed that the SNMP* agent will serialize all the requests for a transaction. (i.e. all requests for a* transaction in a single SNMP PDU). The following are the three allowable SET phase* combination (assumming a single object SET)* - MAPI_TEST, MAPI_COMMIT , MAPI_COMPLETE => SET successful* - MAPI_TEST, MAPI_COMPLETE => TEST failure* - MAPI_TEST, MAPI_COMMIT, MAPI_UNDO => COMMIT failure** The following is a typical transaction for multiple requests to update two rows in* a table:* - MAPI_TEST, MAPI_TEST, MAPI_COMMIT, MAPI_COMMIT, MAPI_COMPLETE, MAPI_COMPLETE* => SET successful* - MAPI_TEST, MAPI_TEST, MAPI_COMPLETE, MAPI_COMPLETE => 2nd TEST failure* - MAPI_TEST, MAPI_TEST, MAPI_COMMIT, MAPI_COMMIT, MAPI_UNDO, MAPI_UNDO* => 2nd COMMIT failure** RETURNS: OK or ERROR** ERRNO: none** NOMANUAL*/LOCAL STATUS ospf_mApi_setReqCnt( mApiReqType_t reqType ){ /* lock mib api mutex semaphore for exclusive access to mApiOspfClass_t */ semTake( thisMapi->semMapiMutex, WAIT_FOREVER ); switch( reqType ) { case MAPI_TEST: /* if agent has issued the SNMP Commit or Undo requests, transaction * has yet completed. Disallow the SNMP Test Request. */ if ( (thisMapi->mApiCommitReqCnt != 0) || (thisMapi->mApiUndoReqCnt != 0) ) { thisMapi->mApiBogusReqCnt++; semGive( thisMapi->semMapiMutex ); mApiOspfError(("ospf_mApi_setReqCnt:test request not allowed!\n")); return ERROR; } thisMapi->mApiTestReqCnt++; break; case MAPI_COMMIT: /* if agent has started the SNMP Undo process, can't issue a request * for Commit until all Undo processes have been completed. */ if ( thisMapi->mApiUndoReqCnt != 0 ) { thisMapi->mApiBogusReqCnt++; semGive( thisMapi->semMapiMutex ); mApiOspfError(("ospf_mApi_setReqCnt:commit request not allowed!\n")); return ERROR; } /* number of SNMP Commit must never greater than the Test request count */ if ( thisMapi->mApiCommitReqCnt > thisMapi->mApiTestReqCnt ) { thisMapi->mApiBogusReqCnt++; semGive( thisMapi->semMapiMutex ); mApiOspfError(("ospf_mApi_setReqCnt:too many commit request!\n")); return ERROR; } thisMapi->mApiCommitReqCnt++; break; case MAPI_UNDO:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -