qnetworkinterface_unix.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/kernel/qnetworkinterface_unix.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qset.h"-
35#include "qnetworkinterface.h"-
36#include "qnetworkinterface_p.h"-
37#include "qalgorithms.h"-
38#include "private/qnet_unix_p.h"-
39-
40#ifndef QT_NO_NETWORKINTERFACE-
41-
42#define IP_MULTICAST // make AIX happy and define IFF_MULTICAST-
43-
44#include <sys/types.h>-
45#include <sys/socket.h>-
46-
47#ifdef Q_OS_SOLARIS-
48# include <sys/sockio.h>-
49#endif-
50#include <net/if.h>-
51-
52#if defined(QT_LINUXBASE)-
53# define QT_NO_GETIFADDRS-
54#endif-
55-
56#ifdef Q_OS_ANDROID-
57// android lacks if_nameindex-
58# define QT_NO_IPV6IFNAME-
59#endif-
60-
61#ifdef Q_OS_HAIKU-
62# include <sys/sockio.h>-
63# define IFF_RUNNING 0x0001-
64#endif-
65-
66#ifndef QT_NO_GETIFADDRS-
67# include <ifaddrs.h>-
68#endif-
69-
70#ifdef QT_LINUXBASE-
71# include <arpa/inet.h>-
72# ifndef SIOCGIFBRDADDR-
73# define SIOCGIFBRDADDR 0x8919-
74# endif-
75#endif // QT_LINUXBASE-
76-
77#include <qplatformdefs.h>-
78-
79QT_BEGIN_NAMESPACE-
80-
81static QHostAddress addressFromSockaddr(sockaddr *sa, int ifindex = 0, const QString &ifname = QString())-
82{-
83 QHostAddress address;-
84 if (!sa)
!saDescription
TRUEevaluated 408 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 3468 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
408-3468
85 return address;
executed 408 times by 20 tests: return address;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
408
86-
87 if (sa->sa_family == AF_INET)
sa->sa_family == 2Description
TRUEevaluated 1632 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
1632-1836
88 address.setAddress(htonl(((sockaddr_in *)sa)->sin_addr.s_addr));
executed 1632 times by 20 tests: address.setAddress(htonl(((sockaddr_in *)sa)->sin_addr.s_addr));
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
1632
89 else if (sa->sa_family == AF_INET6) {
sa->sa_family == 10Description
TRUEevaluated 1224 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 612 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
612-1224
90 address.setAddress(((sockaddr_in6 *)sa)->sin6_addr.s6_addr);-
91 int scope = ((sockaddr_in6 *)sa)->sin6_scope_id;-
92 if (scope && scope == ifindex) {
scopeDescription
TRUEevaluated 408 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 816 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
scope == ifindexDescription
TRUEevaluated 408 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-816
93 // this is the most likely scenario:-
94 // a scope ID in a socket is that of the interface this address came from-
95 address.setScopeId(ifname);-
96 } else if (scope) {
executed 408 times by 20 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
scopeDescription
TRUEnever evaluated
FALSEevaluated 816 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
0-816
97#ifndef QT_NO_IPV6IFNAME-
98 char scopeid[IFNAMSIZ];-
99 if (::if_indextoname(scope, scopeid)) {
::if_indextona...cope, scopeid)Description
TRUEnever evaluated
FALSEnever evaluated
0
100 address.setScopeId(QLatin1String(scopeid));-
101 } else
never executed: end of block
0
102#endif-
103 address.setScopeId(QString::number(uint(scope)));
never executed: address.setScopeId(QString::number(uint(scope)));
0
104 }-
105 }
executed 1224 times by 20 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
1224
106 return address;
executed 3468 times by 20 tests: return address;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
3468
107-
108}-
109-
110static QNetworkInterface::InterfaceFlags convertFlags(uint rawFlags)-
111{-
112 QNetworkInterface::InterfaceFlags flags = 0;-
113 flags |= (rawFlags & IFF_UP) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0);
(rawFlags & IFF_UP)Description
TRUEevaluated 612 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-612
114 flags |= (rawFlags & IFF_RUNNING) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0);
(rawFlags & IFF_RUNNING)Description
TRUEevaluated 612 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-612
115 flags |= (rawFlags & IFF_BROADCAST) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0);
(rawFlags & IFF_BROADCAST)Description
TRUEevaluated 408 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 204 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204-408
116 flags |= (rawFlags & IFF_LOOPBACK) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0);
(rawFlags & IFF_LOOPBACK)Description
TRUEevaluated 204 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 408 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204-408
117#ifdef IFF_POINTOPOINT //cygwin doesn't define IFF_POINTOPOINT-
118 flags |= (rawFlags & IFF_POINTOPOINT) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0);
(rawFlags & IFF_POINTOPOINT)Description
TRUEnever evaluated
FALSEevaluated 612 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
0-612
119#endif-
120-
121#ifdef IFF_MULTICAST-
122 flags |= (rawFlags & IFF_MULTICAST) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0);
(rawFlags & IFF_MULTICAST)Description
TRUEevaluated 408 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 204 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204-408
123#endif-
124 return flags;
executed 612 times by 20 tests: return flags;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
612
125}-
126-
127#ifdef QT_NO_GETIFADDRS-
128// getifaddrs not available-
129-
130static QSet<QByteArray> interfaceNames(int socket)-
131{-
132 QSet<QByteArray> result;-
133#ifdef QT_NO_IPV6IFNAME-
134 QByteArray storageBuffer;-
135 struct ifconf interfaceList;-
136 static const int STORAGEBUFFER_GROWTH = 256;-
137-
138 forever {-
139 // grow the storage buffer-
140 storageBuffer.resize(storageBuffer.size() + STORAGEBUFFER_GROWTH);-
141 interfaceList.ifc_buf = storageBuffer.data();-
142 interfaceList.ifc_len = storageBuffer.size();-
143-
144 // get the interface list-
145 if (qt_safe_ioctl(socket, SIOCGIFCONF, &interfaceList) >= 0) {-
146 if (int(interfaceList.ifc_len + sizeof(ifreq) + 64) < storageBuffer.size()) {-
147 // if the buffer was big enough, break-
148 storageBuffer.resize(interfaceList.ifc_len);-
149 break;-
150 }-
151 } else {-
152 // internal error-
153 return result;-
154 }-
155 if (storageBuffer.size() > 100000) {-
156 // out of space-
157 return result;-
158 }-
159 }-
160-
161 int interfaceCount = interfaceList.ifc_len / sizeof(ifreq);-
162 for (int i = 0; i < interfaceCount; ++i) {-
163 QByteArray name = QByteArray(interfaceList.ifc_req[i].ifr_name);-
164 if (!name.isEmpty())-
165 result << name;-
166 }-
167-
168 return result;-
169#else-
170 Q_UNUSED(socket);-
171-
172 // use if_nameindex-
173 struct if_nameindex *interfaceList = ::if_nameindex();-
174 for (struct if_nameindex *ptr = interfaceList; ptr && ptr->if_name; ++ptr)-
175 result << ptr->if_name;-
176-
177 if_freenameindex(interfaceList);-
178 return result;-
179#endif-
180}-
181-
182static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfacePrivate *> &interfaces,-
183 struct ifreq &req)-
184{-
185 QNetworkInterfacePrivate *iface = 0;-
186 int ifindex = 0;-
187-
188#if !defined(QT_NO_IPV6IFNAME) || defined(SIOCGIFINDEX)-
189 // Get the interface index-
190# ifdef SIOCGIFINDEX-
191 if (qt_safe_ioctl(socket, SIOCGIFINDEX, &req) >= 0)-
192 ifindex = req.ifr_ifindex;-
193# else-
194 ifindex = if_nametoindex(req.ifr_name);-
195# endif-
196-
197 // find the interface data-
198 QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();-
199 for ( ; if_it != interfaces.end(); ++if_it)-
200 if ((*if_it)->index == ifindex) {-
201 // existing interface-
202 iface = *if_it;-
203 break;-
204 }-
205#else-
206 // Search by name-
207 QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();-
208 for ( ; if_it != interfaces.end(); ++if_it)-
209 if ((*if_it)->name == QLatin1String(req.ifr_name)) {-
210 // existing interface-
211 iface = *if_it;-
212 break;-
213 }-
214#endif-
215-
216 if (!iface) {-
217 // new interface, create data:-
218 iface = new QNetworkInterfacePrivate;-
219 iface->index = ifindex;-
220 interfaces << iface;-
221 }-
222-
223 return iface;-
224}-
225-
226static QList<QNetworkInterfacePrivate *> interfaceListing()-
227{-
228 QList<QNetworkInterfacePrivate *> interfaces;-
229-
230 int socket;-
231 if ((socket = qt_safe_socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1)-
232 return interfaces; // error-
233-
234 QSet<QByteArray> names = interfaceNames(socket);-
235 QSet<QByteArray>::ConstIterator it = names.constBegin();-
236 for ( ; it != names.constEnd(); ++it) {-
237 ifreq req;-
238 memset(&req, 0, sizeof(ifreq));-
239 memcpy(req.ifr_name, *it, qMin<int>(it->length() + 1, sizeof(req.ifr_name) - 1));-
240-
241 QNetworkInterfacePrivate *iface = findInterface(socket, interfaces, req);-
242-
243#ifdef SIOCGIFNAME-
244 // Get the canonical name-
245 QByteArray oldName = req.ifr_name;-
246 if (qt_safe_ioctl(socket, SIOCGIFNAME, &req) >= 0) {-
247 iface->name = QString::fromLatin1(req.ifr_name);-
248-
249 // reset the name:-
250 memcpy(req.ifr_name, oldName, qMin<int>(oldName.length() + 1, sizeof(req.ifr_name) - 1));-
251 } else-
252#endif-
253 {-
254 // use this name anyways-
255 iface->name = QString::fromLatin1(req.ifr_name);-
256 }-
257-
258 // Get interface flags-
259 if (qt_safe_ioctl(socket, SIOCGIFFLAGS, &req) >= 0) {-
260 iface->flags = convertFlags(req.ifr_flags);-
261 }-
262-
263#ifdef SIOCGIFHWADDR-
264 // Get the HW address-
265 if (qt_safe_ioctl(socket, SIOCGIFHWADDR, &req) >= 0) {-
266 uchar *addr = (uchar *)req.ifr_addr.sa_data;-
267 iface->hardwareAddress = iface->makeHwAddress(6, addr);-
268 }-
269#endif-
270-
271 // Get the address of the interface-
272 QNetworkAddressEntry entry;-
273 if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) {-
274 sockaddr *sa = &req.ifr_addr;-
275 entry.setIp(addressFromSockaddr(sa));-
276-
277 // Get the interface broadcast address-
278 if (iface->flags & QNetworkInterface::CanBroadcast) {-
279 if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {-
280 sockaddr *sa = &req.ifr_addr;-
281 if (sa->sa_family == AF_INET)-
282 entry.setBroadcast(addressFromSockaddr(sa));-
283 }-
284 }-
285-
286 // Get the interface netmask-
287 if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {-
288 sockaddr *sa = &req.ifr_addr;-
289 entry.setNetmask(addressFromSockaddr(sa));-
290 }-
291-
292 iface->addressEntries << entry;-
293 }-
294 }-
295-
296 ::close(socket);-
297 return interfaces;-
298}-
299-
300#else-
301// use getifaddrs-
302-
303// platform-specific defs:-
304# ifdef Q_OS_LINUX-
305QT_BEGIN_INCLUDE_NAMESPACE-
306# include <features.h>-
307QT_END_INCLUDE_NAMESPACE-
308# endif-
309-
310# if defined(Q_OS_LINUX) && __GLIBC__ - 0 >= 2 && __GLIBC_MINOR__ - 0 >= 1 && !defined(QT_LINUXBASE)-
311# include <netpacket/packet.h>-
312-
313static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)-
314{-
315 QList<QNetworkInterfacePrivate *> interfaces;-
316 QSet<QString> seenInterfaces;-
317 QVarLengthArray<int, 16> seenIndexes; // faster than QSet<int>-
318-
319 // On Linux, glibc, uClibc and MUSL obtain the address listing via two-
320 // netlink calls: first an RTM_GETLINK to obtain the interface listing,-
321 // then one RTM_GETADDR to get all the addresses (uClibc implementation is-
322 // copied from glibc; Bionic currently doesn't support getifaddrs). They-
323 // synthesize AF_PACKET addresses from the RTM_GETLINK responses, which-
324 // means by construction they currently show up first in the interface-
325 // listing.-
326 for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {
ptrDescription
TRUEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 204 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204-1836
327 if (ptr->ifa_addr && ptr->ifa_addr->sa_family == AF_PACKET) {
ptr->ifa_addrDescription
TRUEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
ptr->ifa_addr->sa_family == 17Description
TRUEevaluated 612 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 1224 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
0-1836
328 sockaddr_ll *sll = (sockaddr_ll *)ptr->ifa_addr;-
329 QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;-
330 interfaces << iface;-
331 iface->index = sll->sll_ifindex;-
332 iface->name = QString::fromLatin1(ptr->ifa_name);-
333 iface->flags = convertFlags(ptr->ifa_flags);-
334 iface->hardwareAddress = iface->makeHwAddress(sll->sll_halen, (uchar*)sll->sll_addr);-
335-
336 Q_ASSERT(!seenIndexes.contains(iface->index));-
337 seenIndexes.append(iface->index);-
338 seenInterfaces.insert(iface->name);-
339 }
executed 612 times by 20 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
612
340 }
executed 1836 times by 20 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
1836
341-
342 // see if we missed anything:-
343 // - virtual interfaces with no HW address have no AF_PACKET-
344 // - interface labels have no AF_PACKET, but shouldn't be shown as a new interface-
345 for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {
ptrDescription
TRUEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 204 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204-1836
346 if (!ptr->ifa_addr || ptr->ifa_addr->sa_family != AF_PACKET) {
!ptr->ifa_addrDescription
TRUEnever evaluated
FALSEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
ptr->ifa_addr->sa_family != 17Description
TRUEevaluated 1224 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 612 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
0-1836
347 QString name = QString::fromLatin1(ptr->ifa_name);-
348 if (seenInterfaces.contains(name))
seenInterfaces.contains(name)Description
TRUEevaluated 1224 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-1224
349 continue;
executed 1224 times by 20 tests: continue;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
1224
350-
351 int ifindex = if_nametoindex(ptr->ifa_name);-
352 if (seenIndexes.contains(ifindex))
seenIndexes.contains(ifindex)Description
TRUEnever evaluated
FALSEnever evaluated
0
353 continue;
never executed: continue;
0
354-
355 seenInterfaces.insert(name);-
356 seenIndexes.append(ifindex);-
357-
358 QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;-
359 interfaces << iface;-
360 iface->name = name;-
361 iface->flags = convertFlags(ptr->ifa_flags);-
362 iface->index = ifindex;-
363 }
never executed: end of block
0
364 }
executed 612 times by 20 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
612
365-
366 return interfaces;
executed 204 times by 20 tests: return interfaces;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204
367}-
368-
369# elif defined(Q_OS_BSD4)-
370QT_BEGIN_INCLUDE_NAMESPACE-
371# include <net/if_dl.h>-
372QT_END_INCLUDE_NAMESPACE-
373-
374static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)-
375{-
376 QList<QNetworkInterfacePrivate *> interfaces;-
377-
378 // on NetBSD we use AF_LINK and sockaddr_dl-
379 // scan the list for that family-
380 for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next)-
381 if (ptr->ifa_addr && ptr->ifa_addr->sa_family == AF_LINK) {-
382 QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;-
383 interfaces << iface;-
384-
385 sockaddr_dl *sdl = (sockaddr_dl *)ptr->ifa_addr;-
386 iface->index = sdl->sdl_index;-
387 iface->name = QString::fromLatin1(ptr->ifa_name);-
388 iface->flags = convertFlags(ptr->ifa_flags);-
389 iface->hardwareAddress = iface->makeHwAddress(sdl->sdl_alen, (uchar*)LLADDR(sdl));-
390 }-
391-
392 return interfaces;-
393}-
394-
395# else // Generic version-
396-
397static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)-
398{-
399 QList<QNetworkInterfacePrivate *> interfaces;-
400-
401 // make sure there's one entry for each interface-
402 for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {-
403 // Get the interface index-
404 int ifindex = if_nametoindex(ptr->ifa_name);-
405-
406 QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();-
407 for ( ; if_it != interfaces.end(); ++if_it)-
408 if ((*if_it)->index == ifindex)-
409 // this one has been added already-
410 break;-
411-
412 if (if_it == interfaces.end()) {-
413 // none found, create-
414 QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;-
415 interfaces << iface;-
416-
417 iface->index = ifindex;-
418 iface->name = QString::fromLatin1(ptr->ifa_name);-
419 iface->flags = convertFlags(ptr->ifa_flags);-
420 }-
421 }-
422-
423 return interfaces;-
424}-
425-
426# endif-
427-
428-
429static QList<QNetworkInterfacePrivate *> interfaceListing()-
430{-
431 QList<QNetworkInterfacePrivate *> interfaces;-
432-
433 ifaddrs *interfaceListing;-
434 if (getifaddrs(&interfaceListing) == -1) {
getifaddrs(&in...Listing) == -1Description
TRUEnever evaluated
FALSEevaluated 204 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
0-204
435 // error-
436 return interfaces;
never executed: return interfaces;
0
437 }-
438-
439 interfaces = createInterfaces(interfaceListing);-
440 for (ifaddrs *ptr = interfaceListing; ptr; ptr = ptr->ifa_next) {
ptrDescription
TRUEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 204 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204-1836
441 // Find the interface-
442 QString name = QString::fromLatin1(ptr->ifa_name);-
443 QNetworkInterfacePrivate *iface = 0;-
444 QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();-
445 for ( ; if_it != interfaces.end(); ++if_it)
if_it != interfaces.end()Description
TRUEevaluated 3672 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-3672
446 if ((*if_it)->name == name) {
(*if_it)->name == nameDescription
TRUEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
1836
447 // found this interface already-
448 iface = *if_it;-
449 break;
executed 1836 times by 20 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
1836
450 }-
451-
452 if (!iface) {
!ifaceDescription
TRUEnever evaluated
FALSEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
0-1836
453 // it may be an interface label, search by interface index-
454 int ifindex = if_nametoindex(ptr->ifa_name);-
455 for (if_it = interfaces.begin(); if_it != interfaces.end(); ++if_it)
if_it != interfaces.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
456 if ((*if_it)->index == ifindex) {
(*if_it)->index == ifindexDescription
TRUEnever evaluated
FALSEnever evaluated
0
457 // found this interface already-
458 iface = *if_it;-
459 break;
never executed: break;
0
460 }-
461 }
never executed: end of block
0
462-
463 if (!iface) {
!ifaceDescription
TRUEnever evaluated
FALSEevaluated 1836 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
0-1836
464 // skip all non-IP interfaces-
465 continue;
never executed: continue;
0
466 }-
467-
468 QNetworkAddressEntry entry;-
469 entry.setIp(addressFromSockaddr(ptr->ifa_addr, iface->index, iface->name));-
470 if (entry.ip().isNull())
entry.ip().isNull()Description
TRUEevaluated 612 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 1224 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
612-1224
471 // could not parse the address-
472 continue;
executed 612 times by 20 tests: continue;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
612
473-
474 entry.setNetmask(addressFromSockaddr(ptr->ifa_netmask, iface->index, iface->name));-
475 if (iface->flags & QNetworkInterface::CanBroadcast)
iface->flags &...::CanBroadcastDescription
TRUEevaluated 816 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 408 times by 20 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
408-816
476 entry.setBroadcast(addressFromSockaddr(ptr->ifa_broadaddr, iface->index, iface->name));
executed 816 times by 20 tests: entry.setBroadcast(addressFromSockaddr(ptr->ifa_ifu.ifu_broadaddr, iface->index, iface->name));
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
816
477-
478 iface->addressEntries << entry;-
479 }
executed 1224 times by 20 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
1224
480-
481 freeifaddrs(interfaceListing);-
482 return interfaces;
executed 204 times by 20 tests: return interfaces;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204
483}-
484#endif-
485-
486QList<QNetworkInterfacePrivate *> QNetworkInterfaceManager::scan()-
487{-
488 return interfaceListing();
executed 204 times by 20 tests: return interfaceListing();
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_qnetworkaccessmanager - unknown status
  • tst_qtcpsocket - unknown status
204
489}-
490-
491QT_END_NAMESPACE-
492-
493#endif // QT_NO_NETWORKINTERFACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9