?? ospf_mib_helper.c
字號:
/***************************************************************************************** ospfMapiVirtNbrCompare - compare two virtual neighbor instances** This routine is invoked by AVL to compares two neighbor instances index values.* Node is a node on the given AVL tree. Key is the search criteria provided by the* mib api when invoking the avl routines.** RETURNS: An integer greater than, equal to, or less than 0, according* to whether <s1> is lexicographically greater than, equal to,* or less than <s2>, respectively.** ERRNO: N/A** NOMANUAL*/LOCAL int ospfMapiVirtNbrCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfVirtNbr_t *pVirtNbr; ulong_t mibIndex[OSPF_VIRT_NBR_INSTANCE_LEN]; int oidLength; pVirtNbr = (mApiOspfVirtNbr_t *)node; oidLength = OSPF_VIRT_NBR_INSTANCE_LEN; /* reconstruct the index values for ospfNbrTable. ospfNbrTable is indexed by * ospfNbrIpAddr and ospfNbrAddressLessIndex */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pVirtNbr->ospfVirtNbrArea, &mibIndex[0] ); ospf_mApi_ipAddr2IpIndex( pVirtNbr->ospfVirtNbrRtrId, &mibIndex[4] ); return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiExtLsdbCompare - compare two external lsdb instances** This routine is invoked by AVL to compares two lsdb instances index values.* Node is a node on the given AVL tree. Key is the search criteria provided by the* mib api when invoking the avl routines.** RETURNS: An integer greater than, equal to, or less than 0, according* to whether <s1> is lexicographically greater than, equal to,* or less than <s2>, respectively.** ERRNO: N/A** NOMANUAL*/LOCAL int ospfMapiExtLsdbCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfExtLsdb_t *pExtLsdb; ulong_t mibIndex[OSPF_EXT_LSDB_INSTANCE_LEN]; int oidLength; pExtLsdb = (mApiOspfExtLsdb_t *)node; oidLength = OSPF_EXT_LSDB_INSTANCE_LEN; /* reconstruct the index values for ospfExtLsdbTable. ospfExtLsdbTable is indexed * by ospfExtLsdbType, ospfExtLsdbLsid and ospfExtLsdbRouterId */ memset( mibIndex, 0, sizeof(mibIndex) ); mibIndex[0] = pExtLsdb->ospfExtLsdbType; ospf_mApi_ipAddr2IpIndex( pExtLsdb->ospfExtLsdbLsid, &mibIndex[1] ); ospf_mApi_ipAddr2IpIndex( pExtLsdb->ospfExtLsdbRouterId, &mibIndex[5] ); return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiAreaAggregateCompare - compare two Area Aggregate instances** This routine is invoked by AVL to compares two Area Aggregate instances index values.* Node is a node on the given AVL tree. Key is the search criteria provided by the* mib api when invoking the avl routines.** RETURNS: An integer greater than, equal to, or less than 0, according* to whether <s1> is lexicographically greater than, equal to,* or less than <s2>, respectively.** ERRNO: N/A** NOMANUAL*/LOCAL int ospfMapiAreaAggregateCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfAreaAggregate_t *pAreaAg; ulong_t mibIndex[OSPF_AREA_AGGREGATE_INSTANCE_LEN]; int oidLength; pAreaAg = ( mApiOspfAreaAggregate_t *)node; oidLength = OSPF_AREA_AGGREGATE_INSTANCE_LEN; /* reconstruct the index values for ospfExtLsdbTable. ospfExtLsdbTable is indexed * by ospfExtLsdbType, ospfExtLsdbLsid and ospfExtLsdbRouterId */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pAreaAg->ospfAreaAggregateAreaID, &mibIndex[0] ); mibIndex[4] = pAreaAg->ospfAreaAggregateLsdbType; ospf_mApi_ipAddr2IpIndex( pAreaAg->ospfAreaAggregateNet, &mibIndex[5] ); ospf_mApi_ipAddr2IpIndex( pAreaAg->ospfAreaAggregateMask, &mibIndex[9] ); return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/****************** internal ospf-mib method routines ********************//***************************************************************************************** ospf_mApi_protoCheck - OSPF protocol consistency checks** This routine performs the protocol consistency checks. It check if the OSPF protocol* is enabled. It is called when an attempt is made to instantiate an instance of* conceptual tabular row. Specifically, this routine is called each time a tabular row is* created with the createAndGo(4) rowStatus enumeration value or if the rowStatus* enumeration value for an existing row is set to active(1).** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS ospf_mApi_protoCheck( void ){ mApiOspfGenGroup_t *pMapiOspfGenGroup; pMapiOspfGenGroup = (mApiOspfGenGroup_t *)thisMapi->pMapiOspfGenGroup; if ( pMapiOspfGenGroup->ospfAdminStat == EmApiOspf_disabled ) { mApiOspfPrintf(("ospf_mApi_protoCheck:ospfAdminStat not enabled\n")); return ERROR; } return OK;}/****************************************************************************************** ospf_mApi_areaStatusUpdate - examine and update various Area attributes.** This routine examine and update varios Area attributes. This routine is invoked when* the state of of an interface connected to an area has changed. It checks the transit* area status, update the counter that tracks the number of active areas in the router,* and determined if the area border router (ABR) status for the router needs to be* updated.** RETURNS: N/A** NOMANUAL*/LOCAL void ospf_mApi_areaStatusUpdate( mApiOspfArea_t *pArea, ushort_t initialActiveIfCnt, ushort_t initialActiveHostCnt ){ mApiOspfGenGroup_t *pMapiOspfGenGroup; if ( pArea == NULL ) return; /* special case for handling backbone area */ if ( pArea->ospfAreaId == OSPF_BACKBONE_AREA ) { /* determine if the backbone area is still active. Only the numActiveIf * counter for the backbone is considered here. Ignore the numActiveHost * counter since host interface is somewhat "passive" and should not take * into account when determine if the backbone area is active. */ if ( pArea->numActiveIf > 0 ) thisMapi->ospfBackboneActive = TRUE; else thisMapi->ospfBackboneActive = FALSE; } /* a transit area must have at least one active interface attach to it. * Otherwise, virtual link will not operate. The characteristic of a * transit area is only meaningful is there is virtual link configured * in that area */ if ( (pArea->numActiveIf > 0) && (pArea->numActiveVirtIf > 0) ) pArea->isTransitArea = EmApiOspf_true; /* mark this as an transit area */ else pArea->isTransitArea = EmApiOspf_false; /* keep track the number of active area that we have. If there is no active * interface in the area, area can no longer be labeled as active. Here we * don't consider the host interface at all. */ if ( (pArea->numActiveIf == 0) && (initialActiveIfCnt != 0) ) { if (thisMapi->numActiveArea > 0) /* so that we don't go to negative */ thisMapi->numActiveArea--; } else { /* if there was previously no active interface attached to this area and * there is at least one now, increment the numActiveArea counter. If there was * at least one active interface attached previously, do nothing because * the area has already been declared as active. Notice that the number of * host interface in an area is not considered here. This is because most of * the configurations (such as virtual link) requires an active (non host) * interface in order to operate. */ if ( (initialActiveIfCnt == 0) && (pArea->numActiveIf > 0) ) thisMapi->numActiveArea++; } /* update the ABR status */ pMapiOspfGenGroup = (mApiOspfGenGroup_t *)thisMapi->pMapiOspfGenGroup; if ( thisMapi->numActiveArea > 1 ) pMapiOspfGenGroup->ospfAreaBdrRtrStatus = EmApiOspf_true; else pMapiOspfGenGroup->ospfAreaBdrRtrStatus = EmApiOspf_false; return;}/***************************************************************************************** ospf_mApi_areaRegsiterIf - register a client Interface to an area** This routine add a client interface to the listIfAttached linked list for an area.* There are three types of client that gets onto the list: physical interface,* virtual interface and host interface. It is invoked when (1) the area is first created* (2) the rowStatus for the attached interface has changed (i.e. from active to* notInService) (3) a new client interface is created.** RETURNS: OK or ERROR** NOMANUAL*/LOCAL STATUS ospf_mApi_areaRegisterIf( mApiOspfArea_t *pArea, void *pNewClient, mApiOspfClientType_t clientType, int oldStatus ){ mApiOspfClient_t *pAttachedClient; ushort_t initialActiveIf; ushort_t initialActiveHost; mApiOspfRowStatus_t currStatus; /* save the current active interface count for later comparison */ initialActiveIf = pArea->numActiveIf; initialActiveHost = pArea->numActiveHost; /* make sure we don't have a duplicate entry */ for ( pAttachedClient = (mApiOspfClient_t *)lstFirst( &pArea->listIfAttached); pAttachedClient != NULL; pAttachedClient = (mApiOspfClient_t *)lstNext( &pAttachedClient->node ) ) { if ( pAttachedClient->clientType != clientType ) continue; switch( pAttachedClient->clientType ) { case EmApiOspfClientType_intf: { mApiOspfIf_t *pIf; mApiOspfIf_t *pClient; pIf = (mApiOspfIf_t *)pAttachedClient->pClient; pClient = (mApiOspfIf_t *)pNewClient; if ( (pIf->ospfIfIpAddress == pClient->ospfIfIpAddress) && (pIf->ospfAddressLessIf == pClient->ospfAddressLessIf) ) { mApiOspfPrintf(("ospf_mApi_areaRegisterIf:Client exist\n")); /* remember its previous state */ pAttachedClient->oldStatus = oldStatus; /* get the current client row status information */ currStatus = pClient->ospfIfStatus; /* interface transition from active to notReady or notInService? */ if ( (oldStatus == (int)EmApiOspfRowStatus_active) && ( (currStatus == EmApiOspfRowStatus_notInService) || (currStatus == EmApiOspfRowStatus_notReady) ) ) { if ( pIf->ospfIfAdminStat == EmApiOspf_enabled ) { if ( pArea->numActiveIf > 0 ) pArea->numActiveIf--; /* update the area attributes if necessary */ ospf_mApi_areaStatusUpdate( pArea, initialActiveIf, initialActiveHost ); } return OK; } /* interface transition from notInService or notReady to active? */ else if ( (currStatus == EmApiOspfRowStatus_active) && ( (oldStatus == (int)EmApiOspfRowStatus_notInService) || (oldStatus == (int)EmApiOspfRowStatus_notReady) ) ) { if ( pIf->ospfIfAdminStat == EmApiOspf_enabled ) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -