📄 ospf_mib_utilities.c
字号:
break; case MAPI_TEST_FORCE: case MAPI_COMMIT_FORCE: case MAPI_GET_FORCE: rc = ERROR; break; } return rc;}/**************************************************************************************** ospf_mApi_requestHelper - helper routine for sending request to OSPF MIB API** This is the helper routine for sending the GET, GET NEXT, TEST, and/or COMMIT* request to OSPF MIB API. ** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS ospf_mApi_requestHelper( mApiRequest_t *pRequest, mApiReqType_t reqType, OSPF_MAPI_FUNCPTR mApiGetRequestFunc, OSPF_MAPI_FUNCPTR mApiSetRequestFunc ){ STATUS rc; rc = ERROR; switch( reqType ) { case MAPI_GET: case MAPI_GET_NEXT: if ( mApiGetRequestFunc != NULL ) rc = mApiGetRequestFunc( pRequest, reqType ); break; case MAPI_TEST: case MAPI_COMMIT: case MAPI_COMPLETE: if ( mApiSetRequestFunc == NULL ) printf("Read-Only Table!\n"); else rc = mApiSetRequestFunc( pRequest, reqType ); break; case MAPI_UNDO: case MAPI_TEST_FORCE: case MAPI_COMMIT_FORCE: case MAPI_GET_FORCE: default: printf("Unsupported MIB API request type: %s\n", mApiRequestType[reqType] ); rc = ERROR; break; } return rc;}/***************************************************************************************** wrnOspf_mApi_sendRequest - Invoke the proper MIB API function based on the reqType** This routine invokes the proper MIB API function for WRN-OSPF Enterprise MIB based on * the reqType. The value pointed to by pObjInfo->objectPrefixEnum is the unique * enumeration value for the objects in the WRN-OSPF Enterprise MIB defined by the * MIB API.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS wrnOspf_mApi_sendRequest( mApiRequest_t *pRequest, mApiReqType_t reqType, ospfMibList_t *pObjInfo ) { mApiObject_t *pReqObj; ulong_t *pInstance; char oidIndex[OSPF_INSTANCE_LEN_MAX*4]; STATUS rc; rc = OK; pReqObj = pRequest->pObjectList; pInstance = pRequest->pInstance; memset( oidIndex, 0, sizeof(oidIndex) ); /* figure out what to do... */ if ( (pReqObj->oidPrefixEnum >= mApiWrnOspfRFC1583Compatibility) && (pReqObj->oidPrefixEnum <= mApiWrnOspfType11LsaCksumSum) ) { /* validate the given OID length. Scalar object is equivalent to a table with * one column and one row. Thus, the expected oidLen will be one */ /* rc = ospf_mApi_oidValidate( pRequest->instanceLen, reqType, 1 ); */ rc = ospf_mApi_requestHelper( pRequest, reqType, ospfMapiGetWrnGenGroup, ospfMapiSetWrnGenGroup ); if ( (rc == ERROR) && (pRequest->error != MAPI_NO_ERROR) ) { /* format the display string */ sprintf( oidIndex, "%i", 0 ); /* diplay the error */ ospf_mApi_printError( pObjInfo, oidIndex, pRequest->error ); } else if ( (reqType != MAPI_COMPLETE) && (reqType != MAPI_TEST) ) { /* format the display string */ sprintf( oidIndex, "%i", 0 ); /* display the result */ if ( pReqObj->exception == MAPI_NO_EXCEPTION ) { ospf_mApi_printResult( pObjInfo, oidIndex, pReqObj->pValueBuf ); } else { ospf_mApi_printException( pObjInfo, oidIndex, pReqObj->exception ); } } } else if ( (pReqObj->oidPrefixEnum >= mApiWrnOspfAreaId) && (pReqObj->oidPrefixEnum <= mApiWrnOspfAreaType10LsaCksumSum) ) { /* validate the given OID length */ rc = ospf_mApi_oidValidate( pRequest->instanceLen, reqType, OSPF_AREA_INSTANCE_LEN ); if ( rc == MAPI_WRONG_OID_LEN ) return rc; /* invoke the wrnOspf_mApi_xxxArea() routine for wrnOspfAreaTable objects */ rc = ospf_mApi_requestHelper( pRequest, reqType, ospfMapiGetWrnArea, NULL ); if ( (rc == ERROR) && (pRequest->error != MAPI_NO_ERROR) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3]); /* diplay the error */ ospf_mApi_printError( pObjInfo, oidIndex, pRequest->error ); } else if ( (reqType != MAPI_COMPLETE) && (reqType != MAPI_TEST) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3]); /* display the result */ if ( pReqObj->exception == MAPI_NO_EXCEPTION ) { ospf_mApi_printResult( pObjInfo, oidIndex, pReqObj->pValueBuf ); } else { ospf_mApi_printException( pObjInfo, oidIndex, pReqObj->exception ); } } } else if ( (pReqObj->oidPrefixEnum >= mApiWrnOspfLsdbAreaId) && (pReqObj->oidPrefixEnum <= mApiWrnOspfLsdbAdvertisement) ) { /* validate the given OID length */ rc = ospf_mApi_oidValidate( pRequest->instanceLen, reqType, OSPF_LSDB_INSTANCE_LEN ); if ( rc == MAPI_WRONG_OID_LEN ) return rc; /* invoke the wrnOspf_mApi_xxxLsdb() routine for wrnOspfLsdbTable objects */ rc = ospf_mApi_requestHelper( pRequest, reqType, ospfMapiGetWrnLsdb, NULL ); if ( (rc == ERROR) && (pRequest->error != MAPI_NO_ERROR) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3], pInstance[4]); /* diplay the error */ ospf_mApi_printError( pObjInfo, oidIndex, pRequest->error ); } else if ( (reqType != MAPI_COMPLETE) && (reqType != MAPI_TEST) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3], pInstance[4]); /* display the result */ if ( pReqObj->exception == MAPI_NO_EXCEPTION ) { ospf_mApi_printResult( pObjInfo, oidIndex, pReqObj->pValueBuf ); } else { ospf_mApi_printException( pObjInfo, oidIndex, pReqObj->exception ); } } } else if ( (pReqObj->oidPrefixEnum >= mApiWrnOspfLocalLsdbAreaId) && (pReqObj->oidPrefixEnum <= mApiWrnOspfLocalLsdbAdvertisement) ) { /* validate the given OID length */ rc = ospf_mApi_oidValidate( pRequest->instanceLen, reqType, OSPF_LOCAL_LSDB_INSTANCE_LEN ); if ( rc == MAPI_WRONG_OID_LEN ) return rc; /* invoke the wrnOspf_mApi_xxxLsdb() routine for wrnOspfLocalLsdbTable objects */ rc = ospf_mApi_requestHelper( pRequest, reqType, ospfMapiGetWrnLocalLsdb, NULL ); if ( (rc == ERROR) && (pRequest->error != MAPI_NO_ERROR) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld.%ld:%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3], pInstance[4], pInstance[5], pInstance[6], pInstance[7], pInstance[8], pInstance[9], pInstance[10], pInstance[11], pInstance[12]); /* diplay the error */ ospf_mApi_printError( pObjInfo, oidIndex, pRequest->error ); } else if ( (reqType != MAPI_COMPLETE) && (reqType != MAPI_TEST) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld.%ld:%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3], pInstance[4], pInstance[5], pInstance[6], pInstance[7], pInstance[8], pInstance[9], pInstance[10], pInstance[11], pInstance[12]); /* display the result */ if ( pReqObj->exception == MAPI_NO_EXCEPTION ) { ospf_mApi_printResult( pObjInfo, oidIndex, pReqObj->pValueBuf ); } else { ospf_mApi_printException( pObjInfo, oidIndex, pReqObj->exception ); } } } else if ( (pReqObj->oidPrefixEnum >= mApiWrnOspfExtLsdbType) && (pReqObj->oidPrefixEnum <= mApiWrnOspfExtLsdbAdvertisement) ) { /* validate the given OID length */ rc = ospf_mApi_oidValidate( pRequest->instanceLen, reqType, OSPF_EXT_LSDB_INSTANCE_LEN ); if ( rc == MAPI_WRONG_OID_LEN ) return rc; /* invoke the ospf_mApi_xxxExtLsdb() routine for wrnOspfExtLsdbTable objects */ rc = ospf_mApi_requestHelper( pRequest, reqType, ospfMapiGetWrnExtLsdb, NULL ); if ( (rc == ERROR) && (pRequest->error != MAPI_NO_ERROR) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3], pInstance[4], pInstance[5], pInstance[6], pInstance[7], pInstance[8], pInstance[9], pInstance[10], pInstance[11], pInstance[12]); /* diplay the error */ ospf_mApi_printError( pObjInfo, oidIndex, pRequest->error ); } else if ( (reqType != MAPI_COMPLETE) && (reqType != MAPI_TEST) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3], pInstance[4], pInstance[5], pInstance[6], pInstance[7], pInstance[8], pInstance[9], pInstance[10], pInstance[11], pInstance[12]); /* display the result */ if ( pReqObj->exception == MAPI_NO_EXCEPTION ) { ospf_mApi_printResult( pObjInfo, oidIndex, pReqObj->pValueBuf ); } else { ospf_mApi_printException( pObjInfo, oidIndex, pReqObj->exception ); } } } else if ( (pReqObj->oidPrefixEnum >= mApiWrnOspfIfDstIpAddress) && (pReqObj->oidPrefixEnum <= mApiWrnOspfIfStatus) ) { /* validate the given OID length */ rc = ospf_mApi_oidValidate( pRequest->instanceLen, reqType, OSPF_WRN_INTF_INSTANCE_LEN ); if ( rc == MAPI_WRONG_OID_LEN ) return rc; /* invoke the ospf_mApi_xxxArea() routine for ospfAreaTable objects */ rc = ospf_mApi_requestHelper( pRequest, reqType, ospfMapiGetWrnIf, ospfMapiSetWrnIf ); if ( (rc == ERROR) && (pRequest->error != MAPI_NO_ERROR) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3]); /* diplay the error */ ospf_mApi_printError( pObjInfo, oidIndex, pRequest->error ); } else if ( (reqType != MAPI_COMPLETE) && (reqType != MAPI_TEST) ) { /* format the display string */ sprintf( oidIndex, "%ld.%ld.%ld.%ld", pInstance[0], pInstance[1], pInstance[2], pInstance[3]); /* display the result */ if ( pReqObj->exception == MAPI_NO_EXCEPTION ) { ospf_mApi_printResult( pObjInfo, oidIndex, pReqObj->pValueBuf ); } else { ospf_mApi_printException( pObjInfo, oidIndex, pReqObj->exception ); } } } else { /* Oops, enumeration value out of range... */ printf("WRN OSPF Enterpirse MIB Object Enumeration Value (%ld) out of range!\n", pReqObj->oidPrefixEnum ); rc = ERROR; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -