From 5ab82d0286bf321a68e3c8deb23e04feb042dc5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sun, 2 Apr 2023 14:18:58 +0200 Subject: [PATCH] wifi: Ensure frequency segments belong to the same band --- src/wifi/model/wifi-phy-operating-channel.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index d66c329e7..63c052f5c 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -358,16 +358,23 @@ WifiPhyOperatingChannel::Set(const std::vector& segments, { const auto freq = (*it)->frequency; const auto width = (*it)->width; + const auto band = (*it)->band; const auto maxFreq = freq + (width / 2); ++it; const auto nextFreq = (*it)->frequency; const auto nextWidth = (*it)->width; + const auto nextBand = (*it)->band; const auto nextMinFreq = nextFreq - (nextWidth / 2); if (maxFreq >= nextMinFreq) { throw std::runtime_error( "WifiPhyOperatingChannel is invalid: segments cannot be adjacent nor overlap"); } + if (band != nextBand) + { + throw std::runtime_error("WifiPhyOperatingChannel is invalid: all segments shall " + "belong to the same band"); + } } if ((channelIts.size() > 2) ||