tst_QNetworkInterface: enable IPv6 detection for Windows
This was disabled in d0d1d7403377363a101d4f1781d06a9b44787d0a, I guess accidentally, by a too-wide conditional. The change the same commit applied to QtNetworkSettings didn't make the same mistake. I am also opportunistically updating the conditional to QT_CONFIG (I missed this in 9d4579c1cd0aae5f75c8702826b5d874a6aae83e) and adding the Linux-specific check, as the AF_NETLINK implementation does not rely on getifaddrs() or if_nametoindex(). Drive-by fix indentation. Change-Id: Ifa1111900d6945ea8e05fffd177ef8fcb11b4e1e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 2e51fbf89a748ad3550e786f1bdbf623169550d2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
724f7fb6c8
commit
3590e2cc52
@ -9,6 +9,6 @@ qt_internal_add_test(tst_qnetworkinterface
|
|||||||
SOURCES
|
SOURCES
|
||||||
tst_qnetworkinterface.cpp
|
tst_qnetworkinterface.cpp
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
Qt::Network
|
Qt::NetworkPrivate
|
||||||
QT_TEST_SERVER_LIST "apache2"
|
QT_TEST_SERVER_LIST "apache2"
|
||||||
)
|
)
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include <qudpsocket.h>
|
#include <qudpsocket.h>
|
||||||
#include "../../../network-settings.h"
|
#include "../../../network-settings.h"
|
||||||
|
|
||||||
|
#include <private/qtnetwork-config_p.h>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QHostAddress)
|
Q_DECLARE_METATYPE(QHostAddress)
|
||||||
|
|
||||||
class tst_QNetworkInterface : public QObject
|
class tst_QNetworkInterface : public QObject
|
||||||
@ -49,14 +51,13 @@ tst_QNetworkInterface::~tst_QNetworkInterface()
|
|||||||
|
|
||||||
bool tst_QNetworkInterface::isIPv6Working()
|
bool tst_QNetworkInterface::isIPv6Working()
|
||||||
{
|
{
|
||||||
// Version without following cannot get IPV6 information
|
// QNetworkInterface may be unable to detect IPv6 addresses even if they
|
||||||
#if !defined(QT_NO_GETIFADDRS) && !defined(QT_NO_IPV6IFNAME)
|
// are there, due to limitations of the implementation.
|
||||||
QUdpSocket socket;
|
if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::Windows ||
|
||||||
socket.connectToHost(QHostAddress::LocalHostIPv6, 1234);
|
QT_CONFIG(linux_netlink) || (QT_CONFIG(getifaddrs) && QT_CONFIG(ipv6ifname))) {
|
||||||
return socket.state() == QAbstractSocket::ConnectedState || socket.waitForConnected(100);
|
return QtNetworkSettings::hasIPv6();
|
||||||
#else
|
}
|
||||||
return false;
|
return false;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QNetworkInterface::initTestCase()
|
void tst_QNetworkInterface::initTestCase()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user