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 | 08d984e | 2011-08-13 19:20:22 -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 | |
| 22 | #include "ccnx-content-object-header.h" |
| 23 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 24 | #include "ns3/log.h" |
| 25 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 26 | NS_LOG_COMPONENT_DEFINE ("CcnxContentObjectHeader"); |
| 27 | |
| 28 | namespace ns3 |
| 29 | { |
| 30 | |
| 31 | NS_OBJECT_ENSURE_REGISTERED (CcnxContentObjectHeader); |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 32 | NS_OBJECT_ENSURE_REGISTERED (CcnxContentObjectTail); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 33 | |
| 34 | TypeId |
| 35 | CcnxContentObjectHeader::GetTypeId (void) |
| 36 | { |
| 37 | static TypeId tid = TypeId ("ns3::CcnxContentObjectHeader") |
| 38 | .SetParent<Header> () |
| 39 | .AddConstructor<CcnxContentObjectHeader> () |
| 40 | ; |
| 41 | return tid; |
| 42 | } |
| 43 | |
| 44 | CcnxContentObjectHeader::CcnxContentObjectHeader () |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | void |
| 49 | CcnxContentObjectHeader::SetName (const Ptr<Name::Components> &name) |
| 50 | { |
| 51 | m_name = name; |
| 52 | } |
| 53 | |
| 54 | const Name::Components& |
| 55 | CcnxContentObjectHeader::GetName () const |
| 56 | { |
| 57 | return *m_name; |
| 58 | } |
| 59 | |
| 60 | uint32_t |
| 61 | CcnxContentObjectHeader::GetSerializedSize (void) const |
| 62 | { |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | void |
| 67 | CcnxContentObjectHeader::Serialize (Buffer::Iterator start) const |
| 68 | { |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | uint32_t |
| 73 | CcnxContentObjectHeader::Deserialize (Buffer::Iterator start) |
| 74 | { |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | TypeId |
| 79 | CcnxContentObjectHeader::GetInstanceTypeId (void) const |
| 80 | { |
| 81 | return GetTypeId (); |
| 82 | } |
| 83 | |
| 84 | void |
| 85 | CcnxContentObjectHeader::Print (std::ostream &os) const |
| 86 | { |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 87 | os << "<ContentObject><Name>" << *m_name << "</Name><Content>"; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 90 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 91 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 92 | |
| 93 | CcnxContentObjectTail::CcnxContentObjectTail () |
| 94 | { |
| 95 | } |
| 96 | |
| 97 | TypeId |
| 98 | CcnxContentObjectTail::GetTypeId (void) |
| 99 | { |
Ilya Moiseenko | a7d9150 | 2011-08-17 10:54:40 -0700 | [diff] [blame^] | 100 | static TypeId tid = TypeId ("ns3::CcnxContentObjectTail") |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 101 | .SetParent<Header> () |
| 102 | .AddConstructor<CcnxContentObjectHeader> () |
| 103 | ; |
| 104 | return tid; |
| 105 | } |
| 106 | |
| 107 | TypeId |
| 108 | CcnxContentObjectTail::GetInstanceTypeId (void) const |
| 109 | { |
| 110 | return GetTypeId (); |
| 111 | } |
| 112 | |
| 113 | void |
| 114 | CcnxContentObjectTail::Print (std::ostream &os) const |
| 115 | { |
| 116 | os << "</Content></ContentObject>"; |
| 117 | } |
| 118 | |
| 119 | uint32_t |
| 120 | CcnxContentObjectTail::GetSerializedSize (void) const |
| 121 | { |
| 122 | return 2; |
| 123 | } |
| 124 | |
| 125 | void |
| 126 | CcnxContentObjectTail::Serialize (Buffer::Iterator start) const |
| 127 | { |
| 128 | Buffer::Iterator i = start; |
| 129 | i.WriteU8 (0x00); // </Content> |
| 130 | i.WriteU8 (0x00); // </ContentObject> |
| 131 | } |
| 132 | |
| 133 | uint32_t |
| 134 | CcnxContentObjectTail::Deserialize (Buffer::Iterator start) |
| 135 | { |
| 136 | Buffer::Iterator i = start; |
| 137 | uint8_t __attribute__ ((unused)) closing_tag_content = i.ReadU8 (); |
| 138 | NS_ASSERT_MSG (closing_tag_content==0, "Should be closing tag </Content> (0x00)"); |
| 139 | |
| 140 | uint8_t __attribute__ ((unused)) closing_tag_content_object = i.ReadU8 (); |
| 141 | NS_ASSERT_MSG (closing_tag_content_object==0, "Should be closing tag </ContentObject> (0x00)"); |
| 142 | |
| 143 | return 2; |
| 144 | } |
| 145 | |
| 146 | } // namespace ns3 |