diff options
Diffstat (limited to 'src/network/socket/qnativesocketengine_p.h')
-rw-r--r-- | src/network/socket/qnativesocketengine_p.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 9a76e23013..2dc4bbaced 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -45,6 +45,7 @@ // We mean it. // #include "QtNetwork/qhostaddress.h" +#include "QtNetwork/qnetworkinterface.h" #include "private/qabstractsocketengine_p.h" #ifndef Q_OS_WIN # include "qplatformdefs.h" @@ -98,6 +99,16 @@ union qt_sockaddr { sockaddr_in6 a6; }; +namespace { +namespace SetSALen { + template <typename T> void set(T *sa, typename QtPrivate::QEnableIf<(&T::sa_len, true), QT_SOCKLEN_T>::Type len) + { sa->sa_len = len; } + template <typename T> void set(T *sin6, typename QtPrivate::QEnableIf<(&T::sin6_len, true), QT_SOCKLEN_T>::Type len) + { sin6->sin6_len = len; } + template <typename T> void set(T *, ...) {} +} +} + class QNativeSocketEnginePrivate; #ifndef QT_NO_NETWORKINTERFACE class QNetworkInterface; @@ -266,7 +277,8 @@ public: bool checkProxy(const QHostAddress &address); bool fetchConnectionParameters(); - static uint scopeIdFromString(const QString &scopeid); + static uint scopeIdFromString(const QString &scopeid) + { return QNetworkInterface::interfaceIndexFromName(scopeid); } /*! \internal Sets \a address and \a port in the \a aa sockaddr structure and the size in \a sockAddrSize. @@ -285,12 +297,14 @@ public: Q_IPV6ADDR tmp = address.toIPv6Address(); memcpy(&aa->a6.sin6_addr, &tmp, sizeof(tmp)); *sockAddrSize = sizeof(sockaddr_in6); + SetSALen::set(&aa->a, sizeof(sockaddr_in6)); } else { memset(&aa->a, 0, sizeof(sockaddr_in)); aa->a4.sin_family = AF_INET; aa->a4.sin_port = htons(port); aa->a4.sin_addr.s_addr = htonl(address.toIPv4Address()); *sockAddrSize = sizeof(sockaddr_in); + SetSALen::set(&aa->a, sizeof(sockaddr_in)); } } |