Commit e3fe1071 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

iphlpapi: Implement if_indextoname.

parent 9bafbe10
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
@ stdcall IcmpSendEcho2Ex(ptr ptr ptr ptr long long ptr long ptr ptr long long) @ 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 IcmpSendEcho2(ptr ptr ptr ptr long ptr long ptr ptr long long)
@ stdcall IcmpSendEcho(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 @ stdcall if_nametoindex(str) IPHLP_if_nametoindex
#@ stub InitializeIpForwardEntry #@ stub InitializeIpForwardEntry
#@ stub InitializeIpInterfaceEntry #@ stub InitializeIpInterfaceEntry
......
...@@ -3235,3 +3235,13 @@ IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name) ...@@ -3235,3 +3235,13 @@ IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
return 0; 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);
}
...@@ -97,6 +97,7 @@ static DWORD (WINAPI *pConvertInterfaceLuidToNameA)(const NET_LUID*,char*,SIZE_T ...@@ -97,6 +97,7 @@ static DWORD (WINAPI *pConvertInterfaceLuidToNameA)(const NET_LUID*,char*,SIZE_T
static DWORD (WINAPI *pConvertInterfaceNameToLuidA)(const char*,NET_LUID*); static DWORD (WINAPI *pConvertInterfaceNameToLuidA)(const char*,NET_LUID*);
static DWORD (WINAPI *pConvertInterfaceNameToLuidW)(const WCHAR*,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 NET_IFINDEX (WINAPI *pif_nametoindex)(const char*);
static void loadIPHlpApi(void) static void loadIPHlpApi(void)
...@@ -148,6 +149,7 @@ static void loadIPHlpApi(void) ...@@ -148,6 +149,7 @@ static void loadIPHlpApi(void)
pConvertInterfaceLuidToNameW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToNameW"); pConvertInterfaceLuidToNameW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToNameW");
pConvertInterfaceNameToLuidA = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidA"); pConvertInterfaceNameToLuidA = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidA");
pConvertInterfaceNameToLuidW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidW"); pConvertInterfaceNameToLuidW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidW");
pif_indextoname = (void *)GetProcAddress(hLibrary, "if_indextoname");
pif_nametoindex = (void *)GetProcAddress(hLibrary, "if_nametoindex"); pif_nametoindex = (void *)GetProcAddress(hLibrary, "if_nametoindex");
} }
} }
...@@ -1786,7 +1788,7 @@ static void test_interface_identifier_conversion(void) ...@@ -1786,7 +1788,7 @@ static void test_interface_identifier_conversion(void)
GUID guid; GUID guid;
SIZE_T len; SIZE_T len;
WCHAR nameW[IF_MAX_STRING_SIZE + 1]; 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; NET_IFINDEX index, index2;
if (!pConvertInterfaceIndexToLuid) if (!pConvertInterfaceIndexToLuid)
...@@ -1947,22 +1949,37 @@ static void test_interface_identifier_conversion(void) ...@@ -1947,22 +1949,37 @@ static void test_interface_identifier_conversion(void)
ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" ); ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" );
ok( luid.Info.IfType == IF_TYPE_ETHERNET_CSMACD, "got %u\n", luid.Info.IfType ); ok( luid.Info.IfType == IF_TYPE_ETHERNET_CSMACD, "got %u\n", luid.Info.IfType );
/* if_nametoindex */ if (!pif_nametoindex || !pif_indextoname)
if (pif_nametoindex)
{ {
index2 = pif_nametoindex( NULL ); skip("if_nametoindex/if_indextoname not supported\n");
ok( !index2, "Got unexpected index %u\n", index2 ); return;
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 ) );
} }
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 );
} }
} }
......
...@@ -174,5 +174,7 @@ void WINAPI FreeMibTable(void*); ...@@ -174,5 +174,7 @@ void WINAPI FreeMibTable(void*);
DWORD WINAPI GetIfEntry2(MIB_IF_ROW2*); DWORD WINAPI GetIfEntry2(MIB_IF_ROW2*);
DWORD WINAPI GetIfTable2(MIB_IF_TABLE2**); DWORD WINAPI GetIfTable2(MIB_IF_TABLE2**);
DWORD WINAPI GetUnicastIpAddressEntry(MIB_UNICASTIPADDRESS_ROW*); DWORD WINAPI GetUnicastIpAddressEntry(MIB_UNICASTIPADDRESS_ROW*);
PCHAR WINAPI if_indextoname(NET_IFINDEX,PCHAR);
NET_IFINDEX WINAPI if_nametoindex(PCSTR);
#endif /* __WINE_NETIOAPI_H */ #endif /* __WINE_NETIOAPI_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment