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

📄 ospf_mib_api.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
* NOMANUAL*/LOCAL void wrnOspf_mApi_areaIndexSet( void *pRow, mApiRequest_t *pRequest ){    mApiWrnOspfArea_t *pArea;    pArea = (mApiWrnOspfArea_t *)pRow;    /* wrnOspfAreaTable is indexed by wrnOspfAreaId */    ospf_mApi_ipAddr2IpIndex( pArea->wrnOspfAreaId, &pRequest->pInstance[0] );    pRequest->instanceLen = OSPF_AREA_INSTANCE_LEN;    return;}/**************************************************************************************** wrnOspf_mApi_lsdbIndexSet - set the index value for wrnOspfLsdbTable** This routine set the next index value for the request for the wrnOspfLsdbTable** RETURNS: OK or ERROR** NOMANUAL*/LOCAL void wrnOspf_mApi_lsdbIndexSet( void *pRow, mApiRequest_t *pRequest ){    mApiWrnOspfLsdb_t *pLsdb;    pLsdb = (mApiWrnOspfLsdb_t *)pRow;    /* wrnOspfLsdbTable is indexed by wrnOspfLsdbAreaId, wrnOspfLsdbType, wrnOspfLsdbLsid     * and wrnOspfLsdbRouterId     */    ospf_mApi_ipAddr2IpIndex( pLsdb->wrnOspfLsdbAreaId, &pRequest->pInstance[0] );    pRequest->pInstance[4] = (int)pLsdb->wrnOspfLsdbType;    ospf_mApi_ipAddr2IpIndex( pLsdb->wrnOspfLsdbLsid, &pRequest->pInstance[5] );    ospf_mApi_ipAddr2IpIndex( pLsdb->wrnOspfLsdbRouterId, &pRequest->pInstance[9] );    pRequest->instanceLen = OSPF_LSDB_INSTANCE_LEN;    return;}/**************************************************************************************** wrnOspf_mApi_localLsdbIndexSet - set the index value wrnOspfLocalLsdbTable** This routine set the next index value for the request for the wrnOspfLocalLsdbTable** RETURNS: OK or ERROR** NOMANUAL*/LOCAL void wrnOspf_mApi_localLsdbIndexSet( void *pRow, mApiRequest_t *pRequest ){    mApiWrnOspfLocalLsdb_t *pLsdb;    pLsdb = (mApiWrnOspfLocalLsdb_t *)pRow;    /* wrnOspfLsdbTable is indexed by wrnOspfLocalLsdbAreaId, wrnOspfLocalLsdbIpAddress,     * wrnOspfLocalLsdbType, wrnOspfLocalLsdbLsid and wrnOspfLocalLsdbRouterId     */    ospf_mApi_ipAddr2IpIndex( pLsdb->wrnOspfLocalLsdbAreaId, &pRequest->pInstance[0] );    ospf_mApi_ipAddr2IpIndex( pLsdb->wrnOspfLocalLsdbIpAddress, &pRequest->pInstance[4] );    pRequest->pInstance[8] = (int)pLsdb->wrnOspfLocalLsdbType;    ospf_mApi_ipAddr2IpIndex( pLsdb->wrnOspfLocalLsdbLsid, &pRequest->pInstance[9] );    ospf_mApi_ipAddr2IpIndex( pLsdb->wrnOspfLocalLsdbRouterId, &pRequest->pInstance[13] );    pRequest->instanceLen = OSPF_LOCAL_LSDB_INSTANCE_LEN;    return;}/**************************************************************************************** wrnOspf_mApi_extLsdbIndexSet - set the next index value for wrnOspfExtLsdbTable** This routine set the next index value for the request for the wrnOspfExtLsdbTable** RETURNS: OK or ERROR** NOMANUAL*/LOCAL void wrnOspf_mApi_extLsdbIndexSet( void *pRow, mApiRequest_t *pRequest ){    mApiWrnOspfExtLsdb_t *pExtLsdb;    pExtLsdb = (mApiWrnOspfExtLsdb_t *)pRow;    /* ospfExtLsdbTable is indexed by ospfExtLsdbType, ospfExtLsdbLsid and     * ospfExtLsdbRouterId     */    pRequest->pInstance[0] = (int)pExtLsdb->wrnOspfExtLsdbType;    ospf_mApi_ipAddr2IpIndex( pExtLsdb->wrnOspfExtLsdbLsid, &pRequest->pInstance[1] );    ospf_mApi_ipAddr2IpIndex( pExtLsdb->wrnOspfExtLsdbRouterId, &pRequest->pInstance[5] );    pRequest->instanceLen = OSPF_EXT_LSDB_INSTANCE_LEN;    return;}/***************************************************************************************** ospf_mApi_processSetReq - process the SNMP SET request** This routine process the SNMP SET request. Depends on the reqType, it calls the* ospf_mApi_setHelperRtn to validates, sets, or deletes a conceptual table row. If* the reqType is MAPI_COMMIT request, it also calls the ospf_mApi_dynConfigRtn to* dynamically reconfiguration the OSPF protocol** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS ospf_mApi_processSetReq( mApiRequest_t *pRequest, mApiReqType_t reqType,                                      ulong_t instanceLen,                                       MAPI_HELPER_SET_RTN ospf_mApi_setHelperRtn,                                      MAPI_HELPER_CONFIG_RTN ospf_mApi_dynConfigRtn ){    rsRequest_t    rsReqType;    STATUS         rc;    int            numObjects;    /* make sure MIB API is initialized */    OSPF_MAPI_INIT_CHECK();        /* asr: set the virtual stack context */    #if defined (VIRTUAL_STACK)        virtualStackNumTaskIdSet (ospf.ospf_vsid);    #endif /* VIRTUAL_STACK */    /* make sure the request message is valid */    if ( pRequest == NULL )    {        mApiOspfError(("ospf_mApi_processSetReq:invalid pRequest pointer.\n"));        return ERROR;    }    /* make sure the arguments in request message are valid */    if ( (pRequest->pInstance == NULL) || (pRequest->instanceLen != instanceLen) ||         (pRequest->numObjects == 0) || (pRequest->pObjectList == NULL) )    {        pRequest->error = (ushort_t)MAPI_GEN_ERROR;        pRequest->errorObjIndex = 0;        return ERROR;    }    /* validate SNMP transaction, make sure we are in the right state */    if ( ospf_mApi_setReqCnt( reqType ) == ERROR )    {         pRequest->error = (ushort_t)MAPI_GEN_ERROR;        pRequest->errorObjIndex = 0;        mApiOspfError(("ospf_mApi_processSetReq:Unexpected SNMP (%s) transaction!\n",                       mApiRequest[reqType]));        return ERROR;    }    /* MAPI_COMPLETE request is for hand-shaking only, indicate the end of previous     * TEST/SET/COMMIT/UNDO transaction     * TODO: we don't implement undo now, so just retruen ok if we received undo     *       request     */    if ( (reqType == MAPI_COMPLETE) || (reqType == MAPI_UNDO) )        return OK;    /* initialize global and local variables */    rc = OK;    pRequest->error = (ushort_t)MAPI_NO_ERROR;    pRequest->errorObjIndex = 0;        /* convert mib api request type to the row status request type */    rsReqType = ospf_mApi2rs_reqTypeGet( reqType );    if ( rsReqType == RS_ERROR_REQUEST )    {        pRequest->error = (ushort_t)MAPI_GEN_ERROR;        pRequest->errorObjIndex = 0;        return ERROR;    }    /* lock mib api mutex semaphore for exclusive access to mApiOspfClass_t */    semTake( thisMapi->semMapiMutex, WAIT_FOREVER );    /* explicitly intialize dynamic configuration variables */    thisMapi->dynamicConfig = FALSE;    thisMapi->dynamicDelete = FALSE;    /* remember the current request type we are processing */    thisMapi->currMapiReqType = reqType;        for ( numObjects = 0; numObjects < pRequest->numObjects; numObjects++ )    {        /* stash the current mib api object info that we are accessing so that we         * can directly access it in the rowStatus rowAccess routine.         */        thisMapi->pMapiCurrObj = &pRequest->pObjectList[numObjects];        /* Fixed SPR#85806 - set the currObjInProcess variable to the current object         * that is in processed         */        thisMapi->currObjInProcess = numObjects;        /* make sure the set helper routine is valid */        if ( ospf_mApi_setHelperRtn == NULL )        {            mApiOspfError(("ospf_mApi_processSetReq:%s Invalid helper set routine\n",                            mApiRequest[reqType]));            return ERROR;        }        /* let helper routine does the rest */        rc = ospf_mApi_setHelperRtn( pRequest, rsReqType );        if ( rc == ERROR )        {            thisMapi->pMapiCurrObj = NULL;            if ( reqType == MAPI_TEST )                thisMapi->mApiTestReqFailedCnt++;            else if (reqType == MAPI_COMMIT_FORCE )                thisMapi->mApiNvmSetReqFailedCnt++;            else                thisMapi->mApiCommitReqFailedCnt++;            semGive( thisMapi->semMapiMutex );            mApiOspfError(("ospf_mApi_processSetReq:%s failed\n", mApiRequest[reqType]));            return ERROR;        }    }    /* if we don't have to commit the request, return immediately */    if ( reqType == MAPI_TEST )    {        thisMapi->pMapiCurrObj = NULL;  /* reset 'em */        semGive( thisMapi->semMapiMutex );        return rc;    }    /* reconfigure OSPF with the changes required. This is done here (instead of     * the ospf_mApi_xxxHelperSet() routine) so that we can handle the reconfiguration     * for all varbinds at once. Effectively, we will reconfigure the row as a     * whole so to cause minimum disruption to the OSPF protocol.     */    if ( thisMapi->dynamicConfig == TRUE )     {        if ( (pRequest->pReqCookie != NULL) && (thisMapi->ospfProtoInit == TRUE) )        {            if ( ospf_mApi_dynConfigRtn != NULL )            {                rc = ospf_mApi_dynConfigRtn( pRequest );                if ( rc == ERROR )                {                    thisMapi->mApiDynConfigReqFailedCnt++;                    thisMapi->pMapiCurrObj = NULL;                    semGive( thisMapi->semMapiMutex );                    mApiOspfError(("ospf_mApi_processSetReq:dynConfig failed\n"));                    return ERROR;                }            }        }        if ( thisMapi->dynamicDelete == TRUE )        {            /* invoke the application provided delete callback routine so that the table              * row that has just been deleted from management database can also be removed              * from the nvram. It only makes sense to invoke the nvram callback routines              * only if the request is not the MAPI_NVRAM_SET             */            if ( (reqType == MAPI_COMMIT) && (thisMapi->nvramDelRtn != NULL) )            {                STATUS  err;                                /* notice that even if the nvram delete operation failed, we don't return                 * errro to the caller. The is because from the snmp point of view, we                 * have succeeded to perform the dynamic reconfiguration.                 */                err = thisMapi->nvramDelRtn( pRequest->pInstance, pRequest->instanceLen );                if ( err == ERROR )                {                    /* nvram delete failed, bail out. We don't return error to the caller                     * even if nvram delete failed simply because from the snmp point of                     * view, the dynamic configuration is succeeded.                     */                    mApiOspfError(("ospf_mApi_processSetReq:nvramDelRtn() failed\n"));                }            }        }        else        {            /* yahoo, dynamic configuration actually works! Invoke the application              * provided save routine to save all objects in this varbind to the nvram             */            if ( (reqType == MAPI_COMMIT) && (thisMapi->nvramSaveRtn != NULL) )            {                STATUS  err;                                for ( numObjects = 0; numObjects < pRequest->numObjects; numObjects++ )                {                    /* temporary stash the current mib api object info for convenience */                    thisMapi->pMapiCurrObj = &pRequest->pObjectList[numObjects];                    thisMapi->currObjInProcess = numObjects;                    err = thisMapi->nvramSaveRtn( pRequest->pInstance,                                                   pRequest->instanceLen,                                                  thisMapi->pMapiCurrObj->oidPrefixEnum,                                                  thisMapi->pMapiCurrObj->pValueBuf,                                                  thisMapi->pMapiCurrObj->valueLen );                    if ( err == ERROR )                    {                          /* nvram save failed, bail out. Although nvram save has failed,                         * we don't return error to caller because from the snmp point of                         * view, the dynamic reconfiguration iss succeeded.                         */                        mApiOspfPrintf(("ospf_mApi_processSetReq:nvramSaveRtn() failed\n"));                        break;                    }                }            }        }    }    thisMapi->pMapiCurrObj = NULL;  /* reset 'em */    semGive( thisMapi->semMapiMutex );    return rc;}/***************************************************************************************** ospf_mApi_processGetReq - process the SNMP SET request** This routine process the SNMP GET and GET_NEXT request. The avl tree search behavior* depends on the type reqType. For GET request, the avlSearch() will be called. For* GET_NEXT request, the avlMinimumGet() will be called if the successor is the first* instance in the table (i.e. pRequest->instanceLen = 0). Otherwise, avlSuccessorGet()* is invoked to retrieve the next instance. Using the instance retrieved from the avl* search, it then calls the ospf_mApi_indexSetRtn will also be called to correctly* set the next index values for the instance.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS ospf_mApi_processGetReq( mApiRequest_t *pRequest, mApiReqType_t reqType,                                      ulong_t instanceLen,                                       mApiOspfAvlClass_t *pOspfAvlTree,                                      MAPI_HELPER_GET_RTN ospf_mApi_getHelperRtn,                                      MAPI_INDEX_SET_RTN ospf_mApi_indexSetRtn ){    void              *pRow;    GENERIC_ARGUMENT  key;    mApiObject_t      *pObject;    int               numObjects;    /* make sure MIB API is initialized */    OSPF_MAPI_INIT_CHECK();    /* asr: set the virtual stack context */    #if defined (VIRTUAL_STACK)        virtualStackNumTaskIdSet (ospf.ospf_vsid);    #endif /* VIRTUAL_STACK */

⌨️ 快捷键说明

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