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

📄 ospf_mib_stub.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
    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,                                 ospfMapiIfMetric_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pEnvoyReq );        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to MIB API */    rc = ospfMapiGetIfMetric( &request, reqType );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pEnvoyReq );        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,                               ospfMapiIfMetric_OID_OFFSET );    ospf_envoy_clearBuffer( pEnvoyReq );    return;}/**************************************************************************************** ospfEnvoy_setIfMetric - generic set function for ospfIfMetricTable** This routine is a generic set function for ospfIfMetricTable. It invokes by testproc* and setproc to test and set objects in varbinds.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_setIfMetric( 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 != ospfIfMetricEntry_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.     */    rc = ospf_envoy_buildSetReq( tcount, tlist, pktp, vbp, pEnvoyReq, &request, reqType,                                 ospfMapiIfMetric_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to OSPF MIB API for processing */    rc = ospfMapiSetIfMetric( &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.                 */                ospfMapiSetIfMetric( &request, MAPI_UNDO );                setproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error));            }        }        /* tell MIB API we have completed the transaction */        ospfMapiSetIfMetric( &request, MAPI_COMPLETE );        ospf_envoy_clearBuffer( pEnvoyReq );        if ( (pEnvoyReq->dynamic == TRUE) && (pEnvoyReq->pOctetBuf != NULL) )        {            SNMP_memory_free( pEnvoyReq->pOctetBuf );            pEnvoyReq->pOctetBuf = NULL;        }        return;    }    if ( reqType == MAPI_TEST )    {        /* stash the looked up information here for the setproc. Although Envoy         * provide vb_priv in each varbind, only stash it to the first varbind.         * MIB API only allow one cookie per request, and we only need one anyhow         */        vbp->vb_priv = (void *)request.pReqCookie;    }    /* tell MIB API we have completed the transaction */    if ( reqType == MAPI_COMMIT )        ospfMapiSetIfMetric( &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 );    if (  (pEnvoyReq->dynamic == TRUE) && (pEnvoyReq->pOctetBuf != NULL) )    {        SNMP_memory_free( pEnvoyReq->pOctetBuf );        pEnvoyReq->pOctetBuf = NULL;    }    return;}/***************************************************************************************** ospfEnvoy_getVirtIf - generic get routine for ospfVirtIfTable** This is the generic get routine for ospfVirtIfTable. 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_getVirtIf( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp,                                 mApiReqType_t reqType ){    mApiRequest_t  request;    VB_T           *group_vbp;    char           authKey[4];    STATUS         rc;    if ( ospfEnvoy_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.     */    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) )        {            if ( group_vbp->vb_ml.ml_last_match != LEAF_ospfVirtIfAuthKey )                continue;            /* for ospfVirtIfTable, ospfVirtIfAuthKey is the only object using octet             * string. RFC1850 requires that the ospfVirtIfAuthKey when read, will always             * returns an octet string of length zero. Statically allocate an array of             * ulong_t to satisfy the request             */            memset( authKey, 0, sizeof(authKey) );            pEnvoyReq->pOctetBuf = authKey;            pEnvoyReq->octetBufLen = sizeof(authKey);            /* mark this buffer as static */            pEnvoyReq->dynamic = FALSE;            break;  /* there can be only one octet string object in a row */        }    }    /* build the MIB API request message */    memset( (char *)&request, 0, sizeof(mApiRequest_t) );    rc = ospf_envoy_buildGetReq( tcount, tlist, vbp, pEnvoyReq, &request,                                 ospfMapiVirtIf_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to MIB API */    rc = ospfMapiGetVirtIf( &request, reqType );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pEnvoyReq );        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,                               ospfMapiVirtIf_OID_OFFSET );    return;}/**************************************************************************************** ospfEnvoy_setVirtIf - generic set function for ospfVirtIfTable** This routine is a generic set function for ospfVirtIfTable. It invokes by testproc and* setproc to test and set objects in varbinds.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_setVirtIf( 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 != ospfVirtIfEntry_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.     */    rc = ospf_envoy_buildSetReq( tcount, tlist, pktp, vbp, pEnvoyReq, &request, reqType,                                 ospfMapiVirtIf_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to OSPF MIB API for processing */    rc = ospfMapiSetVirtIf( &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.                 */                ospfMapiSetVirtIf( &request, MAPI_UNDO );                setproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error));            }        }        /* tell MIB API we have completed the transaction */        ospfMapiSetVirtIf( &request, MAPI_COMPLETE );        ospf_envoy_clearBuffer( pEnvoyReq );        if ( (pEnvoyReq->dynamic == TRUE) && (pEnvoyReq->pOctetBuf != NULL) )        {            SNMP_memory_free( pEnvoyReq->pOctetBuf );            pEnvoyReq->pOctetBuf = NULL;        }        return;    }    if ( reqType == MAPI_TEST )    {        /* stash the looked up information here for the setproc. Although Envoy         * provide vb_priv in each varbind, only stash it to the first varbind.         * MIB API only allow one cookie per request, and we only need one anyhow         */        vbp->vb_priv = (void *)request.pReqCookie;    }    /* tell MIB API we have completed the transaction */    if ( reqType == MAPI_COMMIT )        ospfMapiSetVirtIf( &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 );    if (  (pEnvoyReq->dynamic == TRUE) && (pEnvoyReq->pOctetBuf != NULL) )    {        SNMP_memory_free( pEnvoyReq->pOctetBuf );        pEnvoyReq->pOctetBuf = NULL;    }    return;}/***************************************************************************************** ospfEnvoy_getNbr - generic get routine for ospfNbrTable** This is the generic get routine for ospfNbrTable. 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_getNbr( 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,                                 ospfMapiNbr_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pEnvoyReq );        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to MIB API */    rc = ospfMapiGetNbr( &request, reqType );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pEnvoyReq );        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,                               ospfMapiNbr_OID_OFFSET );    ospf_envoy_clearBuffer( pEnvoyReq );    return;}/***************************************************************************************

⌨️ 快捷键说明

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