Alex Henrie : iphlpapi: Implement ParseNetworkString for IPv4 addresses and services.
Alexandre Julliard
julliard at winehq.org
Thu Sep 5 16:54:01 CDT 2019
Module: wine
Branch: master
Commit: faf354cd45e23f6cb8f82dee3fdf340647299b5d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=faf354cd45e23f6cb8f82dee3fdf340647299b5d
Author: Alex Henrie <alexhenrie24 at gmail.com>
Date: Wed Sep 4 23:14:15 2019 -0600
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 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/iphlpapi/iphlpapi.spec | 2 +-
dlls/iphlpapi/iphlpapi_main.c | 61 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec
index abc7152..c5857f2 100644
--- a/dlls/iphlpapi/iphlpapi.spec
+++ b/dlls/iphlpapi/iphlpapi.spec
@@ -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 at 24
@ stub _PfAddGlobalFilterToInterface at 8
@ stdcall _PfBindInterfaceToIPAddress at 12(long long ptr) PfBindInterfaceToIPAddress
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index f1aa0d1..1f823b4 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -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;
+}
More information about the wine-cvs
mailing list