⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ospf_mib_wrn_stub.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 4 页
字号:
/****************************************************************************** ****************************************************************************** **** 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: Tue Oct 16 18:48:26 2001 **** from files: ****  rfc1213.mib, rfc1850.mi2, wrsMasterMib.mi2, wrnOspf.mi2, wrnOspf.ctl ****************************************************************************** ****************************************************************************** */#include <vxWorks.h> /* keeps the compiler happy when !(__OSPF_MIB__) */#if defined (__OSPF_MIB__)#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_wrn_leaf.h"#include "mibApi.h"#include "ospf_mib_envoy_api.h"/* this is the maximum number of objects in the WRN-OSPF MIB */#define MAX_WRN_OSPF_MIB_OBJECTS                9/* WRN-OSPF MIB instance length */#define wrnOspfAreaEntry_INSTANCE_LEN           4#define wrnOspfLsdbEntry_INSTANCE_LEN           13#define wrnOspfLocalLsdbEntry_INSTANCE_LEN      17#define wrnOspfExtLsdbEntry_INSTANCE_LEN        9#define wrnOspfIfEntry_INSTANCE_LEN             4      /* the following defines the offset into the Management Interface object identifer * locally defined by MIB API for Windnet OSPF Enterprise 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_wrnOspfxxx defines in ospf_mib_wrn_leaf.h). MIB API * defines the object identifier on a per MIB basis (see mApiWrnOspf_t enumeration * values in wrnOspf_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_wrnOspfxxx when constructing * the MIB API request messages. */const int wrnOspfMapiGenGroup_OID_OFFSET = 0;const int wrnOspfMapiArea_OID_OFFSET = 12;const int wrnOspfMapiLsdb_OID_OFFSET = 15;const int wrnOspfMapiLocalLsdb_OID_OFFSET = 23 ;const int wrnOspfMapiExtLsdb_OID_OFFSET = 32;const int wrnOspfMapiIf_OID_OFFSET = 39;/* external global variables */IMPORT MIBNODE_T n_wrnOspf;IMPORT MIBNODE_T n_wrnRoutingProto;IMPORT MIBNODE_T n_wrs;IMPORT STATUS ospfMapiGetWrnGenGroup( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiSetWrnGenGroup( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetWrnArea( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetWrnLsdb(mApiRequest_t *pRequest, mApiReqType_t reqType);IMPORT STATUS ospfMapiGetWrnLocalLsdb( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetWrnExtLsdb( mApiRequest_t *pRequest, mApiReqType_t reqType );IMPORT STATUS ospfMapiGetWrnIf(mApiRequest_t *pRequest, mApiReqType_t reqType); IMPORT STATUS ospfMapiSetWrnIf( mApiRequest_t *pRequest, mApiReqType_t reqType );/* private data */LOCAL envoyRequest_t *pWrnEnvoyReq;LOCAL int wrnOspfEnvoyInitDone = 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 wrnOspfEnvoy_init_check( SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){    if ( wrnOspfEnvoyInitDone == FALSE )    {        ospf_envoy_setGenError( pktp, vbp, reqType );        ospfEnvoyPrintf(("OSPF-Envoy interface not inited!\n"));        return ERROR;    }    return OK;}/***************************************************************************************** wrnOspfEnvoy_getGeneralGroup - generic get routine for wrnOspfGeneralGroup** This is the generic get routine for wrnOspfGeneralGroup scalar objects. It query the* mib api for the requested objects.** RETURNS: N/A** NOMANUAL*/LOCAL void wrnOspfEnvoy_getGeneralGroup( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp,                                         VB_T *vbp, mApiReqType_t reqType ){    mApiRequest_t  request;    STATUS         rc;    if ( wrnOspfEnvoy_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, pWrnEnvoyReq, &request,                                 wrnOspfMapiGenGroup_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pWrnEnvoyReq );        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to MIB API */    rc = ospfMapiGetWrnGenGroup( &request, reqType );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pWrnEnvoyReq );        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, pWrnEnvoyReq, &request, reqType,                                     wrnOspfMapiGenGroup_OID_OFFSET );    return;}/**************************************************************************************** wrnOspfEnvoy_setGeneralGroup - generic set function for wrnOspfGeneralGroup** This routine is a generic set function for wrnOspfGeneralGroup scalar objects. It* invokes by testproc and setproc to test and set objects in varbinds.** RETURNS: N/A** NOMANUAL*/LOCAL void wrnOspfEnvoy_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 ( wrnOspfEnvoy_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, pWrnEnvoyReq, &request,                                 reqType, wrnOspfMapiGenGroup_OID_OFFSET );    if ( rc == ERROR )    {        for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link )        {            if ( reqType == MAPI_TEST )                testproc_error( pktp, group_vbp, GEN_ERR );            else                setproc_error( pktp, group_vbp, GEN_ERR );        }        return;    }    /* send the request to OSPF MIB API for processing */    rc = ospfMapiSetWrnGenGroup( &request, reqType );    if ( rc == ERROR )    {        for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link )        {            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.                 */                vbp->undoproc = ospfEnvoy_undo; /* our undo routine */                /* issue a fake undo request to mib api so that it can reset its                 * internal transaction counters.                 */                ospfMapiSetWrnGenGroup( &request, MAPI_UNDO );                setproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error));            }        }        /* tell MIB API we have completed the transaction */        ospfMapiSetWrnGenGroup( &request, MAPI_COMPLETE );        return;    }    /* tell MIB API we have completed the transaction */    if ( reqType == MAPI_COMMIT )        ospfMapiSetWrnGenGroup( &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( pWrnEnvoyReq );    return;}/***************************************************************************************** wrnOspfEnvoy_getArea - generic get routine for wrnOspfAreaTable** This is the generic get routine for wrnOspfAreaTable. 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 wrnOspfEnvoy_getArea( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp,                                 mApiReqType_t reqType ){    mApiRequest_t  request;    STATUS         rc;    if ( wrnOspfEnvoy_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, pWrnEnvoyReq, &request,                                 wrnOspfMapiArea_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pWrnEnvoyReq );        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to MIB API */    rc = ospfMapiGetWrnArea( &request, reqType );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pWrnEnvoyReq );        ospf_envoy_processGetRespError( pktp, vbp, reqType, request.error );        return;    }    /* retrieve all the values from the request structure */    ospf_envoy_processGetResp( vbp, pktp, pWrnEnvoyReq, &request, reqType,                               wrnOspfMapiArea_OID_OFFSET );    return;}/***************************************************************************************** wrnOspfEnvoy_getLsdb - generic get routine for wrnOspfLsdbTable** This is the generic get routine for wrnOspfLsdbTable. It query the mib api for the row of* table 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 wrnOspfEnvoy_getLsdb( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp,                                 mApiReqType_t reqType ){    OIDC_T         inst_oid[wrnOspfLsdbEntry_INSTANCE_LEN];    mApiRequest_t  request;    mApiObject_t   object;    VB_T           *group_vbp;    STATUS         rc;    unsigned       inst_len;    if ( wrnOspfEnvoy_init_check( pktp, vbp, reqType ) == ERROR )        return;    /* the ospfEnvoy_build_getRequest() expects the buffer for the octet string to     * be allocated by the caller. Loop through the varbinds and determine if     * there is an object whose type is octet string.     */    rc = OK;    for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link )    {        if ( (group_vbp->vb_ml.ml_leaf->expected_tag == VT_STRING) ||             (group_vbp->vb_ml.ml_leaf->expected_tag == VT_OPAQUE) )        {            /* for ospfLsdbTable, ospfLsdbAdvertisement is the only object using octet             * string.             */            if ( group_vbp->vb_ml.ml_last_match != LEAF_wrnOspfLsdbAdvertisement )                continue;            /* copy instance portion into a buffer. This buffer will be used to return             * the next instance by the MIB API. This is necessary because the main              * purpose for this transaction here is to query MIB API for the size of              * the wrnOspfLsdbAdvertisement object so that we can allocate a buffer              * (with the exact size) that will be used by MIB API to return the value of              * the advertisement. Therefore, we are not really interesting about the              * index value for the next instance.             */            memset( (char *)inst_oid, 0, sizeof(OIDC_T)*wrnOspfLsdbEntry_INSTANCE_LEN );            inst_len = tcount;            if ( inst_len != 0 )                copy_oids( inst_oid, tlist, inst_len );            /* send a simple get request to query MIB API for the size of the             * advertisement for this row             */            request.pInstance = (ulong_t *)inst_oid;            request.instanceLen = (ushort_t)inst_len;            request.numObjects = 1;            memset( (char *)&object, 0, sizeof(mApiObject_t) );            request.pObjectList = &object;            request.pObjectList->oidPrefixEnum = group_vbp->vb_ml.ml_last_match +                                                 wrnOspfMapiLsdb_OID_OFFSET;            request.pObjectList->pValueBuf = NULL;            request.pObjectList->valueLen = 0;            rc = ospfMapiGetWrnLsdb( &request, reqType );            if ( rc == ERROR )            {                ospf_envoy_processGetRespError( pktp, vbp, reqType, request.error );                ospfEnvoyPrintf(("wrnOspfEnvoy_getLsdb:failed\n"));                return;            }            /* expect an exception to be set by MIB API */            if ( request.pObjectList->exception != MAPI_BUFFER_TOO_SHORT )            {                ospfEnvoyPrintf(("wrnOspfEnvoy_getLsdb:exception not buffer too short\n"));                rc = ERROR;                break;            }            /* MIB API should return the size of the lsdb */            if ( request.pObjectList->valueLen == 0 )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -