From a4ab293c8688b8ccb21d58a3c5e9df5f2e96ffee Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Mon, 22 Aug 2022 17:18:38 +0200 Subject: [PATCH] wifi: Fix deserialization of RNR elements ... with multiple TBTT Information fields per Neighbor AP Information field. --- src/wifi/model/reduced-neighbor-report.cc | 18 +++++++++++++----- src/wifi/model/reduced-neighbor-report.h | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/wifi/model/reduced-neighbor-report.cc b/src/wifi/model/reduced-neighbor-report.cc index 239f3e574..7761dcad0 100644 --- a/src/wifi/model/reduced-neighbor-report.cc +++ b/src/wifi/model/reduced-neighbor-report.cc @@ -347,9 +347,6 @@ ReducedNeighborReport::AddTbttInformationField (std::size_t nbrApInfoId) { NS_ASSERT (nbrApInfoId < m_nbrApInfoFields.size ()); m_nbrApInfoFields.at (nbrApInfoId).tbttInformationSet.push_back (TbttInformation ()); - - // set the TBTT Information Count field - m_nbrApInfoFields.at (nbrApInfoId).tbttInfoHdr.tbttInfoCount = m_nbrApInfoFields.at (nbrApInfoId).tbttInformationSet.size () - 1; } void @@ -568,8 +565,18 @@ ReducedNeighborReport::GetLinkId (std::size_t nbrApInfoId, std::size_t index) co return m_nbrApInfoFields.at (nbrApInfoId).tbttInformationSet.at (index).mldParameters.linkId & 0x0f; } +void +ReducedNeighborReport::WriteTbttInformationCount (std::size_t nbrApInfoId) const +{ + NS_ASSERT (nbrApInfoId < m_nbrApInfoFields.size ()); + NS_ASSERT (!m_nbrApInfoFields.at (nbrApInfoId).tbttInformationSet.empty ()); + + // set the TBTT Information Count field + m_nbrApInfoFields.at (nbrApInfoId).tbttInfoHdr.tbttInfoCount = m_nbrApInfoFields.at (nbrApInfoId).tbttInformationSet.size () - 1; +} + uint8_t -ReducedNeighborReport::GetTbttInformationCount (std::size_t nbrApInfoId) const +ReducedNeighborReport::ReadTbttInformationCount (std::size_t nbrApInfoId) const { NS_ASSERT (nbrApInfoId < m_nbrApInfoFields.size ()); @@ -617,6 +624,7 @@ ReducedNeighborReport::SerializeInformationField (Buffer::Iterator start) const { for (std::size_t id = 0; id < m_nbrApInfoFields.size (); ++ id) { + WriteTbttInformationCount (id); WriteTbttInformationLength (id); } @@ -688,7 +696,7 @@ ReducedNeighborReport::DeserializeInformationField (Buffer::Iterator start, uint std::size_t neighborId = m_nbrApInfoFields.size () - 1; ReadTbttInformationLength (neighborId); - for (uint8_t j = 0; j < GetTbttInformationCount (neighborId); j++) + for (uint8_t j = 0; j < ReadTbttInformationCount (neighborId); j++) { AddTbttInformationField (neighborId); diff --git a/src/wifi/model/reduced-neighbor-report.h b/src/wifi/model/reduced-neighbor-report.h index fd8dd70cd..227d931d7 100644 --- a/src/wifi/model/reduced-neighbor-report.h +++ b/src/wifi/model/reduced-neighbor-report.h @@ -291,15 +291,27 @@ public: */ uint8_t GetLinkId (std::size_t nbrApInfoId, std::size_t index) const; +private: + /** + * Set the TBTT Information Count field of the given Neighbor AP Information field + * based on the size of the tbttInformationSet field. + * + * This method is marked as const because it needs to be called within the + * SerializeInformationField method. In fact, only when serializing this object + * we can set the TBTT Information Count field based on the number of TBTT Information + * fields included in the given Neighbor AP Information field. + * + * \param nbrApInfoId identifier of the given Neighbor AP Information field + */ + void WriteTbttInformationCount (std::size_t nbrApInfoId) const; /** * Get the TBTT Information Count field of the given Neighbor AP Information field. * * \param nbrApInfoId identifier of the given Neighbor AP Information field * \return the TBTT Information Count */ - uint8_t GetTbttInformationCount (std::size_t nbrApInfoId) const; + uint8_t ReadTbttInformationCount (std::size_t nbrApInfoId) const; -private: /** * Set the TBTT Information Length field of the given Neighbor AP Information field * based on the xxxPresent flags of the NeighborApInformation struct