From 9d27253f3660ebbb466f41cd2fa2f862999694b9 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 21 Oct 2009 20:39:51 +0300 Subject: [PATCH] Fix IPv6 setup (the default on Vista) Ensure that the right struct is passed. Cherry-picked from commit 172d60d100d04e301e51ff475ada02007f1709dc in the dbus4win repository by tml@iki.fi. --- dbus/dbus-sysdeps-win.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index b81e2ea..f80bfd4 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1516,6 +1516,16 @@ _dbus_listen_tcp_socket (const char *host, struct addrinfo hints; struct addrinfo *ai, *tmp; + // On Vista, sockaddr_gen must be a sockaddr_in6, and not a sockaddr_in6_old + //That's required for family == IPv6(which is the default on Vista if family is not given) + //So we use our own union instead of sockaddr_gen: + + typedef union { + struct sockaddr Address; + struct sockaddr_in AddressIn; + struct sockaddr_in6 AddressIn6; + } mysockaddr_gen; + *fds_p = NULL; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -1608,7 +1618,7 @@ _dbus_listen_tcp_socket (const char *host, to use the same port */ if (!port || !strcmp(port, "0")) { - sockaddr_gen addr; + mysockaddr_gen addr; socklen_t addrlen = sizeof(addr); char portbuf[10]; -- 2.7.4