blob: 324f7667477bbe16a1f8015171c0fb55ef3b7249 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -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
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070022#ifndef _CCNX_CONTENT_OBJECT_HEADER_H_
23#define _CCNX_CONTENT_OBJECT_HEADER_H_
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070024
Alexander Afanasyev2536e202011-08-12 14:13:10 -070025#include "ns3/integer.h"
26#include "ns3/header.h"
Alexander Afanasyev070aa482011-08-20 00:38:25 -070027#include "ns3/trailer.h"
Alexander Afanasyev9568f952012-04-05 16:09:14 -070028#include "ns3/nstime.h"
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070029
30#include <string>
31#include <vector>
32#include <list>
33
Ilya Moiseenkod26e6822011-08-23 17:48:38 -070034#include "ccnx-name-components.h"
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070035
36namespace ns3
37{
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070038
39/**
40 * CCNx XML definition of ContentObject
41 *
42 * Only few important fields are actually implemented in the simulation
43 *
44 *
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070045 * ContentObjectHeader serializes/deserializes header up-to and including <Content> tags
46 * Necessary closing tags should be added using ContentObjectTail
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070047 *
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070048 * This hacks are necessary to optimize memory use (i.e., virtual payload)
49 *
50 * "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>"
51 *
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070052 */
53
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070054class CcnxContentObjectHeader : public Header
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070055{
56public:
57 /**
58 * Constructor
59 *
60 * Creates a null header
61 **/
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070062 CcnxContentObjectHeader ();
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070063
64 /**
65 * \brief Set interest name
66 *
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070067 * Sets name of the interest. For example, SetName( CcnxNameComponents("prefix")("postfix") );
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070068 **/
69 void
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070070 SetName (const Ptr<CcnxNameComponents> &name);
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070071
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070072 const CcnxNameComponents&
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070073 GetName () const;
74
75 // void
76 // SetSignature ();
77
78 // ?
79 // GetSignature () const;
80
Alexander Afanasyev9568f952012-04-05 16:09:14 -070081 void
82 SetTimestamp (const Time &timestamp);
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070083
Alexander Afanasyev9568f952012-04-05 16:09:14 -070084 Time
85 GetTimestamp () const;
86
87 void
88 SetFreshness (const Time &freshness);
89
90 Time
91 GetFreshness () const;
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070092
93 //////////////////////////////////////////////////////////////////
94
95 static TypeId GetTypeId (void);
96 virtual TypeId GetInstanceTypeId (void) const;
97 virtual void Print (std::ostream &os) const;
98 virtual uint32_t GetSerializedSize (void) const;
99 virtual void Serialize (Buffer::Iterator start) const;
100 virtual uint32_t Deserialize (Buffer::Iterator start);
101
Alexander Afanasyev9568f952012-04-05 16:09:14 -0700102 struct SignedInfo
103 {
104 // PublisherPublicKeyDigest
105 Time m_timestamp;
106 // Type (ContentType)
107 Time m_freshness;
108 // FinalBlockID
109 // KeyLocator
110 };
111
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700112private:
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700113 // m_signature;
Alexander Afanasyev9568f952012-04-05 16:09:14 -0700114 Ptr<CcnxNameComponents> m_name;
115 SignedInfo m_signedInfo;
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700116};
117
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700118/**
119 * ContentObjectTail should always be 2 bytes, representing two closing tags:
120 * "</Content><ContentObject>"
121 */
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700122class CcnxContentObjectTail : public Trailer
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700123{
124public:
125 CcnxContentObjectTail ();
126 //////////////////////////////////////////////////////////////////
127
128 static TypeId GetTypeId (void);
129 virtual TypeId GetInstanceTypeId (void) const;
130 virtual void Print (std::ostream &os) const;
131 virtual uint32_t GetSerializedSize (void) const;
132 virtual void Serialize (Buffer::Iterator start) const;
133 virtual uint32_t Deserialize (Buffer::Iterator start);
134};
135
Alexander Afanasyeve91ab752011-08-31 19:13:40 -0700136class CcnxContentObjectHeaderException {};
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700137
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700138} // namespace ns3
139
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700140#endif // _CCNX_CONTENT_OBJECT_HEADER_H_