[PATCH 3/3] iphlpapi: Implement ParseNetworkString for IPv6 addresses and services

Alex Henrie alexhenrie24 at gmail.com
Wed Mar 18 22:06:17 CDT 2020


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/iphlpapi/iphlpapi_main.c | 38 ++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index 9ee85caeb3..cb4ffce408 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -3357,6 +3357,8 @@ DWORD WINAPI ParseNetworkString(const WCHAR *str, DWORD type,
                                 NET_ADDRESS_INFO *info, USHORT *port, BYTE *prefix_len)
 {
     IN_ADDR temp_addr4;
+    IN6_ADDR temp_addr6;
+    ULONG temp_scope;
     USHORT temp_port = 0;
     NTSTATUS status;
 
@@ -3397,10 +3399,44 @@ DWORD WINAPI ParseNetworkString(const WCHAR *str, DWORD type,
             return ERROR_SUCCESS;
         }
     }
+    if (type & NET_STRING_IPV6_ADDRESS)
+    {
+        status = RtlIpv6StringToAddressExW(str, &temp_addr6, &temp_scope, &temp_port);
+        if (SUCCEEDED(status) && !temp_port)
+        {
+            if (info)
+            {
+                info->Format = NET_ADDRESS_IPV6;
+                info->u.Ipv6Address.sin6_addr = temp_addr6;
+                info->u.Ipv6Address.sin6_scope_id = temp_scope;
+                info->u.Ipv6Address.sin6_port = 0;
+            }
+            if (port) *port = 0;
+            if (prefix_len) *prefix_len = 255;
+            return ERROR_SUCCESS;
+        }
+    }
+    if (type & NET_STRING_IPV6_SERVICE)
+    {
+        status = RtlIpv6StringToAddressExW(str, &temp_addr6, &temp_scope, &temp_port);
+        if (SUCCEEDED(status) && temp_port)
+        {
+            if (info)
+            {
+                info->Format = NET_ADDRESS_IPV6;
+                info->u.Ipv6Address.sin6_addr = temp_addr6;
+                info->u.Ipv6Address.sin6_scope_id = temp_scope;
+                info->u.Ipv6Address.sin6_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))
+    if (type & ~(NET_STRING_IPV4_ADDRESS|NET_STRING_IPV4_SERVICE|NET_STRING_IPV6_ADDRESS|NET_STRING_IPV6_SERVICE))
     {
         FIXME("Unimplemented type 0x%x\n", type);
         return ERROR_NOT_SUPPORTED;
-- 
2.25.1




More information about the wine-devel mailing list