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_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QHOSTADDRESSPRIVATE_H
5#define QHOSTADDRESSPRIVATE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the QHostAddress and QNetworkInterface classes. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19#include "qhostaddress.h"
20#include "qabstractsocket.h"
21
23
26 LocalNetAddress, // RFC 1122
27 LinkLocalAddress, // RFC 4291 (v6), RFC 3927 (v4)
28 MulticastAddress, // RFC 4291 (v6), RFC 3171 (v4)
29 BroadcastAddress, // RFC 919, 922
30
32 TestNetworkAddress, // RFC 3849 (v6), RFC 5737 (v4),
34 UniqueLocalAddress, // RFC 4193
35 SiteLocalAddress, // RFC 4291 (deprecated by RFC 3879, should be treated as global)
36
37 UnknownAddress = 0 // unclassified or reserved
38};
39
41{
42 // stores 0-32 for IPv4, 0-128 for IPv6, or 255 for invalid
44public:
45 constexpr QNetmask() : length(255) {}
46
47 bool setAddress(const QHostAddress &address);
49
50 int prefixLength() const { return length == 255 ? -1 : length; }
52 {
53 int maxlen = -1;
55 maxlen = 32;
56 else if (proto == QAbstractSocket::IPv6Protocol)
57 maxlen = 128;
58 if (len > maxlen || len < 0)
59 length = 255U;
60 else
61 length = unsigned(len);
62 }
63
64 friend bool operator==(QNetmask n1, QNetmask n2)
65 { return n1.length == n2.length; }
66};
67
69{
70public:
72
73 void setAddress(quint32 a_ = 0);
74 void setAddress(const quint8 *a_);
75 void setAddress(const Q_IPV6ADDR &a_);
76
77 bool parse(const QString &ipString);
78 void clear();
79
81
82 union {
83 Q_IPV6ADDR a6; // IPv6 address
84 struct { quint64 c[2]; } a6_64;
85 struct { quint32 c[4]; } a6_32;
86 };
87 quint32 a; // IPv4 address
89
92 { return address.d->classify(); }
93
94 friend class QHostAddress;
95};
96
98
99#endif
static constexpr auto IPv4Protocol
static constexpr auto IPv6Protocol
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
static AddressClassification classify(const QHostAddress &address)
The QHostAddress class provides an IP address.
bool setAddress(const QHostAddress &address)
int prefixLength() const
void setPrefixLength(QAbstractSocket::NetworkLayerProtocol proto, int len)
constexpr QNetmask()
friend bool operator==(QNetmask n1, QNetmask n2)
\inmodule QtCore
Definition qshareddata.h:19
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
QIPv6Address Q_IPV6ADDR
AddressClassification
@ MulticastAddress
@ LocalNetAddress
@ GlobalAddress
@ UniqueLocalAddress
@ SiteLocalAddress
@ PrivateNetworkAddress
@ TestNetworkAddress
@ UnknownAddress
@ BroadcastAddress
@ LoopbackAddress
@ LinkLocalAddress
GLenum GLuint GLenum GLsizei length
const GLubyte * c
GLuint GLuint64EXT address
GLenum GLsizei len
unsigned int quint32
Definition qtypes.h:50
unsigned long long quint64
Definition qtypes.h:61
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition qtypes.h:45
unsigned char quint8
Definition qtypes.h:46