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
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
30QT_BEGIN_NAMESPACE
31
32class QNetworkAddressEntryPrivate
33{
34public:
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
46{
47public:
52
53 int index; // interface index, if know
54 int mtu = 0;
57
61
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
81private:
82 // disallow copying -- avoid detaching
84 QNetworkInterfacePrivate(const QNetworkInterfacePrivate &other);
85};
86
88{
89public:
92
96
97 static uint interfaceIndexFromName(const QString &name);
98 static QString interfaceNameFromIndex(uint index);
99
100 // convenience:
102
103private:
104 QList<QNetworkInterfacePrivate *> scan();
105};
106
107
108QT_END_NAMESPACE
109
110#endif // QT_NO_NETWORKINTERFACE
111
112#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.
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2464
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static QDebug flagsDebug(QDebug debug, QNetworkInterface::InterfaceFlags flags)
static QList< QNetworkInterfacePrivate * > postProcess(QList< QNetworkInterfacePrivate * > list)