diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-08-09 09:38:55 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-11-07 22:15:38 +0000 |
commit | 18ec85a80c06d770c3943d98f3981ac829fd75ca (patch) | |
tree | 8bf11fb2df903e7a8c02e71118287e894e160a06 /src/network/kernel/qnetworkinterface_p.h | |
parent | a93437342b9bf60c24a0d339244e8a0b308d4a7f (diff) |
QNetworkInterface: Add the DNS eligibility
[ChangeLog][QtNetwork][QNetworkInterface] Added dnsEligibility() to
QNetworkAddressEntry to indicate whether the address is eligible or not
for publication in DNS or similar mechanisms.
Change-Id: Id3ae5f853d964358ac1ab19b525334a426e0e052
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/kernel/qnetworkinterface_p.h')
-rw-r--r-- | src/network/kernel/qnetworkinterface_p.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/network/kernel/qnetworkinterface_p.h b/src/network/kernel/qnetworkinterface_p.h index 305a8fe020..b16149e12f 100644 --- a/src/network/kernel/qnetworkinterface_p.h +++ b/src/network/kernel/qnetworkinterface_p.h @@ -76,6 +76,7 @@ public: QNetmask netmask; bool lifetimeKnown = false; + QNetworkAddressEntry::DnsEligibilityStatus dnsEligibility = QNetworkAddressEntry::DnsEligibilityUnknown; }; class QNetworkInterfacePrivate: public QSharedData @@ -97,6 +98,20 @@ public: QList<QNetworkAddressEntry> addressEntries; static QString makeHwAddress(int len, uchar *data); + static void calculateDnsEligibility(QNetworkAddressEntry *entry, bool isTemporary, + bool isDeprecated) + { + // this implements an algorithm that yields the same results as Windows + // produces, for the same input (as far as I can test) + if (isTemporary || isDeprecated) + entry->setDnsEligibility(QNetworkAddressEntry::DnsIneligible); + + AddressClassification cl = QHostAddressPrivate::classify(entry->ip()); + if (cl == LoopbackAddress || cl == LinkLocalAddress) + entry->setDnsEligibility(QNetworkAddressEntry::DnsIneligible); + else + entry->setDnsEligibility(QNetworkAddressEntry::DnsEligible); + } private: // disallow copying -- avoid detaching |