Subject: [clisp-list] ipv6 on cygwin & win32

From: Sam Steingold <[email-masked]>
Date: Fri Mar 8 09:13:12 2002

Those of you who use win32 (msvc) or cygwin -- please test the appended
patch.  If the new-clx users pre-tested 2.28, it would not have broke
new-clx.  If the win32 & cygwin users will not test this patch, the
next release might not work for them.

thanks.

PS is there a site with an ipv6 address around to test this?

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
If I had known that it was harmless, I would have killed it myself.

--- socket.d.~1.54.~	Tue Dec 11 16:44:10 2001
+++ socket.d	Fri Mar  8 11:55:19 2002
@@ -130,7 +130,7 @@
 
 # Converts an AF_INET address to a printable, presentable format.
 # ipv4_ntop(buffer,addr);
-# > sockaddr_in addr: IPv4 address
+# > struct in_addr addr: IPv4 address
 # < char[] buffer: printable address
 # buffer should have at least 15+1 characters.
 #ifdef HAVE_IPV4
@@ -145,35 +145,27 @@
 
 # Converts an AF_INET6 address to a printable, presentable format.
 # ipv6_ntop(buffer,addr);
-# > sockaddr_in6 addr: IPv6 address
+# > struct in6_addr addr: IPv6 address
 # < char[] buffer: printable address
 # buffer should have at least 45+1 characters.
 #ifdef HAVE_IPV6
+  #ifndef s6_addr16
+    #define s6_addr16 in6_u.u6_addr16
+  #endif
   #ifdef HAVE_INET_NTOP
     #define ipv6_ntop(buffer,addr)  \
       inet_ntop(AF_INET6,&addr,buffer,45+1)
-  #elif defined(WIN32) || defined(UNIX_CYGWIN32)
-    #define ipv6_ntop(buffer,addr)  \
-     (sprintf(buffer,"%x:%x:%x:%x:%x:%x:%x:%x", \
-              ntohs(((u_short*)(addr).s6_addr)[0]), \
-              ntohs(((u_short*)(addr).s6_addr)[1]), \
-              ntohs(((u_short*)(addr).s6_addr)[2]), \
-              ntohs(((u_short*)(addr).s6_addr)[3]), \
-              ntohs(((u_short*)(addr).s6_addr)[4]), \
-              ntohs(((u_short*)(addr).s6_addr)[5]), \
-              ntohs(((u_short*)(addr).s6_addr)[6]), \
-              ntohs(((u_short*)(addr).s6_addr)[7])),buffer)
   #else
     #define ipv6_ntop(buffer,addr)  \
      (sprintf(buffer,"%x:%x:%x:%x:%x:%x:%x:%x", \
-              ntohs((addr).in6_u.u6_addr16[0]), \
-              ntohs((addr).in6_u.u6_addr16[1]), \
-              ntohs((addr).in6_u.u6_addr16[2]), \
-              ntohs((addr).in6_u.u6_addr16[3]), \
-              ntohs((addr).in6_u.u6_addr16[4]), \
-              ntohs((addr).in6_u.u6_addr16[5]), \
-              ntohs((addr).in6_u.u6_addr16[6]), \
-              ntohs((addr).in6_u.u6_addr16[7])),buffer)
+              ntohs((addr).s6_addr16[0]),               \
+              ntohs((addr).s6_addr16[1]),               \
+              ntohs((addr).s6_addr16[2]),               \
+              ntohs((addr).s6_addr16[3]),               \
+              ntohs((addr).s6_addr16[4]),               \
+              ntohs((addr).s6_addr16[5]),               \
+              ntohs((addr).s6_addr16[6]),               \
+              ntohs((addr).s6_addr16[7])),buffer)
   #endif
 #endif

---

From: Arseny Slobodjuck <[email-masked]>
Date: Sat Mar 9 03:29:03 2002

Hello Sam,

Saturday, March 09, 2002, 3:07:07 AM, you wrote:

Sam> Those of you who use win32 (msvc) or cygwin -- please test the appended
Sam> patch.

What is in_addr6 ? On MSVC it's declared as

struct in_addr6 {
                u_char  s6_addr[16];    /* IPv6 address */
};

what is in incompatible with

                ipv6_ntop(buffer,*(const struct in6_addr*)h->h_addr);

since in6_addr is declared as

                #define in6_addr in_addr6

-- 
Best regards,
 Arseny                            mailto:[email-masked]

---

From: Sam Steingold <[email-masked]>
Date: Sat Mar 9 07:59:04 2002

Hi Arseny,

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] ipv6 on cygwin & win32"
> * Sent on Sat, 9 Mar 2002 20:49:58 +1000
> * Honorable Arseny Slobodjuck <[email-masked]> writes:
>

I take it to mean that the patch does not work.
What about this one? (it should be trivially equivalent to the current code)

Karsten, please test it too.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
The paperless office will become a reality soon after the paperless toilet.

--- socket.d.~1.54.~	Tue Dec 11 16:44:10 2001
+++ socket.d	Sat Mar  9 10:43:34 2002
@@ -130,7 +130,7 @@
 
@@ -145,35 +145,32 @@
 
 # Converts an AF_INET6 address to a printable, presentable format.
 # ipv6_ntop(buffer,addr);
-# > sockaddr_in6 addr: IPv6 address
+# > struct in6_addr addr: IPv6 address
 # < char[] buffer: printable address
 # buffer should have at least 45+1 characters.
 #ifdef HAVE_IPV6
+  #ifndef s6_addr16
+    #define s6_addr16 in6_u.u6_addr16
+  #endif
+  #if defined(WIN32) || defined(UNIX_CYGWIN32)
+    #define S6_ADDR16(addr)   ((u_short*)((addr).s6_addr))
+  #else
+    #define S6_ADDR16(addr)   (addr).s6_addr16
+  #endif
   #ifdef HAVE_INET_NTOP
     #define ipv6_ntop(buffer,addr)  \
       inet_ntop(AF_INET6,&addr,buffer,45+1)
-  #elif defined(WIN32) || defined(UNIX_CYGWIN32)
-    #define ipv6_ntop(buffer,addr)  \
-     (sprintf(buffer,"%x:%x:%x:%x:%x:%x:%x:%x", \
-              ntohs(((u_short*)(addr).s6_addr)[0]), \
-              ntohs(((u_short*)(addr).s6_addr)[1]), \
-              ntohs(((u_short*)(addr).s6_addr)[2]), \
-              ntohs(((u_short*)(addr).s6_addr)[3]), \
-              ntohs(((u_short*)(addr).s6_addr)[4]), \
-              ntohs(((u_short*)(addr).s6_addr)[5]), \
-              ntohs(((u_short*)(addr).s6_addr)[6]), \
-              ntohs(((u_short*)(addr).s6_addr)[7])),buffer)
   #else
     #define ipv6_ntop(buffer,addr)  \
      (sprintf(buffer,"%x:%x:%x:%x:%x:%x:%x:%x", \
-              ntohs((addr).in6_u.u6_addr16[0]), \
-              ntohs((addr).in6_u.u6_addr16[1]), \
-              ntohs((addr).in6_u.u6_addr16[2]), \
-              ntohs((addr).in6_u.u6_addr16[3]), \
-              ntohs((addr).in6_u.u6_addr16[4]), \
-              ntohs((addr).in6_u.u6_addr16[5]), \
-              ntohs((addr).in6_u.u6_addr16[6]), \
-              ntohs((addr).in6_u.u6_addr16[7])),buffer)
+              ntohs(S6_ADDR16(addr)[0]),                \
+              ntohs(S6_ADDR16(addr)[1]),                \
+              ntohs(S6_ADDR16(addr)[2]),                \
+              ntohs(S6_ADDR16(addr)[3]),                \
+              ntohs(S6_ADDR16(addr)[4]),                \
+              ntohs(S6_ADDR16(addr)[5]),                \
+              ntohs(S6_ADDR16(addr)[6]),                \
+              ntohs(S6_ADDR16(addr)[7])),buffer)
   #endif
 #endif

---

From: Peter Burwood <[email-masked]>
Date: Sat Mar 9 19:47:02 2002

> Karsten, please test it too.

Sam,

It compiles and builds without error. No idea whether it works because
I don't know how to test it.

Peter

---

From: Arseny Slobodjuck <[email-masked]>
Date: Sat Mar 9 20:22:05 2002

Hello Sam,

>>                 u_char  s6_addr[16];    /* IPv6 address */

Sam> I take it to mean that the patch does not work.
Sam> What about this one? (it should be trivially equivalent to the current code)

It compiles on msvc and my HTTP-getter works with it.