From f44b6206104aa3c1cf09a93e5055f99952194e55 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sat, 12 Nov 2016 01:03:56 +0100 Subject: [PATCH] flow-monitor: (fixes #2545) Optimized build fails for flow-monitor --- RELEASE_NOTES | 5 +-- .../helper/flow-monitor-helper.cc | 4 +-- src/flow-monitor/helper/flow-monitor-helper.h | 4 +-- src/flow-monitor/model/flow-classifier.h | 14 ++++++++- src/flow-monitor/model/flow-monitor.cc | 31 ++++++++++++------- src/flow-monitor/model/flow-monitor.h | 4 +-- .../model/ipv4-flow-classifier.cc | 12 +++---- src/flow-monitor/model/ipv4-flow-classifier.h | 2 +- .../model/ipv6-flow-classifier.cc | 11 +++---- src/flow-monitor/model/ipv6-flow-classifier.h | 2 +- 10 files changed, 51 insertions(+), 38 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 84ea63fda8d..d6c3901ef2c 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -35,11 +35,12 @@ Bugs fixed - Bug 2529 - Missing trace when Block ACK timeout is triggered or when missing MPDUs are announced by a Block ACK response - Bug 2530 - Rename aodv::SetBalckListTimeout to aodv::SetBlackListTimeout - Bug 2532 - Inconsistencies between 802.11n MCS and NSS value reported in TXVECTOR -- Bug 2541 - preamble not assigned correctly -- Bug 2542 - dead assignment on wifi mac-low - Bug 2535 - memory leak in bench-simulator.cc - Bug 2536 - fixed dead assignment and potential memory leak in wimax - Bug 2538 - fixed dead assignment on tap-bridge +- Bug 2541 - preamble not assigned correctly +- Bug 2542 - dead assignment on wifi mac-low +- Bug 2545 - Optimized build fails for flow-monitor Known issues ------------ diff --git a/src/flow-monitor/helper/flow-monitor-helper.cc b/src/flow-monitor/helper/flow-monitor-helper.cc index 0f2334fa353..247416b006a 100644 --- a/src/flow-monitor/helper/flow-monitor-helper.cc +++ b/src/flow-monitor/helper/flow-monitor-helper.cc @@ -146,7 +146,7 @@ FlowMonitorHelper::InstallAll () } void -FlowMonitorHelper::SerializeToXmlStream (std::ostream &os, int indent, bool enableHistograms, bool enableProbes) +FlowMonitorHelper::SerializeToXmlStream (std::ostream &os, uint16_t indent, bool enableHistograms, bool enableProbes) { if (m_flowMonitor) { @@ -155,7 +155,7 @@ FlowMonitorHelper::SerializeToXmlStream (std::ostream &os, int indent, bool enab } std::string -FlowMonitorHelper::SerializeToXmlString (int indent, bool enableHistograms, bool enableProbes) +FlowMonitorHelper::SerializeToXmlString (uint16_t indent, bool enableHistograms, bool enableProbes) { std::ostringstream os; if (m_flowMonitor) diff --git a/src/flow-monitor/helper/flow-monitor-helper.h b/src/flow-monitor/helper/flow-monitor-helper.h index 14db8f0c107..41c952ba0a8 100644 --- a/src/flow-monitor/helper/flow-monitor-helper.h +++ b/src/flow-monitor/helper/flow-monitor-helper.h @@ -93,7 +93,7 @@ class FlowMonitorHelper * \param enableHistograms if true, include also the histograms in the output * \param enableProbes if true, include also the per-probe/flow pair statistics in the output */ - void SerializeToXmlStream (std::ostream &os, int indent, bool enableHistograms, bool enableProbes); + void SerializeToXmlStream (std::ostream &os, uint16_t indent, bool enableHistograms, bool enableProbes); /** * Same as SerializeToXmlStream, but returns the output as a std::string @@ -102,7 +102,7 @@ class FlowMonitorHelper * \param enableProbes if true, include also the per-probe/flow pair statistics in the output * \return the XML output as string */ - std::string SerializeToXmlString (int indent, bool enableHistograms, bool enableProbes); + std::string SerializeToXmlString (uint16_t indent, bool enableHistograms, bool enableProbes); /** * Same as SerializeToXmlStream, but writes to a file instead diff --git a/src/flow-monitor/model/flow-classifier.h b/src/flow-monitor/model/flow-classifier.h index 8e500745b72..e711f3bbe2d 100644 --- a/src/flow-monitor/model/flow-classifier.h +++ b/src/flow-monitor/model/flow-classifier.h @@ -69,15 +69,27 @@ class FlowClassifier : public SimpleRefCount /// Serializes the results to an std::ostream in XML format /// \param os the output stream /// \param indent number of spaces to use as base indentation level - virtual void SerializeToXmlStream (std::ostream &os, int indent) const = 0; + virtual void SerializeToXmlStream (std::ostream &os, uint16_t indent) const = 0; protected: /// Returns a new, unique Flow Identifier /// \returns a new FlowId FlowId GetNewFlowId (); + /// + /// \brief Add a number of spaces for indentation purposes. + /// \param os The stream to write to. + /// \param level The number of spaces to add. + void Indent (std::ostream &os, uint16_t level) const; + }; +inline void +FlowClassifier::Indent (std::ostream &os, uint16_t level) const +{ + for (uint16_t __xpto = 0; __xpto < level; __xpto++) os << ' '; +} + } // namespace ns3 diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index 0a87d326c01..9df58174273 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -36,6 +36,13 @@ NS_LOG_COMPONENT_DEFINE ("FlowMonitor"); NS_OBJECT_ENSURE_REGISTERED (FlowMonitor); +inline static void +Indent (std::ostream &os, uint16_t level) +{ + for (uint16_t __xpto = 0; __xpto < level; __xpto++) os << ' '; +} + + TypeId FlowMonitor::GetTypeId (void) { @@ -401,19 +408,19 @@ FlowMonitor::AddFlowClassifier (Ptr classifier) } void -FlowMonitor::SerializeToXmlStream (std::ostream &os, int indent, bool enableHistograms, bool enableProbes) +FlowMonitor::SerializeToXmlStream (std::ostream &os, uint16_t indent, bool enableHistograms, bool enableProbes) { CheckForLostPackets (); - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; indent += 2; - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; indent += 2; for (FlowStatsContainerCI flowI = m_flowStats.begin (); flowI != m_flowStats.end (); flowI++) { - INDENT (indent); + Indent (os, indent); #define ATTRIB(name) << " " # name "=\"" << flowI->second.name << "\"" os << "first << "\"" ATTRIB (timeFirstTxPacket) @@ -436,14 +443,14 @@ FlowMonitor::SerializeToXmlStream (std::ostream &os, int indent, bool enableHist indent += 2; for (uint32_t reasonCode = 0; reasonCode < flowI->second.packetsDropped.size (); reasonCode++) { - INDENT (indent); + Indent (os, indent); os << "second.packetsDropped[reasonCode] << "\" />\n"; } for (uint32_t reasonCode = 0; reasonCode < flowI->second.bytesDropped.size (); reasonCode++) { - INDENT (indent); + Indent (os, indent); os << "second.bytesDropped[reasonCode] << "\" />\n"; @@ -457,10 +464,10 @@ FlowMonitor::SerializeToXmlStream (std::ostream &os, int indent, bool enableHist } indent -= 2; - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; } indent -= 2; - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; for (std::list >::iterator iter = m_classifiers.begin (); iter != m_classifiers.end (); @@ -471,23 +478,23 @@ FlowMonitor::SerializeToXmlStream (std::ostream &os, int indent, bool enableHist if (enableProbes) { - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; indent += 2; for (uint32_t i = 0; i < m_flowProbes.size (); i++) { m_flowProbes[i]->SerializeToXmlStream (os, indent, i); } indent -= 2; - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; } indent -= 2; - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; } std::string -FlowMonitor::SerializeToXmlString (int indent, bool enableHistograms, bool enableProbes) +FlowMonitor::SerializeToXmlString (uint16_t indent, bool enableHistograms, bool enableProbes) { std::ostringstream os; SerializeToXmlStream (os, indent, enableHistograms, enableProbes); diff --git a/src/flow-monitor/model/flow-monitor.h b/src/flow-monitor/model/flow-monitor.h index fa8076f9d9b..90320b5a5eb 100644 --- a/src/flow-monitor/model/flow-monitor.h +++ b/src/flow-monitor/model/flow-monitor.h @@ -241,14 +241,14 @@ class FlowMonitor : public Object /// \param indent number of spaces to use as base indentation level /// \param enableHistograms if true, include also the histograms in the output /// \param enableProbes if true, include also the per-probe/flow pair statistics in the output - void SerializeToXmlStream (std::ostream &os, int indent, bool enableHistograms, bool enableProbes); + void SerializeToXmlStream (std::ostream &os, uint16_t indent, bool enableHistograms, bool enableProbes); /// Same as SerializeToXmlStream, but returns the output as a std::string /// \param indent number of spaces to use as base indentation level /// \param enableHistograms if true, include also the histograms in the output /// \param enableProbes if true, include also the per-probe/flow pair statistics in the output /// \return the XML output as string - std::string SerializeToXmlString (int indent, bool enableHistograms, bool enableProbes); + std::string SerializeToXmlString (uint16_t indent, bool enableHistograms, bool enableProbes); /// Same as SerializeToXmlStream, but writes to a file instead /// \param fileName name or path of the output file that will be created diff --git a/src/flow-monitor/model/ipv4-flow-classifier.cc b/src/flow-monitor/model/ipv4-flow-classifier.cc index cbb689e3439..ac9671fc65c 100644 --- a/src/flow-monitor/model/ipv4-flow-classifier.cc +++ b/src/flow-monitor/model/ipv4-flow-classifier.cc @@ -186,17 +186,15 @@ Ipv4FlowClassifier::FindFlow (FlowId flowId) const } void -Ipv4FlowClassifier::SerializeToXmlStream (std::ostream &os, int indent) const +Ipv4FlowClassifier::SerializeToXmlStream (std::ostream &os, uint16_t indent) const { -#define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' '; - - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; indent += 2; for (std::map::const_iterator iter = m_flowMap.begin (); iter != m_flowMap.end (); iter++) { - INDENT (indent); + Indent (os, indent); os << "second << "\"" << " sourceAddress=\"" << iter->first.sourceAddress << "\"" << " destinationAddress=\"" << iter->first.destinationAddress << "\"" @@ -207,9 +205,7 @@ Ipv4FlowClassifier::SerializeToXmlStream (std::ostream &os, int indent) const } indent -= 2; - INDENT (indent); os << "\n"; - -#undef INDENT + Indent (os, indent); os << "\n"; } diff --git a/src/flow-monitor/model/ipv4-flow-classifier.h b/src/flow-monitor/model/ipv4-flow-classifier.h index 36ee27e13a5..49aadbd546f 100644 --- a/src/flow-monitor/model/ipv4-flow-classifier.h +++ b/src/flow-monitor/model/ipv4-flow-classifier.h @@ -69,7 +69,7 @@ class Ipv4FlowClassifier : public FlowClassifier /// \returns the FiveTuple corresponding to flowId FiveTuple FindFlow (FlowId flowId) const; - virtual void SerializeToXmlStream (std::ostream &os, int indent) const; + virtual void SerializeToXmlStream (std::ostream &os, uint16_t indent) const; private: diff --git a/src/flow-monitor/model/ipv6-flow-classifier.cc b/src/flow-monitor/model/ipv6-flow-classifier.cc index b5d82bf675f..5d09b227c58 100644 --- a/src/flow-monitor/model/ipv6-flow-classifier.cc +++ b/src/flow-monitor/model/ipv6-flow-classifier.cc @@ -187,17 +187,15 @@ Ipv6FlowClassifier::FindFlow (FlowId flowId) const } void -Ipv6FlowClassifier::SerializeToXmlStream (std::ostream &os, int indent) const +Ipv6FlowClassifier::SerializeToXmlStream (std::ostream &os, uint16_t indent) const { -#define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' '; - - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; indent += 2; for (std::map::const_iterator iter = m_flowMap.begin (); iter != m_flowMap.end (); iter++) { - INDENT (indent); + Indent (os, indent); os << "second << "\"" << " sourceAddress=\"" << iter->first.sourceAddress << "\"" << " destinationAddress=\"" << iter->first.destinationAddress << "\"" @@ -208,9 +206,8 @@ Ipv6FlowClassifier::SerializeToXmlStream (std::ostream &os, int indent) const } indent -= 2; - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; -#undef INDENT } diff --git a/src/flow-monitor/model/ipv6-flow-classifier.h b/src/flow-monitor/model/ipv6-flow-classifier.h index 8469394cf3e..bd0b9faec65 100644 --- a/src/flow-monitor/model/ipv6-flow-classifier.h +++ b/src/flow-monitor/model/ipv6-flow-classifier.h @@ -70,7 +70,7 @@ class Ipv6FlowClassifier : public FlowClassifier /// \returns the FiveTuple corresponding to flowId FiveTuple FindFlow (FlowId flowId) const; - virtual void SerializeToXmlStream (std::ostream &os, int indent) const; + virtual void SerializeToXmlStream (std::ostream &os, uint16_t indent) const; private: