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

📄 ospf_mib_wrn_stub.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 4 页
字号:
    OIDC_T    best_inst[wrnOspfLocalLsdbEntry_INSTANCE_LEN];    unsigned  best_inst_len;    /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);    /* copy instance portion into a buffer. This buffer will be used to return     * the next instance by the mib api.     */    memset( (char *)best_inst, 0, sizeof(OIDC_T)*wrnOspfLocalLsdbEntry_INSTANCE_LEN );    best_inst_len = vbp->vb_ml.ml_remaining_objid.num_components;    if ( best_inst_len != 0 )    {        copy_oids( best_inst, vbp->vb_ml.ml_remaining_objid.component_list,                    best_inst_len );    }    /* lock binary semaphore so that we can synchronization into envoy snmp */    semTake( pWrnEnvoyReq->envoyBSem, WAIT_FOREVER );    /* use the instance (tcount and tlist) to look up the next smallest instance     * that is larger than tcount/tlist.     */    wrnOspfEnvoy_getLocalLsdb( best_inst_len, best_inst, pktp, vbp, MAPI_GET_NEXT );    semGive( pWrnEnvoyReq->envoyBSem );}/**************************************************************************************** wrnOspfExtLsdbEntry_get - get method routine for wrnOspfExtLsdbTable** This routine process the SNMP GET request for the WRN OSPF Enterprise MIB Externl* LSDB Table. This routine is called to find the specified instance of the object and,* if the instance exists, to install the value into the vbr varbind.** RETURNS: N/A** ERRNO: N/A*/void wrnOspfExtLsdbEntry_get( OIDC_T lastmatch, int tcount, OIDC_T *tlist,                              SNMP_PKT_T *pktp, VB_T *vbp ){    /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);    if ( tcount != wrnOspfExtLsdbEntry_INSTANCE_LEN )    {        for ( ; vbp; vbp = vbp->vb_link)            getproc_nosuchins (pktp, vbp);        return;    }    /* lock binary semaphore so that we can synchronization into envoy snmp */    semTake( pWrnEnvoyReq->envoyBSem, WAIT_FOREVER );    /* look up the instance */    wrnOspfEnvoy_getExtLsdb( tcount, tlist, pktp, vbp, MAPI_GET );    semGive( pWrnEnvoyReq->envoyBSem );    return;}/**************************************************************************************** wrnOspfExtLsdbEntry_next - next method routine for wrnOspfExtLsdbTable** This routine process the SNMP GET_NEXT request for the WRN OSPF Enterprise MIB* External LSDB Table. This routine is called to locate a variable whose instance is the* SNMP lexicographic successor for the input object identifier, which may or may not* actually exist within this object.** RETURNS: N/A** ERRNO: N/A**/void wrnOspfExtLsdbEntry_next( OIDC_T lastmatch, int tcount, OIDC_T *tlist,                               SNMP_PKT_T *pktp, VB_T *vbp ){    OIDC_T    best_inst[wrnOspfExtLsdbEntry_INSTANCE_LEN];    unsigned  best_inst_len;    /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);    /* copy instance portion into a buffer. This buffer will be used to return     * the next instance by the mib api.     */    memset( (char *)best_inst, 0, sizeof(OIDC_T)*wrnOspfExtLsdbEntry_INSTANCE_LEN );    best_inst_len = vbp->vb_ml.ml_remaining_objid.num_components;    if ( best_inst_len != 0 )    {        copy_oids( best_inst, vbp->vb_ml.ml_remaining_objid.component_list,                    best_inst_len );    }    /* lock binary semaphore so that we can synchronization into envoy snmp */    semTake( pWrnEnvoyReq->envoyBSem, WAIT_FOREVER );    /* use the instance (tcount and tlist) to look up the next smallest instance     * that is larger than tcount/tlist.     */    wrnOspfEnvoy_getExtLsdb( best_inst_len, best_inst, pktp, vbp, MAPI_GET_NEXT );    semGive( pWrnEnvoyReq->envoyBSem );    return;}/***************************************************************************************** wrnOspfEnvoy_getIf - generic get routine for wrnOspfIfTable** This is the generic get routine for wrnOspfIfTable. 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_getIf( 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,                                 wrnOspfMapiIf_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_clearBuffer( pWrnEnvoyReq );        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to MIB API */    rc = ospfMapiGetWrnIf( &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,                               wrnOspfMapiIf_OID_OFFSET );    return;}/**************************************************************************************** wrnOspfEnvoy_setIf - generic set function for wrnOspfIfTable** This routine is a generic set function for wrnOspfIfTable. It invokes by testproc and* setproc to test and set objects in varbinds.** RETURNS: N/A** NOMANUAL                */LOCAL void wrnOspfEnvoy_setIf( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp,                               mApiReqType_t reqType ){    STATUS         rc;    mApiRequest_t  request;    VB_T           *group_vbp;    if ( tcount != wrnOspfIfEntry_INSTANCE_LEN )    {        ospf_envoy_setNoSuchNameError( pktp, vbp, reqType );        return;    }    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,                                 wrnOspfMapiIf_OID_OFFSET );    if ( rc == ERROR )    {        ospf_envoy_setGenError( pktp, vbp, reqType );        return;    }    /* send the request to OSPF MIB API for processing */    /* TODO: Fill in the blank here... */    rc = ospfMapiSetWrnIf( &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.                 */                ospfMapiSetWrnIf( &request, MAPI_UNDO );                setproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error));            }        }        /* tell MIB API we have completed the transaction */        ospfMapiSetWrnIf( &request, MAPI_COMPLETE );        ospf_envoy_clearBuffer( pWrnEnvoyReq );        if (  (pWrnEnvoyReq->dynamic == TRUE) && (pWrnEnvoyReq->pOctetBuf != NULL) )        {            SNMP_memory_free( pWrnEnvoyReq->pOctetBuf );            pWrnEnvoyReq->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 )        ospfMapiSetWrnIf( &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 );    if (  (pWrnEnvoyReq->dynamic == TRUE ) && (pWrnEnvoyReq->pOctetBuf != NULL) )    {        SNMP_memory_free( pWrnEnvoyReq->pOctetBuf );        pWrnEnvoyReq->pOctetBuf = NULL;    }    return;}/**************************************************************************************** wrnOspfIfEntry_get - get method routine for wrnOspfIfTable** This routine process the SNMP GET request for the WRN OSPF Enterprise MIB Interface* Table. This routine is called to find the specified instance of the object and, if* the instance exists, to install the value into the vbr varbind.** RETURNS: N/A** ERRNO: N/A      */void wrnOspfIfEntry_get( OIDC_T lastmatch, int tcount, OIDC_T *tlist,                         SNMP_PKT_T *pktp, VB_T *vbp ){    /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);    if ( tcount != wrnOspfIfEntry_INSTANCE_LEN )    {        for ( ; vbp; vbp = vbp->vb_link)            getproc_nosuchins (pktp, vbp);        return;    }    /* lock binary semaphore so that we can synchronization into envoy snmp */    semTake( pWrnEnvoyReq->envoyBSem, WAIT_FOREVER );    /* look up the instance */    wrnOspfEnvoy_getIf( tcount, tlist, pktp, vbp, MAPI_GET );    semGive( pWrnEnvoyReq->envoyBSem );    return;}/**************************************************************************************** wrnOspfIfEntry_next - next method routine for wrnOspfIfTable** This routine process the SNMP GET_NEXT request for the WRN OSPF Enterprise MIB* Interface Table. This routine is called to locate a variable whose instance is the* SNMP lexicographic successor for the input object identifier, which may or may not* actually exist within this object.** RETURNS: N/A** ERRNO: N/A             **/void wrnOspfIfEntry_next( OIDC_T lastmatch, int tcount, OIDC_T *tlist,                          SNMP_PKT_T *pktp, VB_T *vbp ){    OIDC_T    best_inst[wrnOspfIfEntry_INSTANCE_LEN];    unsigned  best_inst_len;    /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);    /* copy instance portion into a buffer. This buffer will be used to return     * the next instance by the mib api.     */    memset( (char *)best_inst, 0, sizeof(OIDC_T)*wrnOspfIfEntry_INSTANCE_LEN );    best_inst_len = vbp->vb_ml.ml_remaining_objid.num_components;    if ( best_inst_len != 0 )    {        copy_oids( best_inst, vbp->vb_ml.ml_remaining_objid.component_list,                    best_inst_len );    }    /* lock binary semaphore so that we can synchronization into envoy snmp */    semTake( pWrnEnvoyReq->envoyBSem, WAIT_FOREVER );    /* use the instance (tcount and tlist) to look up the next smallest instance     * that is larger than tcount/tlist.     */    wrnOspfEnvoy_getIf( best_inst_len, best_inst, pktp, vbp, MAPI_GET_NEXT );    semGive( pWrnEnvoyReq->envoyBSem );    return;}/**************************************************************************************** wrnOspfIfEntry_test - test method routine for wrnOspfIfTable** This routine is the fist phase of the SNMP SET request for WRN OSPF Enterprise MIB* Interface Table. This routine is called to validate instances that need to be set, * which may or may not actually exist.** RETURNS: N/A** ERRNO: N/A            */void wrnOspfIfEntry_test( OIDC_T lastmatch, int tcount, OIDC_T *tlist,                          SNMP_PKT_T *pktp, VB_T *vbp ){              /* lock binary semaphore so that we can synchronization into envoy snmp */    semTake( pWrnEnvoyReq->envoyBSem, WAIT_FOREVER );    wrnOspfEnvoy_setIf( tcount, tlist, pktp, vbp, MAPI_TEST );    semGive( pWrnEnvoyReq->envoyBSem );    return;}/**************************************************************************************** wrnOspfIfEntry_set - set method routine for wrnOspfIfTable** This routine is the second phase of the SNMP SET request for WRN OSPF Enterprise MIB* Interface Table. This routine is called to set instances that have been previously test.** RETURNS: N/A** ERRNO: N/A      */void wrnOspfIfEntry_set( OIDC_T lastmatch, int tcount, OIDC_T *tlist,                         SNMP_PKT_T *pktp, VB_T *vbp ){    /* lock binary semaphore so that we can synchronization into envoy snmp */    semTake( pWrnEnvoyReq->envoyBSem, WAIT_FOREVER );    wrnOspfEnvoy_setIf( tcount, tlist, pktp, vbp, MAPI_COMMIT );    semGive( pWrnEnvoyReq->envoyBSem );    return;}#endif /* __OSPF_MIB__ */

⌨️ 快捷键说明

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