wifi: Prohibit (de)serializing the Information field of IEs directly

Use the methods to (de)serialize the whole IE instead.
This commit is contained in:
Stefano Avallone
2022-07-12 13:24:00 +02:00
parent 81b66dbab6
commit 932c017e3d
2 changed files with 22 additions and 24 deletions

View File

@@ -69,6 +69,7 @@ MeshInformationElementVector::DeserializeSingleIe (Buffer::Iterator start)
Buffer::Iterator i = start;
uint8_t id = i.ReadU8 ();
uint8_t length = i.ReadU8 ();
i.Prev (2);
Ptr<WifiInformationElement> newElement;
switch (id)
{
@@ -103,17 +104,13 @@ MeshInformationElementVector::DeserializeSingleIe (Buffer::Iterator start)
newElement = Create<dot11s::IePeeringProtocol> ();
break;
default:
// We peeked at the ID and length, so we need to back up the
// pointer before deferring to our parent.
i.Prev (2);
return WifiInformationElementVector::DeserializeSingleIe (i);
}
if (GetSize () + length > m_maxSize)
{
NS_FATAL_ERROR ("Check max size for information element!");
}
newElement->DeserializeInformationField (i, length);
i.Next (length);
i = newElement->Deserialize (i);
m_elements.push_back (newElement);
return i.GetDistanceFrom (start);
}

View File

@@ -292,25 +292,6 @@ public:
* \return the length of serialized information
*/
virtual uint8_t GetInformationFieldSize () const = 0;
/**
* Serialize information (i.e., the body of the IE, not including
* the Element ID and length octets)
*
* \param start an iterator which points to where the information should
* be written.
*/
virtual void SerializeInformationField (Buffer::Iterator start) const = 0;
/**
* Deserialize information (i.e., the body of the IE, not including
* the Element ID and length octets)
*
* \param start an iterator which points to where the information should be written.
* \param length
*
* \return the number of bytes read
*/
virtual uint8_t DeserializeInformationField (Buffer::Iterator start,
uint8_t length) = 0;
/**
* Get the wifi information element ID extension
@@ -336,6 +317,26 @@ public:
*/
virtual bool operator== (WifiInformationElement const & a) const;
private:
/**
* Serialize information (i.e., the body of the IE, not including
* the Element ID and length octets)
*
* \param start an iterator which points to where the information should
* be written.
*/
virtual void SerializeInformationField (Buffer::Iterator start) const = 0;
/**
* Deserialize information (i.e., the body of the IE, not including
* the Element ID and length octets)
*
* \param start an iterator which points to where the information should be written.
* \param length
*
* \return the number of bytes read
*/
virtual uint8_t DeserializeInformationField (Buffer::Iterator start,
uint8_t length) = 0;
};
} //namespace ns3