Skip to content

Commit

Permalink
Store vector of WpaKeyManagement
Browse files Browse the repository at this point in the history
  • Loading branch information
corbin-phipps committed Jul 2, 2024
1 parent 227b788 commit 577bd1e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
44 changes: 22 additions & 22 deletions src/linux/wpa-controller/ProtocolHostapd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -87,54 +87,54 @@ Wpa::WpaPreSharedKeyPropertyKeyAndValue(const WpaPreSharedKey& wpaPreSharedKey)
return std::make_pair(propertyName, std::move(propertyValue));
}

WpaKeyManagement
std::vector<WpaKeyManagement>
Wpa::WpaKeyManagementFromPropertyValue(std::string_view wpaKeyManagementProperty) noexcept
{
std::string wpaKeyManagementString(wpaKeyManagementProperty);
std::istringstream wpaKeyManagementStream(wpaKeyManagementString);
WpaKeyManagement result{ WpaKeyManagement::Unknown };
std::vector<WpaKeyManagement> wpaKeyManagements{};

for (std::string wpaKeyManagement; wpaKeyManagementStream >> wpaKeyManagement;) {
if (wpaKeyManagement == "WPA-EAP") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Ieee8021x));
wpaKeyManagements.push_back(WpaKeyManagement::Ieee8021x);
} else if (wpaKeyManagement == "WPA-PSK") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Psk));
wpaKeyManagements.push_back(WpaKeyManagement::Psk);
} else if (wpaKeyManagement == "FT-EAP") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtIeee8021x));
wpaKeyManagements.push_back(WpaKeyManagement::FtIeee8021x);
} else if (wpaKeyManagement == "FT-PSK") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtPsk));
wpaKeyManagements.push_back(WpaKeyManagement::FtPsk);
} else if (wpaKeyManagement == "WPA-EAP-SHA256") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Ieee8021xSha256));
wpaKeyManagements.push_back(WpaKeyManagement::Ieee8021xSha256);
} else if (wpaKeyManagement == "WPA-PSK-SHA256") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::PskSha256));
wpaKeyManagements.push_back(WpaKeyManagement::PskSha256);
} else if (wpaKeyManagement == "SAE") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Sae));
wpaKeyManagements.push_back(WpaKeyManagement::Sae);
} else if (wpaKeyManagement == "FT-SAE") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtSae));
wpaKeyManagements.push_back(WpaKeyManagement::FtSae);
} else if (wpaKeyManagement == "OSEN") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Osen));
wpaKeyManagements.push_back(WpaKeyManagement::Osen);
} else if (wpaKeyManagement == "WPA-EAP-SUITE-B") {
result = static_cast<WpaKeyManagement>(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<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Ieee8021xSuiteB192));
wpaKeyManagements.push_back(WpaKeyManagement::Ieee8021xSuiteB192);
} else if (wpaKeyManagement == "FILS-SHA256") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FilsSha256));
wpaKeyManagements.push_back(WpaKeyManagement::FilsSha256);
} else if (wpaKeyManagement == "FILS-SHA384") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FilsSha384));
wpaKeyManagements.push_back(WpaKeyManagement::FilsSha384);
} else if (wpaKeyManagement == "FT-FILS-SHA256") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtFilsSha256));
wpaKeyManagements.push_back(WpaKeyManagement::FtFilsSha256);
} else if (wpaKeyManagement == "FT-FILS-SHA384") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtFilsSha384));
wpaKeyManagements.push_back(WpaKeyManagement::FtFilsSha384);
} else if (wpaKeyManagement == "OWE") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Owe));
wpaKeyManagements.push_back(WpaKeyManagement::Owe);
} else if (wpaKeyManagement == "DPP") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Dpp));
wpaKeyManagements.push_back(WpaKeyManagement::Dpp);
} else if (wpaKeyManagement == "FT-EAP-SHA384") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::FtIeee8021xSha384));
wpaKeyManagements.push_back(WpaKeyManagement::FtIeee8021xSha384);
} else if (wpaKeyManagement == "PASN") {
result = static_cast<WpaKeyManagement>(std::to_underlying(result) | std::to_underlying(WpaKeyManagement::Pasn));
wpaKeyManagements.push_back(WpaKeyManagement::Pasn);
}
}

return result;
return wpaKeyManagements;
}
6 changes: 3 additions & 3 deletions src/linux/wpa-controller/include/Wpa/ProtocolHostapd.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ struct HostapdBssConfiguration
// std::optional<WpaPreSharedKey> MultiApBackhaulWpaPsk;

WpaSecurityProtocol Wpa;
WpaKeyManagement WpaKeyMgmt;
std::vector<WpaKeyManagement> WpaKeyMgmt;
WpaCipher GroupCipher;
WpaCipher RsnPairwiseCipher;
WpaCipher WpaPairwiseCipher;
Expand Down Expand Up @@ -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<WpaKeyManagement> The corresponding WpaKeyManagement values.
*/
WpaKeyManagement
std::vector<WpaKeyManagement>
WpaKeyManagementFromPropertyValue(std::string_view wpaKeyManagementProperty) noexcept;

/**
Expand Down

0 comments on commit 577bd1e

Please sign in to comment.