Signed-off-by: Yeshun Ye yeyeshun@uniontech.com --- dlls/iphlpapi/iphlpapi_main.c | 9 ++++++++- dlls/iphlpapi/tests/iphlpapi.c | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
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 358084fde68..e61f2cbd382 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -1115,6 +1115,9 @@ static void testGetAdaptersInfo(void) ; /* no adapter's, that's okay */ else if (apiReturn == ERROR_BUFFER_OVERFLOW) { PIP_ADAPTER_INFO ptr, buf = HeapAlloc(GetProcessHeap(), 0, len); + NET_LUID luid; + GUID guid; + char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
apiReturn = GetAdaptersInfo(buf, &len); ok(apiReturn == NO_ERROR, @@ -1122,6 +1125,13 @@ static void testGetAdaptersInfo(void) apiReturn); ptr = buf; while (ptr) { + ConvertInterfaceIndexToLuid(ptr->Index, &luid); + ConvertInterfaceLuidToGuid(&luid, &guid); + sprintf(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]); + ok(!strcasecmp(ptr->AdapterName, AdapterName), "expected '%s' got '%s'\n", ptr->AdapterName, AdapterName); ok(ptr->IpAddressList.IpAddress.String[0], "A valid IP address must be present\n"); ok(ptr->IpAddressList.IpMask.String[0], "A valid mask must be present\n"); ok(ptr->GatewayList.IpAddress.String[0], "A valid IP address must be present\n");
On Wed, Jun 16, 2021 at 09:51:21AM +0800, Yeshun Ye wrote:
Signed-off-by: Yeshun Ye yeyeshun@uniontech.com
dlls/iphlpapi/iphlpapi_main.c | 9 ++++++++- dlls/iphlpapi/tests/iphlpapi.c | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
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 358084fde68..e61f2cbd382 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -1115,6 +1115,9 @@ static void testGetAdaptersInfo(void) ; /* no adapter's, that's okay */ else if (apiReturn == ERROR_BUFFER_OVERFLOW) { PIP_ADAPTER_INFO ptr, buf = HeapAlloc(GetProcessHeap(), 0, len);
NET_LUID luid;
GUID guid;
char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
ARRAY_SIZE(ptr->AdapterName) would be a little less obscure than MAX_ADAPTER_NAME_LENGTH + 4.
apiReturn = GetAdaptersInfo(buf, &len); ok(apiReturn == NO_ERROR,
@@ -1122,6 +1125,13 @@ static void testGetAdaptersInfo(void) apiReturn); ptr = buf; while (ptr) {
ConvertInterfaceIndexToLuid(ptr->Index, &luid);
ConvertInterfaceLuidToGuid(&luid, &guid);
sprintf(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]);
ok(!strcasecmp(ptr->AdapterName, AdapterName), "expected '%s' got '%s'\n", ptr->AdapterName, AdapterName);
strcmp() should work here.
ok(ptr->IpAddressList.IpAddress.String[0], "A valid IP address must be present\n"); ok(ptr->IpAddressList.IpMask.String[0], "A valid mask must be present\n"); ok(ptr->GatewayList.IpAddress.String[0], "A valid IP address must be present\n");
A separate patch could also change the similar test in test_GetAdapterAddresses() to also use strcmp() (with the appropriate change to the format string).
Huw.