Skip to content

Commit

Permalink
Populate phy types.
Browse files Browse the repository at this point in the history
  • Loading branch information
abeltrano committed Jan 24, 2024
1 parent c28928b commit 9481e28
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/common/tools/cli/NetRemoteCliHandlerOperations.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ NetRemoteAccessPointCapabilitiesToString(const Microsoft::Net::Wifi::Dot11Access

std::stringstream ss;

constexpr auto PhyTypePrefixLength = std::size(std::string_view("Dot11PhyType"));
ss << indent0
<< "Phy Types:";
<< "Phy Types: ";
for (const auto& phyType : accessPointCapabilities.phytypes()) {
ss << '\n'
<< indent1
<< magic_enum::enum_name(static_cast<Microsoft::Net::Wifi::Dot11PhyType>(phyType));
std::string_view phyTypeName(magic_enum::enum_name(static_cast<Microsoft::Net::Wifi::Dot11PhyType>(phyType)));
phyTypeName.remove_prefix(PhyTypePrefixLength);
if (phyType != accessPointCapabilities.phytypes()[0]) {
ss << ' ';
}
ss << phyTypeName;
}

constexpr auto BandPrefixLength = std::size(std::string_view("Dot11FrequencyBand"));
Expand Down
30 changes: 30 additions & 0 deletions src/linux/wifi/core/AccessPointControllerLinux.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,33 @@ Nl80211BandToIeee80211FrequencyBand(nl80211_band nl80211Band) noexcept
return Ieee80211FrequencyBand::Unknown;
}
}

std::vector<Ieee80211Protocol>
Nl80211WiphyToIeee80211Protocols(const Nl80211Wiphy& nl80211Wiphy)
{
// Ieee80211 B & G are always supported.
std::vector<Ieee80211Protocol> protocols{
Ieee80211Protocol::B,
Ieee80211Protocol::G,
};

for (const auto& band : std::views::values(nl80211Wiphy.Bands)) {
if (band.HtCapabilities != 0) {
protocols.push_back(Ieee80211Protocol::N);
}
if (band.VhtCapabilities != 0) {
protocols.push_back(Ieee80211Protocol::AC);
}
// TODO: once Nl80211WiphyBand is updated to support HE (AX) and EHT (BE), add them here.
}


// Remove duplicates.
std::ranges::sort(protocols);
protocols.erase(std::ranges::begin(std::ranges::unique(protocols)), std::ranges::end(protocols));

return protocols;
}
} // namespace detail

Ieee80211AccessPointCapabilities
Expand All @@ -55,6 +82,9 @@ AccessPointControllerLinux::GetCapabilities()

Ieee80211AccessPointCapabilities capabilities;

// Convert protocols.
capabilities.Protocols = detail::Nl80211WiphyToIeee80211Protocols(wiphy.value());

// Convert frequency bands.
capabilities.FrequencyBands = std::vector<Ieee80211FrequencyBand>(std::size(wiphy->Bands));
std::ranges::transform(std::views::keys(wiphy->Bands), std::begin(capabilities.FrequencyBands), detail::Nl80211BandToIeee80211FrequencyBand);
Expand Down

0 comments on commit 9481e28

Please sign in to comment.