From 5534fcf4b6bfcac9e1281f7feb7e3ed2de44d9e4 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sat, 19 Mar 2022 21:51:31 +0100 Subject: [PATCH] wifi: Enable to call WifiPhyOperatingChannel::FindFirst() with unspecified standard --- src/wifi/model/wifi-phy-operating-channel.cc | 12 ++++++------ src/wifi/model/wifi-phy-operating-channel.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index 0d4df8fab..5d2844add 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -347,7 +347,7 @@ WifiPhyOperatingChannel::FindFirst (uint8_t number, uint16_t frequency, uint16_t { return false; } - if (std::get<3> (channel) != GetFrequencyChannelType (standard)) + if (standard != WIFI_STANDARD_UNSPECIFIED && std::get<3> (channel) != GetFrequencyChannelType (standard)) { return false; } @@ -359,12 +359,12 @@ WifiPhyOperatingChannel::FindFirst (uint8_t number, uint16_t frequency, uint16_t }; // Do not search for a channel matching the specified criteria if the given PHY band - // is not allowed for the given standard or the given channel width is not allowed - // for the given standard + // is not allowed for the given standard (if any) or the given channel width is not + // allowed for the given standard (if any) if (const auto standardIt = wifiStandards.find (standard); - standardIt == wifiStandards.cend () - || std::find (standardIt->second.cbegin (), standardIt->second.cend (), band) == standardIt->second.cend () - || width > GetMaximumChannelWidth (standard)) + standardIt != wifiStandards.cend () + && (std::find (standardIt->second.cbegin (), standardIt->second.cend (), band) == standardIt->second.cend () + || width > GetMaximumChannelWidth (standard))) { return m_frequencyChannels.cend (); } diff --git a/src/wifi/model/wifi-phy-operating-channel.h b/src/wifi/model/wifi-phy-operating-channel.h index d4470b0c7..63f6cd3ed 100644 --- a/src/wifi/model/wifi-phy-operating-channel.h +++ b/src/wifi/model/wifi-phy-operating-channel.h @@ -226,7 +226,8 @@ public: * \param number the channel number (use 0 to leave it unspecified) * \param frequency the channel center frequency in MHz (use 0 to leave it unspecified) * \param width the channel width in MHz (use 0 to leave it unspecified) - * \param standard the standard + * \param standard the standard (use WIFI_STANDARD_UNSPECIFIED not to check whether a + * channel is suitable for a specific standard) * \param band the PHY band * \param start an iterator pointing to the channel to start the search with * \return an iterator pointing to the found channel, if any, or to past-the-end