312 lines
11 KiB
Diff
312 lines
11 KiB
Diff
From 6bb4c40bc53330797c301c5947d0d343172f9aa6 Mon Sep 17 00:00:00 2001
|
|
From: liuzhilin <liuzhilin@uniontech.com>
|
|
Date: Mon, 8 Apr 2024 17:04:04 +0800
|
|
Subject: [PATCH] devic-add-interfaceFlag-and-support-WPA3
|
|
|
|
---
|
|
autotests/activeconnectiontest.cpp | 1 +
|
|
autotests/managertest.cpp | 1 +
|
|
src/accesspoint.cpp | 12 ++++++++++++
|
|
src/accesspoint.h | 5 +++++
|
|
src/dbus/deviceinterface.h | 6 ++++++
|
|
src/device.cpp | 11 ++++++++++-
|
|
src/device.h | 10 ++++++++++
|
|
src/device_p.h | 1 +
|
|
src/fakenetwork/device.cpp | 10 ++++++++++
|
|
src/fakenetwork/device.h | 4 ++++
|
|
src/settings/wirelesssecuritysetting.cpp | 4 ++++
|
|
src/settings/wirelesssecuritysetting.h | 1 +
|
|
src/utils.cpp | 2 ++
|
|
src/utils.h | 1 +
|
|
14 files changed, 68 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/autotests/activeconnectiontest.cpp b/autotests/activeconnectiontest.cpp
|
|
index 40153f4..6508ac8 100644
|
|
--- a/autotests/activeconnectiontest.cpp
|
|
+++ b/autotests/activeconnectiontest.cpp
|
|
@@ -33,6 +33,7 @@ void ActiveConnectionTest::initTestCase()
|
|
device->setFirmwareMissing(false);
|
|
device->setFirmwareVersion(QLatin1String("0.13-3"));
|
|
device->setInterface(QLatin1String("em1"));
|
|
+ device->setInterfaceFlags(1);
|
|
device->setManaged(true);
|
|
device->setUdi(QLatin1String("/sys/devices/pci0000:00/0000:00:19.0/net/em1"));
|
|
|
|
diff --git a/autotests/managertest.cpp b/autotests/managertest.cpp
|
|
index 8b85ed5..708ff2d 100644
|
|
--- a/autotests/managertest.cpp
|
|
+++ b/autotests/managertest.cpp
|
|
@@ -28,6 +28,7 @@ void ManagerTest::testDevices()
|
|
device->setDeviceType(1);
|
|
device->setDriver(QLatin1String("e1000e"));
|
|
device->setDriverVersion(QLatin1String("2.3.2-k"));
|
|
+ device->setInterfaceFlags(1);
|
|
device->setFirmwareMissing(false);
|
|
device->setFirmwareVersion(QLatin1String("0.13-3"));
|
|
device->setInterface(QLatin1String("em1"));
|
|
diff --git a/src/accesspoint.cpp b/src/accesspoint.cpp
|
|
index e9dd891..ad69e12 100644
|
|
--- a/src/accesspoint.cpp
|
|
+++ b/src/accesspoint.cpp
|
|
@@ -37,6 +37,18 @@ NetworkManager::AccessPoint::Capabilities NetworkManager::AccessPointPrivate::co
|
|
if (caps & NM_802_11_AP_FLAGS_PRIVACY) {
|
|
capFlags |= AccessPoint::Privacy;
|
|
}
|
|
+ if (caps & NM_802_11_AP_FLAGS_WPS) {
|
|
+ capFlags |= AccessPoint::WPS;
|
|
+ }
|
|
+ if (caps & NM_802_11_AP_FLAGS_WPS_PBC) {
|
|
+ capFlags |= AccessPoint::WPS_PBC;
|
|
+ }
|
|
+ if (caps & NM_802_11_AP_FLAGS_WPS_PIN) {
|
|
+ capFlags |= AccessPoint::WPS_PIN;
|
|
+ }
|
|
+ if (caps & NM_802_11_AP_FLAGS_He) {
|
|
+ capFlags |= AccessPoint::He;
|
|
+ }
|
|
|
|
return capFlags;
|
|
}
|
|
diff --git a/src/accesspoint.h b/src/accesspoint.h
|
|
index 0c2599b..159e346 100644
|
|
--- a/src/accesspoint.h
|
|
+++ b/src/accesspoint.h
|
|
@@ -45,6 +45,10 @@ public:
|
|
enum Capability {
|
|
None = 0x0, /**< Null capability - says nothing about the access point */
|
|
Privacy = 0x1, /**< Access point supports privacy measures */
|
|
+ WPS = 0x2, /**< Access point supports some WPS method */
|
|
+ WPS_PBC = 0x4, /**< Access point supports push-button WPS */
|
|
+ WPS_PIN = 0x8, /**< Access point supports PIN-based WPS */
|
|
+ He = 0x10, /**< Access point support high efficiency (new feature in 802.11ax) */
|
|
};
|
|
/**
|
|
* Flags describing the access point's capabilities according to WPA (Wifi Protected Access)
|
|
@@ -61,6 +65,7 @@ public:
|
|
KeyMgmtPsk = 0x100,
|
|
KeyMgmt8021x = 0x200,
|
|
KeyMgmtSAE = 0x400,
|
|
+ keyMgmtSae = 0x400,
|
|
KeyMgmtEapSuiteB192 = 0x2000,
|
|
};
|
|
Q_DECLARE_FLAGS(Capabilities, Capability)
|
|
diff --git a/src/dbus/deviceinterface.h b/src/dbus/deviceinterface.h
|
|
index 49feb39..6525b3a 100644
|
|
--- a/src/dbus/deviceinterface.h
|
|
+++ b/src/dbus/deviceinterface.h
|
|
@@ -144,6 +144,12 @@ public:
|
|
return qvariant_cast<QString>(property("IpInterface"));
|
|
}
|
|
|
|
+ Q_PROPERTY(uint InterfaceFlags READ interfaceFlags)
|
|
+ inline uint interfaceFlags() const
|
|
+ {
|
|
+ return qvariant_cast<uint>(property("InterfaceFlags"));
|
|
+ }
|
|
+
|
|
Q_PROPERTY(NMVariantMapList LldpNeighbors READ lldpNeighbors)
|
|
inline NMVariantMapList lldpNeighbors() const
|
|
{
|
|
diff --git a/src/device.cpp b/src/device.cpp
|
|
index ab9be9b..1e74ac9 100644
|
|
--- a/src/device.cpp
|
|
+++ b/src/device.cpp
|
|
@@ -299,7 +299,10 @@ void NetworkManager::DevicePrivate::propertyChanged(const QString &property, con
|
|
Q_EMIT q->firmwareVersionChanged();
|
|
} else if (property == QLatin1String("Interface")) {
|
|
interfaceName = value.toString();
|
|
- Q_EMIT q->interfaceNameChanged();
|
|
+ Q_EMIT q->interfaceNameChanged();
|
|
+ } else if (property == QLatin1String("InterfaceFlags")) {
|
|
+ interfaceFlags = value.toUInt();
|
|
+ Q_EMIT q->interfaceFlagsChanged();
|
|
} else if (property == QLatin1String("Ip4Address")) {
|
|
ipV4Address = QHostAddress(ntohl(value.toUInt()));
|
|
Q_EMIT q->ipV4AddressChanged();
|
|
@@ -524,6 +527,12 @@ bool NetworkManager::Device::managed() const
|
|
return d->managed;
|
|
}
|
|
|
|
+uint NetworkManager::Device::interfaceFlags() const
|
|
+{
|
|
+ Q_D(const Device);
|
|
+ return d->interfaceFlags;
|
|
+}
|
|
+
|
|
uint NetworkManager::Device::mtu() const
|
|
{
|
|
Q_D(const Device);
|
|
diff --git a/src/device.h b/src/device.h
|
|
index 3995311..985d85e 100644
|
|
--- a/src/device.h
|
|
+++ b/src/device.h
|
|
@@ -42,6 +42,7 @@ class NETWORKMANAGERQT_EXPORT Device : public QObject
|
|
Q_PROPERTY(QString firmwareVersion READ firmwareVersion)
|
|
Q_PROPERTY(QVariant genericCapabilities READ capabilitiesV)
|
|
Q_PROPERTY(QHostAddress ipV4Address READ ipV4Address)
|
|
+ Q_PROPERTY(uint InterfaceFlags READ interfaceFlags)
|
|
Q_PROPERTY(bool managed READ managed)
|
|
Q_PROPERTY(uint mtu READ mtu)
|
|
Q_PROPERTY(bool nmPluginMissing READ nmPluginMissing)
|
|
@@ -362,6 +363,10 @@ public:
|
|
* Is the device currently being managed by NetworkManager?
|
|
*/
|
|
bool managed() const;
|
|
+ /**
|
|
+ * The up or down flag for the device
|
|
+ */
|
|
+ uint interfaceFlags() const;
|
|
/**
|
|
* Is the firmware needed by the device missing?
|
|
*/
|
|
@@ -550,6 +555,11 @@ Q_SIGNALS:
|
|
*/
|
|
void managedChanged();
|
|
|
|
+ /**
|
|
+ * Emitted when the up or down state of the device changed
|
|
+ */
|
|
+ void interfaceFlagsChanged();
|
|
+
|
|
/**
|
|
* Emitted when the physical port ID changes.
|
|
* @see physicalPortId()
|
|
diff --git a/src/device_p.h b/src/device_p.h
|
|
index bf39c3d..a1a0c4e 100644
|
|
--- a/src/device_p.h
|
|
+++ b/src/device_p.h
|
|
@@ -32,6 +32,7 @@ public:
|
|
Device::Type deviceType;
|
|
Device::State connectionState;
|
|
bool managed;
|
|
+ uint interfaceFlags;
|
|
mutable IpConfig ipV4Config;
|
|
QString ipV4ConfigPath;
|
|
mutable IpConfig ipV6Config;
|
|
diff --git a/src/fakenetwork/device.cpp b/src/fakenetwork/device.cpp
|
|
index 7ae027f..d7dfc84 100644
|
|
--- a/src/fakenetwork/device.cpp
|
|
+++ b/src/fakenetwork/device.cpp
|
|
@@ -139,6 +139,11 @@ QString Device::ipInterface() const
|
|
return m_ipInterface;
|
|
}
|
|
|
|
+uint Device::interfaceFlags() const
|
|
+{
|
|
+ return m_interfaceFlags;
|
|
+}
|
|
+
|
|
bool Device::managed() const
|
|
{
|
|
return m_managed;
|
|
@@ -224,6 +229,11 @@ void Device::setInterface(const QString &interface)
|
|
m_interface = interface;
|
|
}
|
|
|
|
+void Device::setInterfaceFlags(uint interfaceFlags)
|
|
+{
|
|
+ m_interfaceFlags = interfaceFlags;
|
|
+}
|
|
+
|
|
void Device::setIp4Config(const QString &config)
|
|
{
|
|
m_ip4Config = QDBusObjectPath(config);
|
|
diff --git a/src/fakenetwork/device.h b/src/fakenetwork/device.h
|
|
index 58a4f14..6f333b0 100644
|
|
--- a/src/fakenetwork/device.h
|
|
+++ b/src/fakenetwork/device.h
|
|
@@ -38,6 +38,7 @@ public:
|
|
Q_PROPERTY(QDBusObjectPath Ip4Config READ ip4Config)
|
|
Q_PROPERTY(QDBusObjectPath Ip6Config READ ip6Config)
|
|
Q_PROPERTY(QString IpInterface READ ipInterface)
|
|
+ Q_PROPERTY(uint InterfaceFlags READ interfaceFlags)
|
|
Q_PROPERTY(bool Managed READ managed)
|
|
Q_PROPERTY(uint Mtu READ mtu)
|
|
Q_PROPERTY(uint State READ state)
|
|
@@ -61,6 +62,7 @@ public:
|
|
QDBusObjectPath ip4Config() const;
|
|
QDBusObjectPath ip6Config() const;
|
|
QString ipInterface() const;
|
|
+ uint interfaceFlags() const;
|
|
bool managed() const;
|
|
uint mtu() const;
|
|
uint state() const;
|
|
@@ -83,6 +85,7 @@ public:
|
|
void setFirmwareMissing(bool firmwareMissing);
|
|
void setFirmwareVersion(const QString &firmwareVersion);
|
|
void setInterface(const QString &interface);
|
|
+ void setInterfaceFlags(uint interfaceFlags);
|
|
void setIpv4Address(int address);
|
|
void setIp4Config(const QString &config);
|
|
void setIp6Config(const QString &config);
|
|
@@ -114,6 +117,7 @@ private:
|
|
bool m_firmwareMissing;
|
|
QString m_firmwareVersion;
|
|
QString m_interface;
|
|
+ uint m_interfaceFlags;
|
|
int m_ip4Address;
|
|
QDBusObjectPath m_ip4Config;
|
|
QDBusObjectPath m_ip6Config;
|
|
diff --git a/src/settings/wirelesssecuritysetting.cpp b/src/settings/wirelesssecuritysetting.cpp
|
|
index 8d27bad..17b4d1d 100644
|
|
--- a/src/settings/wirelesssecuritysetting.cpp
|
|
+++ b/src/settings/wirelesssecuritysetting.cpp
|
|
@@ -449,6 +449,8 @@ void NetworkManager::WirelessSecuritySetting::fromMap(const QVariantMap &map)
|
|
setKeyMgmt(WpaEap);
|
|
} else if (key == "sae") {
|
|
setKeyMgmt(SAE);
|
|
+ } else if (key == "sae") {
|
|
+ setKeyMgmt(WpaSae);
|
|
} else if (key == "wpa-eap-suite-b-192") {
|
|
setKeyMgmt(WpaEapSuiteB192);
|
|
}
|
|
@@ -587,6 +589,8 @@ QVariantMap NetworkManager::WirelessSecuritySetting::toMap() const
|
|
setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-eap");
|
|
} else if (keyMgmt() == SAE) {
|
|
setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "sae");
|
|
+ } else if (keyMgmt() == WpaSae) {
|
|
+ setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "sae");
|
|
} else if (keyMgmt() == WpaEapSuiteB192) {
|
|
setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-eap-suite-b-192");
|
|
}
|
|
diff --git a/src/settings/wirelesssecuritysetting.h b/src/settings/wirelesssecuritysetting.h
|
|
index 9c2b0af..456021b 100644
|
|
--- a/src/settings/wirelesssecuritysetting.h
|
|
+++ b/src/settings/wirelesssecuritysetting.h
|
|
@@ -32,6 +32,7 @@ public:
|
|
WpaPsk,
|
|
WpaEap,
|
|
SAE,
|
|
+ WpaSae,
|
|
WpaEapSuiteB192,
|
|
};
|
|
enum AuthAlg {
|
|
diff --git a/src/utils.cpp b/src/utils.cpp
|
|
index 2acc7f2..ed07267 100644
|
|
--- a/src/utils.cpp
|
|
+++ b/src/utils.cpp
|
|
@@ -501,6 +501,8 @@ NetworkManager::WirelessSecurityType NetworkManager::securityTypeFromConnectionS
|
|
return Wpa2Eap;
|
|
} else if (wifiSecuritySetting->keyMgmt() == WirelessSecuritySetting::SAE) {
|
|
return SAE;
|
|
+ } else if (wifiSecuritySetting->keyMgmt() == WirelessSecuritySetting::WpaSae) {
|
|
+ return WpaSae;
|
|
} else if (wifiSecuritySetting->keyMgmt() == WirelessSecuritySetting::WpaEapSuiteB192) {
|
|
return Wpa3SuiteB192;
|
|
}
|
|
diff --git a/src/utils.h b/src/utils.h
|
|
index ab2843f..dac64a7 100644
|
|
--- a/src/utils.h
|
|
+++ b/src/utils.h
|
|
@@ -28,6 +28,7 @@ enum WirelessSecurityType {
|
|
Wpa2Psk,
|
|
Wpa2Eap,
|
|
SAE,
|
|
+ WpaSae,
|
|
Wpa3SuiteB192,
|
|
};
|
|
|
|
--
|
|
2.39.3
|
|
|