From e74ffdff6df9ad77d83c884953198515db650af9 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 24 Mar 2023 18:49:19 +0100 Subject: [PATCH] wifi: Information Elements should define Print() instead of ostream operator --- src/wifi/model/eht/eht-capabilities.cc | 13 +++-- src/wifi/model/eht/eht-capabilities.h | 11 +---- src/wifi/model/eht/eht-operation.cc | 57 ++++++++++------------ src/wifi/model/eht/eht-operation.h | 11 +---- src/wifi/model/extended-capabilities.cc | 13 +++-- src/wifi/model/extended-capabilities.h | 11 +---- src/wifi/model/he/he-capabilities.cc | 20 +++----- src/wifi/model/he/he-capabilities.h | 9 +--- src/wifi/model/he/he-operation.cc | 13 +++-- src/wifi/model/he/he-operation.h | 11 +---- src/wifi/model/ht/ht-capabilities.cc | 23 +++++---- src/wifi/model/ht/ht-capabilities.h | 11 +---- src/wifi/model/ht/ht-operation.cc | 39 +++++++-------- src/wifi/model/ht/ht-operation.h | 11 +---- src/wifi/model/ssid.cc | 13 +++-- src/wifi/model/ssid.h | 10 +--- src/wifi/model/supported-rates.cc | 41 ++++++++-------- src/wifi/model/supported-rates.h | 11 +---- src/wifi/model/vht/vht-capabilities.cc | 15 +++--- src/wifi/model/vht/vht-capabilities.h | 11 +---- src/wifi/model/vht/vht-operation.cc | 17 +++---- src/wifi/model/vht/vht-operation.h | 11 +---- src/wifi/model/wifi-information-element.cc | 7 +++ src/wifi/model/wifi-information-element.h | 9 ++++ 24 files changed, 147 insertions(+), 251 deletions(-) diff --git a/src/wifi/model/eht/eht-capabilities.cc b/src/wifi/model/eht/eht-capabilities.cc index ec2e91b06..04123fccf 100644 --- a/src/wifi/model/eht/eht-capabilities.cc +++ b/src/wifi/model/eht/eht-capabilities.cc @@ -423,6 +423,12 @@ EhtCapabilities::ElementIdExt() const return IE_EXT_EHT_CAPABILITIES; } +void +EhtCapabilities::Print(std::ostream& os) const +{ + os << "EHT Capabilities="; // TODO +} + uint16_t EhtCapabilities::GetInformationFieldSize() const { @@ -726,11 +732,4 @@ EhtCapabilities::DeserializeInformationField(Buffer::Iterator start, uint16_t le return count; } -std::ostream& -operator<<(std::ostream& os, const EhtCapabilities& ehtCapabilities) -{ - // TODO - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/eht/eht-capabilities.h b/src/wifi/model/eht/eht-capabilities.h index f54eb81fc..aaf68618a 100644 --- a/src/wifi/model/eht/eht-capabilities.h +++ b/src/wifi/model/eht/eht-capabilities.h @@ -261,6 +261,7 @@ class EhtCapabilities : public WifiInformationElement // Implementations of pure virtual methods, or overridden from base class. WifiInformationElementId ElementId() const override; WifiInformationElementId ElementIdExt() const override; + void Print(std::ostream& os) const override; /** * Set the maximum MPDU length. @@ -347,22 +348,12 @@ class EhtCapabilities : public WifiInformationElement void SerializeInformationField(Buffer::Iterator start) const override; uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override; - friend std::ostream& operator<<(std::ostream& os, const EhtCapabilities& ehtCapabilities); - bool m_is2_4Ghz; //!< flag indicating whether PHY is operating in 2.4 GHz based on other IEs //!< contained in the same management frame std::optional m_heCapabilities; //!< HE capabilities contained in the same management frame if present }; -/** - * output stream output operator - * \param os the output stream - * \param ehtCapabilities the EHT capabilities - * \returns the output stream - */ -std::ostream& operator<<(std::ostream& os, const EhtCapabilities& ehtCapabilities); - } // namespace ns3 #endif /* EHT_CAPABILITIES_H */ diff --git a/src/wifi/model/eht/eht-operation.cc b/src/wifi/model/eht/eht-operation.cc index b3b329c9f..3da6ca4fd 100644 --- a/src/wifi/model/eht/eht-operation.cc +++ b/src/wifi/model/eht/eht-operation.cc @@ -27,6 +27,33 @@ namespace ns3 { +void +EhtOperation::Print(std::ostream& os) const +{ + os << "EHT Operation=" << +m_params.opInfoPresent << "|" << +m_params.disabledSubchBmPresent + << "|" << +m_params.defaultPeDur << "|" << +m_params.grpBuIndLimit << "|" + << +m_params.grpBuExp << "|["; + for (const auto& maxRxNss : m_mcsNssSet.maxRxNss) + { + os << +maxRxNss << "|"; + } + os << "]|["; + for (const auto& maxTxNss : m_mcsNssSet.maxTxNss) + { + os << +maxTxNss << "|"; + } + os << "]"; + if (m_opInfo.has_value()) + { + os << "|" << +m_opInfo->control.channelWidth << "|" << +m_opInfo->ccfs0 << "|" + << +m_opInfo->ccfs1; + if (m_opInfo->disabledSubchBm.has_value()) + { + os << "|" << m_opInfo->disabledSubchBm.value(); + } + } +} + void EhtOperation::EhtOpParams::Serialize(Buffer::Iterator& start) const { @@ -260,34 +287,4 @@ EhtOperation::DeserializeInformationField(Buffer::Iterator start, uint16_t lengt << +count << ")"); return length; } - -std::ostream& -operator<<(std::ostream& os, const EhtOperation& ehtOperation) -{ - os << +ehtOperation.m_params.opInfoPresent << "|" - << +ehtOperation.m_params.disabledSubchBmPresent << "|" - << +ehtOperation.m_params.defaultPeDur << "|" << +ehtOperation.m_params.grpBuIndLimit << "|" - << +ehtOperation.m_params.grpBuExp << "|["; - for (const auto& maxRxNss : ehtOperation.m_mcsNssSet.maxRxNss) - { - os << +maxRxNss << "|"; - } - os << "]|["; - for (const auto& maxTxNss : ehtOperation.m_mcsNssSet.maxTxNss) - { - os << +maxTxNss << "|"; - } - os << "]"; - if (ehtOperation.m_opInfo.has_value()) - { - os << "|" << +ehtOperation.m_opInfo->control.channelWidth << "|" - << +ehtOperation.m_opInfo->ccfs0 << "|" << +ehtOperation.m_opInfo->ccfs1; - if (ehtOperation.m_opInfo->disabledSubchBm.has_value()) - { - os << "|" << ehtOperation.m_opInfo->disabledSubchBm.value(); - } - } - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/eht/eht-operation.h b/src/wifi/model/eht/eht-operation.h index 5e981af34..e30bfc3d5 100644 --- a/src/wifi/model/eht/eht-operation.h +++ b/src/wifi/model/eht/eht-operation.h @@ -161,6 +161,7 @@ class EhtOperation : public WifiInformationElement EhtOperation(); WifiInformationElementId ElementId() const override; WifiInformationElementId ElementIdExt() const override; + void Print(std::ostream& os) const override; /** * Set the max Rx NSS for input MCS index range @@ -187,16 +188,6 @@ class EhtOperation : public WifiInformationElement uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override; }; -/** - * output stream output operator - * - * \param os output stream - * \param ehtOperation the EHT operation - * - * \returns output stream - */ -std::ostream& operator<<(std::ostream& os, const EhtOperation& ehtOperation); - } // namespace ns3 #endif /* EHT_OPERATION_H */ diff --git a/src/wifi/model/extended-capabilities.cc b/src/wifi/model/extended-capabilities.cc index eb8f8a093..18b689840 100644 --- a/src/wifi/model/extended-capabilities.cc +++ b/src/wifi/model/extended-capabilities.cc @@ -91,6 +91,12 @@ ExtendedCapabilities::ElementId() const return IE_EXTENDED_CAPABILITIES; } +void +ExtendedCapabilities::Print(std::ostream& os) const +{ + os << "Extended Capabilities=" << +GetExtendedCapabilitiesByte1(); +} + void ExtendedCapabilities::SetHtSupported(uint8_t htSupported) { @@ -373,11 +379,4 @@ ExtendedCapabilities::DeserializeInformationField(Buffer::Iterator start, uint16 return length; } -std::ostream& -operator<<(std::ostream& os, const ExtendedCapabilities& extendedCapabilities) -{ - os << +extendedCapabilities.GetExtendedCapabilitiesByte1(); - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/extended-capabilities.h b/src/wifi/model/extended-capabilities.h index e2e660770..3e12cdde9 100644 --- a/src/wifi/model/extended-capabilities.h +++ b/src/wifi/model/extended-capabilities.h @@ -41,6 +41,7 @@ class ExtendedCapabilities : public WifiInformationElement uint16_t GetInformationFieldSize() const override; void SerializeInformationField(Buffer::Iterator start) const override; uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override; + void Print(std::ostream& os) const override; /** * Set the HT Supported flag. * @@ -226,16 +227,6 @@ class ExtendedCapabilities : public WifiInformationElement ///< element should be added to the frame or not }; -/** - * output stream output operator - * - * \param os output stream - * \param extendedCapabilities the extended capabilities - * - * \returns output stream - */ -std::ostream& operator<<(std::ostream& os, const ExtendedCapabilities& extendedCapabilities); - } // namespace ns3 #endif /* EXTENDED_CAPABILITIES_H */ diff --git a/src/wifi/model/he/he-capabilities.cc b/src/wifi/model/he/he-capabilities.cc index d0c0bf38b..c9890b062 100644 --- a/src/wifi/model/he/he-capabilities.cc +++ b/src/wifi/model/he/he-capabilities.cc @@ -136,6 +136,14 @@ HeCapabilities::ElementIdExt() const return IE_EXT_HE_CAPABILITIES; } +void +HeCapabilities::Print(std::ostream& os) const +{ + os << "HE Capabilities=" << GetHeMacCapabilitiesInfo1() << "|" << +GetHeMacCapabilitiesInfo2() + << "|" << GetHePhyCapabilitiesInfo1() << "|" << GetHePhyCapabilitiesInfo2() << "|" + << +GetHePhyCapabilitiesInfo3() << "|" << GetSupportedMcsAndNss(); +} + uint16_t HeCapabilities::GetInformationFieldSize() const { @@ -609,16 +617,4 @@ HeCapabilities::GetMaxAmpduLength() const return std::min((1UL << (20 + m_maxAmpduLengthExponent)) - 1, 6500631); } -std::ostream& -operator<<(std::ostream& os, const HeCapabilities& heCapabilities) -{ - os << heCapabilities.GetHeMacCapabilitiesInfo1() << "|" - << +heCapabilities.GetHeMacCapabilitiesInfo2() << "|" - << heCapabilities.GetHePhyCapabilitiesInfo1() << "|" - << heCapabilities.GetHePhyCapabilitiesInfo2() << "|" - << +heCapabilities.GetHePhyCapabilitiesInfo3() << "|" - << heCapabilities.GetSupportedMcsAndNss(); - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/he/he-capabilities.h b/src/wifi/model/he/he-capabilities.h index 97e73ac7b..8f81e4955 100644 --- a/src/wifi/model/he/he-capabilities.h +++ b/src/wifi/model/he/he-capabilities.h @@ -38,6 +38,7 @@ class HeCapabilities : public WifiInformationElement // Implementations of pure virtual methods of WifiInformationElement WifiInformationElementId ElementId() const override; WifiInformationElementId ElementIdExt() const override; + void Print(std::ostream& os) const override; /** * Set the HE MAC Capabilities Info field in the HE Capabilities information element. @@ -333,14 +334,6 @@ class HeCapabilities : public WifiInformationElement std::vector m_rxBwMap; //!< receive BW map }; -/** - * output stream output operator - * \param os the output stream - * \param heCapabilities the HE capabilities - * \returns the output stream - */ -std::ostream& operator<<(std::ostream& os, const HeCapabilities& heCapabilities); - } // namespace ns3 #endif /* HE_CAPABILITY_H */ diff --git a/src/wifi/model/he/he-operation.cc b/src/wifi/model/he/he-operation.cc index ff4f2603a..a6792ad71 100644 --- a/src/wifi/model/he/he-operation.cc +++ b/src/wifi/model/he/he-operation.cc @@ -48,6 +48,12 @@ HeOperation::ElementIdExt() const return IE_EXT_HE_OPERATION; } +void +HeOperation::Print(std::ostream& os) const +{ + os << "HE Operation=" << GetHeOperationParameters() << "|" << GetBasicHeMcsAndNssSet(); +} + uint16_t HeOperation::GetInformationFieldSize() const { @@ -152,11 +158,4 @@ HeOperation::DeserializeInformationField(Buffer::Iterator start, uint16_t length return length; } -std::ostream& -operator<<(std::ostream& os, const HeOperation& HeOperation) -{ - os << HeOperation.GetHeOperationParameters() << "|" << HeOperation.GetBasicHeMcsAndNssSet(); - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/he/he-operation.h b/src/wifi/model/he/he-operation.h index 87ea60803..958370b10 100644 --- a/src/wifi/model/he/he-operation.h +++ b/src/wifi/model/he/he-operation.h @@ -40,6 +40,7 @@ class HeOperation : public WifiInformationElement // Implementations of pure virtual methods of WifiInformationElement WifiInformationElementId ElementId() const override; WifiInformationElementId ElementIdExt() const override; + void Print(std::ostream& os) const override; /** * Set the HE Operation Parameters field in the HE Operation information element. @@ -101,16 +102,6 @@ class HeOperation : public WifiInformationElement // TODO: VHT Operation Information subfields not defined in the standard yet. }; -/** - * output stream output operator - * - * \param os output stream - * \param HeOperation the HE operation - * - * \returns output stream - */ -std::ostream& operator<<(std::ostream& os, const HeOperation& HeOperation); - } // namespace ns3 #endif /* HE_OPERATION_H */ diff --git a/src/wifi/model/ht/ht-capabilities.cc b/src/wifi/model/ht/ht-capabilities.cc index dbcfa20ba..82b61cddb 100644 --- a/src/wifi/model/ht/ht-capabilities.cc +++ b/src/wifi/model/ht/ht-capabilities.cc @@ -97,6 +97,17 @@ HtCapabilities::ElementId() const return IE_HT_CAPABILITIES; } +void +HtCapabilities::Print(std::ostream& os) const +{ + os << "HT Capabilities=" << bool(GetLdpc()) << "|" << bool(GetSupportedChannelWidth()) << "|" + << bool(GetShortGuardInterval20()) << "|"; + for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++) + { + os << IsSupportedMcs(i) << " "; + } +} + void HtCapabilities::SetLdpc(uint8_t ldpc) { @@ -506,16 +517,4 @@ HtCapabilities::DeserializeInformationField(Buffer::Iterator start, uint16_t len return length; } -std::ostream& -operator<<(std::ostream& os, const HtCapabilities& htcapabilities) -{ - os << bool(htcapabilities.GetLdpc()) << "|" << bool(htcapabilities.GetSupportedChannelWidth()) - << "|" << bool(htcapabilities.GetShortGuardInterval20()) << "|"; - for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++) - { - os << htcapabilities.IsSupportedMcs(i) << " "; - } - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/ht/ht-capabilities.h b/src/wifi/model/ht/ht-capabilities.h index 0ca570856..145186826 100644 --- a/src/wifi/model/ht/ht-capabilities.h +++ b/src/wifi/model/ht/ht-capabilities.h @@ -271,6 +271,7 @@ class HtCapabilities : public WifiInformationElement uint16_t GetInformationFieldSize() const override; void SerializeInformationField(Buffer::Iterator start) const override; uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override; + void Print(std::ostream& os) const override; // HT Capabilities Info field uint8_t m_ldpc; ///< LDPC @@ -350,16 +351,6 @@ class HtCapabilities : public WifiInformationElement uint8_t m_reservedASel; ///< reserved ASEL }; -/** - * output stream output operator - * - * \param os output stream - * \param htcapabilities the HT capabilities - * - * \returns output stream - */ -std::ostream& operator<<(std::ostream& os, const HtCapabilities& htcapabilities); - } // namespace ns3 #endif /* HT_CAPABILITY_H */ diff --git a/src/wifi/model/ht/ht-operation.cc b/src/wifi/model/ht/ht-operation.cc index f44550126..1be7508ac 100644 --- a/src/wifi/model/ht/ht-operation.cc +++ b/src/wifi/model/ht/ht-operation.cc @@ -62,6 +62,23 @@ HtOperation::ElementId() const return IE_HT_OPERATION; } +void +HtOperation::Print(std::ostream& os) const +{ + os << "HT Operation=" << bool(GetPrimaryChannel()) << "|" << +GetSecondaryChannelOffset() << "|" + << bool(GetStaChannelWidth()) << "|" << bool(GetRifsMode()) << "|" << +GetHtProtection() + << "|" << bool(GetNonGfHtStasPresent()) << "|" << bool(GetObssNonHtStasPresent()) << "|" + << bool(GetDualBeacon()) << "|" << bool(GetDualCtsProtection()) << "|" + << bool(GetStbcBeacon()) << "|" << bool(GetLSigTxopProtectionFullSupport()) << "|" + << bool(GetPcoActive()) << "|" << bool(GetPhase()) << "|" << GetRxHighestSupportedDataRate() + << "|" << bool(GetTxMcsSetDefined()) << "|" << bool(GetTxRxMcsSetUnequal()) << "|" + << +GetTxMaxNSpatialStreams() << "|" << bool(GetTxUnequalModulation()) << "|"; + for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++) + { + os << IsSupportedMcs(i) << " "; + } +} + uint16_t HtOperation::GetInformationFieldSize() const { @@ -456,26 +473,4 @@ HtOperation::DeserializeInformationField(Buffer::Iterator start, uint16_t length return length; } -std::ostream& -operator<<(std::ostream& os, const HtOperation& htOperation) -{ - os << bool(htOperation.GetPrimaryChannel()) << "|" << +htOperation.GetSecondaryChannelOffset() - << "|" << bool(htOperation.GetStaChannelWidth()) << "|" << bool(htOperation.GetRifsMode()) - << "|" << +htOperation.GetHtProtection() << "|" << bool(htOperation.GetNonGfHtStasPresent()) - << "|" << bool(htOperation.GetObssNonHtStasPresent()) << "|" - << bool(htOperation.GetDualBeacon()) << "|" << bool(htOperation.GetDualCtsProtection()) - << "|" << bool(htOperation.GetStbcBeacon()) << "|" - << bool(htOperation.GetLSigTxopProtectionFullSupport()) << "|" - << bool(htOperation.GetPcoActive()) << "|" << bool(htOperation.GetPhase()) << "|" - << htOperation.GetRxHighestSupportedDataRate() << "|" - << bool(htOperation.GetTxMcsSetDefined()) << "|" << bool(htOperation.GetTxRxMcsSetUnequal()) - << "|" << +htOperation.GetTxMaxNSpatialStreams() << "|" - << bool(htOperation.GetTxUnequalModulation()) << "|"; - for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++) - { - os << htOperation.IsSupportedMcs(i) << " "; - } - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/ht/ht-operation.h b/src/wifi/model/ht/ht-operation.h index 53e1e5c7b..3d8213aef 100644 --- a/src/wifi/model/ht/ht-operation.h +++ b/src/wifi/model/ht/ht-operation.h @@ -54,6 +54,7 @@ class HtOperation : public WifiInformationElement // Implementations of pure virtual methods of WifiInformationElement WifiInformationElementId ElementId() const override; + void Print(std::ostream& os) const override; /** * Set the Primary Channel field in the HT Operation information element. @@ -394,16 +395,6 @@ class HtOperation : public WifiInformationElement uint8_t m_rxMcsBitmask[MAX_SUPPORTED_MCS]; ///< receive MCS bitmask }; -/** - * output stream output operator - * - * \param os output stream - * \param htOperation the HT operation - * - * \returns output stream - */ -std::ostream& operator<<(std::ostream& os, const HtOperation& htOperation); - } // namespace ns3 #endif /* HT_OPERATION_H */ diff --git a/src/wifi/model/ssid.cc b/src/wifi/model/ssid.cc index 39b3928eb..fabc7bc01 100644 --- a/src/wifi/model/ssid.cc +++ b/src/wifi/model/ssid.cc @@ -51,6 +51,12 @@ Ssid::Ssid(std::string s) } } +void +Ssid::Print(std::ostream& os) const +{ + os << "ssid=" << PeekString(); +} + bool Ssid::IsEqual(const Ssid& o) const { @@ -114,13 +120,6 @@ Ssid::DeserializeInformationField(Buffer::Iterator start, uint16_t length) ATTRIBUTE_HELPER_CPP(Ssid); -std::ostream& -operator<<(std::ostream& os, const Ssid& ssid) -{ - os << ssid.PeekString(); - return os; -} - std::istream& operator>>(std::istream& is, Ssid& ssid) { diff --git a/src/wifi/model/ssid.h b/src/wifi/model/ssid.h index 335594788..5ab993614 100644 --- a/src/wifi/model/ssid.h +++ b/src/wifi/model/ssid.h @@ -48,6 +48,7 @@ class Ssid : public WifiInformationElement // Implementations of pure virtual methods of WifiInformationElement WifiInformationElementId ElementId() const override; + void Print(std::ostream& os) const override; /** * Check if the two SSIDs are equal. @@ -82,15 +83,6 @@ class Ssid : public WifiInformationElement uint8_t m_length; //!< Length of the SSID }; -/** - * Serialize SSID to the given ostream - * - * \param os the output stream - * \param ssid the SSID - * - * \return std::ostream - */ -std::ostream& operator<<(std::ostream& os, const Ssid& ssid); /** * Serialize from the given istream to this SSID. * diff --git a/src/wifi/model/supported-rates.cc b/src/wifi/model/supported-rates.cc index 6e3b8fc30..a15d73769 100644 --- a/src/wifi/model/supported-rates.cc +++ b/src/wifi/model/supported-rates.cc @@ -57,6 +57,26 @@ SupportedRates::operator=(const SupportedRates& rates) return (*this); } +void +SupportedRates::Print(std::ostream& os) const +{ + os << "rates=["; + for (uint8_t i = 0; i < GetNRates(); i++) + { + uint32_t rate = GetRate(i); + if (IsBasicRate(rate)) + { + os << "*"; + } + os << rate / 1000000 << "mbs"; + if (i < GetNRates() - 1) + { + os << " "; + } + } + os << "]"; +} + void SupportedRates::AddSupportedRate(uint64_t bs) { @@ -258,25 +278,4 @@ ExtendedSupportedRatesIE::DeserializeInformationField(Buffer::Iterator start, ui return length; } -std::ostream& -operator<<(std::ostream& os, const SupportedRates& rates) -{ - os << "["; - for (uint8_t i = 0; i < rates.GetNRates(); i++) - { - uint32_t rate = rates.GetRate(i); - if (rates.IsBasicRate(rate)) - { - os << "*"; - } - os << rate / 1000000 << "mbs"; - if (i < rates.GetNRates() - 1) - { - os << " "; - } - } - os << "]"; - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/supported-rates.h b/src/wifi/model/supported-rates.h index 3fe8d2b95..4c518786a 100644 --- a/src/wifi/model/supported-rates.h +++ b/src/wifi/model/supported-rates.h @@ -98,6 +98,7 @@ class SupportedRates : public WifiInformationElement // Implementations of pure virtual methods of WifiInformationElement WifiInformationElementId ElementId() const override; + void Print(std::ostream& os) const override; /** * Assignment operator @@ -198,16 +199,6 @@ class SupportedRates : public WifiInformationElement uint8_t m_rates[MAX_SUPPORTED_RATES]; //!< List of supported bit rates (divided by 500000) }; -/** - * Serialize SupportedRates to the given ostream. - * - * \param os output stream - * \param rates the SupportedRates - * - * \return std::ostream - */ -std::ostream& operator<<(std::ostream& os, const SupportedRates& rates); - } // namespace ns3 #endif /* SUPPORTED_RATES_H */ diff --git a/src/wifi/model/vht/vht-capabilities.cc b/src/wifi/model/vht/vht-capabilities.cc index a4d81ac6d..77ae419c6 100644 --- a/src/wifi/model/vht/vht-capabilities.cc +++ b/src/wifi/model/vht/vht-capabilities.cc @@ -63,6 +63,12 @@ VhtCapabilities::ElementId() const return IE_VHT_CAPABILITIES; } +void +VhtCapabilities::Print(std::ostream& os) const +{ + os << "VHT Capabilities=" << GetVhtCapabilitiesInfo() << "|" << GetSupportedMcsAndNssSet(); +} + uint16_t VhtCapabilities::GetInformationFieldSize() const { @@ -384,13 +390,4 @@ VhtCapabilities::GetRxHighestSupportedLgiDataRate() const return m_rxHighestSupportedLongGuardIntervalDataRate; } -std::ostream& -operator<<(std::ostream& os, const VhtCapabilities& vhtCapabilities) -{ - os << vhtCapabilities.GetVhtCapabilitiesInfo() << "|" - << vhtCapabilities.GetSupportedMcsAndNssSet(); - - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/vht/vht-capabilities.h b/src/wifi/model/vht/vht-capabilities.h index b560ccf34..936edc067 100644 --- a/src/wifi/model/vht/vht-capabilities.h +++ b/src/wifi/model/vht/vht-capabilities.h @@ -38,6 +38,7 @@ class VhtCapabilities : public WifiInformationElement // Implementations of pure virtual methods of WifiInformationElement WifiInformationElementId ElementId() const override; + void Print(std::ostream& os) const override; /** * Set the VHT Capabilities Info field in the VHT Capabilities information element. @@ -241,16 +242,6 @@ class VhtCapabilities : public WifiInformationElement ///< guard interval data rate }; -/** - * output stream output operator - * - * \param os the output stream - * \param vhtCapabilities the VHT capabilities - * - * \returns output stream - */ -std::ostream& operator<<(std::ostream& os, const VhtCapabilities& vhtCapabilities); - } // namespace ns3 #endif /* VHT_CAPABILITY_H */ diff --git a/src/wifi/model/vht/vht-operation.cc b/src/wifi/model/vht/vht-operation.cc index 61888935a..36f2f1bdb 100644 --- a/src/wifi/model/vht/vht-operation.cc +++ b/src/wifi/model/vht/vht-operation.cc @@ -36,6 +36,13 @@ VhtOperation::ElementId() const return IE_VHT_OPERATION; } +void +VhtOperation::Print(std::ostream& os) const +{ + os << "VHT Operation=" << +GetChannelWidth() << "|" << +GetChannelCenterFrequencySegment0() + << "|" << +GetChannelCenterFrequencySegment1() << "|" << GetBasicVhtMcsAndNssSet(); +} + uint16_t VhtOperation::GetInformationFieldSize() const { @@ -129,14 +136,4 @@ VhtOperation::DeserializeInformationField(Buffer::Iterator start, uint16_t lengt return length; } -std::ostream& -operator<<(std::ostream& os, const VhtOperation& VhtOperation) -{ - os << +VhtOperation.GetChannelWidth() << "|" - << +VhtOperation.GetChannelCenterFrequencySegment0() << "|" - << +VhtOperation.GetChannelCenterFrequencySegment1() << "|" - << VhtOperation.GetBasicVhtMcsAndNssSet(); - return os; -} - } // namespace ns3 diff --git a/src/wifi/model/vht/vht-operation.h b/src/wifi/model/vht/vht-operation.h index a69014bc6..f8a2c7ef1 100644 --- a/src/wifi/model/vht/vht-operation.h +++ b/src/wifi/model/vht/vht-operation.h @@ -39,6 +39,7 @@ class VhtOperation : public WifiInformationElement // Implementations of pure virtual methods of WifiInformationElement WifiInformationElementId ElementId() const override; + void Print(std::ostream& os) const override; /** * Set the Channel Width field in the VHT Operation information element. @@ -115,16 +116,6 @@ class VhtOperation : public WifiInformationElement uint16_t m_basicVhtMcsAndNssSet; ///< basic VHT MCS NSS set }; -/** - * output stream output operator - * - * \param os the output stream - * \param VhtOperation the VHT operation - * - * \returns output stream - */ -std::ostream& operator<<(std::ostream& os, const VhtOperation& VhtOperation); - } // namespace ns3 #endif /* VHT_OPERATION_H */ diff --git a/src/wifi/model/wifi-information-element.cc b/src/wifi/model/wifi-information-element.cc index c0ba1a126..b2654ced7 100644 --- a/src/wifi/model/wifi-information-element.cc +++ b/src/wifi/model/wifi-information-element.cc @@ -261,4 +261,11 @@ WifiInformationElement::operator==(const WifiInformationElement& a) const return (memcmp(myIe.PeekData(), hisIe.PeekData(), ieSize) == 0); } +std::ostream& +operator<<(std::ostream& os, const WifiInformationElement& element) +{ + element.Print(os); + return os; +} + } // namespace ns3 diff --git a/src/wifi/model/wifi-information-element.h b/src/wifi/model/wifi-information-element.h index 2d21bc246..b27f7e834 100644 --- a/src/wifi/model/wifi-information-element.h +++ b/src/wifi/model/wifi-information-element.h @@ -423,6 +423,15 @@ class WifiInformationElement : public SimpleRefCount virtual uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) = 0; }; +/** + * \brief Stream insertion operator. + * + * \param os the output stream + * \param element the Information Element + * \returns a reference to the stream + */ +std::ostream& operator<<(std::ostream& os, const WifiInformationElement& element); + } // namespace ns3 /***************************************************************