From 577bd1ec36bd86b39d0ef01645ebbdffa27ef365 Mon Sep 17 00:00:00 2001 From: Corbin Date: Tue, 2 Jul 2024 23:46:51 +0000 Subject: [PATCH] Store vector of WpaKeyManagement --- src/linux/wpa-controller/ProtocolHostapd.cxx | 44 +++++++++---------- .../include/Wpa/ProtocolHostapd.hxx | 6 +-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/linux/wpa-controller/ProtocolHostapd.cxx b/src/linux/wpa-controller/ProtocolHostapd.cxx index 288b3fce..d9c252c8 100644 --- a/src/linux/wpa-controller/ProtocolHostapd.cxx +++ b/src/linux/wpa-controller/ProtocolHostapd.cxx @@ -87,54 +87,54 @@ Wpa::WpaPreSharedKeyPropertyKeyAndValue(const WpaPreSharedKey& wpaPreSharedKey) return std::make_pair(propertyName, std::move(propertyValue)); } -WpaKeyManagement +std::vector Wpa::WpaKeyManagementFromPropertyValue(std::string_view wpaKeyManagementProperty) noexcept { std::string wpaKeyManagementString(wpaKeyManagementProperty); std::istringstream wpaKeyManagementStream(wpaKeyManagementString); - WpaKeyManagement result{ WpaKeyManagement::Unknown }; + std::vector wpaKeyManagements{}; for (std::string wpaKeyManagement; wpaKeyManagementStream >> wpaKeyManagement;) { if (wpaKeyManagement == "WPA-EAP") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Ieee8021x)); + wpaKeyManagements.push_back(WpaKeyManagement::Ieee8021x); } else if (wpaKeyManagement == "WPA-PSK") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Psk)); + wpaKeyManagements.push_back(WpaKeyManagement::Psk); } else if (wpaKeyManagement == "FT-EAP") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtIeee8021x)); + wpaKeyManagements.push_back(WpaKeyManagement::FtIeee8021x); } else if (wpaKeyManagement == "FT-PSK") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtPsk)); + wpaKeyManagements.push_back(WpaKeyManagement::FtPsk); } else if (wpaKeyManagement == "WPA-EAP-SHA256") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Ieee8021xSha256)); + wpaKeyManagements.push_back(WpaKeyManagement::Ieee8021xSha256); } else if (wpaKeyManagement == "WPA-PSK-SHA256") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::PskSha256)); + wpaKeyManagements.push_back(WpaKeyManagement::PskSha256); } else if (wpaKeyManagement == "SAE") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Sae)); + wpaKeyManagements.push_back(WpaKeyManagement::Sae); } else if (wpaKeyManagement == "FT-SAE") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtSae)); + wpaKeyManagements.push_back(WpaKeyManagement::FtSae); } else if (wpaKeyManagement == "OSEN") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Osen)); + wpaKeyManagements.push_back(WpaKeyManagement::Osen); } else if (wpaKeyManagement == "WPA-EAP-SUITE-B") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Ieee8021xSuiteB)); + wpaKeyManagements.push_back(WpaKeyManagement::Ieee8021xSuiteB); } else if (wpaKeyManagement == "WPA-EAP-SUITE-B-192") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Ieee8021xSuiteB192)); + wpaKeyManagements.push_back(WpaKeyManagement::Ieee8021xSuiteB192); } else if (wpaKeyManagement == "FILS-SHA256") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FilsSha256)); + wpaKeyManagements.push_back(WpaKeyManagement::FilsSha256); } else if (wpaKeyManagement == "FILS-SHA384") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FilsSha384)); + wpaKeyManagements.push_back(WpaKeyManagement::FilsSha384); } else if (wpaKeyManagement == "FT-FILS-SHA256") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtFilsSha256)); + wpaKeyManagements.push_back(WpaKeyManagement::FtFilsSha256); } else if (wpaKeyManagement == "FT-FILS-SHA384") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtFilsSha384)); + wpaKeyManagements.push_back(WpaKeyManagement::FtFilsSha384); } else if (wpaKeyManagement == "OWE") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Owe)); + wpaKeyManagements.push_back(WpaKeyManagement::Owe); } else if (wpaKeyManagement == "DPP") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Dpp)); + wpaKeyManagements.push_back(WpaKeyManagement::Dpp); } else if (wpaKeyManagement == "FT-EAP-SHA384") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtIeee8021xSha384)); + wpaKeyManagements.push_back(WpaKeyManagement::FtIeee8021xSha384); } else if (wpaKeyManagement == "PASN") { - result = static_cast(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Pasn)); + wpaKeyManagements.push_back(WpaKeyManagement::Pasn); } } - return result; + return wpaKeyManagements; } diff --git a/src/linux/wpa-controller/include/Wpa/ProtocolHostapd.hxx b/src/linux/wpa-controller/include/Wpa/ProtocolHostapd.hxx index 11364e4f..6250a26e 100644 --- a/src/linux/wpa-controller/include/Wpa/ProtocolHostapd.hxx +++ b/src/linux/wpa-controller/include/Wpa/ProtocolHostapd.hxx @@ -548,7 +548,7 @@ struct HostapdBssConfiguration // std::optional MultiApBackhaulWpaPsk; WpaSecurityProtocol Wpa; - WpaKeyManagement WpaKeyMgmt; + std::vector WpaKeyMgmt; WpaCipher GroupCipher; WpaCipher RsnPairwiseCipher; WpaCipher WpaPairwiseCipher; @@ -835,9 +835,9 @@ WpaKeyManagementPropertyValue(WpaKeyManagement wpaKeyManagement) noexcept * This string may have several whitespace-separated values, such as "WPA-PSK SAE". * * @param wpaKeyManagementProperty The hostapd property value string to convert. - * @return WpaKeyManagement The corresponding WpaKeyManagement value. + * @return std::vector The corresponding WpaKeyManagement values. */ -WpaKeyManagement +std::vector WpaKeyManagementFromPropertyValue(std::string_view wpaKeyManagementProperty) noexcept; /**