Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/iphlpapi/iphlpapi.spec | 2 +- dlls/iphlpapi/iphlpapi_main.c | 33 +++++++++++++++++++++++++++++++++ include/netioapi.h | 1 + 3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec index ded265f5719..9180eb84af7 100644 --- a/dlls/iphlpapi/iphlpapi.spec +++ b/dlls/iphlpapi/iphlpapi.spec @@ -12,7 +12,7 @@ @ stdcall CancelMibChangeNotify2( ptr ) #@ stub ConvertGuidToStringA #@ stub ConvertGuidToStringW -#@ stub ConvertInterfaceAliasToLuid +@ stdcall ConvertInterfaceAliasToLuid( ptr ptr ) @ stdcall ConvertInterfaceGuidToLuid( ptr ptr ) @ stdcall ConvertInterfaceIndexToLuid( long ptr ) #@ stub ConvertInterfaceLuidToAlias diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 403b51391af..448c1d873af 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -3159,6 +3159,39 @@ ULONG WINAPI GetTcp6Table2(PMIB_TCP6TABLE2 table, PULONG size, BOOL order) return ERROR_NOT_SUPPORTED; }
+/****************************************************************** + * ConvertInterfaceAliasToLuid (IPHLPAPI.@) + */ +DWORD WINAPI ConvertInterfaceAliasToLuid( const WCHAR *alias, NET_LUID *luid ) +{ + struct nsi_ndis_ifinfo_rw *data; + DWORD err, count, i, len; + NET_LUID *keys; + + TRACE( "(%s %p)\n", debugstr_w(alias), luid ); + + if (!alias || !*alias || !luid) return ERROR_INVALID_PARAMETER; + luid->Value = 0; + len = strlenW( alias ); + + err = NsiAllocateAndGetTable( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, (void **)&keys, sizeof(*keys), + (void **)&data, sizeof(*data), NULL, 0, NULL, 0, &count, 0 ); + if (err) return err; + + err = ERROR_INVALID_PARAMETER; + for (i = 0; i < count; i++) + { + if (data[i].alias.Length == len * 2 && !memcmp( data[i].alias.String, alias, len * 2 )) + { + luid->Value = keys[i].Value; + err = ERROR_SUCCESS; + break; + } + } + NsiFreeTable( keys, data, NULL, NULL ); + return err; +} + /****************************************************************** * ConvertInterfaceGuidToLuid (IPHLPAPI.@) */ diff --git a/include/netioapi.h b/include/netioapi.h index 7238d527ad4..6d08d54a444 100644 --- a/include/netioapi.h +++ b/include/netioapi.h @@ -238,6 +238,7 @@ typedef VOID (WINAPI *PUNICAST_IPADDRESS_CHANGE_CALLBACK)(PVOID, PMIB_UNICASTIPA
typedef VOID (WINAPI *PIPFORWARD_CHANGE_CALLBACK)(VOID*,MIB_IPFORWARD_ROW2*,MIB_NOTIFICATION_TYPE);
+DWORD WINAPI ConvertInterfaceAliasToLuid(const WCHAR*,NET_LUID*); DWORD WINAPI ConvertInterfaceGuidToLuid(const GUID*,NET_LUID*); DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX,NET_LUID*); DWORD WINAPI ConvertInterfaceLuidToGuid(const NET_LUID*,GUID*);