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
qnetworkinterface.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 QNETWORKINTERFACE_H
5#define QNETWORKINTERFACE_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/qshareddata.h>
9#include <QtCore/qscopedpointer.h>
10#include <QtNetwork/qhostaddress.h>
11
12#include <memory>
13
14#ifndef QT_NO_NETWORKINTERFACE
15
17
18class QDeadlineTimer;
19
21class Q_NETWORK_EXPORT QNetworkAddressEntry
22{
23public:
25 DnsEligibilityUnknown = -1,
26 DnsIneligible = 0,
27 DnsEligible = 1
28 };
29
35
36 void swap(QNetworkAddressEntry &other) noexcept { d.swap(other.d); }
37
38 bool operator==(const QNetworkAddressEntry &other) const;
39 inline bool operator!=(const QNetworkAddressEntry &other) const
40 { return !(*this == other); }
41
42 DnsEligibilityStatus dnsEligibility() const;
43 void setDnsEligibility(DnsEligibilityStatus status);
44
45 QHostAddress ip() const;
46 void setIp(const QHostAddress &newIp);
47
48 QHostAddress netmask() const;
49 void setNetmask(const QHostAddress &newNetmask);
50 int prefixLength() const;
51 void setPrefixLength(int length);
52
53 QHostAddress broadcast() const;
54 void setBroadcast(const QHostAddress &newBroadcast);
55
56 bool isLifetimeKnown() const;
57 QDeadlineTimer preferredLifetime() const;
58 QDeadlineTimer validityLifetime() const;
59 void setAddressLifetime(QDeadlineTimer preferred, QDeadlineTimer validity);
60 void clearAddressLifetime();
61 bool isPermanent() const;
62 bool isTemporary() const { return !isPermanent(); }
63
64private:
65 // ### Qt 7: make implicitly shared
66 std::unique_ptr<QNetworkAddressEntryPrivate> d;
67};
68
69Q_DECLARE_SHARED(QNetworkAddressEntry)
70
72class Q_NETWORK_EXPORT QNetworkInterface
73{
75public:
77 IsUp = 0x1,
78 IsRunning = 0x2,
79 CanBroadcast = 0x4,
80 IsLoopBack = 0x8,
81 IsPointToPoint = 0x10,
82 CanMulticast = 0x20
83 };
84 Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)
85 Q_FLAG(InterfaceFlags)
86
88 Loopback = 1,
96 Ieee80211 = Wifi, // alias
99 SixLoWPAN, // 6LoWPAN, but we can't start with a digit
102
103 Unknown = 0
104 };
105 Q_ENUM(InterfaceType)
106
110 QNetworkInterface &operator=(const QNetworkInterface &other);
112
113 void swap(QNetworkInterface &other) noexcept { d.swap(other.d); }
114
115 bool isValid() const;
116
117 int index() const;
118 int maximumTransmissionUnit() const;
119 QString name() const;
120 QString humanReadableName() const;
121 InterfaceFlags flags() const;
122 InterfaceType type() const;
123 QString hardwareAddress() const;
124 QList<QNetworkAddressEntry> addressEntries() const;
125
126 static int interfaceIndexFromName(const QString &name);
127 static QNetworkInterface interfaceFromName(const QString &name);
128 static QNetworkInterface interfaceFromIndex(int index);
129 static QString interfaceNameFromIndex(int index);
130 static QList<QNetworkInterface> allInterfaces();
131 static QList<QHostAddress> allAddresses();
132
133private:
135 QSharedDataPointer<QNetworkInterfacePrivate> d;
136};
137
138Q_DECLARE_SHARED(QNetworkInterface)
139
140Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkInterface::InterfaceFlags)
141
142#ifndef QT_NO_DEBUG_STREAM
144Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkInterface &networkInterface);
145#endif
146
148
151
152#endif // QT_NO_NETWORKINTERFACE
153
154#endif
\inmodule QtCore
\inmodule QtCore
The QHostAddress class provides an IP address.
The QNetworkAddressEntry class stores one IP address supported by a network interface,...
bool operator!=(const QNetworkAddressEntry &other) const
Returns true if this network address entry is different from other.
void swap(QNetworkAddressEntry &other) noexcept
QNetworkAddressEntry & operator=(QNetworkAddressEntry &&other) noexcept
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
QNetworkInterface & operator=(QNetworkInterface &&other) noexcept
void swap(QNetworkInterface &other) noexcept
InterfaceFlag
Specifies the flags associated with this network interface.
InterfaceType
Specifies the type of hardware (PHY layer, OSI level 1) this interface is, if it could be determined.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1388
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkAddressEntry &entry)
GLuint index
[2]
GLenum GLuint GLenum GLsizei length
GLenum type
GLbitfield flags
GLuint name
GLuint entry
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
#define Q_ENUM(x)
#define Q_FLAG(x)
#define Q_GADGET
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition qtypes.h:45
QSharedPointer< T > other(t)
[5]
this swap(other)