Signed-off-by: Yeshun Ye yeyeshun@uniontech.com --- dlls/iphlpapi/tests/iphlpapi.c | 79 ++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 358084fde68..44ead2580bf 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -2338,6 +2338,84 @@ static void test_NotifyUnicastIpAddressChange(void) ok(!CloseHandle(handle), "CloseHandle() succeeded.\n"); }
+static void test_GetAdaptersInfo_AdapterName(void) +{ + DWORD apiReturn; + ULONG size = 0; + ULONG family = AF_UNSPEC; + ULONG flags = GAA_FLAG_INCLUDE_PREFIX; + + apiReturn = GetAdaptersInfo(NULL, NULL); + if (apiReturn == ERROR_NOT_SUPPORTED) { + skip("GetAdaptersInfo is not supported\n"); + return; + } + apiReturn = GetAdaptersAddresses(0, 0, NULL, NULL, NULL); + if (apiReturn == ERROR_NOT_SUPPORTED) { + skip("GetAdaptersInfo is not supported\n"); + return; + } + apiReturn = GetAdaptersAddresses(family, flags, 0, 0, &size); + ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_BUFFER_OVERFLOW, + "GetAdaptersAddresses returned %d, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n", + apiReturn); + if (apiReturn == ERROR_NO_DATA) + ; /* no adapter's, that's okay */ + else if (apiReturn == ERROR_BUFFER_OVERFLOW) + { + PIP_ADAPTER_ADDRESSES pAdapterAddress; + PIP_ADAPTER_ADDRESSES pCurrentAddress; + + pAdapterAddress = HeapAlloc(GetProcessHeap(), 0, size); + apiReturn = GetAdaptersAddresses(family, flags, 0, pAdapterAddress, &size); + ok(apiReturn == NO_ERROR, + "GetAdaptersAddresses(family, flags, 0, pAdapterAddress, &size) returned %d, expected NO_ERROR\n", + apiReturn); + + pCurrentAddress = pAdapterAddress; + while (pCurrentAddress) + { + if (pCurrentAddress->IfType == IF_TYPE_ETHERNET_CSMACD && + ((pCurrentAddress->Flags & IP_ADAPTER_IPV4_ENABLED) || (pCurrentAddress->Flags & IP_ADAPTER_IPV6_ENABLED))) + { + ULONG len = 0; + PIP_ADAPTER_INFO ptr, buf; + char IpAddress[16] = {0}; + char IpMask[16] = {0}; + + apiReturn = GetAdaptersInfo(NULL, &len); + ok(apiReturn == ERROR_BUFFER_OVERFLOW, + "GetAdaptersInfo returned %d, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n", + apiReturn); + buf = HeapAlloc(GetProcessHeap(), 0, len); + apiReturn = GetAdaptersInfo(buf, &len); + ok(apiReturn == NO_ERROR, + "GetAdaptersInfo(buf, &len) returned %d, expected NO_ERROR\n", + apiReturn); + ptr = buf; + while (ptr) { + if (strcmp(pCurrentAddress->AdapterName, ptr->AdapterName) == 0) + { + ok(ptr->IpAddressList.IpAddress.String[0], "A valid IP must be present\n"); + ok(ptr->IpAddressList.IpMask.String[0], "A valid mask must be present\n"); + trace("Adapter '%s', IP %s, Mask %s\n", ptr->AdapterName, + ptr->IpAddressList.IpAddress.String, ptr->IpAddressList.IpMask.String); + strcpy(IpAddress, ptr->IpAddressList.IpAddress.String); + strcpy(IpMask, ptr->IpAddressList.IpMask.String); + break; + } + ptr = ptr->Next; + } + todo_wine ok(IpAddress[0], "A valid IP must be present for adapter [%s]\n", pCurrentAddress->AdapterName); + todo_wine ok(IpMask[0], "A valid mask must be present for adapter [%s]\n", pCurrentAddress->AdapterName); + HeapFree(GetProcessHeap(), 0, buf); + } + pCurrentAddress = pCurrentAddress->Next; + } + HeapFree(GetProcessHeap(), 0, pAdapterAddress); + } +} + START_TEST(iphlpapi) {
@@ -2370,6 +2448,7 @@ START_TEST(iphlpapi) test_GetUdp6Table(); test_ParseNetworkString(); test_NotifyUnicastIpAddressChange(); + test_GetAdaptersInfo_AdapterName(); freeIPHlpApi(); } }
Signed-off-by: Yeshun Ye yeyeshun@uniontech.com --- dlls/iphlpapi/iphlpapi_main.c | 9 ++++++++- dlls/iphlpapi/tests/iphlpapi.c | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 09414d26dde..21edd9ee128 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -706,9 +706,16 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen) DWORD i; PIP_ADDR_STRING currentIPAddr = &ptr->IpAddressList; BOOL firstIPAddr = TRUE; + NET_LUID luid; + GUID guid;
/* on Win98 this is left empty, but whatever */ - getInterfaceNameByIndex(table->indexes[ndx], ptr->AdapterName); + ConvertInterfaceIndexToLuid(table->indexes[ndx], &luid); + ConvertInterfaceLuidToGuid(&luid, &guid); + sprintf(ptr->AdapterName, "{%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]); getInterfaceNameByIndex(table->indexes[ndx], ptr->Description); ptr->AddressLength = sizeof(ptr->Address); getInterfacePhysicalByIndex(table->indexes[ndx], diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 44ead2580bf..807b9446cb7 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -2406,8 +2406,8 @@ static void test_GetAdaptersInfo_AdapterName(void) } ptr = ptr->Next; } - todo_wine ok(IpAddress[0], "A valid IP must be present for adapter [%s]\n", pCurrentAddress->AdapterName); - todo_wine ok(IpMask[0], "A valid mask must be present for adapter [%s]\n", pCurrentAddress->AdapterName); + ok(IpAddress[0], "A valid IP must be present for adapter [%s]\n", pCurrentAddress->AdapterName); + ok(IpMask[0], "A valid mask must be present for adapter [%s]\n", pCurrentAddress->AdapterName); HeapFree(GetProcessHeap(), 0, buf); } pCurrentAddress = pCurrentAddress->Next;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86002
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86002
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86001
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86001
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report