Juan Lang : inetmib1: Use a helper function to set the Oid with an IP address-based instance.

Alexandre Julliard julliard at winehq.org
Wed Jun 25 16:44:44 CDT 2008


Module: wine
Branch: master
Commit: d3f0e8c9dbb98159d32baffdf9b45ffdeb76d7e8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d3f0e8c9dbb98159d32baffdf9b45ffdeb76d7e8

Author: Juan Lang <juan.lang at gmail.com>
Date:   Wed Jun 25 09:35:13 2008 -0700

inetmib1: Use a helper function to set the Oid with an IP address-based instance.

---

 dlls/inetmib1/main.c |   61 ++++++++++++++++++-------------------------------
 1 files changed, 23 insertions(+), 38 deletions(-)

diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c
index e7bb28e..3ce7b6c 100644
--- a/dlls/inetmib1/main.c
+++ b/dlls/inetmib1/main.c
@@ -431,6 +431,25 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid,
     return ret;
 }
 
+static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst,
+    AsnObjectIdentifier *base, UINT item, DWORD addr)
+{
+    UINT id;
+    BYTE *ptr;
+    AsnObjectIdentifier oid;
+
+    SnmpUtilOidCpy(dst, base);
+    oid.idLength = 1;
+    oid.ids = &id;
+    id = item;
+    SnmpUtilOidAppend(dst, &oid);
+    for (ptr = (BYTE *)&addr; ptr < (BYTE *)&addr + sizeof(DWORD); ptr++)
+    {
+        id = *ptr;
+        SnmpUtilOidAppend(dst, &oid);
+    }
+}
+
 static struct structToAsnValue mib2IfEntryMap[] = {
     { FIELD_OFFSET(MIB_IFROW, dwIndex), copyInt },
     { FIELD_OFFSET(MIB_IFROW, dwDescrLen), copyLengthPrecededString },
@@ -648,24 +667,8 @@ static BOOL mib2IpAddrQuery(BYTE bPduType, SnmpVarBind *pVarBind,
                 DEFINE_SIZEOF(mib2IpAddrMap),
                 &ipAddrTable->table[tableIndex - 1], item, bPduType, pVarBind);
             if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
-            {
-                UINT id;
-                BYTE *ptr;
-                AsnObjectIdentifier oid;
-
-                SnmpUtilOidCpy(&pVarBind->name, &myOid);
-                oid.idLength = 1;
-                oid.ids = &id;
-                id = item;
-                SnmpUtilOidAppend(&pVarBind->name, &oid);
-                for (ptr = (BYTE *)&ipAddrTable->table[tableIndex - 1].dwAddr;
-                    ptr < (BYTE *)&ipAddrTable->table[tableIndex - 1].dwAddr +
-                    sizeof(DWORD); ptr++)
-                {
-                    id = *ptr;
-                    SnmpUtilOidAppend(&pVarBind->name, &oid);
-                }
-            }
+                setOidWithItemAndIpAddr(&pVarBind->name, &myOid, item,
+                    ipAddrTable->table[tableIndex - 1].dwAddr);
         }
         break;
     case SNMP_PDU_SET:
@@ -733,26 +736,8 @@ static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind,
                 DEFINE_SIZEOF(mib2IpRouteMap),
                 &ipRouteTable->table[tableIndex - 1], item, bPduType, pVarBind);
             if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
-            {
-                UINT id;
-                BYTE *ptr;
-                AsnObjectIdentifier oid;
-
-                SnmpUtilOidCpy(&pVarBind->name, &myOid);
-                oid.idLength = 1;
-                oid.ids = &id;
-                id = item;
-                SnmpUtilOidAppend(&pVarBind->name, &oid);
-                for (ptr =
-                    (BYTE *)&ipRouteTable->table[tableIndex - 1].dwForwardDest;
-                    ptr <
-                    (BYTE *)&ipRouteTable->table[tableIndex - 1].dwForwardDest
-                    + sizeof(DWORD); ptr++)
-                {
-                    id = *ptr;
-                    SnmpUtilOidAppend(&pVarBind->name, &oid);
-                }
-            }
+                setOidWithItemAndIpAddr(&pVarBind->name, &myOid, item,
+                    ipRouteTable->table[tableIndex - 1].dwForwardDest);
         }
         break;
     case SNMP_PDU_SET:




More information about the wine-cvs mailing list