Commit 79c12f15 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

iphlpapi: Implement ConvertInterfaceLuidToAlias().

parent e62eadad
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
@ stdcall ConvertInterfaceAliasToLuid( ptr ptr ) @ stdcall ConvertInterfaceAliasToLuid( ptr ptr )
@ stdcall ConvertInterfaceGuidToLuid( ptr ptr ) @ stdcall ConvertInterfaceGuidToLuid( ptr ptr )
@ stdcall ConvertInterfaceIndexToLuid( long ptr ) @ stdcall ConvertInterfaceIndexToLuid( long ptr )
#@ stub ConvertInterfaceLuidToAlias @ stdcall ConvertInterfaceLuidToAlias( ptr ptr long )
@ stdcall ConvertInterfaceLuidToGuid( ptr ptr ) @ stdcall ConvertInterfaceLuidToGuid( ptr ptr )
@ stdcall ConvertInterfaceLuidToIndex( ptr ptr ) @ stdcall ConvertInterfaceLuidToIndex( ptr ptr )
@ stdcall ConvertInterfaceLuidToNameA( ptr ptr long ) @ stdcall ConvertInterfaceLuidToNameA( ptr ptr long )
......
...@@ -3242,6 +3242,30 @@ DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX index, NET_LUID *luid) ...@@ -3242,6 +3242,30 @@ DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX index, NET_LUID *luid)
} }
/****************************************************************** /******************************************************************
* ConvertInterfaceLuidToAlias (IPHLPAPI.@)
*/
DWORD WINAPI ConvertInterfaceLuidToAlias( const NET_LUID *luid, WCHAR *alias, SIZE_T len )
{
DWORD err;
IF_COUNTED_STRING name;
TRACE( "(%p %p %u)\n", luid, alias, (DWORD)len );
if (!luid || !alias) return ERROR_INVALID_PARAMETER;
err = NsiGetParameter( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, luid, sizeof(*luid),
NSI_PARAM_TYPE_RW, &name, sizeof(name),
FIELD_OFFSET(struct nsi_ndis_ifinfo_rw, alias) );
if (err) return err;
if (len <= name.Length / sizeof(WCHAR)) return ERROR_NOT_ENOUGH_MEMORY;
memcpy( alias, name.String, name.Length );
alias[name.Length / sizeof(WCHAR)] = '\0';
return err;
}
/******************************************************************
* ConvertInterfaceLuidToGuid (IPHLPAPI.@) * ConvertInterfaceLuidToGuid (IPHLPAPI.@)
*/ */
DWORD WINAPI ConvertInterfaceLuidToGuid(const NET_LUID *luid, GUID *guid) DWORD WINAPI ConvertInterfaceLuidToGuid(const NET_LUID *luid, GUID *guid)
......
...@@ -1625,6 +1625,7 @@ static void test_interface_identifier_conversion(void) ...@@ -1625,6 +1625,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];
WCHAR alias[IF_MAX_STRING_SIZE + 1];
char nameA[IF_MAX_STRING_SIZE + 1], *name; char nameA[IF_MAX_STRING_SIZE + 1], *name;
NET_IFINDEX index; NET_IFINDEX index;
MIB_IF_TABLE2 *table; MIB_IF_TABLE2 *table;
...@@ -1779,6 +1780,16 @@ static void test_interface_identifier_conversion(void) ...@@ -1779,6 +1780,16 @@ static void test_interface_identifier_conversion(void)
ok( !ret, "got %u\n", ret ); ok( !ret, "got %u\n", ret );
ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" ); ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" );
/* ConvertInterfaceAliasToLuid */
ret = ConvertInterfaceAliasToLuid( row->Alias, &luid );
ok( !ret, "got %u\n", ret );
ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" );
/* ConvertInterfaceLuidToAlias */
ret = ConvertInterfaceLuidToAlias( &row->InterfaceLuid, alias, ARRAY_SIZE(alias) );
ok( !ret, "got %u\n", ret );
ok( !wcscmp( alias, row->Alias ), "got %s vs %s\n", wine_dbgstr_w( alias ), wine_dbgstr_w( row->Alias ) );
index = if_nametoindex( NULL ); index = if_nametoindex( NULL );
ok( !index, "Got unexpected index %u\n", index ); ok( !index, "Got unexpected index %u\n", index );
index = if_nametoindex( nameA ); index = if_nametoindex( nameA );
......
...@@ -241,6 +241,7 @@ typedef VOID (WINAPI *PIPFORWARD_CHANGE_CALLBACK)(VOID*,MIB_IPFORWARD_ROW2*,MIB_ ...@@ -241,6 +241,7 @@ typedef VOID (WINAPI *PIPFORWARD_CHANGE_CALLBACK)(VOID*,MIB_IPFORWARD_ROW2*,MIB_
DWORD WINAPI ConvertInterfaceAliasToLuid(const WCHAR*,NET_LUID*); DWORD WINAPI ConvertInterfaceAliasToLuid(const WCHAR*,NET_LUID*);
DWORD WINAPI ConvertInterfaceGuidToLuid(const GUID*,NET_LUID*); DWORD WINAPI ConvertInterfaceGuidToLuid(const GUID*,NET_LUID*);
DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX,NET_LUID*); DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX,NET_LUID*);
DWORD WINAPI ConvertInterfaceLuidToAlias(const NET_LUID*,WCHAR*,SIZE_T);
DWORD WINAPI ConvertInterfaceLuidToGuid(const NET_LUID*,GUID*); DWORD WINAPI ConvertInterfaceLuidToGuid(const NET_LUID*,GUID*);
DWORD WINAPI ConvertInterfaceLuidToIndex(const NET_LUID*,NET_IFINDEX*); DWORD WINAPI ConvertInterfaceLuidToIndex(const NET_LUID*,NET_IFINDEX*);
DWORD WINAPI ConvertInterfaceLuidToNameA(const NET_LUID*,char*,SIZE_T); DWORD WINAPI ConvertInterfaceLuidToNameA(const NET_LUID*,char*,SIZE_T);
......
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