summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2010-12-14 15:48:10 -0800
committerJan Dubois <jand@activestate.com>2010-12-14 16:50:44 -0800
commit1ab9ebc1154972420d469084d44fa5abd7f8a1a6 (patch)
treec4e344e255895ea483976a0ae3ea80924070db0a /win32
parent8e564886c8ebc2b7a1ef021fd382c03c5908da57 (diff)
downloadperl-1ab9ebc1154972420d469084d44fa5abd7f8a1a6.tar.gz
Define our own sockaddr_in6 for VC6
The version defined by the VC6 headers is missing the sin6_scope_id field, used by Socket.xs. Ideally VC6 should be used with later versions of the header files from a Windows Platform SDK, but this patch at least keeps it compilable with plain VC6. I have not verified that the IPv6 code will actually works with this configuration.
Diffstat (limited to 'win32')
-rw-r--r--win32/include/sys/socket.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/win32/include/sys/socket.h b/win32/include/sys/socket.h
index d551d4bab7..a396f00584 100644
--- a/win32/include/sys/socket.h
+++ b/win32/include/sys/socket.h
@@ -28,6 +28,51 @@
*/
# define _WSPIAPI_COUNTOF(_Array) (sizeof(_Array) / sizeof(_Array[0]))
# include <ws2tcpip.h>
+
+# ifndef SIO_GET_INTERFACE_LIST_EX
+ /* The ws2tcpip.h header included in VC6 doesn't define the
+ * sin6_scope_id member of sockaddr_in6. We define our own
+ * version and redefine sockaddr_in6 to point to this one
+ * instead for compiling e.g. Socket.xs.
+ */
+ struct my_sockaddr_in6 {
+ short sin6_family; /* AF_INET6 */
+ u_short sin6_port; /* Transport level port number */
+ u_long sin6_flowinfo; /* IPv6 flow information */
+ struct in_addr6 sin6_addr; /* IPv6 address */
+ u_long sin6_scope_id; /* set of interfaces for a scope */
+ };
+# define sockaddr_in6 my_sockaddr_in6
+
+ /* Provide implementations of IN6ADDR_SETANY() and IN6ADDR_SETLOOPBACK
+ * that also initialize the sin6_scope_id field.
+ */
+# undef IN6ADDR_SETANY
+# define IN6ADDR_SETANY(x) {\
+(x)->sin6_family = AF_INET6; \
+(x)->sin6_port = 0; \
+(x)->sin6_flowinfo = 0; \
+*((u_long *)((x)->sin6_addr.s6_addr) ) = 0; \
+*((u_long *)((x)->sin6_addr.s6_addr) + 1) = 0; \
+*((u_long *)((x)->sin6_addr.s6_addr) + 2) = 0; \
+*((u_long *)((x)->sin6_addr.s6_addr) + 3) = 0; \
+(x)->sin6_scope_id = 0; \
+}
+
+# undef IN6ADDR_SETLOOPBACK
+# define IN6ADDR_SETLOOPBACK(x) {\
+(x)->sin6_family = AF_INET6; \
+(x)->sin6_port = 0; \
+(x)->sin6_flowinfo = 0; \
+*((u_long *)((x)->sin6_addr.s6_addr) ) = 0; \
+*((u_long *)((x)->sin6_addr.s6_addr) + 1) = 0; \
+*((u_long *)((x)->sin6_addr.s6_addr) + 2) = 0; \
+*((u_long *)((x)->sin6_addr.s6_addr) + 3) = 1; \
+(x)->sin6_scope_id = 0; \
+}
+
+# endif
+
# endif
#endif