📄 ospf_mib_wrn_helper.c
字号:
} } break; case mApiWrnOspfRedistributeRIPRoutes: if ( reqType == MAPI_TEST ) { switch( valueBuf ) { case EmApiOspf_true: case EmApiOspf_false: break; default: OSPF_MIB_ERROR_SET( pRequest, MAPI_WRONG_VALUE, pObject->oidPrefixEnum ); return ERROR; } } else { if ( pMapiWrnOspfGenGroup->wrnOspfRedistributeRIPRoutes != (mApiOspfTrueValue_t)valueBuf ) { pMapiWrnOspfGenGroup->wrnOspfRedistributeRIPRoutes = (mApiOspfTrueValue_t)valueBuf; /* to allow the redistribute option changes to take effert, the * ospf protocol must be enabled and the router must be configured * as an ASBR. OSPF will not redistribute any external routes if * the router is not an ASBR. */ if ( (pMapiOspfGenGroup->ospfAdminStat == EmApiOspf_enabled) && (pMapiOspfGenGroup->ospfASBdrRtrStatus == EmApiOspf_true) ) thisMapi->dynamicConfig = TRUE; } } break; case mApiWrnOspfRedistributeBGPRoutes: if ( reqType == MAPI_TEST ) { switch( valueBuf ) { case EmApiOspf_true: case EmApiOspf_false: break; default: OSPF_MIB_ERROR_SET( pRequest, MAPI_WRONG_VALUE, pObject->oidPrefixEnum ); return ERROR; } } else { if ( pMapiWrnOspfGenGroup->wrnOspfRedistributeBGPRoutes != (mApiOspfTrueValue_t)valueBuf ) { pMapiWrnOspfGenGroup->wrnOspfRedistributeBGPRoutes = (mApiOspfTrueValue_t)valueBuf; /* to allow the redistribute option changes to take effert, the * ospf protocol must be enabled and the router must be configured * as an ASBR. OSPF will not redistribute any external routes if * the router is not an ASBR. */ if ( (pMapiOspfGenGroup->ospfAdminStat == EmApiOspf_enabled) && (pMapiOspfGenGroup->ospfASBdrRtrStatus == EmApiOspf_true) ) thisMapi->dynamicConfig = TRUE; } } break; default: OSPF_MIB_ERROR_SET( pRequest, MAPI_WRONG_VALUE, pObject->oidPrefixEnum ); return ERROR; } return OK;}/***************************************************************************************** wrnOspf_mApi_areaHelperGet - retrieve the value of an object from the wrnOspfAreaTable** This routine retrieve the value of an object from the wrnOspfAreaTable. The routine* checks the given buffer length before copying the object value to the given buffer.* If it is too short, the actual data length will be returned.** RETURNS: OK or ERROR** ERRNO: N/A*/STATUS wrnOspf_mApi_areaHelperGet( void *pRow, mApiRequest_t *pRequest, mApiObject_t *pObject ){ mApiWrnOspfArea_t *pSpfArea; pSpfArea = (mApiWrnOspfArea_t *)pRow; switch( pObject->oidPrefixEnum ) { case mApiWrnOspfAreaId: { uchar_t area_id[4]; /* sanity check the given buflen */ OSPF_MIB_BUFLEN_CHECK( pRequest, pObject, sizeof(area_id) ); /* store the Area ID as octet string to avoid byte ordering problem */ memset( area_id, 0, sizeof(area_id) ); ospf_mApi_ipAddr2OctetString( pSpfArea->wrnOspfAreaId, area_id ); memcpy( (uchar_t *)(pObject->pValueBuf), area_id, sizeof(area_id) ); pObject->valueLen = sizeof(area_id); } break; case mApiWrnOspfAreaType10LsaCount: /* sanity check the given buflen */ OSPF_MIB_BUFLEN_CHECK( pRequest, pObject, sizeof(ulong_t) ); *(ulong_t *)pObject->pValueBuf = pSpfArea->wrnOspfAreaType10LsaCount; pObject->valueLen = sizeof(ulong_t); break; case mApiWrnOspfAreaType10LsaCksumSum: /* sanity check the given buflen */ OSPF_MIB_BUFLEN_CHECK( pRequest, pObject, sizeof(ulong_t) ); *(ulong_t *)pObject->pValueBuf = pSpfArea->wrnOspfAreaType10LsaCksumSum; pObject->valueLen = sizeof(ulong_t); break; default: OSPF_MIB_ERROR_SET( pRequest, MAPI_GEN_ERROR, pObject->oidPrefixEnum ); pObject->valueLen = 0; return ERROR; } return OK;}/***************************************************************************************** wrnOspf_mApi_areaDelete - delete an instance of Type-10 Opaque LSA Area** This routine delete the given Type-10 Opaque LSA area instance from the * wrnOspfAreaTable. The instance will be removed from the avl tree and all memory * occupied by the instance will be reclaimed. The appropriate MIB API statistics will * also be update if necessary.** RETURNS: N/A**/void wrnOspf_mApi_areaDelete( ulong_t wrnOspfAreaId ){ mApiWrnOspfArea_t *pType10Area; mApiOspfAvlClass_t *pWrnAreaAvl; GENERIC_ARGUMENT key; ulong_t mibIndex[OSPF_AREA_INSTANCE_LEN]; /* build the index value */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( wrnOspfAreaId, &mibIndex[0] ); key.p = (void *)mibIndex; pWrnAreaAvl = &thisMapi->wrnOspfAreaAvl; /* delete this node from the avl tree */ pType10Area = (mApiWrnOspfArea_t *)avlDelete( &pWrnAreaAvl->pOspfAvlRoot, key, pWrnAreaAvl->ospfAvlCompareRtn); /* avlDelete returns NULL if it can't find the node to delete. This is ok since * deleting a row that does not exist is acceptable */ if ( pType10Area == NULL ) return; /* reclaim the memory */ memset( (char *)pType10Area, 0, sizeof(mApiWrnOspfArea_t) ); lstAdd( &pWrnAreaAvl->ospfFreePoolList, (NODE *)pType10Area ); /* reclaim the max number of entries allowed */ thisMapi->mApiWrnOspfCurrAreaCnt--; return;}/*************************************************************************************** wrnOspf2Mapi_area_update - update Type-10 Opaque LSA cumulative statistics** This routine update the Type-10 Opaque LSA cumulative statistics for the* wrnOspfAreaTable found in the WRN OSPF Enterprise MIB. The routine first try to locate* the row to which it needs to update. If the lookup failed, a new instance of the* Type-10 Opaque LSA will be added to the Type-10 Opaque LSA avl tree.** RETURNS: N/A** ERRNO: N/A*/void wrnOspf2Mapi_area_update( void *pOspf2MapiReqBuf ){ mApiOspfArea_t *pArea; mApiWrnOspfArea_t *pType10Area; ospf2MapiReqBuf_t *pOspfReqBuf; mApiOspfAvlClass_t *pWrnAreaAvl; GENERIC_ARGUMENT key; STATUS rc; ulong_t mibIndex[OSPF_AREA_INSTANCE_LEN]; pOspfReqBuf = (ospf2MapiReqBuf_t *)pOspf2MapiReqBuf; /* type-10 lsa has area scope. Don't allow an instance to be created if the area * doesn't exist */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pOspfReqBuf->valueBuf[0], &mibIndex[0] ); key.p = (void *)mibIndex; /* lock mib api mutex semaphore for exclusive access to mApiOspfClass_t */ if ( semTake( thisMapi->semMapiMutex, thisMapi->semTimeout ) == ERROR ) { mApiOspfPrintf(("wrnOspf2Mapi_area_update:semTake timeout!\n")); return; } /* first determine if the area exist in ospf-mib */ pArea = (mApiOspfArea_t *)avlSearch( thisMapi->ospfAreaAvl.pOspfAvlRoot, key, thisMapi->ospfAreaAvl.ospfAvlCompareRtn); if ( pArea == NULL ) { thisMapi->mApiWrnOspfAreaFailedCnt++; semGive( thisMapi->semMapiMutex ); mApiOspfPrintf(("wrnOspf2Mapi_area_update:Area not found\n")); return; } /* area exit, now search the avl tree for the wrnOspfAreaTable */ pWrnAreaAvl = &thisMapi->wrnOspfAreaAvl; key.p = (void *)mibIndex; pType10Area = (mApiWrnOspfArea_t *)avlSearch(pWrnAreaAvl->pOspfAvlRoot, key, pWrnAreaAvl->ospfAvlCompareRtn); if ( pType10Area == NULL ) { if ( thisMapi->mApiWrnOspfCurrAreaCnt >= thisMapi->mApiWrnOspfMaxArea ) { thisMapi->mApiWrnOspfAreaMaxReached++; semGive( thisMapi->semMapiMutex ); mApiOspfPrintf(("wrnOspf2Mapi_area_update:max capacity reached.\n")); return; } /* get memory from free pool */ pType10Area = (mApiWrnOspfArea_t *)lstGet( &pWrnAreaAvl->ospfFreePoolList ); if ( pType10Area == NULL ) { /* we know we have not reached the max capacity. Allocate a new node */ pType10Area = (mApiWrnOspfArea_t *)calloc( 1, sizeof(mApiWrnOspfArea_t) ); if ( pType10Area == NULL ) { pWrnAreaAvl->memReqFailedCnt++; semGive( thisMapi->semMapiMutex ); mApiOspfPrintf(("wrnOspf2Mapi_area_update:resource unavailable.\n")); return; } } /* insert the new row in the ospf lsdb avl tree */ rc = avlInsert(&pWrnAreaAvl->pOspfAvlRoot, pType10Area, key, pWrnAreaAvl->ospfAvlCompareRtn ); if ( rc != OK ) { /* fatal error in the AVL insert routine. Return memory to free pool */ memset( (char *)pType10Area, 0, sizeof(mApiWrnOspfArea_t) ); lstAdd( &pWrnAreaAvl->ospfFreePoolList, (NODE *)pType10Area ); thisMapi->mApiWrnOspfAreaFailedCnt++; semGive( thisMapi->semMapiMutex ); mApiOspfPrintf(("wrnOspf2Mapi_area_update:avlInsert failed.\n")); return; } thisMapi->mApiWrnOspfCurrAreaCnt++; /* another instance has been created */ /* fill in the index values for the ospflsdbTable */ pType10Area->wrnOspfAreaId = pOspfReqBuf->valueBuf[0]; /* register this Type-10 Opaque area */ pArea->pOpaqueArea = pType10Area; } /* either the instance has been found or a new one has been created */ pType10Area->wrnOspfAreaType10LsaCount = pOspfReqBuf->valueBuf[1]; pType10Area->wrnOspfAreaType10LsaCksumSum = ntohl(pOspfReqBuf->valueBuf[2]); semGive( thisMapi->semMapiMutex ); return;}/***************************************************************************************** wrnOspf_mApi_lsdbHelperGet - retrieve the value of a Type-10 Opaque LSA object** This routine retrieve the value of a a Type-10 Opaque LSA object object from the* wrnOspfLsdbTable. The routine checks the given buffer length before copying the object* value to the given buffer. If it is too short, the actual data length will be returned.** RETURNS: OK or ERROR** ERRNO: N/A*/STATUS wrnOspf_mApi_lsdbHelperGet( void *pRow, mApiRequest_t *pRequest, mApiObject_t *pObject ){ mApiWrnOspfLsdb_t *pLsa; pLsa = (mApiWrnOspfLsdb_t *)pRow; switch( pObject->oidPrefixEnum ) { case mA
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -