--- a/samples/main-packet.cc Wed May 30 09:48:53 2007 +0200
+++ b/samples/main-packet.cc Wed May 30 10:03:15 2007 +0200
@@ -15,6 +15,7 @@
void SetData (uint16_t data);
uint16_t GetData (void) const;
private:
+ virtual std::string DoGetName (void) const;
virtual void PrintTo (std::ostream &os) const;
virtual void SerializeTo (Buffer::Iterator start) const;
virtual uint32_t DeserializeFrom (Buffer::Iterator start);
@@ -27,6 +28,11 @@
{}
MyHeader::~MyHeader ()
{}
+std::string
+MyHeader::DoGetName (void) const
+{
+ return "MyHeader";
+}
void
MyHeader::PrintTo (std::ostream &os) const
{
--- a/src/common/chunk.cc Wed May 30 09:48:53 2007 +0200
+++ b/src/common/chunk.cc Wed May 30 10:03:15 2007 +0200
@@ -30,6 +30,11 @@
Chunk::~Chunk ()
{}
+std::string
+Chunk::GetName (void) const
+{
+ return DoGetName ();
+}
void
Chunk::Print (std::ostream &os) const
{
--- a/src/common/chunk.h Wed May 30 09:48:53 2007 +0200
+++ b/src/common/chunk.h Wed May 30 10:03:15 2007 +0200
@@ -33,11 +33,13 @@
Chunk ();
virtual ~Chunk ();
+ std::string GetName (void) const;
void Print (std::ostream &os) const;
uint32_t GetSize (void) const;
void Serialize (Buffer::Iterator start) const;
uint32_t Deserialize (Buffer::Iterator start);
private:
+ virtual std::string DoGetName (void) const = 0;
virtual void PrintTo (std::ostream &os) const = 0;
virtual uint32_t GetSerializedSize (void) const = 0;
virtual void SerializeTo (Buffer::Iterator i) const = 0;
--- a/src/common/header.h Wed May 30 09:48:53 2007 +0200
+++ b/src/common/header.h Wed May 30 10:03:15 2007 +0200
@@ -42,6 +42,10 @@
virtual ~Header ();
private:
/**
+ * \returns a user-readable name to identify this type of header.
+ */
+ virtual std::string DoGetName (void) const = 0;
+ /**
* \param os the std output stream in which this
* protocol header must print itself.
*/
--- a/src/common/packet-history.cc Wed May 30 09:48:53 2007 +0200
+++ b/src/common/packet-history.cc Wed May 30 10:03:15 2007 +0200
@@ -925,6 +925,7 @@
#include <stdarg.h>
#include <iostream>
+#include <sstream>
#include "ns3/test.h"
#include "header.h"
#include "trailer.h"
@@ -964,6 +965,7 @@
class HistoryHeader : public Header
{
private:
+ virtual std::string DoGetName (void) const;
virtual void PrintTo (std::ostream &os) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void SerializeTo (Buffer::Iterator start) const;
@@ -971,6 +973,15 @@
};
template <int N>
+std::string
+HistoryHeader<N>::DoGetName (void) const
+{
+ std::ostringstream oss;
+ oss << N;
+ return oss.str ();
+}
+
+template <int N>
void
HistoryHeader<N>::PrintTo (std::ostream &os) const
{
@@ -1006,6 +1017,7 @@
class HistoryTrailer : public Trailer
{
private:
+ virtual std::string DoGetName (void) const;
virtual void PrintTo (std::ostream &os) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void SerializeTo (Buffer::Iterator start) const;
@@ -1013,6 +1025,14 @@
};
template <int N>
+std::string
+HistoryTrailer<N>::DoGetName (void) const
+{
+ std::ostringstream oss;
+ oss << N;
+ return oss.str ();
+}
+template <int N>
void
HistoryTrailer<N>::PrintTo (std::ostream &os) const
{
--- a/src/common/trailer.h Wed May 30 09:48:53 2007 +0200
+++ b/src/common/trailer.h Wed May 30 10:03:15 2007 +0200
@@ -42,6 +42,10 @@
virtual ~Trailer ();
private:
/**
+ * \returns a user-readable name to identify this type of header.
+ */
+ virtual std::string DoGetName (void) const = 0;
+ /**
* \param os the std output stream in which this
* protocol trailer must print itself.
*/
--- a/src/internet-node/arp-header.cc Wed May 30 09:48:53 2007 +0200
+++ b/src/internet-node/arp-header.cc Wed May 30 10:03:15 2007 +0200
@@ -83,6 +83,11 @@
return m_ipv4Dest;
}
+std::string
+ArpHeader::DoGetName (void) const
+{
+ return "Arp";
+}
void
ArpHeader::PrintTo (std::ostream &os) const
--- a/src/internet-node/arp-header.h Wed May 30 09:48:53 2007 +0200
+++ b/src/internet-node/arp-header.h Wed May 30 10:03:15 2007 +0200
@@ -50,6 +50,7 @@
Ipv4Address GetDestinationIpv4Address (void);
private:
+ virtual std::string DoGetName (void) const;
/**
* \param os
*/
--- a/src/internet-node/ipv4-header.cc Wed May 30 09:48:53 2007 +0200
+++ b/src/internet-node/ipv4-header.cc Wed May 30 10:03:15 2007 +0200
@@ -190,6 +190,12 @@
return m_goodChecksum;
}
+std::string
+Ipv4Header::DoGetName (void) const
+{
+ return "Ipv4";
+}
+
void
Ipv4Header::PrintTo (std::ostream &os) const
{
--- a/src/internet-node/ipv4-header.h Wed May 30 09:48:53 2007 +0200
+++ b/src/internet-node/ipv4-header.h Wed May 30 10:03:15 2007 +0200
@@ -140,6 +140,7 @@
bool IsChecksumOk (void) const;
private:
+ virtual std::string DoGetName (void) const;
virtual void PrintTo (std::ostream &os) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void SerializeTo (Buffer::Iterator start) const;
--- a/src/internet-node/udp-header.cc Wed May 30 09:48:53 2007 +0200
+++ b/src/internet-node/udp-header.cc Wed May 30 10:03:15 2007 +0200
@@ -91,7 +91,11 @@
m_initialChecksum = Ipv4ChecksumCalculate (0, buf, 12);
}
-
+std::string
+UdpHeader::DoGetName (void) const
+{
+ return "Udp";
+}
void
UdpHeader::PrintTo (std::ostream &os) const
--- a/src/internet-node/udp-header.h Wed May 30 09:48:53 2007 +0200
+++ b/src/internet-node/udp-header.h Wed May 30 10:03:15 2007 +0200
@@ -81,6 +81,7 @@
uint8_t protocol);
private:
+ virtual std::string DoGetName (void) const;
virtual void PrintTo (std::ostream &os) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void SerializeTo (Buffer::Iterator start) const;
--- a/src/node/llc-snap-header.cc Wed May 30 09:48:53 2007 +0200
+++ b/src/node/llc-snap-header.cc Wed May 30 10:03:15 2007 +0200
@@ -47,6 +47,12 @@
return 1 + 1 + 1 + 3 + 2;
}
+std::string
+LlcSnapHeader::DoGetName (void) const
+{
+ return "LlcSnap";
+}
+
void
LlcSnapHeader::PrintTo (std::ostream &os) const
{
--- a/src/node/llc-snap-header.h Wed May 30 09:48:53 2007 +0200
+++ b/src/node/llc-snap-header.h Wed May 30 10:03:15 2007 +0200
@@ -37,6 +37,7 @@
uint16_t GetType (void);
private:
+ virtual std::string DoGetName (void) const;
virtual void PrintTo (std::ostream &os) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void SerializeTo (Buffer::Iterator start) const;