iphlpapi: Adapter names returned from GetAdaptersAddresses are GUID strings.
Hans Leidekker
hans at codeweavers.com
Thu May 11 03:15:26 CDT 2017
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
dlls/iphlpapi/iphlpapi_main.c | 9 +++++----
dlls/iphlpapi/tests/iphlpapi.c | 15 ++++++++++++++-
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index b40f91b..796950e 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -978,7 +978,7 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
}
total_size = sizeof(IP_ADAPTER_ADDRESSES);
- total_size += IF_NAMESIZE;
+ total_size += 39; /* "{00000000-0000-0000-0000-000000000000}" */
total_size += IF_NAMESIZE * sizeof(WCHAR);
if (!(flags & GAA_FLAG_SKIP_FRIENDLY_NAME))
total_size += IF_NAMESIZE * sizeof(WCHAR);
@@ -1009,10 +1009,11 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
aa->u.s.Length = sizeof(IP_ADAPTER_ADDRESSES);
aa->u.s.IfIndex = index;
- getInterfaceNameByIndex(index, name);
- memcpy(ptr, name, IF_NAMESIZE);
+ sprintf(ptr, "{%08x-0000-0000-0000-000000000000}", index);
aa->AdapterName = ptr;
- ptr += IF_NAMESIZE;
+ ptr += 39;
+
+ getInterfaceNameByIndex(index, name);
if (!(flags & GAA_FLAG_SKIP_FRIENDLY_NAME))
{
aa->FriendlyName = (WCHAR *)ptr;
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index 9deccc2..5fb23fb 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -1414,8 +1414,10 @@ static void test_GetAdaptersAddresses(void)
for (aa = ptr; !ret && aa; aa = aa->Next)
{
- char temp[128];
+ char temp[128], buf[39];
IP_ADAPTER_PREFIX *prefix;
+ DWORD status;
+ GUID guid;
ok(S(U(*aa)).Length == sizeof(IP_ADAPTER_ADDRESSES_LH) ||
S(U(*aa)).Length == sizeof(IP_ADAPTER_ADDRESSES_XP),
@@ -1524,6 +1526,17 @@ static void test_GetAdaptersAddresses(void)
trace("Dhcpv6Iaid: %u\n", aa->Dhcpv6Iaid);
trace("FirstDnsSuffix: %p\n", aa->FirstDnsSuffix);
trace("\n");
+
+ if (pConvertInterfaceLuidToGuid)
+ {
+ status = pConvertInterfaceLuidToGuid(&aa->Luid, &guid);
+ ok(!status, "got %u\n", status);
+ sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
+ guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1],
+ guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
+ guid.Data4[6], guid.Data4[7]);
+ ok(!strcasecmp(aa->AdapterName, buf), "expected '%s' got '%s'\n", aa->AdapterName, buf);
+ }
}
HeapFree(GetProcessHeap(), 0, ptr);
}
--
2.1.4
More information about the wine-patches
mailing list