blob: 46a155409b58e32d8a33bdd242b0f86e23dc1b23 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07002/*
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 Afanasyev45b92d42011-08-14 23:11:38 -070024#include "ns3/log.h"
25
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070026NS_LOG_COMPONENT_DEFINE ("CcnxContentObjectHeader");
27
28namespace ns3
29{
30
31NS_OBJECT_ENSURE_REGISTERED (CcnxContentObjectHeader);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070032NS_OBJECT_ENSURE_REGISTERED (CcnxContentObjectTail);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070033
34TypeId
35CcnxContentObjectHeader::GetTypeId (void)
36{
37 static TypeId tid = TypeId ("ns3::CcnxContentObjectHeader")
38 .SetParent<Header> ()
39 .AddConstructor<CcnxContentObjectHeader> ()
40 ;
41 return tid;
42}
43
44CcnxContentObjectHeader::CcnxContentObjectHeader ()
45{
46}
47
48void
49CcnxContentObjectHeader::SetName (const Ptr<Name::Components> &name)
50{
51 m_name = name;
52}
53
54const Name::Components&
55CcnxContentObjectHeader::GetName () const
56{
57 return *m_name;
58}
59
60uint32_t
61CcnxContentObjectHeader::GetSerializedSize (void) const
62{
63 return 0;
64}
65
66void
67CcnxContentObjectHeader::Serialize (Buffer::Iterator start) const
68{
69 return;
70}
71
72uint32_t
73CcnxContentObjectHeader::Deserialize (Buffer::Iterator start)
74{
75 return 0;
76}
77
78TypeId
79CcnxContentObjectHeader::GetInstanceTypeId (void) const
80{
81 return GetTypeId ();
82}
83
84void
85CcnxContentObjectHeader::Print (std::ostream &os) const
86{
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070087 os << "<ContentObject><Name>" << *m_name << "</Name><Content>";
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070088}
89
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070090
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070091////////////////////////////////////////////////////////////////////////////////////////////////////
92
93CcnxContentObjectTail::CcnxContentObjectTail ()
94{
95}
96
97TypeId
98CcnxContentObjectTail::GetTypeId (void)
99{
100 static TypeId tid = TypeId ("ns3::CcnxContentObjectHeader")
101 .SetParent<Header> ()
102 .AddConstructor<CcnxContentObjectHeader> ()
103 ;
104 return tid;
105}
106
107TypeId
108CcnxContentObjectTail::GetInstanceTypeId (void) const
109{
110 return GetTypeId ();
111}
112
113void
114CcnxContentObjectTail::Print (std::ostream &os) const
115{
116 os << "</Content></ContentObject>";
117}
118
119uint32_t
120CcnxContentObjectTail::GetSerializedSize (void) const
121{
122 return 2;
123}
124
125void
126CcnxContentObjectTail::Serialize (Buffer::Iterator start) const
127{
128 Buffer::Iterator i = start;
129 i.WriteU8 (0x00); // </Content>
130 i.WriteU8 (0x00); // </ContentObject>
131}
132
133uint32_t
134CcnxContentObjectTail::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