From 11e430616c908681354ef4e042ba978e555cfd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Thu, 1 Jun 2023 21:44:46 +0200 Subject: [PATCH] wifi: Extend operating channel class to return the channel width type --- src/wifi/model/wifi-phy-operating-channel.cc | 28 ++++++++++++++++++++ src/wifi/model/wifi-phy-operating-channel.h | 6 +++++ 2 files changed, 34 insertions(+) diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index 1b898b6c3..c43700e01 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -441,6 +441,34 @@ WifiPhyOperatingChannel::Is80211p() const return std::get(*m_channelIt) == WIFI_PHY_80211p_CHANNEL; } +WifiChannelWidthType +WifiPhyOperatingChannel::GetWidthType() const +{ + NS_ASSERT(IsSet()); + switch (GetWidth()) + { + case 20: + return WifiChannelWidthType::CW_20MHZ; + case 22: + return WifiChannelWidthType::CW_22MHZ; + case 5: + return WifiChannelWidthType::CW_5MHZ; + case 10: + return WifiChannelWidthType::CW_10MHZ; + case 40: + return WifiChannelWidthType::CW_40MHZ; + case 80: + return WifiChannelWidthType::CW_80MHZ; + case 160: + return WifiChannelWidthType::CW_160MHZ; + case 2160: + return WifiChannelWidthType::CW_2160MHZ; + case 0: + default: + return WifiChannelWidthType::UNKNOWN; + } +} + uint8_t WifiPhyOperatingChannel::GetPrimaryChannelIndex(ChannelWidthMhz primaryChannelWidth) const { diff --git a/src/wifi/model/wifi-phy-operating-channel.h b/src/wifi/model/wifi-phy-operating-channel.h index 7a43f2986..130d4fa98 100644 --- a/src/wifi/model/wifi-phy-operating-channel.h +++ b/src/wifi/model/wifi-phy-operating-channel.h @@ -154,6 +154,12 @@ class WifiPhyOperatingChannel * \return the width of the whole operating channel (in MHz) */ ChannelWidthMhz GetWidth() const; + /** + * Return the width type of the operating channel. + * + * \return the width type of the operating channel + */ + WifiChannelWidthType GetWidthType() const; /** * Return the PHY band of the operating channel *