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
31QT_BEGIN_NAMESPACE
32
33class QNetworkAddressEntryPrivate
34{
35public:
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
47{
48public:
53
54 int index; // interface index, if know
55 int mtu = 0;
58
62
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
82private:
83 // disallow copying -- avoid detaching
85 QNetworkInterfacePrivate(const QNetworkInterfacePrivate &other);
86};
87
89{
90public:
93
97
98 static uint interfaceIndexFromName(const QString &name);
99 static QString interfaceNameFromIndex(uint index);
100
101 // convenience:
103
104private:
105 QList<QNetworkInterfacePrivate *> scan();
106};
107
108
109QT_END_NAMESPACE
110
111#endif // QT_NO_NETWORKINTERFACE
112
113#endif
The QNetworkAddressEntry class stores one IP address supported by a network interface,...
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromName(const QString &name)
static uint interfaceIndexFromName(const QString &name)
QList< QSharedDataPointer< QNetworkInterfacePrivate > > allInterfaces()
QSharedDataPointer< QNetworkInterfacePrivate > empty
static QString interfaceNameFromIndex(uint index)
QSharedDataPointer< QNetworkInterfacePrivate > interfaceFromIndex(int index)
static QString makeHwAddress(int len, uchar *data)
static void calculateDnsEligibility(QNetworkAddressEntry *entry, bool isTemporary, bool isDeprecated)
QList< QNetworkAddressEntry > addressEntries
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)
Definition qdir.cpp:2568
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static QDebug flagsDebug(QDebug debug, QNetworkInterface::InterfaceFlags flags)