Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | #include "qset.h" | - |
42 | #include "qnetworkinterface.h" | - |
43 | #include "qnetworkinterface_p.h" | - |
44 | #include "qalgorithms.h" | - |
45 | #include "private/qnet_unix_p.h" | - |
46 | | - |
47 | #ifndef QT_NO_NETWORKINTERFACE | - |
48 | | - |
49 | #define IP_MULTICAST // make AIX happy and define IFF_MULTICAST | - |
50 | | - |
51 | #include <sys/types.h> | - |
52 | #include <sys/socket.h> | - |
53 | | - |
54 | #ifdef Q_OS_SOLARIS | - |
55 | # include <sys/sockio.h> | - |
56 | #endif | - |
57 | #include <net/if.h> | - |
58 | | - |
59 | #if defined(QT_LINUXBASE) | - |
60 | # define QT_NO_GETIFADDRS | - |
61 | #endif | - |
62 | | - |
63 | #ifdef Q_OS_ANDROID | - |
64 | | - |
65 | # define QT_NO_IPV6IFNAME | - |
66 | #endif | - |
67 | | - |
68 | #ifdef Q_OS_HAIKU | - |
69 | # include <sys/sockio.h> | - |
70 | # define IFF_RUNNING 0x0001 | - |
71 | #endif | - |
72 | | - |
73 | #ifndef QT_NO_GETIFADDRS | - |
74 | # include <ifaddrs.h> | - |
75 | #endif | - |
76 | | - |
77 | #ifdef QT_LINUXBASE | - |
78 | # include <arpa/inet.h> | - |
79 | # ifndef SIOCGIFBRDADDR | - |
80 | # define SIOCGIFBRDADDR 0x8919 | - |
81 | # endif | - |
82 | #endif // QT_LINUXBASE | - |
83 | | - |
84 | #include <qplatformdefs.h> | - |
85 | | - |
86 | QT_BEGIN_NAMESPACE | - |
87 | | - |
88 | static QHostAddress addressFromSockaddr(sockaddr *sa, int ifindex = 0, const QString &ifname = QString()) | - |
89 | { | - |
90 | QHostAddress address; | - |
91 | if (!sa)TRUE | evaluated 408 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 3468 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 408-3468 |
92 | return address;executed 408 times by 19 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_qtcpsocket - unknown status
| 408 |
93 | | - |
94 | if (sa->sa_family == AF_INET)TRUE | evaluated 1632 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 1632-1836 |
95 | address.setAddress(htonl(((sockaddr_in *)sa)->sin_addr.s_addr));executed 1632 times by 19 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_qtcpsocket - unknown status
| 1632 |
96 | else if (sa->sa_family == AF_INET6) {TRUE | evaluated 1224 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 612 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 612-1224 |
97 | address.setAddress(((sockaddr_in6 *)sa)->sin6_addr.s6_addr); | - |
98 | int scope = ((sockaddr_in6 *)sa)->sin6_scope_id; | - |
99 | if (scope && scope == ifindex) {TRUE | evaluated 408 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 816 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
TRUE | evaluated 408 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | never evaluated |
| 0-816 |
100 | | - |
101 | | - |
102 | address.setScopeId(ifname); | - |
103 | } else if (scope) {executed 408 times by 19 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_qtcpsocket - unknown status
TRUE | never evaluated | FALSE | evaluated 816 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 0-816 |
104 | address.setScopeId(QNetworkInterfaceManager::interfaceNameFromIndex(scope)); | - |
105 | } never executed: end of block | 0 |
106 | }executed 1224 times by 19 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_qtcpsocket - unknown status
| 1224 |
107 | return address;executed 3468 times by 19 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_qtcpsocket - unknown status
| 3468 |
108 | | - |
109 | } | - |
110 | | - |
111 | static QNetworkInterface::InterfaceFlags convertFlags(uint rawFlags) | - |
112 | { | - |
113 | QNetworkInterface::InterfaceFlags flags = 0; | - |
114 | flags |= (rawFlags & IFF_UP) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0);TRUE | evaluated 612 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | never evaluated |
| 0-612 |
115 | flags |= (rawFlags & IFF_RUNNING) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0);TRUE | evaluated 612 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | never evaluated |
| 0-612 |
116 | flags |= (rawFlags & IFF_BROADCAST) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0);TRUE | evaluated 408 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 204 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 204-408 |
117 | flags |= (rawFlags & IFF_LOOPBACK) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0);TRUE | evaluated 204 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 408 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 204-408 |
118 | #ifdef IFF_POINTOPOINT //cygwin doesn't define IFF_POINTOPOINT | - |
119 | flags |= (rawFlags & IFF_POINTOPOINT) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0);TRUE | never evaluated | FALSE | evaluated 612 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 0-612 |
120 | #endif | - |
121 | | - |
122 | #ifdef IFF_MULTICAST | - |
123 | flags |= (rawFlags & IFF_MULTICAST) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0);TRUE | evaluated 408 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 204 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 204-408 |
124 | #endif | - |
125 | return flags;executed 612 times by 19 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_qtcpsocket - unknown status
| 612 |
126 | } | - |
127 | | - |
128 | uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name) | - |
129 | { | - |
130 | #ifndef QT_NO_IPV6IFNAME | - |
131 | return ::if_nametoindex(name.toLatin1());executed 27 times by 3 tests: return ::if_nametoindex(name.toLatin1()); Executed by:- tst_QNetworkInterface
- tst_QTcpServer
- tst_QUdpSocket
| 27 |
132 | #elif defined(SIOCGIFINDEX) | - |
133 | struct ifreq req; | - |
134 | int socket = qt_safe_socket(AF_INET, SOCK_STREAM, 0); | - |
135 | if (socket < 0) | - |
136 | return 0; | - |
137 | | - |
138 | QByteArray name8bit = name.toLatin1(); | - |
139 | memset(&req, 0, sizeof(ifreq)); | - |
140 | memcpy(req.ifr_name, name8bit, qMin<int>(name8bit.length() + 1, sizeof(req.ifr_name) - 1)); | - |
141 | | - |
142 | uint id = 0; | - |
143 | if (qt_safe_ioctl(socket, SIOCGIFINDEX, &req) >= 0) | - |
144 | id = req.ifr_ifindex; | - |
145 | qt_safe_close(socket); | - |
146 | return id; | - |
147 | #else | - |
148 | return 0; | - |
149 | #endif | - |
150 | } | - |
151 | | - |
152 | QString QNetworkInterfaceManager::interfaceNameFromIndex(uint index) | - |
153 | { | - |
154 | #ifndef QT_NO_IPV6IFNAME | - |
155 | char buf[IF_NAMESIZE]; | - |
156 | if (::if_indextoname(index, buf))TRUE | evaluated 33 times by 3 testsEvaluated by:- tst_QNetworkInterface
- tst_QTcpServer
- tst_QUdpSocket
| FALSE | never evaluated |
| 0-33 |
157 | return QString::fromLatin1(buf);executed 33 times by 3 tests: return QString::fromLatin1(buf); Executed by:- tst_QNetworkInterface
- tst_QTcpServer
- tst_QUdpSocket
| 33 |
158 | #elif defined(SIOCGIFNAME) | - |
159 | struct ifreq req; | - |
160 | int socket = qt_safe_socket(AF_INET, SOCK_STREAM, 0); | - |
161 | if (socket >= 0) { | - |
162 | memset(&req, 0, sizeof(ifreq)); | - |
163 | req.ifr_ifindex = index; | - |
164 | | - |
165 | if (qt_safe_ioctl(socket, SIOCGIFNAME, &req) >= 0) { | - |
166 | qt_safe_close(socket); | - |
167 | return QString::fromLatin1(req.ifr_name); | - |
168 | } | - |
169 | qt_safe_close(socket); | - |
170 | } | - |
171 | #endif | - |
172 | return QString::number(uint(index)); never executed: return QString::number(uint(index)); | 0 |
173 | } | - |
174 | | - |
175 | #ifdef QT_NO_GETIFADDRS | - |
176 | | - |
177 | | - |
178 | static QSet<QByteArray> interfaceNames(int socket) | - |
179 | { | - |
180 | QSet<QByteArray> result; | - |
181 | #ifdef QT_NO_IPV6IFNAME | - |
182 | QByteArray storageBuffer; | - |
183 | struct ifconf interfaceList; | - |
184 | static const int STORAGEBUFFER_GROWTH = 256; | - |
185 | | - |
186 | forever { | - |
187 | | - |
188 | storageBuffer.resize(storageBuffer.size() + STORAGEBUFFER_GROWTH); | - |
189 | interfaceList.ifc_buf = storageBuffer.data(); | - |
190 | interfaceList.ifc_len = storageBuffer.size(); | - |
191 | | - |
192 | | - |
193 | if (qt_safe_ioctl(socket, SIOCGIFCONF, &interfaceList) >= 0) { | - |
194 | if (int(interfaceList.ifc_len + sizeof(ifreq) + 64) < storageBuffer.size()) { | - |
195 | | - |
196 | storageBuffer.resize(interfaceList.ifc_len); | - |
197 | break; | - |
198 | } | - |
199 | } else { | - |
200 | | - |
201 | return result; | - |
202 | } | - |
203 | if (storageBuffer.size() > 100000) { | - |
204 | | - |
205 | return result; | - |
206 | } | - |
207 | } | - |
208 | | - |
209 | int interfaceCount = interfaceList.ifc_len / sizeof(ifreq); | - |
210 | for (int i = 0; i < interfaceCount; ++i) { | - |
211 | QByteArray name = QByteArray(interfaceList.ifc_req[i].ifr_name); | - |
212 | if (!name.isEmpty()) | - |
213 | result << name; | - |
214 | } | - |
215 | | - |
216 | return result; | - |
217 | #else | - |
218 | Q_UNUSED(socket); | - |
219 | | - |
220 | | - |
221 | struct if_nameindex *interfaceList = ::if_nameindex(); | - |
222 | for (struct if_nameindex *ptr = interfaceList; ptr && ptr->if_name; ++ptr) | - |
223 | result << ptr->if_name; | - |
224 | | - |
225 | if_freenameindex(interfaceList); | - |
226 | return result; | - |
227 | #endif | - |
228 | } | - |
229 | | - |
230 | static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfacePrivate *> &interfaces, | - |
231 | struct ifreq &req) | - |
232 | { | - |
233 | QNetworkInterfacePrivate *iface = 0; | - |
234 | int ifindex = 0; | - |
235 | | - |
236 | #if !defined(QT_NO_IPV6IFNAME) || defined(SIOCGIFINDEX) | - |
237 | | - |
238 | # ifdef SIOCGIFINDEX | - |
239 | if (qt_safe_ioctl(socket, SIOCGIFINDEX, &req) >= 0) | - |
240 | # if defined(Q_OS_HAIKU) | - |
241 | ifindex = req.ifr_index; | - |
242 | # else | - |
243 | ifindex = req.ifr_ifindex; | - |
244 | # endif | - |
245 | # else | - |
246 | ifindex = if_nametoindex(req.ifr_name); | - |
247 | # endif | - |
248 | | - |
249 | | - |
250 | QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin(); | - |
251 | for ( ; if_it != interfaces.end(); ++if_it) | - |
252 | if ((*if_it)->index == ifindex) { | - |
253 | | - |
254 | iface = *if_it; | - |
255 | break; | - |
256 | } | - |
257 | #else | - |
258 | | - |
259 | QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin(); | - |
260 | for ( ; if_it != interfaces.end(); ++if_it) | - |
261 | if ((*if_it)->name == QLatin1String(req.ifr_name)) { | - |
262 | | - |
263 | iface = *if_it; | - |
264 | break; | - |
265 | } | - |
266 | #endif | - |
267 | | - |
268 | if (!iface) { | - |
269 | | - |
270 | iface = new QNetworkInterfacePrivate; | - |
271 | iface->index = ifindex; | - |
272 | interfaces << iface; | - |
273 | } | - |
274 | | - |
275 | return iface; | - |
276 | } | - |
277 | | - |
278 | static QList<QNetworkInterfacePrivate *> interfaceListing() | - |
279 | { | - |
280 | QList<QNetworkInterfacePrivate *> interfaces; | - |
281 | | - |
282 | int socket; | - |
283 | if ((socket = qt_safe_socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1) | - |
284 | return interfaces; | - |
285 | | - |
286 | QSet<QByteArray> names = interfaceNames(socket); | - |
287 | QSet<QByteArray>::ConstIterator it = names.constBegin(); | - |
288 | for ( ; it != names.constEnd(); ++it) { | - |
289 | ifreq req; | - |
290 | memset(&req, 0, sizeof(ifreq)); | - |
291 | memcpy(req.ifr_name, *it, qMin<int>(it->length() + 1, sizeof(req.ifr_name) - 1)); | - |
292 | | - |
293 | QNetworkInterfacePrivate *iface = findInterface(socket, interfaces, req); | - |
294 | | - |
295 | #ifdef SIOCGIFNAME | - |
296 | | - |
297 | QByteArray oldName = req.ifr_name; | - |
298 | if (qt_safe_ioctl(socket, SIOCGIFNAME, &req) >= 0) { | - |
299 | iface->name = QString::fromLatin1(req.ifr_name); | - |
300 | | - |
301 | | - |
302 | memcpy(req.ifr_name, oldName, qMin<int>(oldName.length() + 1, sizeof(req.ifr_name) - 1)); | - |
303 | } else | - |
304 | #endif | - |
305 | { | - |
306 | | - |
307 | iface->name = QString::fromLatin1(req.ifr_name); | - |
308 | } | - |
309 | | - |
310 | | - |
311 | if (qt_safe_ioctl(socket, SIOCGIFFLAGS, &req) >= 0) { | - |
312 | iface->flags = convertFlags(req.ifr_flags); | - |
313 | } | - |
314 | | - |
315 | #ifdef SIOCGIFHWADDR | - |
316 | | - |
317 | if (qt_safe_ioctl(socket, SIOCGIFHWADDR, &req) >= 0) { | - |
318 | uchar *addr = (uchar *)req.ifr_addr.sa_data; | - |
319 | iface->hardwareAddress = iface->makeHwAddress(6, addr); | - |
320 | } | - |
321 | #endif | - |
322 | | - |
323 | | - |
324 | QNetworkAddressEntry entry; | - |
325 | if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) { | - |
326 | sockaddr *sa = &req.ifr_addr; | - |
327 | entry.setIp(addressFromSockaddr(sa)); | - |
328 | | - |
329 | | - |
330 | if (iface->flags & QNetworkInterface::CanBroadcast) { | - |
331 | if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) { | - |
332 | sockaddr *sa = &req.ifr_addr; | - |
333 | if (sa->sa_family == AF_INET) | - |
334 | entry.setBroadcast(addressFromSockaddr(sa)); | - |
335 | } | - |
336 | } | - |
337 | | - |
338 | | - |
339 | if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) { | - |
340 | sockaddr *sa = &req.ifr_addr; | - |
341 | entry.setNetmask(addressFromSockaddr(sa)); | - |
342 | } | - |
343 | | - |
344 | iface->addressEntries << entry; | - |
345 | } | - |
346 | } | - |
347 | | - |
348 | ::close(socket); | - |
349 | return interfaces; | - |
350 | } | - |
351 | | - |
352 | #else | - |
353 | | - |
354 | | - |
355 | | - |
356 | # ifdef Q_OS_LINUX | - |
357 | QT_BEGIN_INCLUDE_NAMESPACE | - |
358 | # include <features.h> | - |
359 | QT_END_INCLUDE_NAMESPACE | - |
360 | # endif | - |
361 | | - |
362 | # if defined(Q_OS_LINUX) && __GLIBC__ - 0 >= 2 && __GLIBC_MINOR__ - 0 >= 1 && !defined(QT_LINUXBASE) | - |
363 | # include <netpacket/packet.h> | - |
364 | | - |
365 | static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList) | - |
366 | { | - |
367 | QList<QNetworkInterfacePrivate *> interfaces; | - |
368 | QSet<QString> seenInterfaces; | - |
369 | QVarLengthArray<int, 16> seenIndexes; | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | | - |
375 | | - |
376 | | - |
377 | | - |
378 | for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {TRUE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 204 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 204-1836 |
379 | if (ptr->ifa_addr && ptr->ifa_addr->sa_family == AF_PACKET) {TRUE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | never evaluated |
TRUE | evaluated 612 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 1224 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 0-1836 |
380 | sockaddr_ll *sll = (sockaddr_ll *)ptr->ifa_addr; | - |
381 | QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate; | - |
382 | interfaces << iface; | - |
383 | iface->index = sll->sll_ifindex; | - |
384 | iface->name = QString::fromLatin1(ptr->ifa_name); | - |
385 | iface->flags = convertFlags(ptr->ifa_flags); | - |
386 | iface->hardwareAddress = iface->makeHwAddress(sll->sll_halen, (uchar*)sll->sll_addr); | - |
387 | | - |
388 | Q_ASSERT(!seenIndexes.contains(iface->index)); | - |
389 | seenIndexes.append(iface->index); | - |
390 | seenInterfaces.insert(iface->name); | - |
391 | }executed 612 times by 19 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_qtcpsocket - unknown status
| 612 |
392 | }executed 1836 times by 19 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_qtcpsocket - unknown status
| 1836 |
393 | | - |
394 | | - |
395 | | - |
396 | | - |
397 | for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {TRUE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 204 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 204-1836 |
398 | if (!ptr->ifa_addr || ptr->ifa_addr->sa_family != AF_PACKET) {TRUE | never evaluated | FALSE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
TRUE | evaluated 1224 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 612 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 0-1836 |
399 | QString name = QString::fromLatin1(ptr->ifa_name); | - |
400 | if (seenInterfaces.contains(name))TRUE | evaluated 1224 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | never evaluated |
| 0-1224 |
401 | continue;executed 1224 times by 19 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_qtcpsocket - unknown status
| 1224 |
402 | | - |
403 | int ifindex = if_nametoindex(ptr->ifa_name); | - |
404 | if (seenIndexes.contains(ifindex))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
405 | continue; never executed: continue; | 0 |
406 | | - |
407 | seenInterfaces.insert(name); | - |
408 | seenIndexes.append(ifindex); | - |
409 | | - |
410 | QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate; | - |
411 | interfaces << iface; | - |
412 | iface->name = name; | - |
413 | iface->flags = convertFlags(ptr->ifa_flags); | - |
414 | iface->index = ifindex; | - |
415 | } never executed: end of block | 0 |
416 | }executed 612 times by 19 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_qtcpsocket - unknown status
| 612 |
417 | | - |
418 | return interfaces;executed 204 times by 19 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_qtcpsocket - unknown status
| 204 |
419 | } | - |
420 | | - |
421 | # elif defined(Q_OS_BSD4) | - |
422 | QT_BEGIN_INCLUDE_NAMESPACE | - |
423 | # include <net/if_dl.h> | - |
424 | QT_END_INCLUDE_NAMESPACE | - |
425 | | - |
426 | static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList) | - |
427 | { | - |
428 | QList<QNetworkInterfacePrivate *> interfaces; | - |
429 | | - |
430 | | - |
431 | | - |
432 | for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) | - |
433 | if (ptr->ifa_addr && ptr->ifa_addr->sa_family == AF_LINK) { | - |
434 | QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate; | - |
435 | interfaces << iface; | - |
436 | | - |
437 | sockaddr_dl *sdl = (sockaddr_dl *)ptr->ifa_addr; | - |
438 | iface->index = sdl->sdl_index; | - |
439 | iface->name = QString::fromLatin1(ptr->ifa_name); | - |
440 | iface->flags = convertFlags(ptr->ifa_flags); | - |
441 | iface->hardwareAddress = iface->makeHwAddress(sdl->sdl_alen, (uchar*)LLADDR(sdl)); | - |
442 | } | - |
443 | | - |
444 | return interfaces; | - |
445 | } | - |
446 | | - |
447 | # else // Generic version | - |
448 | | - |
449 | static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList) | - |
450 | { | - |
451 | QList<QNetworkInterfacePrivate *> interfaces; | - |
452 | | - |
453 | | - |
454 | for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) { | - |
455 | | - |
456 | int ifindex = if_nametoindex(ptr->ifa_name); | - |
457 | | - |
458 | QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin(); | - |
459 | for ( ; if_it != interfaces.end(); ++if_it) | - |
460 | if ((*if_it)->index == ifindex) | - |
461 | | - |
462 | break; | - |
463 | | - |
464 | if (if_it == interfaces.end()) { | - |
465 | | - |
466 | QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate; | - |
467 | interfaces << iface; | - |
468 | | - |
469 | iface->index = ifindex; | - |
470 | iface->name = QString::fromLatin1(ptr->ifa_name); | - |
471 | iface->flags = convertFlags(ptr->ifa_flags); | - |
472 | } | - |
473 | } | - |
474 | | - |
475 | return interfaces; | - |
476 | } | - |
477 | | - |
478 | # endif | - |
479 | | - |
480 | | - |
481 | static QList<QNetworkInterfacePrivate *> interfaceListing() | - |
482 | { | - |
483 | QList<QNetworkInterfacePrivate *> interfaces; | - |
484 | | - |
485 | ifaddrs *interfaceListing; | - |
486 | if (getifaddrs(&interfaceListing) == -1) {TRUE | never evaluated | FALSE | evaluated 204 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 0-204 |
487 | | - |
488 | return interfaces; never executed: return interfaces; | 0 |
489 | } | - |
490 | | - |
491 | interfaces = createInterfaces(interfaceListing); | - |
492 | for (ifaddrs *ptr = interfaceListing; ptr; ptr = ptr->ifa_next) {TRUE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 204 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 204-1836 |
493 | | - |
494 | QString name = QString::fromLatin1(ptr->ifa_name); | - |
495 | QNetworkInterfacePrivate *iface = 0; | - |
496 | QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin(); | - |
497 | for ( ; if_it != interfaces.end(); ++if_it)TRUE | evaluated 3672 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | never evaluated |
| 0-3672 |
498 | if ((*if_it)->name == name) {TRUE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 1836 |
499 | | - |
500 | iface = *if_it; | - |
501 | break;executed 1836 times by 19 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_qtcpsocket - unknown status
| 1836 |
502 | } | - |
503 | | - |
504 | if (!iface) {TRUE | never evaluated | FALSE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 0-1836 |
505 | | - |
506 | int ifindex = if_nametoindex(ptr->ifa_name); | - |
507 | for (if_it = interfaces.begin(); if_it != interfaces.end(); ++if_it)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
508 | if ((*if_it)->index == ifindex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
509 | | - |
510 | iface = *if_it; | - |
511 | break; never executed: break; | 0 |
512 | } | - |
513 | } never executed: end of block | 0 |
514 | | - |
515 | if (!iface) {TRUE | never evaluated | FALSE | evaluated 1836 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 0-1836 |
516 | | - |
517 | continue; never executed: continue; | 0 |
518 | } | - |
519 | | - |
520 | QNetworkAddressEntry entry; | - |
521 | entry.setIp(addressFromSockaddr(ptr->ifa_addr, iface->index, iface->name)); | - |
522 | if (entry.ip().isNull())TRUE | evaluated 612 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 1224 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 612-1224 |
523 | | - |
524 | continue;executed 612 times by 19 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_qtcpsocket - unknown status
| 612 |
525 | | - |
526 | entry.setNetmask(addressFromSockaddr(ptr->ifa_netmask, iface->index, iface->name)); | - |
527 | if (iface->flags & QNetworkInterface::CanBroadcast)TRUE | evaluated 816 times by 19 testsEvaluated 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_qtcpsocket - unknown status
| FALSE | evaluated 408 times by 19 testsEvaluated 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_qtcpsocket - unknown status
|
| 408-816 |
528 | entry.setBroadcast(addressFromSockaddr(ptr->ifa_broadaddr, iface->index, iface->name));executed 816 times by 19 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_qtcpsocket - unknown status
| 816 |
529 | | - |
530 | iface->addressEntries << entry; | - |
531 | }executed 1224 times by 19 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_qtcpsocket - unknown status
| 1224 |
532 | | - |
533 | freeifaddrs(interfaceListing); | - |
534 | return interfaces;executed 204 times by 19 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_qtcpsocket - unknown status
| 204 |
535 | } | - |
536 | #endif | - |
537 | | - |
538 | QList<QNetworkInterfacePrivate *> QNetworkInterfaceManager::scan() | - |
539 | { | - |
540 | return interfaceListing();executed 204 times by 19 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_qtcpsocket - unknown status
| 204 |
541 | } | - |
542 | | - |
543 | QT_END_NAMESPACE | - |
544 | | - |
545 | #endif // QT_NO_NETWORKINTERFACE | - |
| | |