wifi: Remove unneeded WifiInformationElement::DeserializeIfPresent() variant
This commit is contained in:
committed by
Stefano Avallone
parent
73de010af5
commit
b5476b8560
@@ -127,7 +127,13 @@ PeerLinkOpenStart::Deserialize(Buffer::Iterator start)
|
||||
|
||||
m_capability = i.ReadLsbtohU16();
|
||||
i = m_rates.Deserialize(i);
|
||||
i = WifiInformationElement::DeserializeIfPresent(m_extendedRates, i);
|
||||
m_extendedRates.emplace();
|
||||
auto tmp = m_extendedRates->DeserializeIfPresent(i);
|
||||
if (tmp.GetDistanceFrom(i) == 0)
|
||||
{
|
||||
m_extendedRates.reset();
|
||||
}
|
||||
i = tmp;
|
||||
uint8_t id = i.ReadU8();
|
||||
uint8_t length = i.ReadU8();
|
||||
m_meshId.DeserializeInformationField(i, length);
|
||||
@@ -334,7 +340,13 @@ PeerLinkConfirmStart::Deserialize(Buffer::Iterator start)
|
||||
m_capability = i.ReadLsbtohU16();
|
||||
m_aid = i.ReadLsbtohU16();
|
||||
i = m_rates.Deserialize(i);
|
||||
i = WifiInformationElement::DeserializeIfPresent(m_extendedRates, i);
|
||||
m_extendedRates.emplace();
|
||||
auto tmp = m_extendedRates->DeserializeIfPresent(i);
|
||||
if (tmp.GetDistanceFrom(i) == 0)
|
||||
{
|
||||
m_extendedRates.reset();
|
||||
}
|
||||
i = tmp;
|
||||
uint8_t id = i.ReadU8();
|
||||
uint8_t length = i.ReadU8();
|
||||
m_config.DeserializeInformationField(i, length);
|
||||
|
||||
@@ -317,26 +317,6 @@ class WifiInformationElement : public SimpleRefCount<WifiInformationElement>
|
||||
* \return an iterator
|
||||
*/
|
||||
Buffer::Iterator DeserializeIfPresent(Buffer::Iterator i);
|
||||
/**
|
||||
* Deserialize an entire IE (which may possibly be fragmented into multiple
|
||||
* elements) that is optionally present. The iterator passed in
|
||||
* must be pointing at the Element ID of an information element. If
|
||||
* the Element ID is not the requested one, the same iterator will
|
||||
* be returned. Otherwise, an iterator pointing to the octet after
|
||||
* the end of the information element is returned.
|
||||
*
|
||||
* \tparam IE \deduced Information Element type
|
||||
* \tparam Args \deduced type of the arguments to forward to the constructor of the IE
|
||||
* \param[out] optElem an object that contains the information element, if present
|
||||
* \param i an iterator which points to where the IE should be read
|
||||
* \param args arguments to forward to the constructor of the IE.
|
||||
* \return the input iterator, if the requested IE is not present, or an iterator
|
||||
* pointing to the octet after the end of the information element, otherwise
|
||||
*/
|
||||
template <typename IE, typename... Args>
|
||||
static Buffer::Iterator DeserializeIfPresent(std::optional<IE>& optElem,
|
||||
Buffer::Iterator i,
|
||||
Args&&... args);
|
||||
/**
|
||||
* Get the size of the serialized IE including Element ID and
|
||||
* length fields (for every element this IE is possibly fragmented into).
|
||||
@@ -434,34 +414,4 @@ std::ostream& operator<<(std::ostream& os, const WifiInformationElement& element
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
/***************************************************************
|
||||
* Implementation of the templates declared above.
|
||||
***************************************************************/
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
template <typename IE, typename... Args>
|
||||
Buffer::Iterator
|
||||
WifiInformationElement::DeserializeIfPresent(std::optional<IE>& optElem,
|
||||
Buffer::Iterator i,
|
||||
Args&&... args)
|
||||
{
|
||||
optElem = std::nullopt;
|
||||
IE elem(std::forward<Args>(args)...);
|
||||
|
||||
Buffer::Iterator start = i;
|
||||
i = elem.DeserializeIfPresent(i);
|
||||
|
||||
if (i.GetDistanceFrom(start) != 0)
|
||||
{
|
||||
// the element is present and has been deserialized
|
||||
optElem = elem;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* WIFI_INFORMATION_ELEMENT_H */
|
||||
|
||||
Reference in New Issue
Block a user