Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/iphlpapi/iphlpapi.spec | 2 +- dlls/iphlpapi/iphlpapi_main.c | 24 ++++++++++++++++++++++++ dlls/iphlpapi/tests/iphlpapi.c | 11 +++++++++++ include/netioapi.h | 1 + 4 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec index 9180eb84af7..604852a754d 100644 --- a/dlls/iphlpapi/iphlpapi.spec +++ b/dlls/iphlpapi/iphlpapi.spec @@ -15,7 +15,7 @@ @ stdcall ConvertInterfaceAliasToLuid( ptr ptr ) @ stdcall ConvertInterfaceGuidToLuid( ptr ptr ) @ stdcall ConvertInterfaceIndexToLuid( long ptr ) -#@ stub ConvertInterfaceLuidToAlias +@ stdcall ConvertInterfaceLuidToAlias( ptr ptr long ) @ stdcall ConvertInterfaceLuidToGuid( ptr ptr ) @ stdcall ConvertInterfaceLuidToIndex( ptr ptr ) @ stdcall ConvertInterfaceLuidToNameA( ptr ptr long ) diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 448c1d873af..e5dc1012cb0 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -3241,6 +3241,30 @@ DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX index, NET_LUID *luid) return err; }
+/****************************************************************** + * 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.@) */ diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 480d6ac06c5..e43cb9b1f78 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -1625,6 +1625,7 @@ static void test_interface_identifier_conversion(void) GUID guid; SIZE_T len; WCHAR nameW[IF_MAX_STRING_SIZE + 1]; + WCHAR alias[IF_MAX_STRING_SIZE + 1]; char nameA[IF_MAX_STRING_SIZE + 1], *name; NET_IFINDEX index; MIB_IF_TABLE2 *table; @@ -1779,6 +1780,16 @@ static void test_interface_identifier_conversion(void) ok( !ret, "got %u\n", ret ); 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 ); ok( !index, "Got unexpected index %u\n", index ); index = if_nametoindex( nameA ); diff --git a/include/netioapi.h b/include/netioapi.h index 6d08d54a444..055266d946e 100644 --- a/include/netioapi.h +++ b/include/netioapi.h @@ -241,6 +241,7 @@ typedef VOID (WINAPI *PIPFORWARD_CHANGE_CALLBACK)(VOID*,MIB_IPFORWARD_ROW2*,MIB_ DWORD WINAPI ConvertInterfaceAliasToLuid(const WCHAR*,NET_LUID*); DWORD WINAPI ConvertInterfaceGuidToLuid(const GUID*,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 ConvertInterfaceLuidToIndex(const NET_LUID*,NET_IFINDEX*); DWORD WINAPI ConvertInterfaceLuidToNameA(const NET_LUID*,char*,SIZE_T);