iphlpapi: Implement ParseNetworkString for IPv4 addresses and services.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45560
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Alex Henrie 2019-09-04 23:14:15 -06:00 committed by Alexandre Julliard
parent 8599d8e52e
commit faf354cd45
2 changed files with 62 additions and 1 deletions

View File

@ -243,7 +243,7 @@
@ stdcall NotifyUnicastIpAddressChange(long ptr ptr long ptr)
#@ stub NTPTimeToNTFileTime
#@ stub NTTimeToNTPTime
#@ stub ParseNetworkString
@ stdcall ParseNetworkString(wstr long ptr ptr ptr)
@ stub _PfAddFiltersToInterface@24
@ stub _PfAddGlobalFilterToInterface@8
@ stdcall _PfBindInterfaceToIPAddress@12(long long ptr) PfBindInterfaceToIPAddress

View File

@ -46,6 +46,7 @@
#include "winsock2.h"
#include "winternl.h"
#include "ws2ipdef.h"
#include "windns.h"
#include "iphlpapi.h"
#include "ifenum.h"
#include "ipstats.h"
@ -54,6 +55,7 @@
#include "ifdef.h"
#include "netioapi.h"
#include "tcpestats.h"
#include "ip2string.h"
#include "wine/debug.h"
#include "wine/unicode.h"
@ -3333,3 +3335,62 @@ DWORD WINAPI GetBestRoute2(NET_LUID *luid, NET_IFINDEX index,
return ERROR_NOT_SUPPORTED;
}
/******************************************************************
* ParseNetworkString (IPHLPAPI.@)
*/
DWORD WINAPI ParseNetworkString(const WCHAR *str, DWORD type,
NET_ADDRESS_INFO *info, USHORT *port, BYTE *prefix_len)
{
IN_ADDR temp_addr4;
USHORT temp_port = 0;
NTSTATUS status;
TRACE("(%s, %d, %p, %p, %p)\n", debugstr_w(str), type, info, port, prefix_len);
if (!str)
return ERROR_INVALID_PARAMETER;
if (type & NET_STRING_IPV4_ADDRESS)
{
status = RtlIpv4StringToAddressExW(str, TRUE, &temp_addr4, &temp_port);
if (SUCCEEDED(status) && !temp_port)
{
if (info)
{
info->Format = NET_ADDRESS_IPV4;
info->u.Ipv4Address.sin_addr = temp_addr4;
info->u.Ipv4Address.sin_port = 0;
}
if (port) *port = 0;
if (prefix_len) *prefix_len = 255;
return ERROR_SUCCESS;
}
}
if (type & NET_STRING_IPV4_SERVICE)
{
status = RtlIpv4StringToAddressExW(str, TRUE, &temp_addr4, &temp_port);
if (SUCCEEDED(status) && temp_port)
{
if (info)
{
info->Format = NET_ADDRESS_IPV4;
info->u.Ipv4Address.sin_addr = temp_addr4;
info->u.Ipv4Address.sin_port = temp_port;
}
if (port) *port = ntohs(temp_port);
if (prefix_len) *prefix_len = 255;
return ERROR_SUCCESS;
}
}
if (info) info->Format = NET_ADDRESS_FORMAT_UNSPECIFIED;
if (type & ~(NET_STRING_IPV4_ADDRESS|NET_STRING_IPV4_SERVICE))
{
FIXME("Unimplemented type 0x%x\n", type);
return ERROR_NOT_SUPPORTED;
}
return ERROR_INVALID_PARAMETER;
}