mirror of
git://source.winehq.org/git/wine.git
synced 2024-08-31 08:44:07 +00:00
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:
parent
9bafbe1086
commit
e3fe10719e
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,22 +1949,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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue