Properly set (sa|sin|sin6)_len on Unix systems that need it
Change-Id: I7de033f80b0e4431b7f1ffff13f90288a50606e7 Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
parent
4242fe0a03
commit
2fb42eb4af
@ -37,6 +37,7 @@
|
|||||||
#include <qscopedpointer.h>
|
#include <qscopedpointer.h>
|
||||||
#include <qurl.h>
|
#include <qurl.h>
|
||||||
#include <private/qmutexpool_p.h>
|
#include <private/qmutexpool_p.h>
|
||||||
|
#include <private/qnativesocketengine_p.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -160,6 +161,7 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN
|
|||||||
state._u._ext.nscount6 = 1;
|
state._u._ext.nscount6 = 1;
|
||||||
ns->sin6_family = AF_INET6;
|
ns->sin6_family = AF_INET6;
|
||||||
ns->sin6_port = htons(53);
|
ns->sin6_port = htons(53);
|
||||||
|
SetSALen::set(ns, sizeof(*ns));
|
||||||
|
|
||||||
Q_IPV6ADDR ipv6Address = nameserver.toIPv6Address();
|
Q_IPV6ADDR ipv6Address = nameserver.toIPv6Address();
|
||||||
for (int i=0; i<16; i++) {
|
for (int i=0; i<16; i++) {
|
||||||
|
@ -99,6 +99,16 @@ union qt_sockaddr {
|
|||||||
sockaddr_in6 a6;
|
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;
|
class QNativeSocketEnginePrivate;
|
||||||
#ifndef QT_NO_NETWORKINTERFACE
|
#ifndef QT_NO_NETWORKINTERFACE
|
||||||
class QNetworkInterface;
|
class QNetworkInterface;
|
||||||
@ -287,12 +297,14 @@ public:
|
|||||||
Q_IPV6ADDR tmp = address.toIPv6Address();
|
Q_IPV6ADDR tmp = address.toIPv6Address();
|
||||||
memcpy(&aa->a6.sin6_addr, &tmp, sizeof(tmp));
|
memcpy(&aa->a6.sin6_addr, &tmp, sizeof(tmp));
|
||||||
*sockAddrSize = sizeof(sockaddr_in6);
|
*sockAddrSize = sizeof(sockaddr_in6);
|
||||||
|
SetSALen::set(&aa->a, sizeof(sockaddr_in6));
|
||||||
} else {
|
} else {
|
||||||
memset(&aa->a, 0, sizeof(sockaddr_in));
|
memset(&aa->a, 0, sizeof(sockaddr_in));
|
||||||
aa->a4.sin_family = AF_INET;
|
aa->a4.sin_family = AF_INET;
|
||||||
aa->a4.sin_port = htons(port);
|
aa->a4.sin_port = htons(port);
|
||||||
aa->a4.sin_addr.s_addr = htonl(address.toIPv4Address());
|
aa->a4.sin_addr.s_addr = htonl(address.toIPv4Address());
|
||||||
*sockAddrSize = sizeof(sockaddr_in);
|
*sockAddrSize = sizeof(sockaddr_in);
|
||||||
|
SetSALen::set(&aa->a, sizeof(sockaddr_in));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user