diff --git a/src/mesh/model/dot11s/peer-link-frame.cc b/src/mesh/model/dot11s/peer-link-frame.cc index a0f54c19c..822270124 100644 --- a/src/mesh/model/dot11s/peer-link-frame.cc +++ b/src/mesh/model/dot11s/peer-link-frame.cc @@ -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); diff --git a/src/wifi/model/wifi-information-element.h b/src/wifi/model/wifi-information-element.h index 28ead92f9..f15094935 100644 --- a/src/wifi/model/wifi-information-element.h +++ b/src/wifi/model/wifi-information-element.h @@ -317,26 +317,6 @@ class WifiInformationElement : public SimpleRefCount * \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 - static Buffer::Iterator DeserializeIfPresent(std::optional& 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 -Buffer::Iterator -WifiInformationElement::DeserializeIfPresent(std::optional& optElem, - Buffer::Iterator i, - Args&&... args) -{ - optElem = std::nullopt; - IE elem(std::forward(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 */