[PATCH 3/5] iphlpapi: Implement if_nametoindex() using the ConvertInterface* functions.

Huw Davies huw at codeweavers.com
Fri Jul 2 03:41:34 CDT 2021


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/iphlpapi/iphlpapi_main.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index a774e60c3d9..aaa6a80c19e 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -3357,13 +3357,18 @@ DWORD WINAPI ConvertLengthToIpv4Mask(ULONG mask_len, ULONG *mask)
  */
 IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
 {
-    IF_INDEX idx;
+    IF_INDEX index;
+    NET_LUID luid;
+    DWORD err;
 
-    TRACE("(%s)\n", name);
-    if (getInterfaceIndexByName(name, &idx) == NO_ERROR)
-        return idx;
+    TRACE( "(%s)\n", name );
 
-    return 0;
+    err = ConvertInterfaceNameToLuidA( name, &luid );
+    if (err) return 0;
+
+    err = ConvertInterfaceLuidToIndex( &luid, &index );
+    if (err) index = 0;
+    return index;
 }
 
 /******************************************************************
-- 
2.23.0




More information about the wine-devel mailing list