[PATCH] iphlpapi: Implement if_indextoname.
Hans Leidekker
hans at codeweavers.com
Tue Jan 23 02:43:50 CST 2018
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
dlls/iphlpapi/iphlpapi.spec | 2 +-
dlls/iphlpapi/iphlpapi_main.c | 10 ++++++++++
dlls/iphlpapi/tests/iphlpapi.c | 45 +++++++++++++++++++++++++++++-------------
include/netioapi.h | 2 ++
4 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec
index fee99607b6..b6c9aef2f8 100644
--- a/dlls/iphlpapi/iphlpapi.spec
+++ b/dlls/iphlpapi/iphlpapi.spec
@@ -159,7 +159,7 @@
@ stdcall IcmpSendEcho2Ex(ptr ptr ptr ptr long long ptr long ptr ptr long long)
@ stdcall IcmpSendEcho2(ptr ptr ptr ptr long ptr long ptr ptr long long)
@ stdcall IcmpSendEcho(ptr long ptr long ptr ptr long long)
-#@ stub if_indextoname
+@ stdcall if_indextoname(long ptr) IPHLP_if_indextoname
@ stdcall if_nametoindex(str) IPHLP_if_nametoindex
#@ stub InitializeIpForwardEntry
#@ stub InitializeIpInterfaceEntry
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index 5f36d4666d..d31504e5a9 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -3237,3 +3237,13 @@ IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
return 0;
}
+
+/******************************************************************
+ * if_indextoname (IPHLPAPI.@)
+ */
+PCHAR WINAPI IPHLP_if_indextoname(NET_IFINDEX index, PCHAR name)
+{
+ TRACE("(%u, %p)\n", index, name);
+
+ return getInterfaceNameByIndex(index, name);
+}
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index ccaafd728e..f0d19673f4 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -99,6 +99,7 @@ static DWORD (WINAPI *pConvertInterfaceLuidToNameA)(const NET_LUID*,char*,SIZE_T
static DWORD (WINAPI *pConvertInterfaceNameToLuidA)(const char*,NET_LUID*);
static DWORD (WINAPI *pConvertInterfaceNameToLuidW)(const WCHAR*,NET_LUID*);
+static PCHAR (WINAPI *pif_indextoname)(NET_IFINDEX,PCHAR);
static NET_IFINDEX (WINAPI *pif_nametoindex)(const char*);
static void loadIPHlpApi(void)
@@ -151,6 +152,7 @@ static void loadIPHlpApi(void)
pConvertInterfaceLuidToNameW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToNameW");
pConvertInterfaceNameToLuidA = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidA");
pConvertInterfaceNameToLuidW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidW");
+ pif_indextoname = (void *)GetProcAddress(hLibrary, "if_indextoname");
pif_nametoindex = (void *)GetProcAddress(hLibrary, "if_nametoindex");
}
}
@@ -1789,7 +1791,7 @@ static void test_interface_identifier_conversion(void)
GUID guid;
SIZE_T len;
WCHAR nameW[IF_MAX_STRING_SIZE + 1];
- char nameA[IF_MAX_STRING_SIZE + 1];
+ char nameA[IF_MAX_STRING_SIZE + 1], *name;
NET_IFINDEX index, index2;
if (!pConvertInterfaceIndexToLuid)
@@ -1950,22 +1952,37 @@ static void test_interface_identifier_conversion(void)
ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" );
ok( luid.Info.IfType == IF_TYPE_ETHERNET_CSMACD, "got %u\n", luid.Info.IfType );
- /* if_nametoindex */
- if (pif_nametoindex)
+ if (!pif_nametoindex || !pif_indextoname)
{
- index2 = pif_nametoindex( NULL );
- ok( !index2, "Got unexpected index %u\n", index2 );
- index2 = pif_nametoindex( nameA );
- ok( index2 == index, "Got index %u for %s, expected %u\n", index2, nameA, index );
- /* Wargaming.net Game Center passes a GUID-like string. */
- index2 = pif_nametoindex( "{00000001-0000-0000-0000-000000000000}" );
- ok( !index2, "Got unexpected index %u\n", index2 );
- index2 = pif_nametoindex( wine_dbgstr_guid( &guid ) );
- ok( !index2, "Got unexpected index %u for input %s\n", index2, wine_dbgstr_guid( &guid ) );
+ skip("if_nametoindex/if_indextoname not supported\n");
+ return;
}
- else
+
+ index2 = pif_nametoindex( NULL );
+ ok( !index2, "Got unexpected index %u\n", index2 );
+ index2 = pif_nametoindex( nameA );
+ ok( index2 == index, "Got index %u for %s, expected %u\n", index2, nameA, index );
+ /* Wargaming.net Game Center passes a GUID-like string. */
+ index2 = pif_nametoindex( "{00000001-0000-0000-0000-000000000000}" );
+ ok( !index2, "Got unexpected index %u\n", index2 );
+ index2 = pif_nametoindex( wine_dbgstr_guid( &guid ) );
+ ok( !index2, "Got unexpected index %u for input %s\n", index2, wine_dbgstr_guid( &guid ) );
+
+ name = pif_indextoname( 0, NULL );
+ ok( name == NULL, "got %s\n", name );
+
+ name = pif_indextoname( 0, nameA );
+ ok( name == NULL, "got %p\n", name );
+
+ name = pif_indextoname( ~0u, nameA );
+ ok( name == NULL, "got %p\n", name );
+
+ nameA[0] = 0;
+ name = pif_indextoname( 1, nameA );
+ if (name != NULL)
{
- skip("if_nametoindex not supported\n");
+ ok( name[0], "empty name\n" );
+ ok( name == nameA, "got %p\n", name );
}
}
diff --git a/include/netioapi.h b/include/netioapi.h
index 4f5f67171c..109588804a 100644
--- a/include/netioapi.h
+++ b/include/netioapi.h
@@ -174,5 +174,7 @@ void WINAPI FreeMibTable(void*);
DWORD WINAPI GetIfEntry2(MIB_IF_ROW2*);
DWORD WINAPI GetIfTable2(MIB_IF_TABLE2**);
DWORD WINAPI GetUnicastIpAddressEntry(MIB_UNICASTIPADDRESS_ROW*);
+PCHAR WINAPI if_indextoname(NET_IFINDEX,PCHAR);
+NET_IFINDEX WINAPI if_nametoindex(PCSTR);
#endif /* __WINE_NETIOAPI_H */
--
2.11.0
More information about the wine-devel
mailing list