wifi: Ensure frequency segments belong to the same band

This commit is contained in:
Sébastien Deronne
2023-04-02 14:18:58 +02:00
parent 26d15e41f6
commit 5ab82d0286

View File

@@ -358,16 +358,23 @@ WifiPhyOperatingChannel::Set(const std::vector<FrequencyChannelInfo>& 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) ||