Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qnetworkinterface_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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QNETWORKINTERFACEPRIVATE_H
6
#
define
QNETWORKINTERFACEPRIVATE_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtNetwork
/
private
/
qtnetworkglobal_p
.
h
>
20
#
include
<
QtNetwork
/
qnetworkinterface
.
h
>
21
#
include
<
QtCore
/
qatomic
.
h
>
22
#
include
<
QtCore
/
qdeadlinetimer
.
h
>
23
#
include
<
QtCore
/
qlist
.
h
>
24
#
include
<
QtCore
/
qstring
.
h
>
25
#
include
<
QtNetwork
/
qhostaddress
.
h
>
26
#
include
<
QtNetwork
/
qabstractsocket
.
h
>
27
#
include
<
private
/
qhostaddress_p
.
h
>
28
29
#
ifndef
QT_NO_NETWORKINTERFACE
30
31
QT_BEGIN_NAMESPACE
32
33
class
QNetworkAddressEntryPrivate
34
{
35
public
:
36
QHostAddress address;
37
QHostAddress broadcast;
38
QDeadlineTimer preferredLifetime = QDeadlineTimer::Forever;
39
QDeadlineTimer validityLifetime = QDeadlineTimer::Forever;
40
41
QNetmask netmask;
42
bool
lifetimeKnown =
false
;
43
QNetworkAddressEntry::DnsEligibilityStatus dnsEligibility = QNetworkAddressEntry::DnsEligibilityUnknown;
44
};
45
46
class
QNetworkInterfacePrivate
:
public
QSharedData
47
{
48
public
:
49
QNetworkInterfacePrivate
() :
index
(0)
50
{ }
51
~
QNetworkInterfacePrivate
()
52
{ }
53
54
int
index
;
// interface index, if know
55
int
mtu
= 0;
56
QNetworkInterface
::
InterfaceFlags
flags
;
57
QNetworkInterface
::
InterfaceType
type
=
QNetworkInterface
::
Unknown
;
58
59
QString
name
;
60
QString
friendlyName
;
61
QString
hardwareAddress
;
62
63
QList
<
QNetworkAddressEntry
>
addressEntries
;
64
65
static
QString
makeHwAddress
(
int
len, uchar *data);
66
static
void
calculateDnsEligibility
(QNetworkAddressEntry *entry,
bool
isTemporary,
67
bool
isDeprecated)
68
{
69
// this implements an algorithm that yields the same results as Windows
70
// produces, for the same input (as far as I can test)
71
if
(isTemporary || isDeprecated) {
72
entry->setDnsEligibility(QNetworkAddressEntry::DnsIneligible);
73
}
else
{
74
AddressClassification cl = QHostAddressPrivate::classify(entry->ip());
75
if
(cl == LoopbackAddress || cl == LinkLocalAddress)
76
entry->setDnsEligibility(QNetworkAddressEntry::DnsIneligible);
77
else
78
entry->setDnsEligibility(QNetworkAddressEntry::DnsEligible);
79
}
80
}
81
82
private
:
83
// disallow copying -- avoid detaching
84
QNetworkInterfacePrivate
&operator=(
const
QNetworkInterfacePrivate
&other);
85
QNetworkInterfacePrivate(
const
QNetworkInterfacePrivate
&other);
86
};
87
88
class
QNetworkInterfaceManager
89
{
90
public
:
91
QNetworkInterfaceManager
();
92
~
QNetworkInterfaceManager
();
93
94
QSharedDataPointer
<
QNetworkInterfacePrivate
>
interfaceFromName
(
const
QString &name);
95
QSharedDataPointer
<
QNetworkInterfacePrivate
>
interfaceFromIndex
(
int
index);
96
QList
<
QSharedDataPointer
<
QNetworkInterfacePrivate
> >
allInterfaces
();
97
98
static
uint
interfaceIndexFromName
(
const
QString &name);
99
static
QString
interfaceNameFromIndex
(uint index);
100
101
// convenience:
102
QSharedDataPointer
<
QNetworkInterfacePrivate
>
empty
;
103
104
private
:
105
QList<QNetworkInterfacePrivate *> scan();
106
};
107
108
109
QT_END_NAMESPACE
110
111
#
endif
// QT_NO_NETWORKINTERFACE
112
113
#
endif
QNetworkAddressEntry
The QNetworkAddressEntry class stores one IP address supported by a network interface,...
Definition
qnetworkinterface.h:23
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::interfaceIndexFromName
static uint interfaceIndexFromName(const QString &name)
Definition
qnetworkinterface_linux.cpp:169
QNetworkInterfaceManager::QNetworkInterfaceManager
QNetworkInterfaceManager()
Definition
qnetworkinterface.cpp:48
QNetworkInterfaceManager::allInterfaces
QList< QSharedDataPointer< QNetworkInterfacePrivate > > allInterfaces()
Definition
qnetworkinterface.cpp:84
QNetworkInterfaceManager::empty
QSharedDataPointer< QNetworkInterfacePrivate > empty
Definition
qnetworkinterface_p.h:102
QNetworkInterfaceManager::interfaceNameFromIndex
static QString interfaceNameFromIndex(uint index)
Definition
qnetworkinterface_linux.cpp:188
QNetworkInterfaceManager::interfaceFromIndex
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromIndex(int index)
Definition
qnetworkinterface.cpp:73
QNetworkInterfacePrivate
Definition
qnetworkinterface_p.h:47
QNetworkInterfacePrivate::makeHwAddress
static QString makeHwAddress(int len, uchar *data)
Definition
qnetworkinterface.cpp:103
QNetworkInterfacePrivate::friendlyName
QString friendlyName
Definition
qnetworkinterface_p.h:60
QNetworkInterfacePrivate::mtu
int mtu
Definition
qnetworkinterface_p.h:55
QNetworkInterfacePrivate::hardwareAddress
QString hardwareAddress
Definition
qnetworkinterface_p.h:61
QNetworkInterfacePrivate::name
QString name
Definition
qnetworkinterface_p.h:59
QNetworkInterfacePrivate::index
int index
Definition
qnetworkinterface_p.h:54
QNetworkInterfacePrivate::calculateDnsEligibility
static void calculateDnsEligibility(QNetworkAddressEntry *entry, bool isTemporary, bool isDeprecated)
Definition
qnetworkinterface_p.h:66
QNetworkInterfacePrivate::QNetworkInterfacePrivate
QNetworkInterfacePrivate()
Definition
qnetworkinterface_p.h:49
QNetworkInterfacePrivate::addressEntries
QList< QNetworkAddressEntry > addressEntries
Definition
qnetworkinterface_p.h:63
QNetworkInterfacePrivate::~QNetworkInterfacePrivate
~QNetworkInterfacePrivate()
Definition
qnetworkinterface_p.h:51
QNetworkInterface
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
Definition
qnetworkinterface.h:74
QPlatformGraphicsBufferHelper
\inmodule QtGui
operator<<
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition
qdir.cpp:2568
operator<<
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
Definition
qfileinfo.cpp:1807
flagsDebug
static QDebug flagsDebug(QDebug debug, QNetworkInterface::InterfaceFlags flags)
Definition
qnetworkinterface.cpp:878
qtbase
src
network
kernel
qnetworkinterface_p.h
Generated on
for Qt by
1.14.0