📄 ospf_mib_stub.c
字号:
/****************************************************************************** ****************************************************************************** **** This file was automatically generated by Epilogue Technology's **** Emissary SNMP MIB Compiler, version 9.1. **** This file was generated using the -stub switch. **** **** This file contains stub function declarations to aid in building **** the agent MIB interface. It creates all the MIB get, set, test, and **** next method routines that you will need to supply. However, **** since it doesn't know your system, several things are left to you. **** Look for comments with `!!!' in them for places you're likely to want **** to change for your system. Also, while the layout of the method **** routines is a commonly useful one, it will not fit all data structures **** and systems. Look at this output as a guide to how to write your **** method routines; a guide that will, in most cases, significantly reduce **** the amount of typing you need to do. **** **** The code here assumes you've created a file called `mibleaf.h' with **** the -leaf option to the mibcompiler. **** **** YOU WILL PROBABLY MODIFY THIS FILE BUT BEWARE ACCIDENTALLY **** OVERWRITING IT BY REGENERATING IT WITH THE MIB COMPILER. **** **** Last build date: Thu Aug 16 16:04:19 2001 **** from files: **** rfc1213.mib, rfc1850.mi2, rfc1850.ctl ****************************************************************************** ****************************************************************************** */#include <vxWorks.h> /* keeps the compiler happy when !(__OSPF_MIB__) */#if defined (__OSPF_MIB__)/* Envoy SNMP includes */#include <asn1conf.h>#include <asn1.h>#include <buffer.h>#include <mib.h>#include <localio.h>#include <snmpdefs.h>#include <snmp.h>#include <auxfuncs.h>/* vxWorks standard includes */#include <stdio.h>#include <stdlib.h>#include "semLib.h"#include "lstLib.h"/* ospf management interface includes */#include "ospf_mib_leaf.h"#include "mibApi.h"#include "ospf_mib_envoy_api.h"#undef ENVOY_DEBUG#ifdef ENVOY_DEBUG#include "sysLib.h"#include "taskLib.h"#endif /* ENVOY_DEBUG *//* this is the maximum number of objects in the OSPF-MIB */#define MAX_OSPF_MIB_OBJECTS 20#define ospfAreaEntry_INST_LEN 4#define ospfStubAreaEntry_INST_LEN 5#define ospfLsdbEntry_INST_LEN 13#define ospfHostEntry_INST_LEN 5#define ospfIfEntry_INST_LEN 5#define ospfIfMetricEntry_INST_LEN 6#define ospfVirtIfEntry_INST_LEN 8#define ospfNbrEntry_INST_LEN 5#define ospfVirtNbrEntry_INST_LEN 8#define ospfExtLsdbEntry_INSTANCE_LEN 9#define ospfAreaAggregateEntry_INSTANCE_LEN 13/* the following defines the offset into the Management Interface object identifer * locally defined by MIB API for OSPF MIB. Envoy SNMP defines the object identifier * on a per table basis in which the object identifier starts at 1 for each table * (see LEAF_ospfxxx defines in ospf_mib_rfc1850_leaf.h). MIB API, on the hand, defines * the object identifier on a per MIB basis (see mApiOspf_t enumeration values in * ospf_mib_rfc1850_mapihelper.h). Therefore, the following defines are necessary in order * to overcome the descrepency between the two schemes. These OID offset will be added * to the value of the appropriate LEAF_ospfxxx when constructing the MIB API request * messages. */const int ospfMapiGenGrop_OID_OFFSET = 0;const int ospfMapiArea_OID_OFFSET = 14;const int ospfMapiStub_OID_OFFSET = 24;const int ospfMapiLsdb_OID_OFFSET = 29;const int ospfMapiHost_OID_OFFSET = 42;const int ospfMapiIf_OID_OFFSET = 47;const int ospfMapiIfMetric_OID_OFFSET = 67;const int ospfMapiVirtIf_OID_OFFSET = 72;const int ospfMapiNbr_OID_OFFSET = 83;const int ospfMapiVirtNbr_OID_OFFSET = 94;const int ospfMapiExtLsdb_OID_OFFSET = 102;const int ospfMapiAreaAggregate_OID_OFFSET = 109;/* external MIB API prototypes */IMPORT STATUS ospfMapiGetGenGroup(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiSetGenGroup(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiGetArea(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiSetArea(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiGetStub(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiSetStub(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiGetHost( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiSetHost( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetLsdb(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiGetIf(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiSetIf( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetIfMetric( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiSetIfMetric( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetVirtIf(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiSetVirtIf( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetNbr(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiSetNbr( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetVirtNbr( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetExtLsdb(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiGetAreaAggregate( mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiSetAreaAggregate( mApiRequest_t *pRequest, mApiReqType_t reqType);/* external global variables */IMPORT MIBNODE_T n_ospf;/* private data */LOCAL envoyRequest_t *pEnvoyReq;LOCAL int ospfEnvoyInitDone = FALSE;/**************************************************************************************** ospfEnvoy_init_check - check if ospf stub is initialized** This routine checks if the ospf stub has been initialized.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS ospfEnvoy_init_check( SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ if ( ospfEnvoyInitDone == FALSE ) { ospf_envoy_setGenError( pktp, vbp, reqType ); ospfEnvoyPrintf(("OSPF-Envoy interface not inited!\n")); return ERROR; } return OK;}/***************************************************************************************** ospfEnvoy_getGeneralGroup - generic get routine for ospfGeneralGroup scalar objects** This is the generic get routine for ospfGeneralGroup scalar objects. It query the mib* api for the requested objects.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_getGeneralGroup( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ mApiRequest_t request; STATUS rc; if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* build the MIB API request message */ memset( (char *)&request, 0, sizeof(mApiRequest_t) ); rc = ospf_envoy_buildGetReq( tcount, tlist, vbp, pEnvoyReq, &request, ospfMapiGenGrop_OID_OFFSET ); if ( rc == ERROR ) { ospf_envoy_clearBuffer( pEnvoyReq ); ospf_envoy_setGenError( pktp, vbp, reqType ); return; } /* send the request to MIB API */ rc = ospfMapiGetGenGroup( &request, reqType ); if ( rc == ERROR ) { ospf_envoy_clearBuffer( pEnvoyReq ); for ( ; vbp ; vbp = vbp->vb_link ) { if ( reqType == MAPI_GET_NEXT ) nextproc_no_next(pktp, vbp); else getproc_nosuchins(pktp, vbp); } return; } /* retrieve all the values from the request structure */ ospf_envoy_processScalarGetResp( vbp, pktp, pEnvoyReq, &request, reqType, ospfMapiGenGrop_OID_OFFSET ); return;}/**************************************************************************************** ospfEnvoy_setGeneralGroup - generic set function for ospfGeneralGroup scalar objects** This routine is a generic set function for ospfGeneralGroup scalar objects. It* invokes by testproc and setproc to test and set objects in varbinds.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_setGeneralGroup( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ mApiRequest_t request; VB_T *group_vbp; STATUS rc; if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* use the data provided by the varbinds directly. This eliminates the need * to copy the data from varbinds to locally allocated buffer. */ rc = ospf_envoy_buildSetReq( tcount, tlist, pktp, vbp, pEnvoyReq, &request, reqType, (int)ospfMapiGenGrop_OID_OFFSET ); if ( rc == ERROR ) { ospf_envoy_setGenError( pktp, vbp, reqType ); return; } /* send the request to OSPF MIB API for processing */ rc = ospfMapiSetGenGroup( &request, reqType ); if ( rc == ERROR ) { for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link ) { group_vbp->vb_priv = NULL; if ( reqType == MAPI_TEST ) testproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error)); else { /* tell envoy to start the undo operation. Envoy should call the * undo routine immediately once the setproc_error indicates * the set process has failed. */ group_vbp->undoproc = ospfEnvoy_undo; /* our undo routine */ /* issue a fake undo request to mib api so that it can reset its * internal transaction counters. */ ospfMapiSetGenGroup( &request, MAPI_UNDO ); setproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error)); } } /* tell MIB API we have completed the transaction */ ospfMapiSetGenGroup( &request, MAPI_COMPLETE ); return; } /* tell MIB API we have completed the transaction */ if ( reqType == MAPI_COMMIT ) ospfMapiSetGenGroup( &request, MAPI_COMPLETE ); /* make the varbind as done and check for any exception in varbinds */ ospf_envoy_markVarbind( vbp, pktp, &request, reqType ); ospf_envoy_clearBuffer( pEnvoyReq ); return;}/***************************************************************************************** ospfEnvoy_getArea - generic get routine for ospfAreaTable** This is the generic get routine for ospfAreaTable. It query the mib api for the table* row in which the requested object instances can be found. The behavior of the mib api* is based on request type, either GET or GET_NEXT. If it is a GET_NEXT request, the* smallest instance that is larger than the given tcount/tlist will be returned.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_getArea( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ mApiRequest_t request; STATUS rc; if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* build the MIB API request message */ memset( (char *)&request, 0, sizeof(mApiRequest_t) ); rc = ospf_envoy_buildGetReq( tcount, tlist, vbp, pEnvoyReq, &request, ospfMapiArea_OID_OFFSET ); if ( rc == ERROR ) { ospf_envoy_clearBuffer( pEnvoyReq ); ospf_envoy_setGenError( pktp, vbp, reqType ); return; } /* send the request to MIB API */ rc = ospfMapiGetArea( &request, reqType ); if ( rc == ERROR ) { ospf_envoy_clearBuffer( pEnvoyReq ); /* use the varbind pointer provided by envoy snmp directly. When we are done * setting the flag in the varbind, the pointer will be pointed to null. Envoy * SNMP will then know that all the varbinds have been processed. */ ospf_envoy_processGetRespError( pktp, vbp, reqType, request.error ); return; } /* retrieve all the values from the request structure */ ospf_envoy_processGetResp( vbp, pktp, pEnvoyReq, &request, reqType, ospfMapiArea_OID_OFFSET ); return;}/**************************************************************************************** ospfEnvoy_setArea - generic set function for ospfAreaTable** This routine is a generic set function for ospfAreaTable. It invokes by testproc and* setproc to test and set objects in varbinds.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_setArea( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ mApiRequest_t request; VB_T *group_vbp; STATUS rc; if ( tcount != ospfAreaEntry_INST_LEN ) { ospf_envoy_setNoSuchNameError( pktp, vbp, reqType ); return; } if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* use the data provided by the varbinds directly. This eliminates the need * to copy the data from varbinds to locally allocated buffer.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -