00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2008 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef TAG_H 00021 #define TAG_H 00022 00023 #include "ns3/object-base.h" 00024 #include "tag-buffer.h" 00025 #include <stdint.h> 00026 00027 namespace ns3 { 00028 00029 /** 00030 * \ingroup packet 00031 * 00032 * \brief tag a set of bytes in a packet 00033 * 00034 * New kinds of tags can be created by subclassing this base class. 00035 */ 00036 class Tag : public ObjectBase 00037 { 00038 public: 00039 static TypeId GetTypeId (void); 00040 00041 /** 00042 * \returns the number of bytes required to serialize the data of the tag. 00043 * 00044 * This method is typically invoked by Packet::AddTag just prior to calling 00045 * Tag::Serialize. 00046 */ 00047 virtual uint32_t GetSerializedSize (void) const = 0; 00048 /** 00049 * \param i the buffer to write data into. 00050 * 00051 * Write the content of the tag in the provided tag buffer. 00052 * DO NOT attempt to write more bytes than you requested 00053 * with Tag::GetSerializedSize. 00054 */ 00055 virtual void Serialize (TagBuffer i) const = 0; 00056 /** 00057 * \param i the buffer to read data from. 00058 * 00059 * Read the content of the tag from the provided tag buffer. 00060 * DO NOT attempt to read more bytes than you wrote with 00061 * Tag::Serialize. 00062 */ 00063 virtual void Deserialize (TagBuffer i) = 0; 00064 00065 /** 00066 * \param os the stream to print to 00067 * 00068 * This method is typically invoked from the Packet::PrintTags method 00069 */ 00070 virtual void Print (std::ostream &os) const = 0; 00071 }; 00072 00073 } // namespace ns3 00074 00075 #endif /* TAG_H */