ospf_mib_helper.c
来自「vxworks下ospf协议栈」· C语言 代码 · 共 1,433 行 · 第 1/5 页
C
1,433 行
#include "mibApi.h"#include "ospf.h"#include "ospf_mib_helper.h"#include "ospf_mib_helper_update.h"#include "ospf_mib_api.h"#include "ospf_mib_wrn_helper.h"/* public data *//* private data */#define SUBNET_FOUND -2/* forward declarations */LOCAL STATUS ospf_mApi_ifRowValidate( mApiOspfIf_t *pIf );LOCAL STATUS ospf_mApi_areaAggregateRowValidate( mApiOspfAreaAggregate_t *pAreaAg );LOCAL STATUS ospf_mApi_virtIfRowValidate( mApiOspfVirtIf_t *pVirtIf );/********** Callback functions invoked by AVL routines to compare two instances **********//***************************************************************************************** ospfMapiAreaCompare - compare two area instances** This routine is invoked by AVL to compares two area 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 ospfMapiAreaCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfArea_t *pArea; ulong_t mibIndex[OSPF_AREA_INSTANCE_LEN]; int oidLength; pArea = (mApiOspfArea_t *)node; oidLength = OSPF_AREA_INSTANCE_LEN; /* reconstruct the index values for ospfAreaTable. ospfAreaTable is indexed by * ospfAreaId */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pArea->ospfAreaId, &mibIndex[0] ); return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiStubCompare - compare two stub instances** This routine is invoked by AVL to compares two stub 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 ospfMapiStubCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfStub_t *pStub; ulong_t mibIndex[OSPF_STUB_INSTANCE_LEN]; int oidLength; pStub = (mApiOspfStub_t *)node; oidLength = OSPF_STUB_INSTANCE_LEN; /* reconstruct the index values for ospfAreaTable. ospfAreaTable is indexed by * ospfAreaId */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pStub->ospfStubAreaId, &mibIndex[0] ); mibIndex[4] = pStub->ospfStubTOS; return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiLsdbCompare - compare two 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 ospfMapiLsdbCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfLsdb_t *pLsdb; ulong_t mibIndex[OSPF_LSDB_INSTANCE_LEN]; int oidLength; pLsdb = (mApiOspfLsdb_t *)node; oidLength = OSPF_LSDB_INSTANCE_LEN; /* reconstruct the index values for ospfLsdbTable. ospfLsdbTable is indexed by * ospfLsdbAreaId, ospfLsdbType, ospfLsdbLsid and ospfLsdbRouterId */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pLsdb->ospfLsdbAreaId, &mibIndex[0] ); mibIndex[4] = pLsdb->ospfLsdbType; ospf_mApi_ipAddr2IpIndex( pLsdb->ospfLsdbLsid, &mibIndex[5] ); ospf_mApi_ipAddr2IpIndex( pLsdb->ospfLsdbRouterId, &mibIndex[9] ); return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiHostCompare - compare two host instances** This routine is invoked by AVL to compares two area 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*/int ospfMapiHostCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfHost_t *pHost; ulong_t mibIndex[OSPF_HOST_INSTANCE_LEN]; int oidLength; pHost = (mApiOspfHost_t *)node; oidLength = OSPF_HOST_INSTANCE_LEN; /* reconstruct the index values for ospfHostTable. ospfHostTable is indexed by * ospfHostIpAddress and ospfHostTOS */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pHost->ospfHostIpAddress, &mibIndex[0] ); mibIndex[4] = pHost->ospfHostTOS; return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiIfCompare - compare two interface instances** This routine is invoked by AVL to compares two interface 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 ospfMapiIfCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfIf_t *pIf; ulong_t mibIndex[OSPF_INTF_INSTANCE_LEN]; int oidLength; pIf = (mApiOspfIf_t *)node; oidLength = OSPF_INTF_INSTANCE_LEN; /* reconstruct the index values for ospfIfTable. ospfIfTable is indexed by * ospfIfIpAddress and ospfAddressLessIf */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pIf->ospfIfIpAddress, &mibIndex[0] ); mibIndex[4] = pIf->ospfAddressLessIf; return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiIfMetricCompare - compare two interface metric instances** This routine is invoked by AVL to compares two interface metric 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 ospfMapiIfMetricCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfIfMetric_t *pIfm; ulong_t mibIndex[OSPF_METRIC_INSTANCE_LEN]; int oidLength; pIfm = (mApiOspfIfMetric_t *)node; oidLength = OSPF_METRIC_INSTANCE_LEN; /* reconstruct the index values for ospfIfTable. ospfIfMetricTable is indexed by * ospfIfMetricIpAddress, ospfIfMetricAddressLessIf and ospfIfMetricTOS */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pIfm->ospfIfMetricIpAddress, &mibIndex[0] ); mibIndex[4] = pIfm->ospfIfMetricAddressLessIf; mibIndex[5] = pIfm->ospfIfMetricTOS; return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiVirtIfCompare - compare two virtual interface instances** This routine is invoked by AVL to compares two virtual interface 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 ospfMapiVirtIfCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfVirtIf_t *pVirtIf; ulong_t mibIndex[OSPF_VIRT_INTF_INSTANCE_LEN]; int oidLength; pVirtIf = (mApiOspfVirtIf_t *)node; oidLength = OSPF_VIRT_INTF_INSTANCE_LEN; /* reconstruct the index values for ospfVirtIfTable. ospfVirtIfTable is indexed by * ospfVirtIfAreaId and ospfVirtIfNeighbor */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pVirtIf->ospfVirtIfAreaId, &mibIndex[0] ); ospf_mApi_ipAddr2IpIndex( pVirtIf->ospfVirtIfNeighbor, &mibIndex[4] ); return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}/***************************************************************************************** ospfMapiNbrCompare - compare two 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 ospfMapiNbrCompare( void * node, GENERIC_ARGUMENT key ){ mApiOspfNbr_t *pNbr; ulong_t mibIndex[OSPF_NBR_INSTANCE_LEN]; int oidLength; pNbr = (mApiOspfNbr_t *)node; oidLength = OSPF_NBR_INSTANCE_LEN; /* reconstruct the index values for ospfNbrTable. ospfNbrTable is indexed by * ospfNbrIpAddr and ospfNbrAddressLessIndex */ memset( mibIndex, 0, sizeof(mibIndex) ); ospf_mApi_ipAddr2IpIndex( pNbr->ospfNbrIpAddr, &mibIndex[0] ); mibIndex[4] = pNbr->ospfNbrAddressLessIndex; return ospfMapiOidCompare( oidLength, (ulong_t *)key.p, mibIndex );}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?