wifi: Fix deserialization of RNR elements

... with multiple TBTT Information fields per Neighbor AP Information field.
This commit is contained in:
Stefano Avallone
2022-08-22 17:18:38 +02:00
committed by Stefano Avallone
parent b9b6dbc48d
commit a4ab293c86
2 changed files with 27 additions and 7 deletions

View File

@@ -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);

View File

@@ -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