diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2011-07-01 14:09:46 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-04 14:32:41 +0200 |
commit | 85869920bb9a4ee45cf4a89e74b1bd3d4ce67eaa (patch) | |
tree | 1dad7fd8061b8b254833873ed8de35b1a2f8f07d /src/network/socket/qnativesocketengine_win.cpp | |
parent | 3d5d8b6c4ff08806934a07df77f9387edc4243df (diff) |
Always assume IPv6 support
It's 2011 baby! And until Qt5 is released probably 2012 :-)
Change-Id: I397aabf25e93c8afb5f562636710985cf0c7acfa
Reviewed-on: http://codereview.qt.nokia.com/1008
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network/socket/qnativesocketengine_win.cpp')
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index ba62bd6da2..67a9a2131a 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -165,7 +165,6 @@ static QByteArray qt_prettyDebug(const char *data, int len, int maxLength) */ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt_sockaddr *sa, quint16 *port, QHostAddress *address) { -#if !defined (QT_NO_IPV6) if (sa->a.sa_family == AF_INET6) { const qt_sockaddr_in6 *sa6 = &sa->a6; Q_IPV6ADDR tmp; @@ -178,7 +177,7 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt if (port) WSANtohs(socketDescriptor, sa6->sin6_port, port); } else -#endif + if (sa->a.sa_family == AF_INET) { const sockaddr_in *sa4 = &sa->a4; unsigned long addr; @@ -200,7 +199,7 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt void QNativeSocketEnginePrivate::setPortAndAddress(sockaddr_in * sockAddrIPv4, qt_sockaddr_in6 * sockAddrIPv6, quint16 port, const QHostAddress & address, sockaddr ** sockAddrPtr, QT_SOCKLEN_T *sockAddrSize) { -#if !defined(QT_NO_IPV6) + if (address.protocol() == QAbstractSocket::IPv6Protocol || address.protocol() == QAbstractSocket::AnyIPProtocol || socketProtocol == QAbstractSocket::IPv6Protocol) { @@ -213,7 +212,7 @@ void QNativeSocketEnginePrivate::setPortAndAddress(sockaddr_in * sockAddrIPv4, q *sockAddrSize = sizeof(qt_sockaddr_in6); *sockAddrPtr = (struct sockaddr *) sockAddrIPv6; } else -#endif + if (address.protocol() == QAbstractSocket::IPv4Protocol || address.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) { memset(sockAddrIPv4, 0, sizeof(sockaddr_in)); @@ -403,24 +402,21 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co n = SO_KEEPALIVE; break; case QNativeSocketEngine::MulticastTtlOption: -#ifndef QT_NO_IPV6 + if (socketProtocol == QAbstractSocket::IPv6Protocol) { level = IPPROTO_IPV6; n = IPV6_MULTICAST_HOPS; } else -#endif { level = IPPROTO_IP; n = IP_MULTICAST_TTL; } break; case QNativeSocketEngine::MulticastLoopbackOption: -#ifndef QT_NO_IPV6 if (socketProtocol == QAbstractSocket::IPv6Protocol) { level = IPPROTO_IPV6; n = IPV6_MULTICAST_LOOP; } else -#endif { level = IPPROTO_IP; n = IP_MULTICAST_LOOP; @@ -487,24 +483,20 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt n = SO_KEEPALIVE; break; case QNativeSocketEngine::MulticastTtlOption: -#ifndef QT_NO_IPV6 if (socketProtocol == QAbstractSocket::IPv6Protocol) { level = IPPROTO_IPV6; n = IPV6_MULTICAST_HOPS; } else -#endif { level = IPPROTO_IP; n = IP_MULTICAST_TTL; } break; case QNativeSocketEngine::MulticastLoopbackOption: -#ifndef QT_NO_IPV6 if (socketProtocol == QAbstractSocket::IPv6Protocol) { level = IPPROTO_IPV6; n = IPV6_MULTICAST_LOOP; } else -#endif { level = IPPROTO_IP; n = IP_MULTICAST_LOOP; @@ -545,11 +537,9 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() case AF_INET: socketProtocol = QAbstractSocket::IPv4Protocol; break; -#if !defined (QT_NO_IPV6) case AF_INET6: socketProtocol = QAbstractSocket::IPv6Protocol; break; -#endif default: socketProtocol = QAbstractSocket::UnknownNetworkLayerProtocol; break; @@ -714,7 +704,7 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port) // binding to a multicast address address = QHostAddress(QHostAddress::AnyIPv6); } -#if !defined (QT_NO_IPV6) && defined (IPV6_V6ONLY) +#if defined (IPV6_V6ONLY) //This is default in current windows versions, it may change in future so set it explicitly if (QSysInfo::windowsVersion() >= QSysInfo::WV_6_0) { ipv6only = 1; @@ -729,7 +719,7 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port) } break; case QAbstractSocket::AnyIPProtocol: -#if !defined (QT_NO_IPV6) && defined (IPV6_V6ONLY) +#if defined (IPV6_V6ONLY) if (QSysInfo::windowsVersion() >= QSysInfo::WV_6_0) ipv6only = ::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, sizeof(ipv6only) ); else @@ -849,7 +839,6 @@ static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d, int sockArgSize; struct ip_mreq mreq4; -#ifndef QT_NO_IPV6 struct ipv6_mreq mreq6; if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) { @@ -862,7 +851,7 @@ static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d, memcpy(&mreq6.ipv6mr_multiaddr, &ip6, sizeof(ip6)); mreq6.ipv6mr_interface = iface.index(); } else -#endif + if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol) { level = IPPROTO_IP; sockOpt = how4; @@ -904,11 +893,7 @@ bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress &gr const QNetworkInterface &iface) { return multicastMembershipHelper(this, -#ifndef QT_NO_IPV6 IPV6_JOIN_GROUP, -#else - 0, -#endif IP_ADD_MEMBERSHIP, groupAddress, iface); @@ -918,11 +903,7 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g const QNetworkInterface &iface) { return multicastMembershipHelper(this, -#ifndef QT_NO_IPV6 IPV6_LEAVE_GROUP, -#else - 0, -#endif IP_DROP_MEMBERSHIP, groupAddress, iface); @@ -930,7 +911,6 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const { -#ifndef QT_NO_IPV6 if (socketProtocol == QAbstractSocket::IPv6Protocol) { uint v; QT_SOCKOPTLEN_T sizeofv = sizeof(v); @@ -938,7 +918,6 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const return QNetworkInterface(); return QNetworkInterface::interfaceFromIndex(v); } -#endif struct in_addr v; v.s_addr = 0; @@ -965,12 +944,11 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface) { -#ifndef QT_NO_IPV6 + if (socketProtocol == QAbstractSocket::IPv6Protocol) { uint v = iface.isValid() ? iface.index() : 0; return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *) &v, sizeof(v)) != -1); } -#endif struct in_addr v; if (iface.isValid()) { |