summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qnetworkinterface_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/kernel/qnetworkinterface_win.cpp')
-rw-r--r--src/network/kernel/qnetworkinterface_win.cpp58
1 files changed, 55 insertions, 3 deletions
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index 64c3fa6f83..150553f673 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -62,6 +62,10 @@
#include <qt_windows.h>
+// In case these aren't defined
+#define IF_TYPE_IEEE80216_WMAN 237
+#define IF_TYPE_IEEE802154 259
+
QT_BEGIN_NAMESPACE
static QHostAddress addressFromSockaddr(sockaddr *sa)
@@ -147,6 +151,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
else if (ptr->IfIndex != 0)
iface->index = ptr->IfIndex;
+ iface->mtu = qMin<qint64>(ptr->Mtu, INT_MAX);
iface->flags = QNetworkInterface::CanBroadcast;
if (ptr->OperStatus == IfOperStatusUp)
iface->flags |= QNetworkInterface::IsUp | QNetworkInterface::IsRunning;
@@ -155,6 +160,45 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
if (ptr->IfType == IF_TYPE_PPP)
iface->flags |= QNetworkInterface::IsPointToPoint;
+ switch (ptr->IfType) {
+ case IF_TYPE_ETHERNET_CSMACD:
+ iface->type = QNetworkInterface::Ethernet;
+ break;
+
+ case IF_TYPE_FDDI:
+ iface->type = QNetworkInterface::Fddi;
+ break;
+
+ case IF_TYPE_PPP:
+ iface->type = QNetworkInterface::Ppp;
+ break;
+
+ case IF_TYPE_SLIP:
+ iface->type = QNetworkInterface::Slip;
+ break;
+
+ case IF_TYPE_SOFTWARE_LOOPBACK:
+ iface->type = QNetworkInterface::Loopback;
+ iface->flags |= QNetworkInterface::IsLoopBack;
+ break;
+
+ case IF_TYPE_IEEE80211:
+ iface->type = QNetworkInterface::Ieee80211;
+ break;
+
+ case IF_TYPE_IEEE1394:
+ iface->type = QNetworkInterface::Ieee1394;
+ break;
+
+ case IF_TYPE_IEEE80216_WMAN:
+ iface->type = QNetworkInterface::Ieee80216;
+ break;
+
+ case IF_TYPE_IEEE802154:
+ iface->type = QNetworkInterface::Ieee802154;
+ break;
+ }
+
// use ConvertInterfaceLuidToNameW because that returns a friendlier name, though not
// as "friendly" as FriendlyName below
WCHAR buf[IF_MAX_STRING_SIZE + 1];
@@ -167,9 +211,6 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
if (ptr->PhysicalAddressLength)
iface->hardwareAddress = iface->makeHwAddress(ptr->PhysicalAddressLength,
ptr->PhysicalAddress);
- else
- // loopback if it has no address
- iface->flags |= QNetworkInterface::IsLoopBack;
// parse the IP (unicast) addresses
for (PIP_ADAPTER_UNICAST_ADDRESS addr = ptr->FirstUnicastAddress; addr; addr = addr->Next) {
@@ -182,6 +223,17 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
QNetworkAddressEntry entry;
entry.setIp(addressFromSockaddr(addr->Address.lpSockaddr));
entry.setPrefixLength(addr->OnLinkPrefixLength);
+
+ auto toDeadline = [](ULONG lifetime) -> QDeadlineTimer {
+ if (lifetime == 0xffffffffUL)
+ return QDeadlineTimer::Forever;
+ return QDeadlineTimer(lifetime * 1000);
+ };
+ entry.setAddressLifetime(toDeadline(addr->ValidLifetime), toDeadline(addr->PreferredLifetime));
+ entry.setDnsEligibility(addr->Flags & IP_ADAPTER_ADDRESS_DNS_ELIGIBLE ?
+ QNetworkAddressEntry::DnsEligible :
+ QNetworkAddressEntry::DnsIneligible);
+
iface->addressEntries << entry;
}
}