From fb5ed767bee902e367b51bb78ed030308a341eff Mon Sep 17 00:00:00 2001 From: Sharan Naribole Date: Tue, 3 Sep 2024 16:30:43 +0200 Subject: [PATCH] wifi: Add Per-STA Profile BSS Params Change count (de)serialization --- src/wifi/model/eht/multi-link-element.cc | 39 +++++++++++++++++++++++- src/wifi/model/eht/multi-link-element.h | 24 +++++++++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/wifi/model/eht/multi-link-element.cc b/src/wifi/model/eht/multi-link-element.cc index 1dcbc409a..0f28aee8e 100644 --- a/src/wifi/model/eht/multi-link-element.cc +++ b/src/wifi/model/eht/multi-link-element.cc @@ -274,7 +274,8 @@ MultiLinkElement::PerStaProfileSubelement::PerStaProfileSubelement( const PerStaProfileSubelement& perStaProfile) : m_variant(perStaProfile.m_variant), m_staControl(perStaProfile.m_staControl), - m_staMacAddress(perStaProfile.m_staMacAddress) + m_staMacAddress(perStaProfile.m_staMacAddress), + m_bssParamsChgCnt(perStaProfile.m_bssParamsChgCnt) { // deep copy of the STA Profile field auto staProfileCopy = [&](auto&& frame) { @@ -304,6 +305,7 @@ MultiLinkElement::PerStaProfileSubelement::operator=(const PerStaProfileSubeleme m_variant = perStaProfile.m_variant; m_staControl = perStaProfile.m_staControl; m_staMacAddress = perStaProfile.m_staMacAddress; + m_bssParamsChgCnt = perStaProfile.m_bssParamsChgCnt; // deep copy of the STA Profile field auto staProfileCopy = [&](auto&& frame) { @@ -369,6 +371,29 @@ MultiLinkElement::PerStaProfileSubelement::GetStaMacAddress() const return m_staMacAddress; } +void +MultiLinkElement::PerStaProfileSubelement::SetBssParamsChgCnt(uint8_t count) +{ + NS_ABORT_MSG_IF(m_variant != BASIC_VARIANT, + "Expected Basic Variant, variant:" << +static_cast(m_variant)); + m_bssParamsChgCnt = count; + m_staControl |= 0x0800; +} + +bool +MultiLinkElement::PerStaProfileSubelement::HasBssParamsChgCnt() const +{ + return (m_staControl & 0x0800) != 0; +} + +uint8_t +MultiLinkElement::PerStaProfileSubelement::GetBssParamsChgCnt() const +{ + NS_ASSERT_MSG(m_bssParamsChgCnt.has_value(), "No value set for m_bssParamsChgCnt"); + NS_ASSERT_MSG(HasBssParamsChgCnt(), "BSS Parameters Change count bit not set"); + return m_bssParamsChgCnt.value(); +} + void MultiLinkElement::PerStaProfileSubelement::SetAssocRequest( const std::variant& assoc) @@ -479,6 +504,10 @@ MultiLinkElement::PerStaProfileSubelement::GetStaInfoLength() const { ret += 6; } + if (HasBssParamsChgCnt()) + { + ret += 1; + } // TODO add other subfields of the STA Info field return ret; } @@ -536,6 +565,10 @@ MultiLinkElement::PerStaProfileSubelement::SerializeInformationField(Buffer::Ite { WriteTo(start, m_staMacAddress); } + if (HasBssParamsChgCnt()) + { + start.WriteU8(GetBssParamsChgCnt()); + } // TODO add other subfields of the STA Info field auto staProfileSerialize = [&](auto&& frame) { using T = std::decay_t; @@ -576,6 +609,10 @@ MultiLinkElement::PerStaProfileSubelement::DeserializeInformationField(Buffer::I { ReadFrom(i, m_staMacAddress); } + if (HasBssParamsChgCnt()) + { + m_bssParamsChgCnt = i.ReadU8(); + } // TODO add other subfields of the STA Info field uint16_t count = i.GetDistanceFrom(start); diff --git a/src/wifi/model/eht/multi-link-element.h b/src/wifi/model/eht/multi-link-element.h index 651888aa3..e3dca61c6 100644 --- a/src/wifi/model/eht/multi-link-element.h +++ b/src/wifi/model/eht/multi-link-element.h @@ -348,6 +348,23 @@ class MultiLinkElement : public WifiInformationElement */ Mac48Address GetStaMacAddress() const; + /** + * Set the BSS Parameters Change Count subfield in the STA Info field. + * + * @param count BSS Parameters Change Count + */ + void SetBssParamsChgCnt(uint8_t count); + + /// @return whether the BSS Parameters Change Count subfield in STA Info field is present + bool HasBssParamsChgCnt() const; + + /** + * Get BSS Parameters Change Count subfield in the STA Info field. + * + * @return count value + */ + uint8_t GetBssParamsChgCnt() const; + /** * Include the given (Re)Association Request frame body in the STA Profile field * of this Per-STA Profile subelement @@ -457,9 +474,10 @@ class MultiLinkElement : public WifiInformationElement */ uint16_t DeserProbeReqMlePerSta(ns3::Buffer::Iterator start, uint16_t length); - Variant m_variant; //!< Multi-Link element variant - uint16_t m_staControl; //!< STA Control field - Mac48Address m_staMacAddress; //!< STA MAC address + Variant m_variant; //!< Multi-Link element variant + uint16_t m_staControl; //!< STA Control field + Mac48Address m_staMacAddress; //!< STA MAC address + std::optional m_bssParamsChgCnt; //!< BSS Params Change Count (Basic MLE) std::variant, std::unique_ptr,