Qt
6.x
The Qt SDK
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
4
#ifndef QNETWORKINTERFACEPRIVATE_H
5
#define QNETWORKINTERFACEPRIVATE_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#include <QtNetwork/private/qtnetworkglobal_p.h>
19
#include <QtNetwork/qnetworkinterface.h>
20
#include <QtCore/qatomic.h>
21
#include <QtCore/qdeadlinetimer.h>
22
#include <QtCore/qlist.h>
23
#include <QtCore/qstring.h>
24
#include <QtNetwork/qhostaddress.h>
25
#include <QtNetwork/qabstractsocket.h>
26
#include <private/qhostaddress_p.h>
27
28
#ifndef QT_NO_NETWORKINTERFACE
29
30
QT_BEGIN_NAMESPACE
31
32
class
QNetworkAddressEntryPrivate
33
{
34
public
:
35
QHostAddress
address
;
36
QHostAddress
broadcast
;
37
QDeadlineTimer
preferredLifetime
=
QDeadlineTimer::Forever
;
38
QDeadlineTimer
validityLifetime
=
QDeadlineTimer::Forever
;
39
40
QNetmask
netmask
;
41
bool
lifetimeKnown
=
false
;
42
QNetworkAddressEntry::DnsEligibilityStatus
dnsEligibility
=
QNetworkAddressEntry::DnsEligibilityUnknown
;
43
};
44
45
class
QNetworkInterfacePrivate
:
public
QSharedData
46
{
47
public
:
48
QNetworkInterfacePrivate
() :
index
(0)
49
{ }
50
~QNetworkInterfacePrivate
()
51
{ }
52
53
int
index
;
// interface index, if know
54
int
mtu
= 0;
55
QNetworkInterface::InterfaceFlags
flags
;
56
QNetworkInterface::InterfaceType
type
=
QNetworkInterface::Unknown
;
57
58
QString
name
;
59
QString
friendlyName
;
60
QString
hardwareAddress
;
61
62
QList<QNetworkAddressEntry>
addressEntries
;
63
64
static
QString
makeHwAddress
(
int
len
,
uchar
*
data
);
65
static
void
calculateDnsEligibility
(
QNetworkAddressEntry
*
entry
,
bool
isTemporary,
66
bool
isDeprecated)
67
{
68
// this implements an algorithm that yields the same results as Windows
69
// produces, for the same input (as far as I can test)
70
if
(isTemporary || isDeprecated) {
71
entry
->setDnsEligibility(
QNetworkAddressEntry::DnsIneligible
);
72
}
else
{
73
AddressClassification
cl =
QHostAddressPrivate::classify
(
entry
->ip());
74
if
(cl ==
LoopbackAddress
|| cl ==
LinkLocalAddress
)
75
entry
->setDnsEligibility(
QNetworkAddressEntry::DnsIneligible
);
76
else
77
entry
->setDnsEligibility(
QNetworkAddressEntry::DnsEligible
);
78
}
79
}
80
81
private
:
82
// disallow copying -- avoid detaching
83
QNetworkInterfacePrivate
&operator=(
const
QNetworkInterfacePrivate
&
other
);
84
QNetworkInterfacePrivate
(
const
QNetworkInterfacePrivate
&
other
);
85
};
86
87
class
QNetworkInterfaceManager
88
{
89
public
:
90
QNetworkInterfaceManager
();
91
~QNetworkInterfaceManager
();
92
93
QSharedDataPointer<QNetworkInterfacePrivate>
interfaceFromName
(
const
QString
&
name
);
94
QSharedDataPointer<QNetworkInterfacePrivate>
interfaceFromIndex
(
int
index
);
95
QList<QSharedDataPointer<QNetworkInterfacePrivate>
>
allInterfaces
();
96
97
static
uint
interfaceIndexFromName
(
const
QString
&
name
);
98
static
QString
interfaceNameFromIndex
(
uint
index
);
99
100
// convenience:
101
QSharedDataPointer<QNetworkInterfacePrivate>
empty
;
102
103
private
:
104
QList<QNetworkInterfacePrivate *>
scan();
105
};
106
107
108
QT_END_NAMESPACE
109
110
#endif
// QT_NO_NETWORKINTERFACE
111
112
#endif
QDeadlineTimer
\inmodule QtCore
Definition
qdeadlinetimer.h:24
QDeadlineTimer::Forever
static constexpr ForeverConstant Forever
Definition
qdeadlinetimer.h:27
QHostAddressPrivate::classify
AddressClassification classify() const
Definition
qhostaddress.cpp:146
QHostAddress
The QHostAddress class provides an IP address.
Definition
qhostaddress.h:38
QList
Definition
qlist.h:74
QNetmask
Definition
qhostaddress_p.h:41
QNetworkAddressEntryPrivate
Definition
qnetworkinterface_p.h:33
QNetworkAddressEntryPrivate::lifetimeKnown
bool lifetimeKnown
Definition
qnetworkinterface_p.h:41
QNetworkAddressEntryPrivate::dnsEligibility
QNetworkAddressEntry::DnsEligibilityStatus dnsEligibility
Definition
qnetworkinterface_p.h:42
QNetworkAddressEntryPrivate::netmask
QNetmask netmask
Definition
qnetworkinterface_p.h:40
QNetworkAddressEntryPrivate::broadcast
QHostAddress broadcast
Definition
qnetworkinterface_p.h:36
QNetworkAddressEntryPrivate::validityLifetime
QDeadlineTimer validityLifetime
Definition
qnetworkinterface_p.h:38
QNetworkAddressEntryPrivate::address
QHostAddress address
Definition
qnetworkinterface_p.h:35
QNetworkAddressEntryPrivate::preferredLifetime
QDeadlineTimer preferredLifetime
Definition
qnetworkinterface_p.h:37
QNetworkAddressEntry
The QNetworkAddressEntry class stores one IP address supported by a network interface,...
Definition
qnetworkinterface.h:22
QNetworkAddressEntry::DnsEligibilityStatus
DnsEligibilityStatus
Definition
qnetworkinterface.h:24
QNetworkAddressEntry::DnsEligibilityUnknown
@ DnsEligibilityUnknown
Definition
qnetworkinterface.h:25
QNetworkAddressEntry::DnsIneligible
@ DnsIneligible
Definition
qnetworkinterface.h:26
QNetworkAddressEntry::DnsEligible
@ DnsEligible
Definition
qnetworkinterface.h:27
QNetworkInterfaceManager
Definition
qnetworkinterface_p.h:88
QNetworkInterfaceManager::~QNetworkInterfaceManager
~QNetworkInterfaceManager()
Definition
qnetworkinterface.cpp:54
QNetworkInterfaceManager::interfaceFromName
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromName(const QString &name)
Definition
qnetworkinterface.cpp:58
QNetworkInterfaceManager::interfaceIndexFromName
static uint interfaceIndexFromName(const QString &name)
Definition
qnetworkinterface_linux.cpp:186
QNetworkInterfaceManager::QNetworkInterfaceManager
QNetworkInterfaceManager()
Definition
qnetworkinterface.cpp:50
QNetworkInterfaceManager::allInterfaces
QList< QSharedDataPointer< QNetworkInterfacePrivate > > allInterfaces()
Definition
qnetworkinterface.cpp:86
QNetworkInterfaceManager::empty
QSharedDataPointer< QNetworkInterfacePrivate > empty
Definition
qnetworkinterface_p.h:101
QNetworkInterfaceManager::interfaceNameFromIndex
static QString interfaceNameFromIndex(uint index)
Definition
qnetworkinterface_linux.cpp:205
QNetworkInterfaceManager::interfaceFromIndex
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromIndex(int index)
Definition
qnetworkinterface.cpp:75
QNetworkInterfacePrivate
Definition
qnetworkinterface_p.h:46
QNetworkInterfacePrivate::makeHwAddress
static QString makeHwAddress(int len, uchar *data)
Definition
qnetworkinterface.cpp:105
QNetworkInterfacePrivate::friendlyName
QString friendlyName
Definition
qnetworkinterface_p.h:59
QNetworkInterfacePrivate::mtu
int mtu
Definition
qnetworkinterface_p.h:54
QNetworkInterfacePrivate::flags
QNetworkInterface::InterfaceFlags flags
Definition
qnetworkinterface_p.h:55
QNetworkInterfacePrivate::hardwareAddress
QString hardwareAddress
Definition
qnetworkinterface_p.h:60
QNetworkInterfacePrivate::name
QString name
Definition
qnetworkinterface_p.h:58
QNetworkInterfacePrivate::index
int index
Definition
qnetworkinterface_p.h:53
QNetworkInterfacePrivate::calculateDnsEligibility
static void calculateDnsEligibility(QNetworkAddressEntry *entry, bool isTemporary, bool isDeprecated)
Definition
qnetworkinterface_p.h:65
QNetworkInterfacePrivate::QNetworkInterfacePrivate
QNetworkInterfacePrivate()
Definition
qnetworkinterface_p.h:48
QNetworkInterfacePrivate::addressEntries
QList< QNetworkAddressEntry > addressEntries
Definition
qnetworkinterface_p.h:62
QNetworkInterfacePrivate::~QNetworkInterfacePrivate
~QNetworkInterfacePrivate()
Definition
qnetworkinterface_p.h:50
QNetworkInterface::InterfaceType
InterfaceType
Specifies the type of hardware (PHY layer, OSI level 1) this interface is, if it could be determined.
Definition
qnetworkinterface.h:87
QNetworkInterface::Unknown
@ Unknown
Definition
qnetworkinterface.h:103
QSharedDataPointer
\inmodule QtCore
Definition
qshareddata.h:35
QSharedData
\inmodule QtCore
Definition
qshareddata.h:19
QString
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition
qstring.h:127
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1545
AddressClassification
AddressClassification
Definition
qhostaddress_p.h:24
LoopbackAddress
@ LoopbackAddress
Definition
qhostaddress_p.h:25
LinkLocalAddress
@ LinkLocalAddress
Definition
qhostaddress_p.h:27
index
GLuint index
[2]
Definition
qopengles2ext.h:331
type
GLenum type
Definition
qopengles2ext.h:150
data
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
Definition
qopengles2ext.h:206
name
GLuint name
Definition
qopengles2ext.h:156
entry
GLuint entry
Definition
qopenglext.h:11002
len
GLenum GLsizei len
Definition
qopenglext.h:3292
uchar
unsigned char uchar
Definition
qtypes.h:27
uint
unsigned int uint
Definition
qtypes.h:29
other
QSharedPointer< T > other(t)
[5]
qtbase
src
network
kernel
qnetworkinterface_p.h
Generated by
1.9.7