Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QNETWORKINTERFACE_H
6
#
define
QNETWORKINTERFACE_H
7
8
#
include
<
QtNetwork
/
qtnetworkglobal
.
h
>
9
10
#
include
<
QtCore
/
qmetatype
.
h
>
11
#
include
<
QtCore
/
qshareddata
.
h
>
12
#
include
<
QtCore
/
qscopedpointer
.
h
>
13
#
include
<
QtNetwork
/
qhostaddress
.
h
>
14
15
#
include
<
memory
>
16
17
#
ifndef
QT_NO_NETWORKINTERFACE
18
19
QT_BEGIN_NAMESPACE
20
21
class
QDeadlineTimer;
22
23
class
QNetworkAddressEntryPrivate;
24
class
Q_NETWORK_EXPORT
QNetworkAddressEntry
25
{
26
public
:
27
enum
DnsEligibilityStatus : qint8 {
28
DnsEligibilityUnknown = -1,
29
DnsIneligible = 0,
30
DnsEligible = 1
31
};
32
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();
38
39
void
swap(QNetworkAddressEntry &other)
noexcept
{ d.swap(other.d); }
40
41
bool
operator==(
const
QNetworkAddressEntry &other)
const
;
42
inline
bool
operator!=(
const
QNetworkAddressEntry &other)
const
43
{
return
!(*
this
== other); }
44
45
DnsEligibilityStatus dnsEligibility()
const
;
46
void
setDnsEligibility(DnsEligibilityStatus status);
47
48
QHostAddress ip()
const
;
49
void
setIp(
const
QHostAddress &newIp);
50
51
QHostAddress netmask()
const
;
52
void
setNetmask(
const
QHostAddress &newNetmask);
53
int
prefixLength()
const
;
54
void
setPrefixLength(
int
length);
55
56
QHostAddress broadcast()
const
;
57
void
setBroadcast(
const
QHostAddress &newBroadcast);
58
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(); }
66
67
private
:
68
// ### Qt 7: make implicitly shared
69
std::unique_ptr<QNetworkAddressEntryPrivate> d;
70
};
71
72
Q_DECLARE_SHARED
(
QNetworkAddressEntry
)
73
74
class
QNetworkInterfacePrivate
;
75
class
Q_NETWORK_EXPORT
QNetworkInterface
76
{
77
Q_GADGET
78
public
:
79
enum
InterfaceFlag {
80
IsUp = 0x1,
81
IsRunning = 0x2,
82
CanBroadcast = 0x4,
83
IsLoopBack = 0x8,
84
IsPointToPoint = 0x10,
85
CanMulticast = 0x20
86
};
87
Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)
88
Q_FLAG(InterfaceFlags)
89
90
enum
InterfaceType {
91
Loopback = 1,
92
Virtual,
93
Ethernet,
94
Slip,
95
CanBus,
96
Ppp,
97
Fddi,
98
Wifi,
99
Ieee80211 = Wifi,
// alias
100
Phonet,
101
Ieee802154,
102
SixLoWPAN,
// 6LoWPAN, but we can't start with a digit
103
Ieee80216,
104
Ieee1394,
105
106
Unknown = 0
107
};
108
Q_ENUM(InterfaceType)
109
110
QNetworkInterface();
111
QNetworkInterface(
const
QNetworkInterface &other);
112
QNetworkInterface &operator=(QNetworkInterface &&other)
noexcept
{ swap(other);
return
*
this
; }
113
QNetworkInterface &operator=(
const
QNetworkInterface &other);
114
~QNetworkInterface();
115
116
void
swap(QNetworkInterface &other)
noexcept
{ d.swap(other.d); }
117
118
bool
isValid()
const
;
119
120
int
index()
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
;
128
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();
135
136
private
:
137
friend
class
QNetworkInterfacePrivate;
138
QSharedDataPointer<QNetworkInterfacePrivate> d;
139
};
140
141
Q_DECLARE_SHARED
(
QNetworkInterface
)
142
143
Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkInterface::InterfaceFlags)
144
145
#
ifndef
QT_NO_DEBUG_STREAM
146
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug,
const
QNetworkAddressEntry &entry);
147
Q_NETWORK_EXPORT
QDebug
operator<<(QDebug debug,
const
QNetworkInterface &networkInterface);
148
#
endif
149
150
QT_END_NAMESPACE
151
152
QT_DECL_METATYPE_EXTERN(QNetworkAddressEntry, Q_NETWORK_EXPORT)
153
QT_DECL_METATYPE_EXTERN(QNetworkInterface, Q_NETWORK_EXPORT)
154
155
#
endif
// QT_NO_NETWORKINTERFACE
156
157
#
endif
QNetworkAddressEntry
The QNetworkAddressEntry class stores one IP address supported by a network interface,...
Definition
qnetworkinterface.h:25
QNetworkInterfaceManager
Definition
qnetworkinterface_p.h:89
QNetworkInterfaceManager::~QNetworkInterfaceManager
~QNetworkInterfaceManager()
Definition
qnetworkinterface.cpp:52
QNetworkInterfaceManager::interfaceFromName
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromName(const QString &name)
Definition
qnetworkinterface.cpp:56
QNetworkInterfaceManager::allInterfaces
QList< QSharedDataPointer< QNetworkInterfacePrivate > > allInterfaces()
Definition
qnetworkinterface.cpp:84
QNetworkInterfaceManager::interfaceFromIndex
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromIndex(int index)
Definition
qnetworkinterface.cpp:73
QNetworkInterfacePrivate
Definition
qnetworkinterface_p.h:47
QNetworkInterface
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
Definition
qnetworkinterface.h:76
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
operator<<
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition
qdir.cpp:2620
operator<<
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
Definition
qfileinfo.cpp:1830
flagsDebug
static QDebug flagsDebug(QDebug debug, QNetworkInterface::InterfaceFlags flags)
Definition
qnetworkinterface.cpp:883
qtbase
src
network
kernel
qnetworkinterface.h
Generated on
for Qt by
1.18.0