Commit a1026df4 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

iphlpapi: Implement if_nametoindex.

parent 8b4a31eb
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
@ 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 #@ stub if_indextoname
#@ stub if_nametoindex @ stdcall if_nametoindex(str) IPHLP_if_nametoindex
#@ stub InitializeIpForwardEntry #@ stub InitializeIpForwardEntry
#@ stub InitializeIpInterfaceEntry #@ stub InitializeIpInterfaceEntry
#@ stub InitializeUnicastIpAddressEntry #@ stub InitializeUnicastIpAddressEntry
......
...@@ -3208,3 +3208,17 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR *name, NET_LUID *luid) ...@@ -3208,3 +3208,17 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR *name, NET_LUID *luid)
luid->Info.IfType = row.dwType; luid->Info.IfType = row.dwType;
return NO_ERROR; 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 ...@@ -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 *pConvertInterfaceNameToLuidA)(const char*,NET_LUID*);
static DWORD (WINAPI *pConvertInterfaceNameToLuidW)(const WCHAR*,NET_LUID*); static DWORD (WINAPI *pConvertInterfaceNameToLuidW)(const WCHAR*,NET_LUID*);
static NET_IFINDEX (WINAPI *pif_nametoindex)(const char*);
static void loadIPHlpApi(void) static void loadIPHlpApi(void)
{ {
hLibrary = LoadLibraryA("iphlpapi.dll"); hLibrary = LoadLibraryA("iphlpapi.dll");
...@@ -144,6 +146,7 @@ static void loadIPHlpApi(void) ...@@ -144,6 +146,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_nametoindex = (void *)GetProcAddress(hLibrary, "if_nametoindex");
} }
} }
...@@ -1792,7 +1795,7 @@ static void test_interface_identifier_conversion(void) ...@@ -1792,7 +1795,7 @@ static void test_interface_identifier_conversion(void)
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];
NET_IFINDEX index; NET_IFINDEX index, index2;
if (!pConvertInterfaceIndexToLuid) if (!pConvertInterfaceIndexToLuid)
{ {
...@@ -1951,6 +1954,24 @@ static void test_interface_identifier_conversion(void) ...@@ -1951,6 +1954,24 @@ static void test_interface_identifier_conversion(void)
ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved );
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)
{
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) static void test_GetIfEntry2(void)
......
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