diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/access.pri | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyhttpimpl.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinterface.cpp | 46 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinterface.h | 2 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinterface_p.h | 3 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinterface_unix.cpp | 58 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinterface_win.cpp | 43 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinterface_winrt.cpp | 13 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 70 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket.h | 2 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket_p.h | 2 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_p.h | 4 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 26 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 13 | ||||
-rw-r--r-- | src/network/ssl/qsslsocket_mac.cpp | 7 |
16 files changed, 229 insertions, 66 deletions
diff --git a/src/network/access/access.pri b/src/network/access/access.pri index e829d52cbe..42c7c80f3b 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -78,6 +78,8 @@ ios { OBJECTIVE_SOURCES += \ access/qnetworkreplynsurlconnectionimpl.mm + + LIBS_PRIVATE += -framework Foundation } include($$PWD/../../3rdparty/zlib_dependency.pri) diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index ad8a5321b4..2c31afc225 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1733,7 +1733,7 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation() // ensure this function is only being called once if (state == Working) { - qDebug("QNetworkReplyImpl::_q_startOperation was called more than once"); + qDebug() << "QNetworkReplyHttpImplPrivate::_q_startOperation was called more than once" << url; return; } state = Working; diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index c73e6162d1..3df39c9bdc 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -67,7 +67,7 @@ void QNetworkReplyImplPrivate::_q_startOperation() { // ensure this function is only being called once if (state == Working || state == Finished) { - qDebug("QNetworkReplyImpl::_q_startOperation was called more than once"); + qDebug() << "QNetworkReplyImpl::_q_startOperation was called more than once" << url; return; } state = Working; diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index 4a527052d1..81906edc47 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -519,6 +519,31 @@ QList<QNetworkAddressEntry> QNetworkInterface::addressEntries() const } /*! + \since 5.7 + + Returns the index of the interface whose name is \a name or 0 if there is + no interface with that name. This function should produce the same result + as the following code, but will probably execute faster. + + \code + QNetworkInterface::interfaceFromName(name).index() + \endcode + + \sa interfaceFromName(), interfaceNameFromIndex(), QUdpDatagram::interfaceIndex() +*/ +int QNetworkInterface::interfaceIndexFromName(const QString &name) +{ + if (name.isEmpty()) + return 0; + + bool ok; + uint id = name.toUInt(&ok); + if (!ok) + id = QNetworkInterfaceManager::interfaceIndexFromName(name); + return int(id); +} + +/*! Returns a QNetworkInterface object for the interface named \a name. If no such interface exists, this function returns an invalid QNetworkInterface object. @@ -553,6 +578,27 @@ QNetworkInterface QNetworkInterface::interfaceFromIndex(int index) } /*! + \since 5.7 + + Returns the name of the interface whose index is \a index or an empty + string if there is no interface with that index. This function should + produce the same result as the following code, but will probably execute + faster. + + \code + QNetworkInterface::interfaceFromIndex(index).name() + \endcode + + \sa interfaceFromIndex(), interfaceIndexFromName(), QUdpDatagram::interfaceIndex() +*/ +QString QNetworkInterface::interfaceNameFromIndex(int index) +{ + if (!index) + return QString(); + return QNetworkInterfaceManager::interfaceNameFromIndex(index); +} + +/*! Returns a listing of all the network interfaces found on the host machine. In case of failure it returns a list with zero elements. */ diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h index b3daa3d4a0..bd57aea1cb 100644 --- a/src/network/kernel/qnetworkinterface.h +++ b/src/network/kernel/qnetworkinterface.h @@ -113,8 +113,10 @@ public: QString hardwareAddress() const; QList<QNetworkAddressEntry> addressEntries() const; + static int interfaceIndexFromName(const QString &name); static QNetworkInterface interfaceFromName(const QString &name); static QNetworkInterface interfaceFromIndex(int index); + static QString interfaceNameFromIndex(int index); static QList<QNetworkInterface> allInterfaces(); static QList<QHostAddress> allAddresses(); diff --git a/src/network/kernel/qnetworkinterface_p.h b/src/network/kernel/qnetworkinterface_p.h index 140a28c536..146ba7820c 100644 --- a/src/network/kernel/qnetworkinterface_p.h +++ b/src/network/kernel/qnetworkinterface_p.h @@ -100,6 +100,9 @@ public: QSharedDataPointer<QNetworkInterfacePrivate> interfaceFromIndex(int index); QList<QSharedDataPointer<QNetworkInterfacePrivate> > allInterfaces(); + static uint interfaceIndexFromName(const QString &name); + static QString interfaceNameFromIndex(uint index); + // convenience: QSharedDataPointer<QNetworkInterfacePrivate> empty; diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index cc53087024..541c78d838 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. @@ -93,14 +94,8 @@ static QHostAddress addressFromSockaddr(sockaddr *sa, int ifindex = 0, const QSt // this is the most likely scenario: // a scope ID in a socket is that of the interface this address came from address.setScopeId(ifname); - } else if (scope) { -#ifndef QT_NO_IPV6IFNAME - char scopeid[IFNAMSIZ]; - if (::if_indextoname(scope, scopeid)) { - address.setScopeId(QLatin1String(scopeid)); - } else -#endif - address.setScopeId(QString::number(uint(scope))); + } else if (scope) { + address.setScopeId(QNetworkInterfaceManager::interfaceNameFromIndex(scope)); } } return address; @@ -124,6 +119,53 @@ static QNetworkInterface::InterfaceFlags convertFlags(uint rawFlags) return flags; } +uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name) +{ +#ifndef QT_NO_IPV6IFNAME + return ::if_nametoindex(name.toLatin1()); +#elif defined(SIOCGIFINDEX) + struct ifreq req; + int socket = qt_safe_socket(AF_INET, SOCK_STREAM, 0); + if (socket < 0) + return 0; + + QByteArray name8bit = name.toLatin1(); + memset(&req, 0, sizeof(ifreq)); + memcpy(req.ifr_name, name8bit, qMin<int>(name8bit.length() + 1, sizeof(req.ifr_name) - 1)); + + uint id = 0; + if (qt_safe_ioctl(socket, SIOCGIFINDEX, &req) >= 0) + id = req.ifr_ifindex; + qt_safe_close(socket); + return id; +#else + return 0; +#endif +} + +QString QNetworkInterfaceManager::interfaceNameFromIndex(uint index) +{ +#ifndef QT_NO_IPV6IFNAME + char buf[IF_NAMESIZE]; + if (::if_indextoname(index, buf)) + return QString::fromLatin1(buf); +#elif defined(SIOCGIFNAME) + struct ifreq req; + int socket = qt_safe_socket(AF_INET, SOCK_STREAM, 0); + if (socket >= 0) { + memset(&req, 0, sizeof(ifreq)); + req.ifr_ifindex = index; + + if (qt_safe_ioctl(socket, SIOCGIFNAME, &req) >= 0) { + qt_safe_close(socket); + return QString::fromLatin1(req.ifr_name); + } + qt_safe_close(socket); + } +#endif + return QString::number(uint(index)); +} + #ifdef QT_NO_GETIFADDRS // getifaddrs not available diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index 907638f73e..238f913846 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -57,8 +57,14 @@ QT_BEGIN_NAMESPACE +typedef NETIO_STATUS (WINAPI *PtrConvertInterfaceIndexToLuid)(NET_IFINDEX, PNET_LUID); typedef NETIO_STATUS (WINAPI *PtrConvertInterfaceLuidToName)(const NET_LUID *, PWSTR, SIZE_T); +typedef NETIO_STATUS (WINAPI *PtrConvertInterfaceLuidToIndex)(const NET_LUID *, PNET_IFINDEX); +typedef NETIO_STATUS (WINAPI *PtrConvertInterfaceNameToLuid)(const WCHAR *, PNET_LUID); +static PtrConvertInterfaceIndexToLuid ptrConvertInterfaceIndexToLuid = 0; static PtrConvertInterfaceLuidToName ptrConvertInterfaceLuidToName = 0; +static PtrConvertInterfaceLuidToIndex ptrConvertInterfaceLuidToIndex = 0; +static PtrConvertInterfaceNameToLuid ptrConvertInterfaceNameToLuid = 0; static void resolveLibs() { @@ -71,10 +77,16 @@ static void resolveLibs() #if defined(Q_OS_WINCE) // since Windows Embedded Compact 7 + ptrConvertInterfaceIndexToLuid = (PtrConvertInterfaceIndexToLuid)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceIndexToLuid"); ptrConvertInterfaceLuidToName = (PtrConvertInterfaceLuidToName)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceLuidToNameW"); + ptrConvertInterfaceLuidToIndex = (PtrConvertInterfaceLuidToIndex)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceLuidToIndex"); + ptrConvertInterfaceNameToLuid = (PtrConvertInterfaceNameToLuid)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceNameToLuidW"); #else // since Windows Vista + ptrConvertInterfaceIndexToLuid = (PtrConvertInterfaceIndexToLuid)GetProcAddress(iphlpapiHnd, "ConvertInterfaceIndexToLuid"); ptrConvertInterfaceLuidToName = (PtrConvertInterfaceLuidToName)GetProcAddress(iphlpapiHnd, "ConvertInterfaceLuidToNameW"); + ptrConvertInterfaceLuidToIndex = (PtrConvertInterfaceLuidToIndex)GetProcAddress(iphlpapiHnd, "ConvertInterfaceLuidToIndex"); + ptrConvertInterfaceNameToLuid = (PtrConvertInterfaceNameToLuid)GetProcAddress(iphlpapiHnd, "ConvertInterfaceNameToLuidW"); #endif done = true; } @@ -92,13 +104,42 @@ static QHostAddress addressFromSockaddr(sockaddr *sa) address.setAddress(((sockaddr_in6 *)sa)->sin6_addr.s6_addr); int scope = ((sockaddr_in6 *)sa)->sin6_scope_id; if (scope) - address.setScopeId(QString::number(scope)); + address.setScopeId(QNetworkInterfaceManager::interfaceNameFromIndex(scope)); } else qWarning("Got unknown socket family %d", sa->sa_family); return address; } +uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name) +{ + resolveLibs(); + if (!ptrConvertInterfaceNameToLuid || !ptrConvertInterfaceLuidToIndex) + return 0; + + NET_IFINDEX id; + NET_LUID luid; + if (ptrConvertInterfaceNameToLuid(reinterpret_cast<const wchar_t *>(name.constData()), &luid) == NO_ERROR + && ptrConvertInterfaceLuidToIndex(&luid, &id) == NO_ERROR) + return uint(id); + return 0; +} + +QString QNetworkInterfaceManager::interfaceNameFromIndex(uint index) +{ + resolveLibs(); + if (ptrConvertInterfaceIndexToLuid && ptrConvertInterfaceLuidToName) { + NET_LUID luid; + if (ptrConvertInterfaceIndexToLuid(index, &luid) == NO_ERROR) { + WCHAR buf[IF_MAX_STRING_SIZE + 1]; + if (ptrConvertInterfaceLuidToName(&luid, buf, sizeof(buf)/sizeof(buf[0])) == NO_ERROR) + return QString::fromWCharArray(buf); + } + } + + return QString::number(index); +} + static QHash<QHostAddress, QHostAddress> ipv4Netmasks() { //Retrieve all the IPV4 addresses & netmasks diff --git a/src/network/kernel/qnetworkinterface_winrt.cpp b/src/network/kernel/qnetworkinterface_winrt.cpp index 6791caaf21..18bfcaabda 100644 --- a/src/network/kernel/qnetworkinterface_winrt.cpp +++ b/src/network/kernel/qnetworkinterface_winrt.cpp @@ -61,6 +61,19 @@ struct HostNameInfo { QString address; }; +uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name) +{ + // TBD - may not be possible + Q_UNUSED(name); + return 0; +} + +QString QNetworkInterfaceManager::interfaceNameFromIndex(uint index) +{ + // TBD - may not be possible + return QString::number(index); +} + static QNetworkInterfacePrivate *interfaceFromProfile(IConnectionProfile *profile, QList<HostNameInfo> *hostList) { if (!profile) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 1831d25718..08ccff83fa 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -722,7 +722,7 @@ bool QAbstractSocketPrivate::canReadNotification() } } - // only emit readyRead() when not recursing, and only if there is data available + // Only emit readyRead() if there is data available. bool hasData = newBytes > 0 #ifndef QT_NO_UDPSOCKET || (!isBuffered && socketType != QAbstractSocket::TcpSocket && socketEngine && socketEngine->hasPendingDatagrams()) @@ -730,11 +730,8 @@ bool QAbstractSocketPrivate::canReadNotification() || (!isBuffered && socketType == QAbstractSocket::TcpSocket && socketEngine) ; - if (!emittedReadyRead && hasData) { - QScopedValueRollback<bool> r(emittedReadyRead); - emittedReadyRead = true; - emit q->readyRead(); - } + if (hasData) + emitReadyRead(); // If we were closed as a result of the readyRead() signal, // return. @@ -792,12 +789,12 @@ void QAbstractSocketPrivate::canCloseNotification() // then occur when we read from the socket again and fail // in canReadNotification or by the manually created // closeNotification below. - emit q->readyRead(); + emitReadyRead(); QMetaObject::invokeMethod(socketEngine, "closeNotification", Qt::QueuedConnection); } } else if (socketType == QAbstractSocket::TcpSocket && socketEngine) { - emit q->readyRead(); + emitReadyRead(); } } @@ -817,8 +814,7 @@ bool QAbstractSocketPrivate::canWriteNotification() #if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocketPrivate::canWriteNotification() flushing"); #endif - qint64 tmp = writeBuffer.size(); - flush(); + bool dataWasWritten = writeToSocket(); if (socketEngine) { #if defined (Q_OS_WIN) @@ -830,7 +826,7 @@ bool QAbstractSocketPrivate::canWriteNotification() #endif } - return (writeBuffer.size() < tmp); + return dataWasWritten; } /*! \internal @@ -852,21 +848,20 @@ void QAbstractSocketPrivate::connectionNotification() /*! \internal - Writes pending data in the write buffers to the socket. The - function writes as much as it can without blocking. + Writes one pending data block in the write buffer to the socket. It is usually invoked by canWriteNotification after one or more calls to write(). Emits bytesWritten(). */ -bool QAbstractSocketPrivate::flush() +bool QAbstractSocketPrivate::writeToSocket() { Q_Q(QAbstractSocket); if (!socketEngine || !socketEngine->isValid() || (writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0)) { #if defined (QABSTRACTSOCKET_DEBUG) - qDebug("QAbstractSocketPrivate::flush() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s", + qDebug("QAbstractSocketPrivate::writeToSocket() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s", (socketEngine && socketEngine->isValid()) ? "yes" : "no", writeBuffer.isEmpty() ? "yes" : "no"); #endif @@ -884,7 +879,8 @@ bool QAbstractSocketPrivate::flush() qint64 written = socketEngine->write(ptr, nextSize); if (written < 0) { #if defined (QABSTRACTSOCKET_DEBUG) - qDebug() << "QAbstractSocketPrivate::flush() write error, aborting." << socketEngine->errorString(); + qDebug() << "QAbstractSocketPrivate::writeToSocket() write error, aborting." + << socketEngine->errorString(); #endif setErrorAndEmit(socketEngine->error(), socketEngine->errorString()); // an unexpected error so close the socket. @@ -893,7 +889,7 @@ bool QAbstractSocketPrivate::flush() } #if defined (QABSTRACTSOCKET_DEBUG) - qDebug("QAbstractSocketPrivate::flush() %lld bytes written to the network", + qDebug("QAbstractSocketPrivate::writeToSocket() %lld bytes written to the network", written); #endif @@ -914,7 +910,23 @@ bool QAbstractSocketPrivate::flush() if (state == QAbstractSocket::ClosingState) q->disconnectFromHost(); - return true; + return written > 0; +} + +/*! \internal + + Writes pending data in the write buffers to the socket. The function + writes as much as it can without blocking. If any data was written, + this function returns true; otherwise false is returned. +*/ +bool QAbstractSocketPrivate::flush() +{ + bool dataWasWritten = false; + + while (!writeBuffer.isEmpty() && writeToSocket()) + dataWasWritten = true; + + return dataWasWritten; } #ifndef QT_NO_NETWORKPROXY @@ -1248,10 +1260,7 @@ void QAbstractSocketPrivate::_q_forceDisconnect() */ bool QAbstractSocketPrivate::readFromSocket() { -#ifdef QABSTRACTSOCKET_DEBUG Q_Q(QAbstractSocket); -#endif - // Find how many bytes we can read from the socket layer. qint64 bytesToRead = socketEngine->bytesAvailable(); if (bytesToRead == 0) { @@ -1280,7 +1289,7 @@ bool QAbstractSocketPrivate::readFromSocket() buffer.chop(bytesToRead); return true; } - buffer.chop(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes)); + buffer.chop(bytesToRead - ((readBytes < 0 || !q->isReadable()) ? qint64(0) : readBytes)); #if defined(QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocketPrivate::readFromSocket() got %lld bytes, buffer size = %lld", readBytes, buffer.size()); @@ -1301,6 +1310,21 @@ bool QAbstractSocketPrivate::readFromSocket() /*! \internal + Prevents from the recursive readyRead() emission. +*/ +void QAbstractSocketPrivate::emitReadyRead() +{ + Q_Q(QAbstractSocket); + // Only emit readyRead() when not recursing. + if (!emittedReadyRead) { + QScopedValueRollback<bool> r(emittedReadyRead); + emittedReadyRead = true; + emit q->readyRead(); + } +} + +/*! \internal + Sets up the internal state after the connection has succeeded. */ void QAbstractSocketPrivate::fetchConnectionParameters() @@ -2378,7 +2402,7 @@ bool QAbstractSocket::isSequential() const */ bool QAbstractSocket::atEnd() const { - return QIODevice::atEnd() && (!isOpen() || d_func()->buffer.isEmpty()); + return QIODevice::atEnd(); } /*! diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index 23f0d26cbd..f8edc74a24 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -176,7 +176,7 @@ public: // from QIODevice void close() Q_DECL_OVERRIDE; bool isSequential() const Q_DECL_OVERRIDE; - bool atEnd() const Q_DECL_OVERRIDE; + bool atEnd() const Q_DECL_OVERRIDE; // ### Qt6: remove me bool flush(); // for synchronous access diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h index a905625b19..ba129b48df 100644 --- a/src/network/socket/qabstractsocket_p.h +++ b/src/network/socket/qabstractsocket_p.h @@ -135,6 +135,8 @@ public: void fetchConnectionParameters(); void setupSocketNotifiers(); bool readFromSocket(); + bool writeToSocket(); + void emitReadyRead(); void setError(QAbstractSocket::SocketError errorCode, const QString &errorString); void setErrorAndEmit(QAbstractSocket::SocketError errorCode, const QString &errorString); diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 0fa1d8f96e..5cc5e529fc 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" @@ -264,7 +265,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. diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 8626a6be0f..6aff1d25b2 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -107,15 +107,8 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po QHostAddress tmpAddress; tmpAddress.setAddress(tmp); *addr = tmpAddress; - if (s->a6.sin6_scope_id) { -#ifndef QT_NO_IPV6IFNAME - char scopeid[IFNAMSIZ]; - if (::if_indextoname(s->a6.sin6_scope_id, scopeid)) { - addr->setScopeId(QLatin1String(scopeid)); - } else -#endif - addr->setScopeId(QString::number(s->a6.sin6_scope_id)); - } + if (s->a6.sin6_scope_id) + addr->setScopeId(QNetworkInterface::interfaceNameFromIndex(s->a6.sin6_scope_id)); } if (port) *port = ntohs(s->a6.sin6_port); @@ -131,21 +124,6 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po } } -// inline on purpose -inline uint QNativeSocketEnginePrivate::scopeIdFromString(const QString &scopeid) -{ - if (scopeid.isEmpty()) - return 0; - - bool ok; - uint id = scopeid.toUInt(&ok); -#ifndef QT_NO_IPV6IFNAME - if (!ok) - id = ::if_nametoindex(scopeid.toLatin1()); -#endif - return id; -} - static void convertToLevelAndOption(QNativeSocketEngine::SocketOption opt, QAbstractSocket::NetworkLayerProtocol socketProtocol, int &level, int &n) { diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 9aed0caa25..1379ed93ba 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -322,12 +322,6 @@ static inline int qt_socket_getMaxMsgSize(qintptr socketDescriptor) # define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) #endif -// inline on purpose -inline uint QNativeSocketEnginePrivate::scopeIdFromString(const QString &scopeid) -{ - return scopeid.toUInt(); -} - bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType socketType, QAbstractSocket::NetworkLayerProtocol &socketProtocol) { @@ -657,6 +651,13 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin int tries = 0; do { if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) { + if (value != NOERROR) { + // MSDN says getsockopt with SO_ERROR clears the error, but it's not actually cleared + // and this can affect all subsequent WSAConnect attempts, so clear it now. + const int val = NO_ERROR; + ::setsockopt(socketDescriptor, SOL_SOCKET, SO_ERROR, reinterpret_cast<const char*>(&val), sizeof val); + } + if (value == WSAECONNREFUSED) { setError(QAbstractSocket::ConnectionRefusedError, ConnectionRefusedErrorString); socketState = QAbstractSocket::UnconnectedState; diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 06c707f271..a8f7b7320e 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -589,6 +589,9 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384: ciph.d->name = QLatin1String("ECDHE-RSA-AES256-SHA384"); break; + case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: + ciph.d->name = QLatin1String("ECDHE-RSA-AES256-GCM-SHA384"); + break; default: return ciph; } @@ -636,6 +639,10 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui ciph.d->encryptionMethod = QLatin1String("AES(128)"); ciph.d->bits = 128; ciph.d->supportedBits = 128; + } else if (ciph.d->name.contains("AES256-GCM")) { + ciph.d->encryptionMethod = QLatin1String("AESGCM(256)"); + ciph.d->bits = 256; + ciph.d->supportedBits = 256; } else if (ciph.d->name.contains("AES256-")) { ciph.d->encryptionMethod = QLatin1String("AES(256)"); ciph.d->bits = 256; |