Commit 0fb70c6d authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

inetmib1: Use a helper function to set the Oid with an item.

parent 81b0db24
...@@ -431,11 +431,10 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid, ...@@ -431,11 +431,10 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid,
return ret; return ret;
} }
static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst, static void setOidWithItem(AsnObjectIdentifier *dst, AsnObjectIdentifier *base,
AsnObjectIdentifier *base, UINT item, DWORD addr) UINT item)
{ {
UINT id; UINT id;
BYTE *ptr;
AsnObjectIdentifier oid; AsnObjectIdentifier oid;
SnmpUtilOidCpy(dst, base); SnmpUtilOidCpy(dst, base);
...@@ -443,6 +442,18 @@ static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst, ...@@ -443,6 +442,18 @@ static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst,
oid.ids = &id; oid.ids = &id;
id = item; id = item;
SnmpUtilOidAppend(dst, &oid); SnmpUtilOidAppend(dst, &oid);
}
static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst,
AsnObjectIdentifier *base, UINT item, DWORD addr)
{
UINT id;
BYTE *ptr;
AsnObjectIdentifier oid;
setOidWithItem(dst, base, item);
oid.idLength = 1;
oid.ids = &id;
for (ptr = (BYTE *)&addr; ptr < (BYTE *)&addr + sizeof(DWORD); ptr++) for (ptr = (BYTE *)&addr; ptr < (BYTE *)&addr + sizeof(DWORD); ptr++)
{ {
id = *ptr; id = *ptr;
...@@ -455,10 +466,8 @@ static void setOidWithItemAndInteger(AsnObjectIdentifier *dst, ...@@ -455,10 +466,8 @@ static void setOidWithItemAndInteger(AsnObjectIdentifier *dst,
{ {
AsnObjectIdentifier oid; AsnObjectIdentifier oid;
SnmpUtilOidCpy(dst, base); setOidWithItem(dst, base, item);
oid.idLength = 1; oid.idLength = 1;
oid.ids = &item;
SnmpUtilOidAppend(dst, &oid);
oid.ids = &instance; oid.ids = &instance;
SnmpUtilOidAppend(dst, &oid); SnmpUtilOidAppend(dst, &oid);
} }
...@@ -597,14 +606,7 @@ static BOOL mib2IpStatsQuery(BYTE bPduType, SnmpVarBind *pVarBind, ...@@ -597,14 +606,7 @@ static BOOL mib2IpStatsQuery(BYTE bPduType, SnmpVarBind *pVarBind,
*pErrorStatus = mapStructEntryToValue(mib2IpMap, *pErrorStatus = mapStructEntryToValue(mib2IpMap,
DEFINE_SIZEOF(mib2IpMap), &ipStats, item, bPduType, pVarBind); DEFINE_SIZEOF(mib2IpMap), &ipStats, item, bPduType, pVarBind);
if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
{ setOidWithItem(&pVarBind->name, &myOid, item);
AsnObjectIdentifier oid;
SnmpUtilOidCpy(&pVarBind->name, &myOid);
oid.idLength = 1;
oid.ids = &item;
SnmpUtilOidAppend(&pVarBind->name, &oid);
}
} }
break; break;
case SNMP_PDU_SET: case SNMP_PDU_SET:
...@@ -875,15 +877,8 @@ static BOOL mib2IcmpQuery(BYTE bPduType, SnmpVarBind *pVarBind, ...@@ -875,15 +877,8 @@ static BOOL mib2IcmpQuery(BYTE bPduType, SnmpVarBind *pVarBind,
*pErrorStatus = mapStructEntryToValue(mib2IcmpMap, *pErrorStatus = mapStructEntryToValue(mib2IcmpMap,
DEFINE_SIZEOF(mib2IcmpMap), &icmpStats, item, bPduType, DEFINE_SIZEOF(mib2IcmpMap), &icmpStats, item, bPduType,
pVarBind); pVarBind);
if (!*pErrorStatus) if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
{ setOidWithItem(&pVarBind->name, &myOid, item);
AsnObjectIdentifier oid;
SnmpUtilOidCpy(&pVarBind->name, &myOid);
oid.idLength = 1;
oid.ids = &item;
SnmpUtilOidAppend(&pVarBind->name, &oid);
}
} }
break; break;
case SNMP_PDU_SET: case SNMP_PDU_SET:
...@@ -942,14 +937,7 @@ static BOOL mib2TcpQuery(BYTE bPduType, SnmpVarBind *pVarBind, ...@@ -942,14 +937,7 @@ static BOOL mib2TcpQuery(BYTE bPduType, SnmpVarBind *pVarBind,
*pErrorStatus = mapStructEntryToValue(mib2TcpMap, *pErrorStatus = mapStructEntryToValue(mib2TcpMap,
DEFINE_SIZEOF(mib2TcpMap), &tcpStats, item, bPduType, pVarBind); DEFINE_SIZEOF(mib2TcpMap), &tcpStats, item, bPduType, pVarBind);
if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
{ setOidWithItem(&pVarBind->name, &myOid, item);
AsnObjectIdentifier oid;
SnmpUtilOidCpy(&pVarBind->name, &myOid);
oid.idLength = 1;
oid.ids = &item;
SnmpUtilOidAppend(&pVarBind->name, &oid);
}
} }
break; break;
case SNMP_PDU_SET: case SNMP_PDU_SET:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment