wifi: Remove unneeded frame type stored by MultiLinkElement

This commit is contained in:
Stefano Avallone
2023-04-17 21:07:58 +02:00
committed by Stefano Avallone
parent 746311c354
commit 6e7733d37b
8 changed files with 49 additions and 148 deletions

View File

@@ -662,7 +662,7 @@ ApWifiMac::GetMultiLinkElement(uint8_t linkId, WifiMacType frameType, const Mac4
NS_LOG_FUNCTION(this << +linkId << frameType << to);
NS_ABORT_IF(GetNLinks() == 1);
MultiLinkElement mle(MultiLinkElement::BASIC_VARIANT, frameType);
MultiLinkElement mle(MultiLinkElement::BASIC_VARIANT);
mle.SetMldMacAddress(GetAddress());
mle.SetLinkIdInfo(linkId);
mle.SetBssParamsChangeCount(0);

View File

@@ -222,15 +222,14 @@ CommonInfoBasicMle::DecodeEmlsrTransitionDelay(uint8_t value)
/**
* MultiLinkElement
*/
MultiLinkElement::MultiLinkElement(WifiMacType frameType, ContainingFrame frame)
MultiLinkElement::MultiLinkElement(ContainingFrame frame)
: m_containingFrame(frame),
m_frameType(frameType),
m_commonInfo(std::in_place_type<std::monostate>) // initialize as UNSET
{
}
MultiLinkElement::MultiLinkElement(Variant variant, WifiMacType frameType, ContainingFrame frame)
: MultiLinkElement(frameType, frame)
MultiLinkElement::MultiLinkElement(Variant variant, ContainingFrame frame)
: MultiLinkElement(frame)
{
NS_ASSERT(variant != UNSET);
SetVariant(variant);
@@ -495,10 +494,8 @@ MultiLinkElement::GetTransitionTimeout() const
return MicroSeconds(1 << (6 + emlCapabilities->transitionTimeout));
}
MultiLinkElement::PerStaProfileSubelement::PerStaProfileSubelement(Variant variant,
WifiMacType frameType)
MultiLinkElement::PerStaProfileSubelement::PerStaProfileSubelement(Variant variant)
: m_variant(variant),
m_frameType(frameType),
m_staControl(0)
{
}
@@ -506,7 +503,6 @@ MultiLinkElement::PerStaProfileSubelement::PerStaProfileSubelement(Variant varia
MultiLinkElement::PerStaProfileSubelement::PerStaProfileSubelement(
const PerStaProfileSubelement& perStaProfile)
: m_variant(perStaProfile.m_variant),
m_frameType(perStaProfile.m_frameType),
m_staControl(perStaProfile.m_staControl),
m_staMacAddress(perStaProfile.m_staMacAddress)
{
@@ -536,7 +532,6 @@ MultiLinkElement::PerStaProfileSubelement::operator=(const PerStaProfileSubeleme
}
m_variant = perStaProfile.m_variant;
m_frameType = perStaProfile.m_frameType;
m_staControl = perStaProfile.m_staControl;
m_staMacAddress = perStaProfile.m_staMacAddress;
@@ -608,52 +603,35 @@ void
MultiLinkElement::PerStaProfileSubelement::SetAssocRequest(
const std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>& assoc)
{
switch (m_frameType)
{
case WIFI_MAC_MGT_ASSOCIATION_REQUEST:
m_staProfile =
std::make_unique<MgtAssocRequestHeader>(std::get<MgtAssocRequestHeader>(assoc));
break;
case WIFI_MAC_MGT_REASSOCIATION_REQUEST:
m_staProfile =
std::make_unique<MgtReassocRequestHeader>(std::get<MgtReassocRequestHeader>(assoc));
break;
default:
NS_ABORT_MSG("Invalid frame type: " << m_frameType);
}
std::visit(
[&](auto&& frame) {
m_staProfile = std::make_unique<std::decay_t<decltype(frame)>>(frame);
},
assoc);
}
void
MultiLinkElement::PerStaProfileSubelement::SetAssocRequest(
std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>&& assoc)
{
switch (m_frameType)
{
case WIFI_MAC_MGT_ASSOCIATION_REQUEST:
m_staProfile = std::make_unique<MgtAssocRequestHeader>(
std::move(std::get<MgtAssocRequestHeader>(assoc)));
break;
case WIFI_MAC_MGT_REASSOCIATION_REQUEST:
m_staProfile = std::make_unique<MgtReassocRequestHeader>(
std::move(std::get<MgtReassocRequestHeader>(assoc)));
break;
default:
NS_ABORT_MSG("Invalid frame type: " << m_frameType);
}
std::visit(
[&](auto&& frame) {
using T = std::decay_t<decltype(frame)>;
m_staProfile = std::make_unique<T>(std::forward<T>(frame));
},
assoc);
}
bool
MultiLinkElement::PerStaProfileSubelement::HasAssocRequest() const
{
return m_frameType == WIFI_MAC_MGT_ASSOCIATION_REQUEST &&
std::holds_alternative<std::unique_ptr<MgtAssocRequestHeader>>(m_staProfile);
return std::holds_alternative<std::unique_ptr<MgtAssocRequestHeader>>(m_staProfile);
}
bool
MultiLinkElement::PerStaProfileSubelement::HasReassocRequest() const
{
return m_frameType == WIFI_MAC_MGT_REASSOCIATION_REQUEST &&
std::holds_alternative<std::unique_ptr<MgtReassocRequestHeader>>(m_staProfile);
return std::holds_alternative<std::unique_ptr<MgtReassocRequestHeader>>(m_staProfile);
}
AssocReqRefVariant
@@ -670,25 +648,19 @@ MultiLinkElement::PerStaProfileSubelement::GetAssocRequest() const
void
MultiLinkElement::PerStaProfileSubelement::SetAssocResponse(const MgtAssocResponseHeader& assoc)
{
NS_ABORT_IF(m_frameType != WIFI_MAC_MGT_ASSOCIATION_RESPONSE &&
m_frameType != WIFI_MAC_MGT_REASSOCIATION_RESPONSE);
m_staProfile = std::make_unique<MgtAssocResponseHeader>(assoc);
}
void
MultiLinkElement::PerStaProfileSubelement::SetAssocResponse(MgtAssocResponseHeader&& assoc)
{
NS_ABORT_IF(m_frameType != WIFI_MAC_MGT_ASSOCIATION_RESPONSE &&
m_frameType != WIFI_MAC_MGT_REASSOCIATION_RESPONSE);
m_staProfile = std::make_unique<MgtAssocResponseHeader>(std::move(assoc));
}
bool
MultiLinkElement::PerStaProfileSubelement::HasAssocResponse() const
{
return (m_frameType == WIFI_MAC_MGT_ASSOCIATION_RESPONSE ||
m_frameType == WIFI_MAC_MGT_REASSOCIATION_RESPONSE) &&
std::holds_alternative<std::unique_ptr<MgtAssocResponseHeader>>(m_staProfile);
return std::holds_alternative<std::unique_ptr<MgtAssocResponseHeader>>(m_staProfile);
}
MgtAssocResponseHeader&
@@ -824,8 +796,7 @@ MultiLinkElement::AddPerStaProfileSubelement()
{
auto variant = GetVariant();
NS_ABORT_IF(variant == UNSET);
NS_ABORT_IF(m_frameType == WIFI_MAC_DATA);
m_perStaProfileSubelements.emplace_back(variant, m_frameType);
m_perStaProfileSubelements.emplace_back(variant);
}
std::size_t

View File

@@ -193,18 +193,16 @@ class MultiLinkElement : public WifiInformationElement
/**
* Construct a Multi-Link Element with no variant set.
*
* \param frameType the type of the frame containing the Multi-Link Element
* \param frame the management frame containing this Multi-Link Element
*/
MultiLinkElement(WifiMacType frameType, ContainingFrame frame = {});
MultiLinkElement(ContainingFrame frame = {});
/**
* Constructor
*
* \param variant the Multi-Link element variant (cannot be UNSET)
* \param frameType the type of the frame containing the Multi-Link Element
* \param frame the management frame containing this Multi-Link Element
*/
MultiLinkElement(Variant variant, WifiMacType frameType, ContainingFrame frame = {});
MultiLinkElement(Variant variant, ContainingFrame frame = {});
WifiInformationElementId ElementId() const override;
WifiInformationElementId ElementIdExt() const override;
@@ -429,9 +427,8 @@ class MultiLinkElement : public WifiInformationElement
* Constructor
*
* \param variant the Multi-Link element variant
* \param frameType the type of the frame containing the Multi-Link Element
*/
PerStaProfileSubelement(Variant variant, WifiMacType frameType);
PerStaProfileSubelement(Variant variant);
/**
* Copy constructor performing a deep copy of the object
@@ -570,7 +567,6 @@ class MultiLinkElement : public WifiInformationElement
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
Variant m_variant; //!< Multi-Link element variant
WifiMacType m_frameType; //!< type of the frame containing the Multi-Link Element
uint16_t m_staControl; //!< STA Control field
Mac48Address m_staMacAddress; //!< STA MAC address
std::variant<std::monostate,
@@ -614,8 +610,6 @@ class MultiLinkElement : public WifiInformationElement
*/
void SetVariant(Variant variant);
WifiMacType m_frameType; //!< type of the frame containing the Multi-Link Element
/// Typedef for structure holding a Common Info field
using CommonInfo = std::variant<CommonInfoBasicMle,
// TODO Add other variants

View File

@@ -132,12 +132,6 @@ MgtProbeResponseHeader::DeserializeImpl(Buffer::Iterator start)
return distance + WifiMgtHeader<MgtProbeResponseHeader, ProbeResponseElems>::DeserializeImpl(i);
}
void
MgtProbeResponseHeader::InitForDeserialization(std::optional<MultiLinkElement>& optElem)
{
optElem.emplace(WIFI_MAC_MGT_PROBE_RESPONSE);
}
/***********************************************************
* Beacons
***********************************************************/
@@ -155,12 +149,6 @@ MgtBeaconHeader::GetTypeId()
return tid;
}
void
MgtBeaconHeader::InitForDeserialization(std::optional<MultiLinkElement>& optElem)
{
optElem.emplace(WIFI_MAC_MGT_BEACON);
}
/***********************************************************
* Assoc Request
***********************************************************/
@@ -293,13 +281,6 @@ MgtAssocRequestHeader::DeserializeFromPerStaProfileImpl(Buffer::Iterator start,
DeserializeFromPerStaProfileImpl(i, length - distance, frame);
}
void
MgtAssocRequestHeader::InitForDeserialization(std::optional<MultiLinkElement>& optElem)
{
optElem.emplace(WIFI_MAC_MGT_ASSOCIATION_REQUEST);
optElem->m_containingFrame = *this;
}
/***********************************************************
* Ressoc Request
***********************************************************/
@@ -449,13 +430,6 @@ MgtReassocRequestHeader::DeserializeFromPerStaProfileImpl(Buffer::Iterator start
DeserializeFromPerStaProfileImpl(i, length - distance, frame);
}
void
MgtReassocRequestHeader::InitForDeserialization(std::optional<MultiLinkElement>& optElem)
{
optElem.emplace(WIFI_MAC_MGT_REASSOCIATION_REQUEST);
optElem->m_containingFrame = *this;
}
/***********************************************************
* Assoc/Reassoc Response
***********************************************************/
@@ -611,13 +585,6 @@ MgtAssocResponseHeader::DeserializeFromPerStaProfileImpl(Buffer::Iterator start,
DeserializeFromPerStaProfileImpl(i, length - distance, frame);
}
void
MgtAssocResponseHeader::InitForDeserialization(std::optional<MultiLinkElement>& optElem)
{
optElem.emplace(WIFI_MAC_MGT_ASSOCIATION_RESPONSE);
optElem->m_containingFrame = *this;
}
/**********************************************************
* ActionFrame
**********************************************************/

View File

@@ -228,14 +228,6 @@ class MgtAssocRequestHeader
const MgtAssocRequestHeader& frame);
private:
using WifiMgtHeader<MgtAssocRequestHeader, AssocRequestElems>::InitForDeserialization;
/**
* \param optElem the MultiLinkElement object to initialize for deserializing the
* information element into
*/
void InitForDeserialization(std::optional<MultiLinkElement>& optElem);
CapabilityInformation m_capability; //!< Capability information
uint16_t m_listenInterval{0}; //!< listen interval
};
@@ -328,14 +320,6 @@ class MgtReassocRequestHeader
const MgtReassocRequestHeader& frame);
private:
using WifiMgtHeader<MgtReassocRequestHeader, AssocRequestElems>::InitForDeserialization;
/**
* \param optElem the MultiLinkElement object to initialize for deserializing the
* information element into
*/
void InitForDeserialization(std::optional<MultiLinkElement>& optElem);
Mac48Address m_currentApAddr; //!< Address of the current access point
CapabilityInformation m_capability; //!< Capability information
uint16_t m_listenInterval{0}; //!< listen interval
@@ -435,14 +419,6 @@ class MgtAssocResponseHeader
const MgtAssocResponseHeader& frame);
private:
using WifiMgtHeader<MgtAssocResponseHeader, AssocResponseElems>::InitForDeserialization;
/**
* \param optElem the MultiLinkElement object to initialize for deserializing the
* information element into
*/
void InitForDeserialization(std::optional<MultiLinkElement>& optElem);
CapabilityInformation m_capability; //!< Capability information
StatusCode m_code; //!< Status code
uint16_t m_aid{0}; //!< AID
@@ -523,14 +499,6 @@ class MgtProbeResponseHeader : public WifiMgtHeader<MgtProbeResponseHeader, Prob
uint32_t DeserializeImpl(Buffer::Iterator start);
private:
using WifiMgtHeader<MgtProbeResponseHeader, ProbeResponseElems>::InitForDeserialization;
/**
* \param optElem the MultiLinkElement object to initialize for deserializing the
* information element into
*/
void InitForDeserialization(std::optional<MultiLinkElement>& optElem);
uint64_t m_timestamp; //!< Timestamp
uint64_t m_beaconInterval; //!< Beacon interval
CapabilityInformation m_capability; //!< Capability information
@@ -550,15 +518,6 @@ class MgtBeaconHeader : public MgtProbeResponseHeader
* \return The TypeId.
*/
static TypeId GetTypeId();
private:
// using WifiMgtHeader<MgtBeaconHeader, ProbeResponseElems>::InitForDeserialization;
/**
* \param optElem the MultiLinkElement object to initialize for deserializing the
* information element into
*/
void InitForDeserialization(std::optional<MultiLinkElement>& optElem);
};
/****************************

View File

@@ -347,9 +347,7 @@ StaWifiMac::GetMultiLinkElement(bool isReassoc, uint8_t linkId) const
{
NS_LOG_FUNCTION(this << isReassoc << +linkId);
MultiLinkElement multiLinkElement(MultiLinkElement::BASIC_VARIANT,
isReassoc ? WIFI_MAC_MGT_REASSOCIATION_REQUEST
: WIFI_MAC_MGT_ASSOCIATION_REQUEST);
MultiLinkElement multiLinkElement(MultiLinkElement::BASIC_VARIANT);
// The Common info field of the Basic Multi-Link element carried in the (Re)Association
// Request frame shall include the MLD MAC address, the MLD Capabilities and Operations,
// and the EML Capabilities subfields, and shall not include the Link ID Info, the BSS

View File

@@ -277,6 +277,8 @@ class MgtHeaderInPerStaProfile<Derived, std::tuple<Elems...>>
void CopyIesFromContainingFrame(const Derived& frame);
protected:
using WifiMgtHeader<Derived, std::tuple<Elems...>>::InitForDeserialization;
/**
* \param frame the frame containing the Multi-Link Element
* \return the number of bytes that are needed to serialize this header into a Per-STA Profile
@@ -309,6 +311,12 @@ class MgtHeaderInPerStaProfile<Derived, std::tuple<Elems...>>
*/
void SetMleContainingFrame() const;
/**
* \param optElem the MultiLinkElement object to initialize for deserializing the
* information element into
*/
void InitForDeserialization(std::optional<MultiLinkElement>& optElem);
private:
using WifiMgtHeader<Derived, std::tuple<Elems...>>::DoDeserialize;
using WifiMgtHeader<Derived, std::tuple<Elems...>>::m_elements;
@@ -382,6 +390,14 @@ WifiMgtHeader<Derived, std::tuple<Elems...>>::InitForDeserialization(
}
}
template <typename Derived, typename... Elems>
void
MgtHeaderInPerStaProfile<Derived, std::tuple<Elems...>>::InitForDeserialization(
std::optional<MultiLinkElement>& optElem)
{
optElem.emplace(*static_cast<const Derived*>(this));
}
namespace internal
{

View File

@@ -63,14 +63,12 @@ class BasicMultiLinkElementTest : public HeaderSerializationTestCase
private:
void DoRun() override;
WifiMacType m_frameType; //!< the type of frame possibly included in the MLE
MgtAssocRequestHeader m_outerAssoc; //!< the frame containing the MLE
};
BasicMultiLinkElementTest::BasicMultiLinkElementTest()
: HeaderSerializationTestCase(
"Check serialization and deserialization of Basic variant Multi-Link elements"),
m_frameType(WIFI_MAC_MGT_ASSOCIATION_REQUEST)
"Check serialization and deserialization of Basic variant Multi-Link elements")
{
}
@@ -83,7 +81,7 @@ BasicMultiLinkElementTest::GetMultiLinkElement(
const CommonInfoBasicMle& commonInfo,
std::vector<MultiLinkElement::PerStaProfileSubelement> subelements)
{
MultiLinkElement mle(MultiLinkElement::BASIC_VARIANT, m_frameType);
MultiLinkElement mle(MultiLinkElement::BASIC_VARIANT);
mle.SetMldMacAddress(commonInfo.m_mldMacAddress);
if (commonInfo.m_linkIdInfo.has_value())
{
@@ -128,17 +126,17 @@ BasicMultiLinkElementTest::DoRun()
};
// Common Info with MLD MAC address
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}), m_frameType);
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}));
commonInfo.m_linkIdInfo = 3;
// Adding Link ID Info
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}), m_frameType);
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}));
commonInfo.m_bssParamsChangeCount = 1;
// Adding BSS Parameters Change Count
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}), m_frameType);
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}));
commonInfo.m_mediumSyncDelayInfo =
CommonInfoBasicMle::MediumSyncDelayInfo{.mediumSyncDuration = 1,
@@ -146,7 +144,7 @@ BasicMultiLinkElementTest::DoRun()
.mediumSyncMaxNTxops = 5};
// Adding Medium Sync Delay Information
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}), m_frameType);
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}));
commonInfo.m_emlCapabilities = CommonInfoBasicMle::EmlCapabilities{.emlsrSupport = 1,
.emlsrPaddingDelay = 4,
@@ -154,7 +152,7 @@ BasicMultiLinkElementTest::DoRun()
.transitionTimeout = 10};
// Adding Medium Sync Delay Information
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}), m_frameType);
TestHeaderSerialization(GetMultiLinkElement(commonInfo, {}));
/**
* To test the serialization/deserialization of Per-STA Profile subelements, we include
@@ -204,8 +202,7 @@ BasicMultiLinkElementTest::DoRun()
// to the containing frame, so that all the IEs are inherited and the Per-STA Profile
// does not contain any Information Element.
MultiLinkElement::PerStaProfileSubelement perStaProfile1(MultiLinkElement::BASIC_VARIANT,
m_frameType);
MultiLinkElement::PerStaProfileSubelement perStaProfile1(MultiLinkElement::BASIC_VARIANT);
perStaProfile1.SetLinkId(3);
perStaProfile1.SetCompleteProfile();
perStaProfile1.SetAssocRequest(m_outerAssoc);
@@ -233,8 +230,7 @@ BasicMultiLinkElementTest::DoRun()
// EhtCapabilities IE is present in the containing frame but not in the Per-STA Profile
// subelement, hence it is listed in a Non-Inheritance element
MultiLinkElement::PerStaProfileSubelement perStaProfile2(MultiLinkElement::BASIC_VARIANT,
m_frameType);
MultiLinkElement::PerStaProfileSubelement perStaProfile2(MultiLinkElement::BASIC_VARIANT);
perStaProfile2.SetLinkId(0);
perStaProfile2.SetCompleteProfile();
perStaProfile2.SetStaMacAddress(Mac48Address("ba:98:76:54:32:10"));