Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 20 | */ |
| 21 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 22 | #ifndef _CCNX_CONTENT_OBJECT_HEADER_H_ |
| 23 | #define _CCNX_CONTENT_OBJECT_HEADER_H_ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | 2536e20 | 2011-08-12 14:13:10 -0700 | [diff] [blame] | 25 | #include "ns3/integer.h" |
| 26 | #include "ns3/header.h" |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 27 | |
| 28 | #include <string> |
| 29 | #include <vector> |
| 30 | #include <list> |
| 31 | |
| 32 | #include "name-components.h" |
| 33 | |
| 34 | namespace ns3 |
| 35 | { |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * CCNx XML definition of ContentObject |
| 39 | * |
| 40 | * Only few important fields are actually implemented in the simulation |
| 41 | * |
| 42 | * |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 43 | * ContentObjectHeader serializes/deserializes header up-to and including <Content> tags |
| 44 | * Necessary closing tags should be added using ContentObjectTail |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 45 | * |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 46 | * This hacks are necessary to optimize memory use (i.e., virtual payload) |
| 47 | * |
| 48 | * "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>" |
| 49 | * |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 50 | */ |
| 51 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 52 | class CcnxContentObjectHeader : public Header |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 53 | { |
| 54 | public: |
| 55 | /** |
| 56 | * Constructor |
| 57 | * |
| 58 | * Creates a null header |
| 59 | **/ |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 60 | CcnxContentObjectHeader (); |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * \brief Set interest name |
| 64 | * |
| 65 | * Sets name of the interest. For example, SetName( Name::Components("prefix")("postfix") ); |
| 66 | **/ |
| 67 | void |
| 68 | SetName (const Ptr<Name::Components> &name); |
| 69 | |
| 70 | const Name::Components& |
| 71 | GetName () const; |
| 72 | |
| 73 | // void |
| 74 | // SetSignature (); |
| 75 | |
| 76 | // ? |
| 77 | // GetSignature () const; |
| 78 | |
| 79 | // void |
| 80 | // SetSignedInfo (); |
| 81 | |
| 82 | // ? |
| 83 | // GetSignedInfo () const; |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 84 | |
| 85 | ////////////////////////////////////////////////////////////////// |
| 86 | |
| 87 | static TypeId GetTypeId (void); |
| 88 | virtual TypeId GetInstanceTypeId (void) const; |
| 89 | virtual void Print (std::ostream &os) const; |
| 90 | virtual uint32_t GetSerializedSize (void) const; |
| 91 | virtual void Serialize (Buffer::Iterator start) const; |
| 92 | virtual uint32_t Deserialize (Buffer::Iterator start); |
| 93 | |
| 94 | private: |
| 95 | Ptr<Name::Components> m_name; |
| 96 | // m_signature; |
| 97 | // m_signedInfo; |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 100 | /** |
| 101 | * ContentObjectTail should always be 2 bytes, representing two closing tags: |
| 102 | * "</Content><ContentObject>" |
| 103 | */ |
| 104 | class CcnxContentObjectTail : public Header |
| 105 | { |
| 106 | public: |
| 107 | CcnxContentObjectTail (); |
| 108 | ////////////////////////////////////////////////////////////////// |
| 109 | |
| 110 | static TypeId GetTypeId (void); |
| 111 | virtual TypeId GetInstanceTypeId (void) const; |
| 112 | virtual void Print (std::ostream &os) const; |
| 113 | virtual uint32_t GetSerializedSize (void) const; |
| 114 | virtual void Serialize (Buffer::Iterator start) const; |
| 115 | virtual uint32_t Deserialize (Buffer::Iterator start); |
| 116 | }; |
| 117 | |
| 118 | |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 119 | } // namespace ns3 |
| 120 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 121 | #endif // _CCNX_CONTENT_OBJECT_HEADER_H_ |