Bugzilla Bug 294017: make PR_NETADDR_SIZE return the correct value on
authorwtchang%redhat.com
Mon, 20 Jun 2005 22:05:20 +0000
changeset 3408 cf6e109b892c0cdb989e39059a36454f0d14d570
parent 3407 9a4188e1be906654b829098dc32099b52e673f2c
child 3410 9c749b032d0417a8e39b822be9f8d63983d74813
push idunknown
push userunknown
push dateunknown
bugs294017
Bugzilla Bug 294017: make PR_NETADDR_SIZE return the correct value on Windows because Windows' struct in6_addr has different alignment from PRIPv6Addr. The patch is contributed by Shanmu <shanmus@gmail.com>. r=wtc. Modified Files: md/_win95.h md/_winnt.h private/primpl.h
pr/include/md/_win95.h
pr/include/md/_winnt.h
pr/include/private/primpl.h
--- a/pr/include/md/_win95.h
+++ b/pr/include/md/_win95.h
@@ -67,16 +67,32 @@ struct addrinfo {
     int ai_socktype;
     int ai_protocol;
     size_t ai_addrlen;
     char *ai_canonname;
     struct sockaddr *ai_addr;
     struct addrinfo *ai_next;
 };
 #endif
+#define _PR_HAVE_MD_SOCKADDR_IN6
+/* isomorphic to struct in6_addr on Windows */
+struct _md_in6_addr {
+    union {
+        PRUint8  _S6_u8[16];
+        PRUint16 _S6_u16[8];
+    } _S6_un;
+};
+/* isomorphic to struct sockaddr_in6 on Windows */
+struct _md_sockaddr_in6 {
+    PRInt16 sin6_family;
+    PRUint16 sin6_port;
+    PRUint32 sin6_flowinfo;
+    struct _md_in6_addr sin6_addr;
+    PRUint32 sin6_scope_id;
+};
 #endif
 #define _PR_HAVE_THREADSAFE_GETHOST
 #define _PR_HAVE_ATOMIC_OPS
 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
 
 /* --- Common User-Thread/Native-Thread Definitions --------------------- */
 
 /* --- Globals --- */
--- a/pr/include/md/_winnt.h
+++ b/pr/include/md/_winnt.h
@@ -82,16 +82,32 @@ struct addrinfo {
     int ai_socktype;
     int ai_protocol;
     size_t ai_addrlen;
     char *ai_canonname;
     struct sockaddr *ai_addr;
     struct addrinfo *ai_next;
 };
 #endif
+#define _PR_HAVE_MD_SOCKADDR_IN6
+/* isomorphic to struct in6_addr on Windows */
+struct _md_in6_addr {
+    union {
+        PRUint8  _S6_u8[16];
+        PRUint16 _S6_u16[8];
+    } _S6_un;
+};
+/* isomorphic to struct sockaddr_in6 on Windows */
+struct _md_sockaddr_in6 {
+    PRInt16 sin6_family;
+    PRUint16 sin6_port;
+    PRUint32 sin6_flowinfo;
+    struct _md_in6_addr sin6_addr;
+    PRUint32 sin6_scope_id;
+};
 #endif
 #define _PR_HAVE_THREADSAFE_GETHOST
 #define _PR_HAVE_ATOMIC_OPS
 #define _PR_HAVE_ATOMIC_CAS
 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
 #define _PR_HAVE_PEEK_BUFFER
 #define _PR_PEEK_BUFFER_MAX (32 * 1024)
 #define _PR_FD_NEED_EMULATE_MSG_PEEK(fd) \
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1404,17 +1404,17 @@ extern PRUintn _PR_NetAddrSize(const PRN
         ? sizeof((_addr)->inet)					\
         : ((_addr)->raw.family == PR_AF_INET6	\
         ? sizeof(struct _md_sockaddr_in6)		\
         : sizeof((_addr)->local)))
 #else
 #define PR_NETADDR_SIZE(_addr) 					\
         ((_addr)->raw.family == PR_AF_INET		\
         ? sizeof((_addr)->inet)					\
-        : sizeof(struct _md_sockaddr_in6)
+        : sizeof(struct _md_sockaddr_in6))
 #endif /* defined(XP_UNIX) */
 
 #else
 
 #if defined(XP_UNIX) || defined(XP_OS2_EMX)
 #define PR_NETADDR_SIZE(_addr) 					\
         ((_addr)->raw.family == PR_AF_INET		\
         ? sizeof((_addr)->inet)					\