Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qhostaddress.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qhostaddress.h"
6#include "qhostaddress_p.h"
7#include "private/qipaddress_p.h"
8#include "qdebug.h"
9#if defined(Q_OS_WIN)
10# include <winsock2.h>
11# include <ws2tcpip.h>
12#else
13# include <netinet/in.h>
14#endif
15#include "qplatformdefs.h"
16#include "qstringlist.h"
17#include "qendian.h"
18#ifndef QT_NO_DATASTREAM
19#include <qdatastream.h>
20#endif
21#ifdef __SSE2__
22# include <private/qsimd_p.h>
23#endif
24
25#ifdef QT_LINUXBASE
26# include <arpa/inet.h>
27#endif
28
30
32 : a(0), protocol(QHostAddress::UnknownNetworkLayerProtocol)
33{
34 memset(&a6, 0, sizeof(a6));
35}
36
38{
39 a = a_;
41
42 //create mapped address, except for a_ == 0 (any)
43 a6_64.c[0] = 0;
44 if (a) {
45 a6_32.c[2] = qToBigEndian(0xffff);
46 a6_32.c[3] = qToBigEndian(a);
47 } else {
48 a6_64.c[1] = 0;
49 }
50}
51
54static bool convertToIpv4(quint32& a, const Q_IPV6ADDR &a6, const QHostAddress::ConversionMode mode)
55{
57 return false;
58
59 const uchar *ptr = a6.c;
60 if (qFromUnaligned<quint64>(ptr) != 0)
61 return false;
62
63 const quint32 mid = qFromBigEndian<quint32>(ptr + 8);
64 if ((mid == 0xffff) && (mode & QHostAddress::ConvertV4MappedToIPv4)) {
65 a = qFromBigEndian<quint32>(ptr + 12);
66 return true;
67 }
68 if (mid != 0)
69 return false;
70
71 const quint32 low = qFromBigEndian<quint32>(ptr + 12);
72 if ((low == 0) && (mode & QHostAddress::ConvertUnspecifiedAddress)) {
73 a = 0;
74 return true;
75 }
76 if ((low == 1) && (mode & QHostAddress::ConvertLocalHost)) {
77 a = INADDR_LOOPBACK;
78 return true;
79 }
80 if ((low != 1) && (mode & QHostAddress::ConvertV4CompatToIPv4)) {
81 a = low;
82 return true;
83 }
84 return false;
85}
86
95
97{
98 setAddress(a_.c);
99}
100
102{
103 QStringView tmp(address);
104 qsizetype scopeIdPos = tmp.lastIndexOf(u'%');
105 if (scopeIdPos != -1) {
106 *scopeId = tmp.mid(scopeIdPos + 1).toString();
107 tmp.chop(tmp.size() - scopeIdPos);
108 } else {
109 scopeId->clear();
110 }
111 return QIPAddressUtils::parseIp6(addr, tmp.begin(), tmp.end()) == nullptr;
112}
113
115{
117 QString a = ipString.simplified();
118 if (a.isEmpty())
119 return false;
120
121 // All IPv6 addresses contain a ':', and may contain a '.'.
122 if (a.contains(u':')) {
123 quint8 maybeIp6[16];
124 if (parseIp6(a, maybeIp6, &scopeId)) {
125 setAddress(maybeIp6);
126 return true;
127 }
128 }
129
130 quint32 maybeIp4 = 0;
131 if (QIPAddressUtils::parseIp4(maybeIp4, a.constBegin(), a.constEnd())) {
132 setAddress(maybeIp4);
133 return true;
134 }
135
136 return false;
137}
138
140{
141 a = 0;
143 memset(&a6, 0, sizeof(a6));
144}
145
147{
148 if (a) {
149 // This is an IPv4 address or an IPv6 v4-mapped address includes all
150 // IPv6 v4-compat addresses, except for ::ffff:0.0.0.0 (because `a' is
151 // zero). See setAddress(quint8*) below, which calls convertToIpv4(),
152 // for details.
153 // Source: RFC 5735
154 if ((a & 0xff000000U) == 0x7f000000U) // 127.0.0.0/8
155 return LoopbackAddress;
156 if ((a & 0xf0000000U) == 0xe0000000U) // 224.0.0.0/4
157 return MulticastAddress;
158 if ((a & 0xffff0000U) == 0xa9fe0000U) // 169.254.0.0/16
159 return LinkLocalAddress;
160 if ((a & 0xff000000U) == 0) // 0.0.0.0/8 except 0.0.0.0 (handled below)
161 return LocalNetAddress;
162 if ((a & 0xf0000000U) == 0xf0000000U) { // 240.0.0.0/4
163 if (a == 0xffffffffU) // 255.255.255.255
164 return BroadcastAddress;
165 return UnknownAddress;
166 }
167 if (((a & 0xff000000U) == 0x0a000000U) // 10.0.0.0/8
168 || ((a & 0xfff00000U) == 0xac100000U) // 172.16.0.0/12
169 || ((a & 0xffff0000U) == 0xc0a80000U)) // 192.168.0.0/16
171
172 // Not testing for TestNetworkAddress
173 // since we don't need them yet.
174 return GlobalAddress;
175 }
176
177 // As `a' is zero, this address is either ::ffff:0.0.0.0 or a non-v4-mapped IPv6 address.
178 // Source: https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml
179 if (a6_64.c[0]) {
180 quint32 high16 = qFromBigEndian(a6_32.c[0]) >> 16;
181 switch (high16 >> 8) {
182 case 0xff: // ff00::/8
183 return MulticastAddress;
184 case 0xfe:
185 switch (high16 & 0xffc0) {
186 case 0xfec0: // fec0::/10
187 return SiteLocalAddress;
188
189 case 0xfe80: // fe80::/10
190 return LinkLocalAddress;
191
192 default: // fe00::/9
193 return UnknownAddress;
194 }
195 case 0xfd: // fc00::/7
196 case 0xfc:
197 return UniqueLocalAddress;
198 default:
199 return GlobalAddress;
200 }
201 }
202
203 quint64 low64 = qFromBigEndian(a6_64.c[1]);
204 if (low64 == 1) // ::1
205 return LoopbackAddress;
206 if (low64 >> 32 == 0xffff) { // ::ffff:0.0.0.0/96
207 Q_ASSERT(quint32(low64) == 0);
208 return LocalNetAddress;
209 }
210 if (low64) // not ::
211 return GlobalAddress;
212
214 return UnknownAddress;
215
216 // only :: and 0.0.0.0 remain now
217 return LocalNetAddress;
218}
219
221{
222 static const quint8 zeroes[16] = { 0 };
223 union {
224 quint32 v4;
225 quint8 v6[16];
226 } ip;
227
228 int netmask = 0;
229 quint8 *ptr = ip.v6;
230 quint8 *end;
231 length = 255;
232
233 if (address.protocol() == QHostAddress::IPv4Protocol) {
234 ip.v4 = qToBigEndian(address.toIPv4Address());
235 end = ptr + 4;
236 } else if (address.protocol() == QHostAddress::IPv6Protocol) {
237 memcpy(ip.v6, address.toIPv6Address().c, 16);
238 end = ptr + 16;
239 } else {
240 return false;
241 }
242
243 while (ptr < end) {
244 switch (*ptr) {
245 case 255:
246 netmask += 8;
247 ++ptr;
248 continue;
249
250 default:
251 return false; // invalid IP-style netmask
252
253 case 254:
254 ++netmask;
256 case 252:
257 ++netmask;
259 case 248:
260 ++netmask;
262 case 240:
263 ++netmask;
265 case 224:
266 ++netmask;
268 case 192:
269 ++netmask;
271 case 128:
272 ++netmask;
274 case 0:
275 break;
276 }
277 break;
278 }
279
280 // confirm that the rest is only zeroes
281 if (ptr < end && memcmp(ptr + 1, zeroes, end - ptr - 1) != 0)
282 return false;
283
284 length = netmask;
285 return true;
286}
287
288static void clearBits(quint8 *where, int start, int end)
289{
290 Q_ASSERT(end == 32 || end == 128);
291 if (start == end)
292 return;
293
294 // for the byte where 'start' is, clear the lower bits only
295 quint8 bytemask = 256 - (1 << (8 - (start & 7)));
296 where[start / 8] &= bytemask;
297
298 // for the tail part, clear everything
299 memset(where + (start + 7) / 8, 0, end / 8 - (start + 7) / 8);
300}
301
303{
304 if (length == 255 || protocol == QHostAddress::AnyIPProtocol ||
306 return QHostAddress();
307 } else if (protocol == QHostAddress::IPv4Protocol) {
308 quint32 a;
309 if (length == 0)
310 a = 0;
311 else if (length == 32)
312 a = quint32(0xffffffff);
313 else
314 a = quint32(0xffffffff) >> (32 - length) << (32 - length);
315 return QHostAddress(a);
316 } else {
317 Q_IPV6ADDR a6;
318 memset(a6.c, 0xFF, sizeof(a6));
319 clearBits(a6.c, length, 128);
320 return QHostAddress(a6);
321 }
322}
323
383
389{
390 setAddress(ip4Addr);
391}
392
402{
403 setAddress(ip6Addr);
404}
405
411{
412 setAddress(ip6Addr);
413}
414
426
435QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
437{
438 if (sockaddr->sa_family == AF_INET)
439 setAddress(htonl(((const sockaddr_in *)sockaddr)->sin_addr.s_addr));
440 else if (sockaddr->sa_family == AF_INET6)
441 setAddress(((const sockaddr_in6 *)sockaddr)->sin6_addr.s6_addr);
442}
443
451
460
467
473{
474 d = address.d;
475 return *this;
476}
477
490
521{
522 d.detach();
523 d->clear();
524}
525
530{
531 d.detach();
532 d->setAddress(ip4Addr);
533}
534
545{
546 d.detach();
547 d->setAddress(ip6Addr);
548}
549
556{
557 d.detach();
558 d->setAddress(ip6Addr);
559}
560
570{
571 d.detach();
572 return d->parse(address);
573}
574
583void QHostAddress::setAddress(const struct sockaddr *sockaddr)
584{
585 d.detach();
586 clear();
587 if (sockaddr->sa_family == AF_INET)
588 setAddress(htonl(((const sockaddr_in *)sockaddr)->sin_addr.s_addr));
589 else if (sockaddr->sa_family == AF_INET6)
590 setAddress(((const sockaddr_in6 *)sockaddr)->sin6_addr.s6_addr);
591}
592
600{
601 clear();
602
603 Q_IPV6ADDR ip6;
604 memset(&ip6, 0, sizeof ip6);
605 quint32 ip4 = INADDR_ANY;
606
607 switch (address) {
608 case Null:
609 return;
610
611 case Broadcast:
612 ip4 = INADDR_BROADCAST;
613 break;
614 case LocalHost:
615 ip4 = INADDR_LOOPBACK;
616 break;
617 case AnyIPv4:
618 break;
619
620 case LocalHostIPv6:
621 ip6[15] = 1;
623 case AnyIPv6:
624 d->setAddress(ip6);
625 return;
626
627 case Any:
629 return;
630 }
631
632 // common IPv4 part
633 d->setAddress(ip4);
634}
635
661
669
685{
686 return d->a6;
687}
688
700{
701 QString s;
706 } else if (d->protocol == QHostAddress::IPv6Protocol) {
708 if (!d->scopeId.isEmpty())
709 s += u'%' + d->scopeId;
710 }
711 return s;
712}
713
754
768{
769 d.detach();
771 d->scopeId = id;
772}
773
781{
782 return d == other.d || isEqual(other, StrictConversion);
783}
784
798{
799 if (d == other.d)
800 return true;
801
803 switch (other.d->protocol) {
805 return d->a == other.d->a;
807 quint32 a4;
808 return convertToIpv4(a4, other.d->a6, mode) && (a4 == d->a);
812 return false;
813 }
814 }
815
817 switch (other.d->protocol) {
819 quint32 a4;
820 return convertToIpv4(a4, d->a6, mode) && (a4 == other.d->a);
822 return memcmp(&d->a6, &other.d->a6, sizeof(Q_IPV6ADDR)) == 0;
825 && (d->a6_64.c[0] == 0) && (d->a6_64.c[1] == 0);
827 return false;
828 }
829 }
830
833 switch (other.d->protocol) {
835 return other.d->a == 0;
837 return (other.d->a6_64.c[0] == 0) && (other.d->a6_64.c[1] == 0);
838 default:
839 break;
840 }
841 }
842
843 return d->protocol == other.d->protocol;
844}
845
851{
852 quint32 ip4 = INADDR_ANY;
853 switch (other) {
854 case Null:
856
857 case Broadcast:
858 ip4 = INADDR_BROADCAST;
859 break;
860
861 case LocalHost:
862 ip4 = INADDR_LOOPBACK;
863 break;
864
865 case Any:
867
868 case AnyIPv4:
869 break;
870
871 case LocalHostIPv6:
872 case AnyIPv6:
874 quint64 second = quint8(other == LocalHostIPv6); // 1 for localhost, 0 for any
875 return d->a6_64.c[0] == 0 && d->a6_64.c[1] == qToBigEndian(second);
876 }
877 return false;
878 }
879
880 // common IPv4 part
881 return d->protocol == QHostAddress::IPv4Protocol && d->a == ip4;
882}
883
895
915bool QHostAddress::isInSubnet(const QHostAddress &subnet, int netmask) const
916{
917 if (subnet.protocol() != d->protocol || netmask < 0)
918 return false;
919
920 union {
921 quint32 ip;
922 quint8 data[4];
923 } ip4, net4;
924 const quint8 *ip;
925 const quint8 *net;
927 if (netmask > 32)
928 netmask = 32;
929 ip4.ip = qToBigEndian(d->a);
930 net4.ip = qToBigEndian(subnet.d->a);
931 ip = ip4.data;
932 net = net4.data;
933 } else if (d->protocol == QHostAddress::IPv6Protocol) {
934 if (netmask > 128)
935 netmask = 128;
936 ip = d->a6.c;
937 net = subnet.d->a6.c;
938 } else {
939 return false;
940 }
941
942 if (netmask >= 8 && memcmp(ip, net, netmask / 8) != 0)
943 return false;
944 if ((netmask & 7) == 0)
945 return true;
946
947 // compare the last octet now
948 quint8 bytemask = 256 - (1 << (8 - (netmask & 7)));
949 quint8 ipbyte = ip[netmask / 8];
950 quint8 netbyte = net[netmask / 8];
951 return (ipbyte & bytemask) == (netbyte & bytemask);
952}
953
963bool QHostAddress::isInSubnet(const QPair<QHostAddress, int> &subnet) const
964{
965 return isInSubnet(subnet.first, subnet.second);
966}
967
968
993QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
994{
995 // We support subnets in the form:
996 // ddd.ddd.ddd.ddd/nn
997 // ddd.ddd.ddd/nn
998 // ddd.ddd/nn
999 // ddd/nn
1000 // ddd.ddd.ddd.
1001 // ddd.ddd.ddd
1002 // ddd.ddd.
1003 // ddd.ddd
1004 // ddd.
1005 // ddd
1006 // <ipv6-address>/nn
1007 //
1008 // where nn can be an IPv4-style netmask for the IPv4 forms
1009
1010 const QPair<QHostAddress, int> invalid = qMakePair(QHostAddress(), -1);
1011 if (subnet.isEmpty())
1012 return invalid;
1013
1014 qsizetype slash = subnet.indexOf(u'/');
1015 QStringView netStr(subnet);
1016 if (slash != -1)
1017 netStr.truncate(slash);
1018
1019 int netmask = -1;
1020 bool isIpv6 = netStr.contains(u':');
1021
1022 if (slash != -1) {
1023 // is the netmask given in IP-form or in bit-count form?
1024 if (!isIpv6 && subnet.indexOf(u'.', slash + 1) != -1) {
1025 // IP-style, convert it to bit-count form
1027 QNetmask parser;
1028 if (!mask.setAddress(subnet.mid(slash + 1)))
1029 return invalid;
1030 if (!parser.setAddress(mask))
1031 return invalid;
1032 netmask = parser.prefixLength();
1033 } else {
1034 bool ok;
1035 netmask = QStringView{subnet}.mid(slash + 1).toUInt(&ok);
1036 if (!ok)
1037 return invalid; // failed to parse the subnet
1038 }
1039 }
1040
1041 if (isIpv6) {
1042 // looks like it's an IPv6 address
1043 if (netmask > 128)
1044 return invalid; // invalid netmask
1045 if (netmask < 0)
1046 netmask = 128;
1047
1048 QHostAddress net;
1049 if (!net.setAddress(netStr.toString()))
1050 return invalid; // failed to parse the IP
1051
1052 clearBits(net.d->a6.c, netmask, 128);
1053 return qMakePair(net, netmask);
1054 }
1055
1056 if (netmask > 32)
1057 return invalid; // invalid netmask
1058
1059 // parse the address manually
1060 auto parts = netStr.split(u'.');
1061 if (parts.isEmpty() || parts.size() > 4)
1062 return invalid; // invalid IPv4 address
1063
1064 if (parts.constLast().isEmpty())
1065 parts.removeLast();
1066
1067 quint32 addr = 0;
1068 for (int i = 0; i < parts.size(); ++i) {
1069 bool ok;
1070 uint byteValue = parts.at(i).toUInt(&ok);
1071 if (!ok || byteValue > 255)
1072 return invalid; // invalid IPv4 address
1073
1074 addr <<= 8;
1075 addr += byteValue;
1076 }
1077 addr <<= 8 * (4 - parts.size());
1078 if (netmask == -1) {
1079 netmask = 8 * parts.size();
1080 } else if (netmask == 0) {
1081 // special case here
1082 // x86's instructions "shr" and "shl" do not operate when
1083 // their argument is 32, so the code below doesn't work as expected
1084 addr = 0;
1085 } else if (netmask != 32) {
1086 // clear remaining bits
1087 quint32 mask = quint32(0xffffffff) >> (32 - netmask) << (32 - netmask);
1088 addr &= mask;
1089 }
1090
1091 return qMakePair(QHostAddress(addr), netmask);
1092}
1093
1101{
1102 return d->classify() == LoopbackAddress;
1103}
1104
1123{
1124 return d->classify() & GlobalAddress; // GlobalAddress is a bit
1125}
1126
1141{
1142 return d->classify() == LinkLocalAddress;
1143}
1144
1164{
1165 return d->classify() == SiteLocalAddress;
1166}
1167
1185{
1186 return d->classify() == UniqueLocalAddress;
1187}
1188
1198{
1199 return d->classify() == MulticastAddress;
1200}
1201
1215{
1216 return d->classify() == BroadcastAddress;
1217}
1218
1228{
1229 const AddressClassification classification = d->classify();
1230 return (classification == PrivateNetworkAddress) || (classification == UniqueLocalAddress);
1231}
1232
1233#ifndef QT_NO_DEBUG_STREAM
1235{
1236 QDebugStateSaver saver(d);
1237 d.resetFormat().nospace();
1239 d << "QHostAddress(QHostAddress::Any)";
1240 else
1241 d << "QHostAddress(" << address.toString() << ')';
1242 return d;
1243}
1244#endif
1245
1251size_t qHash(const QHostAddress &key, size_t seed) noexcept
1252{
1253 return qHashBits(key.d->a6.c, 16, seed);
1254}
1255
1275#ifndef QT_NO_DATASTREAM
1276
1285{
1286 qint8 prot;
1287 prot = qint8(address.protocol());
1288 out << prot;
1289 switch (address.protocol()) {
1292 break;
1294 out << address.toIPv4Address();
1295 break;
1297 {
1298 Q_IPV6ADDR ipv6 = address.toIPv6Address();
1299 for (int i = 0; i < 16; ++i)
1300 out << ipv6[i];
1301 out << address.scopeId();
1302 }
1303 break;
1304 }
1305 return out;
1306}
1307
1316{
1317 qint8 prot;
1318 in >> prot;
1319 switch (QHostAddress::NetworkLayerProtocol(prot)) {
1321 address.clear();
1322 break;
1324 {
1325 quint32 ipv4;
1326 in >> ipv4;
1327 address.setAddress(ipv4);
1328 }
1329 break;
1331 {
1332 Q_IPV6ADDR ipv6;
1333 for (int i = 0; i < 16; ++i)
1334 in >> ipv6[i];
1335 address.setAddress(ipv6);
1336
1337 QString scope;
1338 in >> scope;
1339 address.setScopeId(scope);
1340 }
1341 break;
1344 break;
1345 default:
1346 address.clear();
1347 in.setStatus(QDataStream::ReadCorruptData);
1348 }
1349 return in;
1350}
1351
1352#endif //QT_NO_DATASTREAM
1353
1355
1356#include "moc_qhostaddress.cpp"
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
\inmodule QtCore
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
void setAddress(quint32 a_=0)
bool parse(const QString &ipString)
struct QHostAddressPrivate::@401::@404 a6_32
AddressClassification classify() const
struct QHostAddressPrivate::@401::@403 a6_64
The QHostAddress class provides an IP address.
bool isLinkLocal() const
bool isGlobal() const
QString scopeId() const
QExplicitlySharedDataPointer< QHostAddressPrivate > d
SpecialAddress
\value Null The null address object.
@ ConvertUnspecifiedAddress
quint32 toIPv4Address(bool *ok=nullptr) const
Returns the IPv4 address as a number.
bool isLoopback() const
bool isUniqueLocalUnicast() const
QHostAddress & operator=(QHostAddress &&other) noexcept
QDataStream & operator<<(QDataStream &out, const QHostAddress &address)
Writes host address address to the stream out and returns a reference to the stream.
bool isNull() const
Returns true if this host address is not valid for any host or interface.
QDataStream & operator>>(QDataStream &in, QHostAddress &address)
Reads a host address into address from the stream in and returns a reference to the stream.
void clear()
Sets the host address to null and sets the protocol to QAbstractSocket::UnknownNetworkLayerProtocol.
bool isInSubnet(const QHostAddress &subnet, int netmask) const
friend bool operator==(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
Returns true if special address lhs is the same as host address rhs; otherwise returns false.
bool isBroadcast() const
QHostAddress()
Constructs a null host address object, i.e.
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
~QHostAddress()
Destroys the host address object.
static QPair< QHostAddress, int > parseSubnet(const QString &subnet)
Q_IPV6ADDR toIPv6Address() const
Returns the IPv6 address as a Q_IPV6ADDR structure.
bool isSiteLocal() const
@ UnknownNetworkLayerProtocol
bool isEqual(const QHostAddress &address, ConversionMode mode=TolerantConversion) const
void setScopeId(const QString &id)
bool isPrivateUse() const
QString toString() const
Returns the address as a string.
NetworkLayerProtocol protocol() const
Returns the network layer protocol of the host address.
bool isMulticast() const
bool setAddress(const QHostAddress &address)
int prefixLength() const
QHostAddress address(QAbstractSocket::NetworkLayerProtocol protocol) const
\inmodule QtCore
Definition qstringview.h:78
constexpr void chop(qsizetype n) noexcept
Truncates this string view by length characters.
constexpr qsizetype size() const noexcept
Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for...
const_iterator begin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the st...
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
const_iterator end() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary character after...
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
void clear()
Clears the contents of the string and makes it null.
Definition qstring.h:1252
QString simplified() const &
Definition qstring.h:451
quint8 IPv6Address[16]
void toString(QString &appendTo, IPv4Address address)
bool parseIp4(IPv4Address &address, const QChar *begin, const QChar *end)
const QChar * parseIp6(IPv6Address &address, const QChar *begin, const QChar *end)
Combined button and popup list for selecting options.
#define Q_FALLTHROUGH()
constexpr T qToBigEndian(T source)
Definition qendian.h:172
constexpr T qFromBigEndian(T source)
Definition qendian.h:174
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
size_t qHashBits(const void *p, size_t size, size_t seed) noexcept
Definition qhash.cpp:1089
static bool convertToIpv4(quint32 &a, const Q_IPV6ADDR &a6, const QHostAddress::ConversionMode mode)
QDebug operator<<(QDebug d, const QHostAddress &address)
static bool parseIp6(const QString &address, QIPAddressUtils::IPv6Address &addr, QString *scopeId)
static void clearBits(quint8 *where, int start, int end)
QIPv6Address Q_IPV6ADDR
AddressClassification
@ MulticastAddress
@ LocalNetAddress
@ GlobalAddress
@ UniqueLocalAddress
@ SiteLocalAddress
@ PrivateNetworkAddress
@ UnknownAddress
@ BroadcastAddress
@ LoopbackAddress
@ LinkLocalAddress
ConversionMode
Definition qjsoncbor.cpp:25
static ControlElement< T > * ptr(QWidget *widget)
#define AF_INET6
GLenum mode
GLuint64 key
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLuint end
GLenum GLuint GLenum GLsizei length
GLenum GLuint id
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLdouble s
[6]
Definition qopenglext.h:235
GLenum const void * addr
GLuint in
GLuint GLuint64EXT address
QT_BEGIN_NAMESPACE constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
Definition qpair.h:19
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
unsigned int quint32
Definition qtypes.h:50
unsigned char uchar
Definition qtypes.h:32
unsigned long long quint64
Definition qtypes.h:61
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition qtypes.h:45
unsigned char quint8
Definition qtypes.h:46
static const QChar * parseIp6(QString &host, const QChar *begin, const QChar *end, QUrl::ParsingMode mode)
Definition qurl.cpp:1227
QTextStream out(stdout)
[7]
QSharedPointer< T > other(t)
[5]