remove Chunk base class
This commit is contained in:
@@ -17,13 +17,13 @@ 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);
|
||||
virtual uint32_t GetSerializedSize (void) const;
|
||||
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
void Serialize (Buffer::Iterator start) const;
|
||||
uint32_t Deserialize (Buffer::Iterator start);
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
private:
|
||||
uint16_t m_data;
|
||||
};
|
||||
|
||||
@@ -47,14 +47,14 @@ MyHeader::GetUid (void)
|
||||
}
|
||||
|
||||
std::string
|
||||
MyHeader::DoGetName (void) const
|
||||
MyHeader::GetName (void) const
|
||||
{
|
||||
// This string is used to identify the type of
|
||||
// my header by the packet printing routines.
|
||||
return "MYHEADER";
|
||||
}
|
||||
void
|
||||
MyHeader::PrintTo (std::ostream &os) const
|
||||
MyHeader::Print (std::ostream &os) const
|
||||
{
|
||||
// This method is invoked by the packet printing
|
||||
// routines to print the content of my header.
|
||||
@@ -67,14 +67,14 @@ MyHeader::GetSerializedSize (void) const
|
||||
return 2;
|
||||
}
|
||||
void
|
||||
MyHeader::SerializeTo (Buffer::Iterator start) const
|
||||
MyHeader::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
// we can serialize two bytes at the start of the buffer.
|
||||
// we write them in network byte order.
|
||||
start.WriteHtonU16 (m_data);
|
||||
}
|
||||
uint32_t
|
||||
MyHeader::DeserializeFrom (Buffer::Iterator start)
|
||||
MyHeader::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
// we can deserialize two bytes from the start of the buffer.
|
||||
// we read them in network byte order and store them
|
||||
|
||||
@@ -19,55 +19,11 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "chunk.h"
|
||||
#include "chunk-registry.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Chunk::Chunk ()
|
||||
{}
|
||||
|
||||
Chunk::~Chunk ()
|
||||
{}
|
||||
|
||||
std::string
|
||||
Chunk::GetName (void) const
|
||||
{
|
||||
return DoGetName ();
|
||||
}
|
||||
void
|
||||
Chunk::Print (std::ostream &os) const
|
||||
{
|
||||
PrintTo (os);
|
||||
}
|
||||
uint32_t
|
||||
Chunk::GetSize (void) const
|
||||
{
|
||||
return GetSerializedSize ();
|
||||
}
|
||||
void
|
||||
Chunk::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
SerializeTo (start);
|
||||
}
|
||||
uint32_t
|
||||
Chunk::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
uint32_t deserialized = DeserializeFrom (start);
|
||||
return deserialized;
|
||||
}
|
||||
std::ostream& operator<< (std::ostream& os, Chunk const& chunk)
|
||||
{
|
||||
chunk.Print (os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
/**************************************
|
||||
* The Chunk Registry below
|
||||
***************************************/
|
||||
|
||||
|
||||
ChunkRegistry::InfoVector *
|
||||
ChunkRegistry::GetInfoVector (void)
|
||||
{
|
||||
@@ -19,8 +19,8 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef CHUNK_H
|
||||
#define CHUNK_H
|
||||
#ifndef CHUNK_REGISTRY_H
|
||||
#define CHUNK_REGISTRY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ostream>
|
||||
@@ -30,26 +30,6 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Chunk {
|
||||
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;
|
||||
virtual uint32_t DeserializeFrom (Buffer::Iterator i) = 0;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Chunk const& chunk);
|
||||
|
||||
/**
|
||||
* \brief this registry keeps track of all different
|
||||
* types of headers and trailers and assigns to each of them
|
||||
@@ -1,29 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "header.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Header::~Header ()
|
||||
{}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef HEADER_H
|
||||
#define HEADER_H
|
||||
|
||||
#include "chunk.h"
|
||||
#include "chunk-registry.h"
|
||||
|
||||
/**
|
||||
* \relates Header
|
||||
@@ -87,12 +87,12 @@ namespace ns3 {
|
||||
* Sample code which shows how to create a new Header, and how to use it,
|
||||
* is shown in the sample file samples/main-header.cc
|
||||
*/
|
||||
class Header : public Chunk {
|
||||
class Header {
|
||||
public:
|
||||
virtual ~Header ();
|
||||
protected:
|
||||
template <typename T>
|
||||
static uint32_t Register (std::string uuid);
|
||||
#if 0
|
||||
private:
|
||||
/**
|
||||
* \returns a user-readable name to identify this type of header.
|
||||
@@ -143,6 +143,7 @@ private:
|
||||
* Packet::RemoveHeader
|
||||
*/
|
||||
virtual uint32_t DeserializeFrom (Buffer::Iterator start) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -38,12 +38,12 @@ public:
|
||||
static uint32_t GetUid (void);
|
||||
HistoryHeader ();
|
||||
bool IsOk (void) const;
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
void Serialize (Buffer::Iterator start) const;
|
||||
uint32_t Deserialize (Buffer::Iterator start);
|
||||
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);
|
||||
bool m_ok;
|
||||
};
|
||||
|
||||
@@ -71,7 +71,7 @@ HistoryHeader<N>::IsOk (void) const
|
||||
|
||||
template <int N>
|
||||
std::string
|
||||
HistoryHeader<N>::DoGetName (void) const
|
||||
HistoryHeader<N>::GetName (void) const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << N;
|
||||
@@ -80,7 +80,7 @@ HistoryHeader<N>::DoGetName (void) const
|
||||
|
||||
template <int N>
|
||||
void
|
||||
HistoryHeader<N>::PrintTo (std::ostream &os) const
|
||||
HistoryHeader<N>::Print (std::ostream &os) const
|
||||
{
|
||||
NS_ASSERT (false);
|
||||
}
|
||||
@@ -92,13 +92,13 @@ HistoryHeader<N>::GetSerializedSize (void) const
|
||||
}
|
||||
template <int N>
|
||||
void
|
||||
HistoryHeader<N>::SerializeTo (Buffer::Iterator start) const
|
||||
HistoryHeader<N>::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
start.WriteU8 (N, N);
|
||||
}
|
||||
template <int N>
|
||||
uint32_t
|
||||
HistoryHeader<N>::DeserializeFrom (Buffer::Iterator start)
|
||||
HistoryHeader<N>::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
m_ok = true;
|
||||
for (int i = 0; i < N; i++)
|
||||
@@ -118,12 +118,12 @@ public:
|
||||
static uint32_t GetUid (void);
|
||||
HistoryTrailer ();
|
||||
bool IsOk (void) const;
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
void Serialize (Buffer::Iterator start) const;
|
||||
uint32_t Deserialize (Buffer::Iterator start);
|
||||
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);
|
||||
bool m_ok;
|
||||
};
|
||||
|
||||
@@ -152,7 +152,7 @@ HistoryTrailer<N>::IsOk (void) const
|
||||
|
||||
template <int N>
|
||||
std::string
|
||||
HistoryTrailer<N>::DoGetName (void) const
|
||||
HistoryTrailer<N>::GetName (void) const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << N;
|
||||
@@ -160,7 +160,7 @@ HistoryTrailer<N>::DoGetName (void) const
|
||||
}
|
||||
template <int N>
|
||||
void
|
||||
HistoryTrailer<N>::PrintTo (std::ostream &os) const
|
||||
HistoryTrailer<N>::Print (std::ostream &os) const
|
||||
{
|
||||
NS_ASSERT (false);
|
||||
}
|
||||
@@ -172,14 +172,14 @@ HistoryTrailer<N>::GetSerializedSize (void) const
|
||||
}
|
||||
template <int N>
|
||||
void
|
||||
HistoryTrailer<N>::SerializeTo (Buffer::Iterator start) const
|
||||
HistoryTrailer<N>::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
start.Prev (N);
|
||||
start.WriteU8 (N, N);
|
||||
}
|
||||
template <int N>
|
||||
uint32_t
|
||||
HistoryTrailer<N>::DeserializeFrom (Buffer::Iterator start)
|
||||
HistoryTrailer<N>::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
m_ok = true;
|
||||
start.Prev (N);
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "ns3/fatal-error.h"
|
||||
#include "ns3/debug.h"
|
||||
#include "packet-metadata.h"
|
||||
#include "chunk.h"
|
||||
#include "buffer.h"
|
||||
#include "chunk-registry.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("PacketMetadata");
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "packet-printer.h"
|
||||
#include "chunk-registry.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "buffer.h"
|
||||
#include "chunk.h"
|
||||
#include <vector>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
uint32_t GetSize (void) const;
|
||||
/**
|
||||
* Add header to this packet. This method invokes the
|
||||
* ns3::Chunk::GetSerializedSize and ns3::Chunk::SerializeTo
|
||||
* ns3::Header::GetSerializedSize and ns3::Header::SerializeTo
|
||||
* methods to reserve space in the buffer and request the
|
||||
* header to serialize itself in the packet buffer.
|
||||
*
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
void AddHeader (T const &header);
|
||||
/**
|
||||
* Deserialize and remove the header from the internal buffer.
|
||||
* This method invokes ns3::Chunk::DeserializeFrom.
|
||||
* This method invokes ns3::Header::DeserializeFrom.
|
||||
*
|
||||
* \param header a reference to the header to remove from the internal buffer.
|
||||
* \returns the number of bytes removed from the packet.
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
uint32_t RemoveHeader (T &header);
|
||||
/**
|
||||
* Add trailer to this packet. This method invokes the
|
||||
* ns3::Chunk::GetSerializedSize and ns3::Trailer::serializeTo
|
||||
* ns3::Trailer::GetSerializedSize and ns3::Trailer::serializeTo
|
||||
* methods to reserve space in the buffer and request the trailer
|
||||
* to serialize itself in the packet buffer.
|
||||
*
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
void AddTrailer (T const &trailer);
|
||||
/**
|
||||
* Remove a deserialized trailer from the internal buffer.
|
||||
* This method invokes the ns3::Chunk::DeserializeFrom method.
|
||||
* This method invokes the ns3::Trailer::DeserializeFrom method.
|
||||
*
|
||||
* \param trailer a reference to the trailer to remove from the internal buffer.
|
||||
* \returns the number of bytes removed from the end of the packet.
|
||||
@@ -416,9 +416,11 @@ template <typename T>
|
||||
void
|
||||
Packet::AddHeader (T const &header)
|
||||
{
|
||||
NS_ASSERT_MSG (dynamic_cast<Header const *> (&header) != 0,
|
||||
"Must pass Header subclass to Packet::AddHeader");
|
||||
uint32_t size = header.GetSize ();
|
||||
const Header *testHeader;
|
||||
// if the following assignment fails, it is because the
|
||||
// input to this function is not a subclass of the Header class
|
||||
testHeader = &header;
|
||||
uint32_t size = header.GetSerializedSize ();
|
||||
m_buffer.AddAtStart (size);
|
||||
header.Serialize (m_buffer.Begin ());
|
||||
m_metadata.AddHeader (header, size);
|
||||
@@ -427,8 +429,10 @@ template <typename T>
|
||||
uint32_t
|
||||
Packet::RemoveHeader (T &header)
|
||||
{
|
||||
NS_ASSERT_MSG (dynamic_cast<Header const *> (&header) != 0,
|
||||
"Must pass Header subclass to Packet::RemoveHeader");
|
||||
Header *testHeader;
|
||||
// if the following assignment fails, it is because the
|
||||
// input to this function is not a subclass of the Header class
|
||||
testHeader = &header;
|
||||
uint32_t deserialized = header.Deserialize (m_buffer.Begin ());
|
||||
m_buffer.RemoveAtStart (deserialized);
|
||||
m_metadata.RemoveHeader (header, deserialized);
|
||||
@@ -438,9 +442,11 @@ template <typename T>
|
||||
void
|
||||
Packet::AddTrailer (T const &trailer)
|
||||
{
|
||||
NS_ASSERT_MSG (dynamic_cast<Trailer const *> (&trailer) != 0,
|
||||
"Must pass Trailer subclass to Packet::AddTrailer");
|
||||
uint32_t size = trailer.GetSize ();
|
||||
const Trailer *testTrailer;
|
||||
// if the following assignment fails, it is because the
|
||||
// input to this function is not a subclass of the Trailer class
|
||||
testTrailer = &trailer;
|
||||
uint32_t size = trailer.GetSerializedSize ();
|
||||
m_buffer.AddAtEnd (size);
|
||||
Buffer::Iterator end = m_buffer.End ();
|
||||
trailer.Serialize (end);
|
||||
@@ -450,8 +456,10 @@ template <typename T>
|
||||
uint32_t
|
||||
Packet::RemoveTrailer (T &trailer)
|
||||
{
|
||||
NS_ASSERT_MSG (dynamic_cast<Trailer const *> (&trailer) != 0,
|
||||
"Must pass Trailer subclass to Packet::RemoveTrailer");
|
||||
Trailer *testTrailer;
|
||||
// if the following assignment fails, it is because the
|
||||
// input to this function is not a subclass of the Trailer class
|
||||
testTrailer = &trailer;
|
||||
uint32_t deserialized = trailer.Deserialize (m_buffer.End ());
|
||||
m_buffer.RemoveAtEnd (deserialized);
|
||||
m_metadata.RemoveTrailer (trailer, deserialized);
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "trailer.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Trailer::~Trailer ()
|
||||
{}
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef TRAILER_H
|
||||
#define TRAILER_H
|
||||
|
||||
#include "chunk.h"
|
||||
#include "chunk-registry.h"
|
||||
|
||||
/**
|
||||
* \relates Trailer
|
||||
@@ -110,12 +110,12 @@ namespace ns3 {
|
||||
* trailers), the input iterator to DeserializeFrom and SerializeTo points
|
||||
* to the end of the trailer, and not its start.
|
||||
*/
|
||||
class Trailer : public Chunk {
|
||||
class Trailer {
|
||||
public:
|
||||
virtual ~Trailer ();
|
||||
protected:
|
||||
template <typename T>
|
||||
static uint32_t Register (std::string uidString);
|
||||
#if 0
|
||||
private:
|
||||
/**
|
||||
* \returns a user-readable name to identify this type of header.
|
||||
@@ -170,6 +170,7 @@ private:
|
||||
* amount when this method is invoked from Packet::RemoveTrailer
|
||||
*/
|
||||
virtual uint32_t DeserializeFrom (Buffer::Iterator end) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -7,9 +7,7 @@ def build(bld):
|
||||
common.uselib_local = ['ns3-core', 'ns3-simulator']
|
||||
common.source = [
|
||||
'buffer.cc',
|
||||
'chunk.cc',
|
||||
'header.cc',
|
||||
'trailer.cc',
|
||||
'chunk-registry.cc',
|
||||
'packet-printer.cc',
|
||||
'packet-metadata.cc',
|
||||
'packet-metadata-test.cc',
|
||||
@@ -30,7 +28,7 @@ def build(bld):
|
||||
headers = bld.create_obj('ns3header')
|
||||
headers.source = [
|
||||
'buffer.h',
|
||||
'chunk.h',
|
||||
'chunk-registry.h',
|
||||
'header.h',
|
||||
'trailer.h',
|
||||
'tags.h',
|
||||
|
||||
@@ -203,7 +203,7 @@ CsmaCdNetDevice::AddHeader (Packet& p, Eui48Address dest,
|
||||
switch (m_encapMode)
|
||||
{
|
||||
case ETHERNET_V1:
|
||||
lengthType = p.GetSize() + header.GetSize() + trailer.GetSize();
|
||||
lengthType = p.GetSize() + header.GetSerializedSize() + trailer.GetSerializedSize();
|
||||
break;
|
||||
case IP_ARP:
|
||||
lengthType = protocolNumber;
|
||||
|
||||
@@ -34,9 +34,6 @@ ArpHeader::GetUid (void)
|
||||
return uid;
|
||||
}
|
||||
|
||||
ArpHeader::~ArpHeader ()
|
||||
{}
|
||||
|
||||
void
|
||||
ArpHeader::SetRequest (Address sourceHardwareAddress,
|
||||
Ipv4Address sourceProtocolAddress,
|
||||
@@ -93,13 +90,13 @@ ArpHeader::GetDestinationIpv4Address (void)
|
||||
}
|
||||
|
||||
std::string
|
||||
ArpHeader::DoGetName (void) const
|
||||
ArpHeader::GetName (void) const
|
||||
{
|
||||
return "ARP";
|
||||
}
|
||||
|
||||
void
|
||||
ArpHeader::PrintTo (std::ostream &os) const
|
||||
ArpHeader::Print (std::ostream &os) const
|
||||
{
|
||||
if (IsRequest ())
|
||||
{
|
||||
@@ -132,7 +129,7 @@ ArpHeader::GetSerializedSize (void) const
|
||||
}
|
||||
|
||||
void
|
||||
ArpHeader::SerializeTo (Buffer::Iterator start) const
|
||||
ArpHeader::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
NS_ASSERT (m_macSource.GetLength () == m_macDest.GetLength ());
|
||||
@@ -150,7 +147,7 @@ ArpHeader::SerializeTo (Buffer::Iterator start) const
|
||||
WriteTo (i, m_ipv4Dest);
|
||||
}
|
||||
uint32_t
|
||||
ArpHeader::DeserializeFrom (Buffer::Iterator start)
|
||||
ArpHeader::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
i.Next (2+2);
|
||||
|
||||
@@ -36,8 +36,6 @@ class ArpHeader : public Header
|
||||
public:
|
||||
static uint32_t GetUid (void);
|
||||
|
||||
virtual ~ArpHeader ();
|
||||
|
||||
void SetRequest (Address sourceHardwareAddress,
|
||||
Ipv4Address sourceProtocolAddress,
|
||||
Address destinationHardwareAddress,
|
||||
@@ -53,25 +51,11 @@ public:
|
||||
Ipv4Address GetSourceIpv4Address (void);
|
||||
Ipv4Address GetDestinationIpv4Address (void);
|
||||
|
||||
private:
|
||||
virtual std::string DoGetName (void) const;
|
||||
/**
|
||||
* \param os
|
||||
*/
|
||||
virtual void PrintTo (std::ostream &os) const;
|
||||
/**
|
||||
* \return
|
||||
*/
|
||||
virtual uint32_t GetSerializedSize (void) const;
|
||||
/**
|
||||
* \param start
|
||||
*/
|
||||
virtual void SerializeTo (Buffer::Iterator start) const;
|
||||
/**
|
||||
* \param start
|
||||
* \return
|
||||
*/
|
||||
virtual uint32_t DeserializeFrom (Buffer::Iterator start);
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
void Serialize (Buffer::Iterator start) const;
|
||||
uint32_t Deserialize (Buffer::Iterator start);
|
||||
|
||||
enum ArpType_e {
|
||||
ARP_TYPE_REQUEST = 1,
|
||||
|
||||
@@ -49,8 +49,6 @@ Ipv4Header::Ipv4Header ()
|
||||
m_fragmentOffset (0),
|
||||
m_goodChecksum (true)
|
||||
{}
|
||||
Ipv4Header::~Ipv4Header ()
|
||||
{}
|
||||
|
||||
void
|
||||
Ipv4Header::EnableChecksums (void)
|
||||
@@ -189,13 +187,13 @@ Ipv4Header::IsChecksumOk (void) const
|
||||
}
|
||||
|
||||
std::string
|
||||
Ipv4Header::DoGetName (void) const
|
||||
Ipv4Header::GetName (void) const
|
||||
{
|
||||
return "IPV4";
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::PrintTo (std::ostream &os) const
|
||||
Ipv4Header::Print (std::ostream &os) const
|
||||
{
|
||||
// ipv4, right ?
|
||||
std::string flags;
|
||||
@@ -238,7 +236,7 @@ Ipv4Header::GetSerializedSize (void) const
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::SerializeTo (Buffer::Iterator start) const
|
||||
Ipv4Header::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
|
||||
@@ -281,7 +279,7 @@ Ipv4Header::SerializeTo (Buffer::Iterator start) const
|
||||
}
|
||||
}
|
||||
uint32_t
|
||||
Ipv4Header::DeserializeFrom (Buffer::Iterator start)
|
||||
Ipv4Header::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
uint8_t verIhl = i.ReadU8 ();
|
||||
|
||||
@@ -37,7 +37,6 @@ public:
|
||||
* \brief Construct a null IPv4 header
|
||||
*/
|
||||
Ipv4Header ();
|
||||
virtual ~Ipv4Header ();
|
||||
/**
|
||||
* \brief Enable checksum calculation for IP (XXX currently has no effect)
|
||||
*/
|
||||
@@ -141,12 +140,12 @@ public:
|
||||
*/
|
||||
bool IsChecksumOk (void) const;
|
||||
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
void Serialize (Buffer::Iterator start) const;
|
||||
uint32_t Deserialize (Buffer::Iterator start);
|
||||
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);
|
||||
|
||||
enum FlagsE {
|
||||
DONT_FRAGMENT = (1<<0),
|
||||
@@ -167,7 +166,7 @@ private:
|
||||
bool m_goodChecksum;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
#endif /* IPV4_HEADER_H */
|
||||
|
||||
@@ -93,7 +93,7 @@ UdpHeader::InitializeChecksum (Ipv4Address source,
|
||||
destination.Serialize (buf+4);
|
||||
buf[8] = 0;
|
||||
buf[9] = protocol;
|
||||
uint16_t udpLength = m_payloadSize + GetSize ();
|
||||
uint16_t udpLength = m_payloadSize + GetSerializedSize ();
|
||||
buf[10] = udpLength >> 8;
|
||||
buf[11] = udpLength & 0xff;
|
||||
|
||||
@@ -101,16 +101,16 @@ UdpHeader::InitializeChecksum (Ipv4Address source,
|
||||
}
|
||||
|
||||
std::string
|
||||
UdpHeader::DoGetName (void) const
|
||||
UdpHeader::GetName (void) const
|
||||
{
|
||||
return "UDP";
|
||||
}
|
||||
|
||||
void
|
||||
UdpHeader::PrintTo (std::ostream &os) const
|
||||
UdpHeader::Print (std::ostream &os) const
|
||||
{
|
||||
os << "("
|
||||
<< "length: " << m_payloadSize + GetSize ()
|
||||
<< "length: " << m_payloadSize + GetSerializedSize ()
|
||||
<< ") "
|
||||
<< m_sourcePort << " > " << m_destinationPort
|
||||
;
|
||||
@@ -123,12 +123,12 @@ UdpHeader::GetSerializedSize (void) const
|
||||
}
|
||||
|
||||
void
|
||||
UdpHeader::SerializeTo (Buffer::Iterator start) const
|
||||
UdpHeader::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
i.WriteHtonU16 (m_sourcePort);
|
||||
i.WriteHtonU16 (m_destinationPort);
|
||||
i.WriteHtonU16 (m_payloadSize + GetSize ());
|
||||
i.WriteHtonU16 (m_payloadSize + GetSerializedSize ());
|
||||
i.WriteU16 (0);
|
||||
|
||||
if (m_calcChecksum)
|
||||
@@ -137,7 +137,7 @@ UdpHeader::SerializeTo (Buffer::Iterator start) const
|
||||
//XXXX
|
||||
uint16_t checksum = Ipv4ChecksumCalculate (m_initialChecksum,
|
||||
buffer->PeekData (),
|
||||
GetSize () + m_payloadSize);
|
||||
GetSerializedSize () + m_payloadSize);
|
||||
checksum = Ipv4ChecksumComplete (checksum);
|
||||
i = buffer->Begin ();
|
||||
i.Next (6);
|
||||
@@ -146,12 +146,12 @@ UdpHeader::SerializeTo (Buffer::Iterator start) const
|
||||
}
|
||||
}
|
||||
uint32_t
|
||||
UdpHeader::DeserializeFrom (Buffer::Iterator start)
|
||||
UdpHeader::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
m_sourcePort = i.ReadNtohU16 ();
|
||||
m_destinationPort = i.ReadNtohU16 ();
|
||||
m_payloadSize = i.ReadNtohU16 () - GetSize ();
|
||||
m_payloadSize = i.ReadNtohU16 () - GetSerializedSize ();
|
||||
if (m_calcChecksum)
|
||||
{
|
||||
// XXX verify checksum.
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
* Creates a null header
|
||||
*/
|
||||
UdpHeader ();
|
||||
virtual ~UdpHeader ();
|
||||
~UdpHeader ();
|
||||
|
||||
/**
|
||||
* \brief Enable checksum calculation for UDP (XXX currently has no effect)
|
||||
@@ -84,13 +84,13 @@ public:
|
||||
Ipv4Address destination,
|
||||
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;
|
||||
virtual uint32_t DeserializeFrom (Buffer::Iterator start);
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
void Serialize (Buffer::Iterator start) const;
|
||||
uint32_t Deserialize (Buffer::Iterator start);
|
||||
|
||||
private:
|
||||
uint16_t m_sourcePort;
|
||||
uint16_t m_destinationPort;
|
||||
uint16_t m_payloadSize;
|
||||
@@ -99,6 +99,6 @@ private:
|
||||
static bool m_calcChecksum;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* UDP_HEADER */
|
||||
|
||||
@@ -48,9 +48,6 @@ EthernetHeader::EthernetHeader ()
|
||||
m_lengthType (0)
|
||||
{}
|
||||
|
||||
EthernetHeader::~EthernetHeader ()
|
||||
{}
|
||||
|
||||
void
|
||||
EthernetHeader::SetLengthType (uint16_t lengthType)
|
||||
{
|
||||
@@ -108,13 +105,13 @@ EthernetHeader::GetHeaderSize (void) const
|
||||
}
|
||||
|
||||
std::string
|
||||
EthernetHeader::DoGetName (void) const
|
||||
EthernetHeader::GetName (void) const
|
||||
{
|
||||
return "ETHERNET";
|
||||
}
|
||||
|
||||
void
|
||||
EthernetHeader::PrintTo (std::ostream &os) const
|
||||
EthernetHeader::Print (std::ostream &os) const
|
||||
{
|
||||
// ethernet, right ?
|
||||
if (m_enPreambleSfd)
|
||||
@@ -139,7 +136,7 @@ EthernetHeader::GetSerializedSize (void) const
|
||||
}
|
||||
|
||||
void
|
||||
EthernetHeader::SerializeTo (Buffer::Iterator start) const
|
||||
EthernetHeader::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
|
||||
@@ -152,7 +149,7 @@ EthernetHeader::SerializeTo (Buffer::Iterator start) const
|
||||
i.WriteU16 (m_lengthType);
|
||||
}
|
||||
uint32_t
|
||||
EthernetHeader::DeserializeFrom (Buffer::Iterator start)
|
||||
EthernetHeader::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@ public:
|
||||
* By default, does not add or remove an ethernet preamble
|
||||
*/
|
||||
EthernetHeader ();
|
||||
virtual ~EthernetHeader ();
|
||||
/**
|
||||
* \param size The size of the payload in bytes
|
||||
*/
|
||||
@@ -104,17 +103,16 @@ public:
|
||||
*/
|
||||
uint32_t GetHeaderSize() const;
|
||||
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
void Serialize (Buffer::Iterator start) const;
|
||||
uint32_t Deserialize (Buffer::Iterator start);
|
||||
private:
|
||||
static const int PREAMBLE_SIZE = 8; /// size of the preamble_sfd header field
|
||||
static const int LENGTH_SIZE = 2; /// size of the length_type header field
|
||||
static const int MAC_ADDR_SIZE = 6; /// size of src/dest addr header fields
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* If false, the preamble/sfd are not serialised/deserialised.
|
||||
*/
|
||||
|
||||
@@ -44,9 +44,6 @@ EthernetTrailer::EthernetTrailer ()
|
||||
Init();
|
||||
}
|
||||
|
||||
EthernetTrailer::~EthernetTrailer ()
|
||||
{}
|
||||
|
||||
void EthernetTrailer::Init()
|
||||
{
|
||||
m_fcs = 0;
|
||||
@@ -94,13 +91,13 @@ EthernetTrailer::GetTrailerSize (void) const
|
||||
return GetSerializedSize();
|
||||
}
|
||||
std::string
|
||||
EthernetTrailer::DoGetName (void) const
|
||||
EthernetTrailer::GetName (void) const
|
||||
{
|
||||
return "ETHERNET";
|
||||
}
|
||||
|
||||
void
|
||||
EthernetTrailer::PrintTo (std::ostream &os) const
|
||||
EthernetTrailer::Print (std::ostream &os) const
|
||||
{
|
||||
os << " fcs=" << m_fcs;
|
||||
}
|
||||
@@ -111,7 +108,7 @@ EthernetTrailer::GetSerializedSize (void) const
|
||||
}
|
||||
|
||||
void
|
||||
EthernetTrailer::SerializeTo (Buffer::Iterator end) const
|
||||
EthernetTrailer::Serialize (Buffer::Iterator end) const
|
||||
{
|
||||
Buffer::Iterator i = end;
|
||||
i.Prev(GetSerializedSize());
|
||||
@@ -119,7 +116,7 @@ EthernetTrailer::SerializeTo (Buffer::Iterator end) const
|
||||
i.WriteU32 (m_fcs);
|
||||
}
|
||||
uint32_t
|
||||
EthernetTrailer::DeserializeFrom (Buffer::Iterator end)
|
||||
EthernetTrailer::Deserialize (Buffer::Iterator end)
|
||||
{
|
||||
Buffer::Iterator i = end;
|
||||
uint32_t size = GetSerializedSize();
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
* \brief Construct a null ethernet trailer
|
||||
*/
|
||||
EthernetTrailer ();
|
||||
virtual ~EthernetTrailer ();
|
||||
|
||||
/**
|
||||
* \brief Enable or disabled FCS checking and calculations
|
||||
* \param enable If true, enables FCS calculations.
|
||||
@@ -81,12 +81,12 @@ public:
|
||||
*/
|
||||
uint32_t GetTrailerSize() const;
|
||||
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
void Serialize (Buffer::Iterator end) const;
|
||||
uint32_t Deserialize (Buffer::Iterator end);
|
||||
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 end) const;
|
||||
virtual uint32_t DeserializeFrom (Buffer::Iterator end);
|
||||
|
||||
/**
|
||||
* Initializes the trailer parameters during construction.
|
||||
@@ -102,7 +102,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
#endif /* ETHERNET_TRAILER_H */
|
||||
|
||||
@@ -38,8 +38,6 @@ LlcSnapHeader::GetUid (void)
|
||||
LlcSnapHeader::LlcSnapHeader ()
|
||||
{}
|
||||
|
||||
LlcSnapHeader::~LlcSnapHeader ()
|
||||
{}
|
||||
void
|
||||
LlcSnapHeader::SetType (uint16_t type)
|
||||
{
|
||||
@@ -58,13 +56,13 @@ LlcSnapHeader::GetSerializedSize (void) const
|
||||
}
|
||||
|
||||
std::string
|
||||
LlcSnapHeader::DoGetName (void) const
|
||||
LlcSnapHeader::GetName (void) const
|
||||
{
|
||||
return "LLCSNAP";
|
||||
}
|
||||
|
||||
void
|
||||
LlcSnapHeader::PrintTo (std::ostream &os) const
|
||||
LlcSnapHeader::Print (std::ostream &os) const
|
||||
{
|
||||
os << "(type 0x";
|
||||
os.setf (std::ios::hex, std::ios::basefield);
|
||||
@@ -74,7 +72,7 @@ LlcSnapHeader::PrintTo (std::ostream &os) const
|
||||
}
|
||||
|
||||
void
|
||||
LlcSnapHeader::SerializeTo (Buffer::Iterator start) const
|
||||
LlcSnapHeader::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
uint8_t buf[] = {0xaa, 0xaa, 0x03, 0, 0, 0};
|
||||
@@ -82,7 +80,7 @@ LlcSnapHeader::SerializeTo (Buffer::Iterator start) const
|
||||
i.WriteHtonU16 (m_etherType);
|
||||
}
|
||||
uint32_t
|
||||
LlcSnapHeader::DeserializeFrom (Buffer::Iterator start)
|
||||
LlcSnapHeader::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
i.Next (5+1);
|
||||
@@ -91,4 +89,4 @@ LlcSnapHeader::DeserializeFrom (Buffer::Iterator start)
|
||||
}
|
||||
|
||||
|
||||
}; // namespace ns3
|
||||
} // namespace ns3
|
||||
|
||||
@@ -34,21 +34,19 @@ public:
|
||||
static uint32_t GetUid (void);
|
||||
|
||||
LlcSnapHeader ();
|
||||
virtual ~LlcSnapHeader ();
|
||||
|
||||
|
||||
void SetType (uint16_t type);
|
||||
uint16_t GetType (void);
|
||||
|
||||
std::string GetName (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
uint32_t GetSerializedSize (void) const;
|
||||
void Serialize (Buffer::Iterator start) const;
|
||||
uint32_t Deserialize (Buffer::Iterator start);
|
||||
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);
|
||||
uint16_t m_etherType;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* LLC_SNAP_HEADER_H */
|
||||
|
||||
Reference in New Issue
Block a user