iphlpapi: Implement if_indextoname.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2018-01-23 09:43:50 +01:00 committed by Alexandre Julliard
parent 9bafbe1086
commit e3fe10719e
4 changed files with 44 additions and 15 deletions

View file

@ -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

View file

@ -3235,3 +3235,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);
}

View file

@ -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 *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)
@ -148,6 +149,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");
}
}
@ -1786,7 +1788,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)
@ -1947,9 +1949,12 @@ 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)
{
skip("if_nametoindex/if_indextoname not supported\n");
return;
}
index2 = pif_nametoindex( NULL );
ok( !index2, "Got unexpected index %u\n", index2 );
index2 = pif_nametoindex( nameA );
@ -1959,10 +1964,22 @@ static void test_interface_identifier_conversion(void)
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
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 );
}
}

View file

@ -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 */