TcpHeader can be printed in NS_LOG messages
authorNatale Patriciello <natale.patriciello@gmail.com>
Mon, 13 Jul 2015 08:23:40 -0700
changeset 11509 265efea1f685
parent 11508 e50a1cb4d7db
child 11510 030e5d6efdd6
TcpHeader can be printed in NS_LOG messages Implemented the operator << to an output stream.
src/internet/model/tcp-header.cc
src/internet/model/tcp-header.h
--- a/src/internet/model/tcp-header.cc	Mon Jul 13 08:06:38 2015 -0700
+++ b/src/internet/model/tcp-header.cc	Mon Jul 13 08:23:40 2015 -0700
@@ -516,4 +516,11 @@
     );
 }
 
+std::ostream&
+operator<< (std::ostream& os, TcpHeader const & tc)
+{
+  tc.Print (os);
+  return os;
+}
+
 } // namespace ns3
--- a/src/internet/model/tcp-header.h	Mon Jul 13 08:06:38 2015 -0700
+++ b/src/internet/model/tcp-header.h	Mon Jul 13 08:23:40 2015 -0700
@@ -48,6 +48,15 @@
   virtual ~TcpHeader ();
 
   /**
+   * \brief Print a TCP header into an output stream
+   *
+   * \param os output stream
+   * \param tc TCP header to print
+   * \return The ostream passed as first argument
+   */
+  friend std::ostream& operator<<(std::ostream& os, TcpHeader const & tc);
+
+  /**
    * \brief Converts an integer into a human readable list of Tcp flags
    *
    * \param flags Bitfield of TCP flags to convert to a readable string