add Chunk::GetName and implement it
parent
d9f03cafbe
commit
66c3a25fe1
|
@ -15,6 +15,7 @@ public:
|
|||
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 ()
|
|||
{}
|
||||
MyHeader::~MyHeader ()
|
||||
{}
|
||||
std::string
|
||||
MyHeader::DoGetName (void) const
|
||||
{
|
||||
return "MyHeader";
|
||||
}
|
||||
void
|
||||
MyHeader::PrintTo (std::ostream &os) const
|
||||
{
|
||||
|
|
|
@ -30,6 +30,11 @@ Chunk::Chunk ()
|
|||
Chunk::~Chunk ()
|
||||
{}
|
||||
|
||||
std::string
|
||||
Chunk::GetName (void) const
|
||||
{
|
||||
return DoGetName ();
|
||||
}
|
||||
void
|
||||
Chunk::Print (std::ostream &os) const
|
||||
{
|
||||
|
|
|
@ -33,11 +33,13 @@ public:
|
|||
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;
|
||||
|
|
|
@ -41,6 +41,10 @@ class Header : public Chunk {
|
|||
public:
|
||||
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.
|
||||
|
|
|
@ -925,6 +925,7 @@ PacketHistory::RegisterChunkFactory (Chunk *(*createStatic) (void))
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "ns3/test.h"
|
||||
#include "header.h"
|
||||
#include "trailer.h"
|
||||
|
@ -964,12 +965,22 @@ template <int N>
|
|||
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;
|
||||
virtual uint32_t DeserializeFrom (Buffer::Iterator start);
|
||||
};
|
||||
|
||||
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,12 +1017,21 @@ template <int N>
|
|||
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;
|
||||
virtual uint32_t DeserializeFrom (Buffer::Iterator start);
|
||||
};
|
||||
|
||||
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
|
||||
|
|
|
@ -41,6 +41,10 @@ class Trailer : public Chunk {
|
|||
public:
|
||||
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.
|
||||
|
|
|
@ -83,6 +83,11 @@ ArpHeader::GetDestinationIpv4Address (void)
|
|||
return m_ipv4Dest;
|
||||
}
|
||||
|
||||
std::string
|
||||
ArpHeader::DoGetName (void) const
|
||||
{
|
||||
return "Arp";
|
||||
}
|
||||
|
||||
void
|
||||
ArpHeader::PrintTo (std::ostream &os) const
|
||||
|
|
|
@ -50,6 +50,7 @@ class ArpHeader : public Header {
|
|||
Ipv4Address GetDestinationIpv4Address (void);
|
||||
|
||||
private:
|
||||
virtual std::string DoGetName (void) const;
|
||||
/**
|
||||
* \param os
|
||||
*/
|
||||
|
|
|
@ -190,6 +190,12 @@ Ipv4Header::IsChecksumOk (void) const
|
|||
return m_goodChecksum;
|
||||
}
|
||||
|
||||
std::string
|
||||
Ipv4Header::DoGetName (void) const
|
||||
{
|
||||
return "Ipv4";
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::PrintTo (std::ostream &os) const
|
||||
{
|
||||
|
|
|
@ -140,6 +140,7 @@ public:
|
|||
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;
|
||||
|
|
|
@ -91,7 +91,11 @@ UdpHeader::InitializeChecksum (Ipv4Address source,
|
|||
m_initialChecksum = Ipv4ChecksumCalculate (0, buf, 12);
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
UdpHeader::DoGetName (void) const
|
||||
{
|
||||
return "Udp";
|
||||
}
|
||||
|
||||
void
|
||||
UdpHeader::PrintTo (std::ostream &os) const
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
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;
|
||||
|
|
|
@ -47,6 +47,12 @@ LlcSnapHeader::GetSerializedSize (void) const
|
|||
return 1 + 1 + 1 + 3 + 2;
|
||||
}
|
||||
|
||||
std::string
|
||||
LlcSnapHeader::DoGetName (void) const
|
||||
{
|
||||
return "LlcSnap";
|
||||
}
|
||||
|
||||
void
|
||||
LlcSnapHeader::PrintTo (std::ostream &os) const
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@ class LlcSnapHeader : public Header {
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue