5#ifndef QNETWORKINTERFACE_H
6#define QNETWORKINTERFACE_H
8#include <QtNetwork/qtnetworkglobal.h>
9#include <QtCore/qshareddata.h>
10#include <QtCore/qscopedpointer.h>
11#include <QtNetwork/qhostaddress.h>
15#ifndef QT_NO_NETWORKINTERFACE
21class QNetworkAddressEntryPrivate;
25 enum DnsEligibilityStatus : qint8 {
26 DnsEligibilityUnknown = -1,
31 QNetworkAddressEntry();
32 QNetworkAddressEntry(
const QNetworkAddressEntry &other);
33 QNetworkAddressEntry &operator=(QNetworkAddressEntry &&other)
noexcept { swap(other);
return *
this; }
34 QNetworkAddressEntry &operator=(
const QNetworkAddressEntry &other);
35 ~QNetworkAddressEntry();
37 void swap(QNetworkAddressEntry &other)
noexcept { d.swap(other.d); }
39 bool operator==(
const QNetworkAddressEntry &other)
const;
40 inline bool operator!=(
const QNetworkAddressEntry &other)
const
41 {
return !(*
this == other); }
43 DnsEligibilityStatus dnsEligibility()
const;
44 void setDnsEligibility(DnsEligibilityStatus status);
46 QHostAddress ip()
const;
47 void setIp(
const QHostAddress &newIp);
49 QHostAddress netmask()
const;
50 void setNetmask(
const QHostAddress &newNetmask);
51 int prefixLength()
const;
52 void setPrefixLength(
int length);
54 QHostAddress broadcast()
const;
55 void setBroadcast(
const QHostAddress &newBroadcast);
57 bool isLifetimeKnown()
const;
58 QDeadlineTimer preferredLifetime()
const;
59 QDeadlineTimer validityLifetime()
const;
60 void setAddressLifetime(QDeadlineTimer preferred, QDeadlineTimer validity);
61 void clearAddressLifetime();
62 bool isPermanent()
const;
63 bool isTemporary()
const {
return !isPermanent(); }
67 std::unique_ptr<QNetworkAddressEntryPrivate> d;
82 IsPointToPoint = 0x10,
85 Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)
86 Q_FLAG(InterfaceFlags)
106 Q_ENUM(InterfaceType)
109 QNetworkInterface(
const QNetworkInterface &other);
110 QNetworkInterface &operator=(QNetworkInterface &&other)
noexcept { swap(other);
return *
this; }
111 QNetworkInterface &operator=(
const QNetworkInterface &other);
112 ~QNetworkInterface();
114 void swap(QNetworkInterface &other)
noexcept { d.swap(other.d); }
116 bool isValid()
const;
119 int maximumTransmissionUnit()
const;
120 QString name()
const;
121 QString humanReadableName()
const;
122 InterfaceFlags flags()
const;
123 InterfaceType type()
const;
124 QString hardwareAddress()
const;
125 QList<QNetworkAddressEntry> addressEntries()
const;
127 static int interfaceIndexFromName(
const QString &name);
128 static QNetworkInterface interfaceFromName(
const QString &name);
129 static QNetworkInterface interfaceFromIndex(
int index);
130 static QString interfaceNameFromIndex(
int index);
131 static QList<QNetworkInterface> allInterfaces();
132 static QList<QHostAddress> allAddresses();
135 friend class QNetworkInterfacePrivate;
136 QSharedDataPointer<QNetworkInterfacePrivate> d;
141Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkInterface::InterfaceFlags)
143#ifndef QT_NO_DEBUG_STREAM
144Q_NETWORK_EXPORT QDebug operator<<(QDebug debug,
const QNetworkAddressEntry &entry);
145Q_NETWORK_EXPORT
QDebug operator<<(QDebug debug,
const QNetworkInterface &networkInterface);
150QT_DECL_METATYPE_EXTERN(QNetworkAddressEntry, Q_NETWORK_EXPORT)
151QT_DECL_METATYPE_EXTERN(QNetworkInterface, Q_NETWORK_EXPORT)
The QNetworkAddressEntry class stores one IP address supported by a network interface,...
~QNetworkInterfaceManager()
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromName(const QString &name)
QList< QSharedDataPointer< QNetworkInterfacePrivate > > allInterfaces()
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromIndex(int index)
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
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)