From bcf92901acb2d7ba759605f9bb2febefc45a28b6 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 17 Mar 2008 11:47:50 -0700 Subject: [PATCH] really kill dead code. --- src/common/packet-metadata-test.cc | 1 - src/common/packet-printer.cc | 135 --------------------- src/common/packet-printer.h | 181 ----------------------------- src/common/packet.cc | 1 - 4 files changed, 318 deletions(-) delete mode 100644 src/common/packet-printer.cc delete mode 100644 src/common/packet-printer.h diff --git a/src/common/packet-metadata-test.cc b/src/common/packet-metadata-test.cc index 45d7ab5a1..b117cc317 100644 --- a/src/common/packet-metadata-test.cc +++ b/src/common/packet-metadata-test.cc @@ -27,7 +27,6 @@ #include "trailer.h" #include "packet.h" #include "packet-metadata.h" -#include "packet-printer.h" namespace ns3 { diff --git a/src/common/packet-printer.cc b/src/common/packet-printer.cc deleted file mode 100644 index bf879b813..000000000 --- a/src/common/packet-printer.cc +++ /dev/null @@ -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 - */ - -#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 diff --git a/src/common/packet-printer.h b/src/common/packet-printer.h deleted file mode 100644 index ba789a9fe..000000000 --- a/src/common/packet-printer.h +++ /dev/null @@ -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 - */ -#ifndef PACKET_PRINTER_H -#define PACKET_PRINTER_H - -#include "ns3/callback.h" -#include "ns3/ptr.h" -#include "buffer.h" -#include - -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 - PayloadPrinter; - - /** - * \brief callback to print fragmented chunks. - * - * Arguments: output stream, packet uid, size, header/trailer name, fragment information - */ - typedef Callback - 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 - 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 - void SetHeaderPrinter (Callback 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 - void SetTrailerPrinter (Callback 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 m_fragmentPrinter; - }; - typedef std::vector PrinterList; - - PrinterList m_printerList; - PayloadPrinter m_payloadPrinter; - DefaultPrinter m_defaultPrinter; - bool m_forward; - std::string m_separator; -}; - -} // namespace ns3 - -namespace ns3 { - -template -void -PacketPrinter::SetHeaderPrinter (Callback printer, - ChunkFragmentPrinter fragmentPrinter) -{ - Printer p; - p.m_chunkUid = T::GetUid (); - p.m_printer = printer; - p.m_fragmentPrinter = fragmentPrinter; - m_printerList.push_back (p); -} - -template -void -PacketPrinter::SetTrailerPrinter (Callback 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 */ diff --git a/src/common/packet.cc b/src/common/packet.cc index 77539642b..22bca8349 100644 --- a/src/common/packet.cc +++ b/src/common/packet.cc @@ -19,7 +19,6 @@ * Author: Mathieu Lacage */ #include "packet.h" -#include "packet-printer.h" #include "ns3/assert.h" namespace ns3 {