Juan Lang : inetmib1: Make table searching function into a generic helper.
Alexandre Julliard
julliard at winehq.org
Mon Jun 30 08:26:44 CDT 2008
Module: wine
Branch: master
Commit: cf3d35cf15801a97d5e3026f557f3c89a9ae9b4c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cf3d35cf15801a97d5e3026f557f3c89a9ae9b4c
Author: Juan Lang <juan.lang at gmail.com>
Date: Sat Jun 28 08:33:01 2008 -0700
inetmib1: Make table searching function into a generic helper.
---
dlls/inetmib1/main.c | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c
index 20fc0b9..2dba6cf 100644
--- a/dlls/inetmib1/main.c
+++ b/dlls/inetmib1/main.c
@@ -352,18 +352,18 @@ static UINT findValueInTable(AsnObjectIdentifier *oid,
}
/* Given an OID and a base OID that it must begin with, finds the item and
- * element of the table whose IP address matches the instance from the OID.
- * E.g., given an OID foo.1.2.3.4.5 and a base OID foo, returns item 1 and the
- * index of the entry in the table whose IP address is 2.3.4.5.
+ * element of the table whose value matches the instance from the OID.
+ * The OID is converted to a key with the function makeKey, and compared
+ * against entries in the table with the function compare.
* If bPduType is not SNMP_PDU_GETNEXT and either the item or instance is
* missing, returns SNMP_ERRORSTATUS_NOSUCHNAME.
* If bPduType is SNMP_PDU_GETNEXT, returns the successor to the item and
* instance, or item 1, instance 1 if either is missing.
*/
-static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid,
- AsnObjectIdentifier *base, BYTE bPduType, struct GenericTable *table,
- size_t tableEntrySize, oidToKeyFunc makeKey, compareFunc compare,
- UINT *item, UINT *instance)
+static AsnInteger32 getItemAndInstanceFromTable(AsnObjectIdentifier *oid,
+ AsnObjectIdentifier *base, UINT instanceLen, BYTE bPduType,
+ struct GenericTable *table, size_t tableEntrySize, oidToKeyFunc makeKey,
+ compareFunc compare, UINT *item, UINT *instance)
{
AsnInteger32 ret = SNMP_ERRORSTATUS_NOERROR;
@@ -380,7 +380,7 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid,
*instance = 1;
}
else if (!SnmpUtilOidNCmp(oid, base, base->idLength) &&
- oid->idLength < base->idLength + 5)
+ oid->idLength < base->idLength + instanceLen + 1)
{
/* Either the table or an item is specified, but the instance is
* not.
@@ -396,7 +396,7 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid,
*item = 1;
}
else if (!SnmpUtilOidNCmp(oid, base, base->idLength) &&
- oid->idLength == base->idLength + 5)
+ oid->idLength == base->idLength + instanceLen + 1)
{
*item = oid->ids[base->idLength];
if (!*item)
@@ -406,8 +406,8 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid,
}
else
{
- AsnObjectIdentifier ipOid = { 4, oid->ids + base->idLength + 1
- };
+ AsnObjectIdentifier ipOid = { instanceLen,
+ oid->ids + base->idLength + 1 };
*instance = findValueInTable(&ipOid, table, tableEntrySize,
makeKey, compare) + 1;
@@ -420,15 +420,15 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid,
break;
default:
if (!SnmpUtilOidNCmp(oid, base, base->idLength) &&
- oid->idLength == base->idLength + 5)
+ oid->idLength == base->idLength + instanceLen + 1)
{
*item = oid->ids[base->idLength];
if (!*item)
ret = SNMP_ERRORSTATUS_NOSUCHNAME;
else
{
- AsnObjectIdentifier ipOid = { 4, oid->ids + base->idLength + 1
- };
+ AsnObjectIdentifier ipOid = { instanceLen,
+ oid->ids + base->idLength + 1 };
*instance = findValueInTable(&ipOid, table, tableEntrySize,
makeKey, compare);
@@ -680,8 +680,8 @@ static BOOL mib2IpAddrQuery(BYTE bPduType, SnmpVarBind *pVarBind,
{
case SNMP_PDU_GET:
case SNMP_PDU_GETNEXT:
- *pErrorStatus = getItemAndIpAddressInstanceFromOid(&pVarBind->name,
- &myOid, bPduType, (struct GenericTable *)ipAddrTable,
+ *pErrorStatus = getItemAndInstanceFromTable(&pVarBind->name,
+ &myOid, 4, bPduType, (struct GenericTable *)ipAddrTable,
sizeof(MIB_IPADDRROW), oidToIpAddrRow, compareIpAddrRow, &item,
&tableIndex);
if (!*pErrorStatus)
@@ -763,8 +763,8 @@ static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind,
{
case SNMP_PDU_GET:
case SNMP_PDU_GETNEXT:
- *pErrorStatus = getItemAndIpAddressInstanceFromOid(&pVarBind->name,
- &myOid, bPduType, (struct GenericTable *)ipRouteTable,
+ *pErrorStatus = getItemAndInstanceFromTable(&pVarBind->name,
+ &myOid, 4, bPduType, (struct GenericTable *)ipRouteTable,
sizeof(MIB_IPFORWARDROW), oidToIpForwardRow, compareIpForwardRow,
&item, &tableIndex);
if (!*pErrorStatus)
More information about the wine-cvs
mailing list