5#ifndef QNETWORKINTERFACE_H
6#define QNETWORKINTERFACE_H
8#include <QtNetwork/qtnetworkglobal.h>
10#include <QtCore/qmetatype.h>
11#include <QtCore/qshareddata.h>
12#include <QtCore/qscopedpointer.h>
13#include <QtNetwork/qhostaddress.h>
17#ifndef QT_NO_NETWORKINTERFACE
23class QNetworkAddressEntryPrivate;
27 enum DnsEligibilityStatus : qint8 {
28 DnsEligibilityUnknown = -1,
33 QNetworkAddressEntry();
34 QNetworkAddressEntry(
const QNetworkAddressEntry &other);
35 QNetworkAddressEntry &operator=(QNetworkAddressEntry &&other)
noexcept { swap(other);
return *
this; }
36 QNetworkAddressEntry &operator=(
const QNetworkAddressEntry &other);
37 ~QNetworkAddressEntry();
39 void swap(QNetworkAddressEntry &other)
noexcept { d.swap(other.d); }
41 bool operator==(
const QNetworkAddressEntry &other)
const;
42 inline bool operator!=(
const QNetworkAddressEntry &other)
const
43 {
return !(*
this == other); }
45 DnsEligibilityStatus dnsEligibility()
const;
46 void setDnsEligibility(DnsEligibilityStatus status);
48 QHostAddress ip()
const;
49 void setIp(
const QHostAddress &newIp);
51 QHostAddress netmask()
const;
52 void setNetmask(
const QHostAddress &newNetmask);
53 int prefixLength()
const;
54 void setPrefixLength(
int length);
56 QHostAddress broadcast()
const;
57 void setBroadcast(
const QHostAddress &newBroadcast);
59 bool isLifetimeKnown()
const;
60 QDeadlineTimer preferredLifetime()
const;
61 QDeadlineTimer validityLifetime()
const;
62 void setAddressLifetime(QDeadlineTimer preferred, QDeadlineTimer validity);
63 void clearAddressLifetime();
64 bool isPermanent()
const;
65 bool isTemporary()
const {
return !isPermanent(); }
69 std::unique_ptr<QNetworkAddressEntryPrivate> d;
84 IsPointToPoint = 0x10,
87 Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)
88 Q_FLAG(InterfaceFlags)
108 Q_ENUM(InterfaceType)
111 QNetworkInterface(
const QNetworkInterface &other);
112 QNetworkInterface &operator=(QNetworkInterface &&other)
noexcept { swap(other);
return *
this; }
113 QNetworkInterface &operator=(
const QNetworkInterface &other);
114 ~QNetworkInterface();
116 void swap(QNetworkInterface &other)
noexcept { d.swap(other.d); }
118 bool isValid()
const;
121 int maximumTransmissionUnit()
const;
122 QString name()
const;
123 QString humanReadableName()
const;
124 InterfaceFlags flags()
const;
125 InterfaceType type()
const;
126 QString hardwareAddress()
const;
127 QList<QNetworkAddressEntry> addressEntries()
const;
129 static int interfaceIndexFromName(
const QString &name);
130 static QNetworkInterface interfaceFromName(
const QString &name);
131 static QNetworkInterface interfaceFromIndex(
int index);
132 static QString interfaceNameFromIndex(
int index);
133 static QList<QNetworkInterface> allInterfaces();
134 static QList<QHostAddress> allAddresses();
137 friend class QNetworkInterfacePrivate;
138 QSharedDataPointer<QNetworkInterfacePrivate> d;
143Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkInterface::InterfaceFlags)
145#ifndef QT_NO_DEBUG_STREAM
146Q_NETWORK_EXPORT QDebug operator<<(QDebug debug,
const QNetworkAddressEntry &entry);
147Q_NETWORK_EXPORT
QDebug operator<<(QDebug debug,
const QNetworkInterface &networkInterface);
152QT_DECL_METATYPE_EXTERN(QNetworkAddressEntry, Q_NETWORK_EXPORT)
153QT_DECL_METATYPE_EXTERN(QNetworkInterface, Q_NETWORK_EXPORT)
The QNetworkAddressEntry class stores one IP address supported by a network interface,...
~QNetworkInterfaceManager()
QList< QSharedDataPointer< QNetworkInterfacePrivate > > allInterfaces()
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromIndex(int index)
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static QDebug flagsDebug(QDebug debug, QNetworkInterface::InterfaceFlags flags)