From 084bcaa76b4e8c02b5dbc2f9f400d25271067874 Mon Sep 17 00:00:00 2001 From: Bruno Jesus <00cpxxx@gmail.com> Date: Wed, 13 May 2015 22:02:24 -0300 Subject: [PATCH] iphlpapi: Set MIB_IPADDR_PRIMARY as wType for GetIpAddrTable entries. --- dlls/iphlpapi/ifenum.c | 6 +++++- dlls/iphlpapi/tests/iphlpapi.c | 9 +++++++++ include/ipmib.h | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dlls/iphlpapi/ifenum.c b/dlls/iphlpapi/ifenum.c index a12450e5477..3070ae52992 100644 --- a/dlls/iphlpapi/ifenum.c +++ b/dlls/iphlpapi/ifenum.c @@ -807,7 +807,11 @@ static DWORD getIPAddrRowByName(PMIB_IPADDRROW ipAddrRow, const char *ifName, /* FIXME: hardcoded reasm size, not sure where to get it */ ipAddrRow->dwReasmSize = 65535; ipAddrRow->unused1 = 0; - ipAddrRow->wType = 0; + /* wType is a bit field composed of MIB_IPADDR_* flags. Windows <= XP seems + * to like returning undocumented values 0x20 + 0x02 but for our current + * needs returning MIB_IPADDR_PRIMARY is enough. + */ + ipAddrRow->wType = MIB_IPADDR_PRIMARY; return ret; } diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 58fb843e4f6..847ba49e954 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -226,7 +226,16 @@ static void testGetIpAddrTable(void) "GetIpAddrTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n", apiReturn); if (apiReturn == NO_ERROR && buf->dwNumEntries) + { + int i; testGetIfEntry(buf->table[0].dwIndex); + for (i = 0; i < buf->dwNumEntries; i++) + { + ok (buf->table[i].wType != 0, "Test[%d]: expected wType > 0\n", i); + trace("Entry[%d]: addr %s, dwIndex %u, wType 0x%x\n", i, + ntoa(buf->table[i].dwAddr), buf->table[i].dwIndex, buf->table[i].wType); + } + } HeapFree(GetProcessHeap(), 0, buf); } } diff --git a/include/ipmib.h b/include/ipmib.h index 65576be064d..d85ee5a8a1f 100644 --- a/include/ipmib.h +++ b/include/ipmib.h @@ -21,6 +21,13 @@ #include #include +/* Flags used in the wType field from MIB_IPADDRROW */ + +#define MIB_IPADDR_PRIMARY 0x0001 +#define MIB_IPADDR_DYNAMIC 0x0004 +#define MIB_IPADDR_DISCONNECTED 0x0008 +#define MIB_IPADDR_DELETED 0x0040 +#define MIB_IPADDR_TRANSIENT 0x0080 /* IPADDR table */