ws2_32: Add debug support for IPv6 addresses

Juan Lang juan.lang at gmail.com
Tue Jul 28 10:23:20 CDT 2009


This is my response to Jeff Latimer's patch,
http://www.winehq.org/pipermail/wine-patches/2009-July/076459.html

--Juan
-------------- next part --------------
From b5d8ca43d1ac5a8740266b9088c89471f9f76e76 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Mon, 27 Jul 2009 14:32:59 -0700
Subject: [PATCH 07/10] Add debug support for IPv6 addresses

---
 dlls/ws2_32/socket.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 9935e42..6f23624 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -179,10 +179,28 @@ union generic_unix_sockaddr
 static inline const char *debugstr_sockaddr( const struct WS_sockaddr *a )
 {
     if (!a) return "(nil)";
-    return wine_dbg_sprintf("{ family %d, address %s, port %d }",
-                            ((const struct sockaddr_in *)a)->sin_family,
-                            inet_ntoa(((const struct sockaddr_in *)a)->sin_addr),
-                            ntohs(((const struct sockaddr_in *)a)->sin_port));
+    switch (a->sa_family)
+    {
+    case WS_AF_INET:
+        return wine_dbg_sprintf("{ family %d, address %s, port %d }",
+                                ((const struct sockaddr_in *)a)->sin_family,
+                                inet_ntoa(((const struct sockaddr_in *)a)->sin_addr),
+                                ntohs(((const struct sockaddr_in *)a)->sin_port));
+    case WS_AF_INET6:
+    {
+        char buf[46];
+        const char *p;
+        struct WS_sockaddr_in6 *sin = (struct WS_sockaddr_in6 *)a;
+
+        p = WS_inet_ntop( WS_AF_INET6, &sin->sin6_addr, buf, sizeof(buf) );
+        if (!p)
+            p = "(unknown IPv6 address)";
+        return wine_dbg_sprintf("{ family %d, address %s, port %d }",
+                                sin->sin6_family, p, ntohs(sin->sin6_port));
+    }
+    default:
+        return wine_dbg_sprintf("{ family %d }", a->sa_family);
+    }
 }
 
 /* HANDLE<->SOCKET conversion (SOCKET is UINT_PTR). */
-- 
1.6.3.2


More information about the wine-patches mailing list