really kill dead code.
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include "trailer.h"
|
||||
#include "packet.h"
|
||||
#include "packet-metadata.h"
|
||||
#include "packet-printer.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 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 "packet-printer.h"
|
||||
#include "chunk-registry.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
PacketPrinter::PacketPrinter ()
|
||||
: m_forward (true),
|
||||
m_separator (" ")
|
||||
{}
|
||||
|
||||
void
|
||||
PacketPrinter::PrintForward (void)
|
||||
{
|
||||
m_forward = true;
|
||||
}
|
||||
void
|
||||
PacketPrinter::PrintBackward (void)
|
||||
{
|
||||
m_forward = false;
|
||||
}
|
||||
void
|
||||
PacketPrinter::SetSeparator (std::string separator)
|
||||
{
|
||||
m_separator = separator;
|
||||
}
|
||||
void
|
||||
PacketPrinter::SetPayloadPrinter (PayloadPrinter printer)
|
||||
{
|
||||
m_payloadPrinter = printer;
|
||||
}
|
||||
|
||||
void
|
||||
PacketPrinter::PrintChunk (uint32_t chunkUid,
|
||||
Buffer::Iterator start,
|
||||
std::ostream &os,
|
||||
uint32_t packetUid,
|
||||
uint32_t size) const
|
||||
{
|
||||
uint8_t *instance = ChunkRegistry::GetStaticInstance (chunkUid);
|
||||
ChunkRegistry::Deserialize (chunkUid, instance, start);
|
||||
|
||||
for (PrinterList::const_iterator i = m_printerList.begin (); i != m_printerList.end (); i++)
|
||||
{
|
||||
if (i->m_chunkUid == chunkUid)
|
||||
{
|
||||
ChunkRegistry::InvokePrintCallback (chunkUid, instance, os, packetUid, size, i->m_printer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if the over did not override this type of chunk,
|
||||
// we print something by default.
|
||||
std::string name = ChunkRegistry::GetName (chunkUid, instance);
|
||||
os << name << " ";
|
||||
ChunkRegistry::Print (chunkUid, instance, os);
|
||||
}
|
||||
void
|
||||
PacketPrinter::PrintChunkFragment (uint32_t chunkUid,
|
||||
std::ostream &os,
|
||||
uint32_t packetUid,
|
||||
uint32_t size,
|
||||
uint32_t fragmentStart,
|
||||
uint32_t fragmentEnd) const
|
||||
{
|
||||
uint8_t *instance = ChunkRegistry::GetStaticInstance (chunkUid);
|
||||
std::string name = ChunkRegistry::GetName (chunkUid, instance);
|
||||
struct PacketPrinter::FragmentInformation info;
|
||||
info.start = fragmentStart;
|
||||
info.end = fragmentEnd;
|
||||
for (PrinterList::const_iterator i = m_printerList.begin (); i != m_printerList.end (); i++)
|
||||
{
|
||||
if (i->m_chunkUid == chunkUid)
|
||||
{
|
||||
|
||||
i->m_fragmentPrinter (os, packetUid, size, name, info);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if the user did not override this type of chunk,
|
||||
// we print something by default.
|
||||
NS_ASSERT (info.start != 0 || info.end != 0);
|
||||
os << name << " "
|
||||
<< "("
|
||||
<< "length " << size - (info.end + info.start) << " "
|
||||
<< "trim_start " << info.start << " "
|
||||
<< "trim_end " << info.end
|
||||
<< ")";
|
||||
}
|
||||
void
|
||||
PacketPrinter::PrintPayload (std::ostream &os, uint32_t packetUid, uint32_t size,
|
||||
uint32_t fragmentStart, uint32_t fragmentEnd) const
|
||||
{
|
||||
struct PacketPrinter::FragmentInformation info;
|
||||
info.start = fragmentStart;
|
||||
info.end = fragmentEnd;
|
||||
if (!m_payloadPrinter.IsNull ())
|
||||
{
|
||||
m_payloadPrinter (os, packetUid, size, info);
|
||||
return;
|
||||
}
|
||||
// if the user did not override the payload printer,
|
||||
// we print something anyway.
|
||||
os << "DATA ("
|
||||
<< "length " << size - (info.end + info.start);
|
||||
if (info.start != 0 || info.end != 0)
|
||||
{
|
||||
os << " "
|
||||
<< "trim_start " << info.start << " "
|
||||
<< "trim_end " << info.end;
|
||||
}
|
||||
os << ")";
|
||||
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,181 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 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>
|
||||
*/
|
||||
#ifndef PACKET_PRINTER_H
|
||||
#define PACKET_PRINTER_H
|
||||
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "buffer.h"
|
||||
#include <vector>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \brief hold a list of print callbacks for packet headers and trailers
|
||||
*
|
||||
* Users can register in instances of this class print callbacks
|
||||
* which are used by Packet::Print to print the content of a packet.
|
||||
*/
|
||||
class PacketPrinter
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief indicates how many bytes were trimmed from a header
|
||||
* or a trailer.
|
||||
*/
|
||||
struct FragmentInformation
|
||||
{
|
||||
/**
|
||||
* The number of bytes trimmed from the start of the header or the trailer.
|
||||
*/
|
||||
uint32_t start;
|
||||
/**
|
||||
* The number of bytes trimmed from the end of the header or the trailer.
|
||||
*/
|
||||
uint32_t end;
|
||||
};
|
||||
/**
|
||||
* \brief callback to print payload.
|
||||
*
|
||||
* Arguments: output stream, packet uid, size, fragment information
|
||||
*/
|
||||
typedef Callback<void,std::ostream &,uint32_t,uint32_t,struct PacketPrinter::FragmentInformation>
|
||||
PayloadPrinter;
|
||||
|
||||
/**
|
||||
* \brief callback to print fragmented chunks.
|
||||
*
|
||||
* Arguments: output stream, packet uid, size, header/trailer name, fragment information
|
||||
*/
|
||||
typedef Callback<void,std::ostream &,uint32_t,uint32_t,std::string &,struct PacketPrinter::FragmentInformation>
|
||||
ChunkFragmentPrinter;
|
||||
|
||||
/**
|
||||
* \brief callback to print chunks for which no specific callback was specified.
|
||||
*
|
||||
* Arguments: output stream, packet uid, size, header/trailer name, fragment information
|
||||
*/
|
||||
typedef Callback<void,std::ostream&,uint32_t,uint32_t,std::string&,struct PacketPrinter::FragmentInformation>
|
||||
DefaultPrinter;
|
||||
|
||||
PacketPrinter ();
|
||||
|
||||
/**
|
||||
* Print the content of the packet forward.
|
||||
*/
|
||||
void PrintForward (void);
|
||||
/**
|
||||
* Print the content of the packet backward.
|
||||
*/
|
||||
void PrintBackward (void);
|
||||
/**
|
||||
* \param separator the new separator
|
||||
*
|
||||
* The default separator is a single space character.
|
||||
*/
|
||||
void SetSeparator (std::string separator);
|
||||
/**
|
||||
* \param printer printer for payload
|
||||
*/
|
||||
void SetPayloadPrinter (PayloadPrinter printer);
|
||||
/**
|
||||
* \param printer printer for the specified chunk
|
||||
* \param fragmentPrinter printer for a fragment of the specified chunk
|
||||
*
|
||||
* If the user does not force a user-specific printing function through
|
||||
* a call to SetHeaderPrinter, the default print output is generated.
|
||||
*/
|
||||
template <typename T>
|
||||
void SetHeaderPrinter (Callback<void,std::ostream &,uint32_t,uint32_t,const T *> printer,
|
||||
ChunkFragmentPrinter fragmentPrinter);
|
||||
/**
|
||||
* \param printer printer for the specified chunk
|
||||
* \param fragmentPrinter printer for a fragment of the specified chunk
|
||||
*
|
||||
* If the user does not force a user-specific printing function through
|
||||
* a call to SetTrailerPrinter, the default print output is generated.
|
||||
*/
|
||||
template <typename T>
|
||||
void SetTrailerPrinter (Callback<void,std::ostream &,uint32_t,uint32_t,const T *> printer,
|
||||
ChunkFragmentPrinter fragmentPrinter);
|
||||
private:
|
||||
friend class PacketMetadata;
|
||||
void PrintChunk (uint32_t uid,
|
||||
Buffer::Iterator i,
|
||||
std::ostream &os,
|
||||
uint32_t packetUid,
|
||||
uint32_t size) const;
|
||||
void PrintChunkFragment (uint32_t uid,
|
||||
std::ostream &os,
|
||||
uint32_t packetUid,
|
||||
uint32_t size,
|
||||
uint32_t fragmentStart,
|
||||
uint32_t fragmentEnd) const;
|
||||
void PrintPayload (std::ostream &os, uint32_t packetUid, uint32_t size,
|
||||
uint32_t fragmentStart, uint32_t fragmentEnd) const;
|
||||
struct Printer
|
||||
{
|
||||
uint32_t m_chunkUid;
|
||||
CallbackBase m_printer;
|
||||
Callback<void,std::ostream &,uint32_t,uint32_t,std::string &,
|
||||
struct PacketPrinter::FragmentInformation> m_fragmentPrinter;
|
||||
};
|
||||
typedef std::vector<struct PacketPrinter::Printer> PrinterList;
|
||||
|
||||
PrinterList m_printerList;
|
||||
PayloadPrinter m_payloadPrinter;
|
||||
DefaultPrinter m_defaultPrinter;
|
||||
bool m_forward;
|
||||
std::string m_separator;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
PacketPrinter::SetHeaderPrinter (Callback<void,std::ostream &,uint32_t,uint32_t,const T *> printer,
|
||||
ChunkFragmentPrinter fragmentPrinter)
|
||||
{
|
||||
Printer p;
|
||||
p.m_chunkUid = T::GetUid ();
|
||||
p.m_printer = printer;
|
||||
p.m_fragmentPrinter = fragmentPrinter;
|
||||
m_printerList.push_back (p);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
PacketPrinter::SetTrailerPrinter (Callback<void,std::ostream &,uint32_t,uint32_t,const T *> printer,
|
||||
ChunkFragmentPrinter fragmentPrinter)
|
||||
{
|
||||
Printer p;
|
||||
p.m_chunkUid = T::GetUid ();
|
||||
p.m_printer = printer;
|
||||
p.m_fragmentPrinter = fragmentPrinter;
|
||||
m_printerList.push_back (p);
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* PACKET_PRINTER_H */
|
||||
@@ -19,7 +19,6 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "packet.h"
|
||||
#include "packet-printer.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Reference in New Issue
Block a user