Skip to content

Commit

Permalink
wifi: Add Per-STA Profile BSS Params Change count (de)serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharan Naribole authored and Stefano Avallone committed Jan 15, 2025
1 parent 1acc384 commit fb5ed76
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
39 changes: 38 additions & 1 deletion src/wifi/model/eht/multi-link-element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<uint8_t>(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<MgtAssocRequestHeader, MgtReassocRequestHeader>& assoc)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<decltype(frame)>;
Expand Down Expand Up @@ -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);
Expand Down
24 changes: 21 additions & 3 deletions src/wifi/model/eht/multi-link-element.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<uint8_t> m_bssParamsChgCnt; //!< BSS Params Change Count (Basic MLE)
std::variant<std::monostate,
std::unique_ptr<MgtAssocRequestHeader>,
std::unique_ptr<MgtReassocRequestHeader>,
Expand Down

0 comments on commit fb5ed76

Please sign in to comment.