mirror of
https://github.com/reactos/wine.git
synced 2025-03-03 10:17:23 +00:00
iphlpapi: Implement if_nametoindex.
Signed-off-by: Stefan Dösinger <stefan@codeweavers.com> Signed-off-by: Bruno Jesus <bjesus@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8b4a31ebd5
commit
a1026df403
@ -160,7 +160,7 @@
|
||||
@ 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
|
||||
#@ stub if_nametoindex
|
||||
@ stdcall if_nametoindex(str) IPHLP_if_nametoindex
|
||||
#@ stub InitializeIpForwardEntry
|
||||
#@ stub InitializeIpInterfaceEntry
|
||||
#@ stub InitializeUnicastIpAddressEntry
|
||||
|
@ -3208,3 +3208,17 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR *name, NET_LUID *luid)
|
||||
luid->Info.IfType = row.dwType;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* if_nametoindex (IPHLPAPI.@)
|
||||
*/
|
||||
IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
|
||||
{
|
||||
IF_INDEX idx;
|
||||
|
||||
TRACE("(%s)\n", name);
|
||||
if (getInterfaceIndexByName(name, &idx) == NO_ERROR)
|
||||
return idx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -96,6 +96,8 @@ 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 NET_IFINDEX (WINAPI *pif_nametoindex)(const char*);
|
||||
|
||||
static void loadIPHlpApi(void)
|
||||
{
|
||||
hLibrary = LoadLibraryA("iphlpapi.dll");
|
||||
@ -144,6 +146,7 @@ static void loadIPHlpApi(void)
|
||||
pConvertInterfaceLuidToNameW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToNameW");
|
||||
pConvertInterfaceNameToLuidA = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidA");
|
||||
pConvertInterfaceNameToLuidW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidW");
|
||||
pif_nametoindex = (void *)GetProcAddress(hLibrary, "if_nametoindex");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1792,7 +1795,7 @@ static void test_interface_identifier_conversion(void)
|
||||
SIZE_T len;
|
||||
WCHAR nameW[IF_MAX_STRING_SIZE + 1];
|
||||
char nameA[IF_MAX_STRING_SIZE + 1];
|
||||
NET_IFINDEX index;
|
||||
NET_IFINDEX index, index2;
|
||||
|
||||
if (!pConvertInterfaceIndexToLuid)
|
||||
{
|
||||
@ -1951,6 +1954,24 @@ static void test_interface_identifier_conversion(void)
|
||||
ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved );
|
||||
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)
|
||||
{
|
||||
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 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
skip("if_nametoindex not supported\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void test_GetIfEntry2(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user