blob: 26e83330c3083ab915f1752ebd6833f4ccd90d57 [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 Afanasyeve275cf82012-04-18 14:25:02 -070027#include "ns3/simple-ref-count.h"
Alexander Afanasyev070aa482011-08-20 00:38:25 -070028#include "ns3/trailer.h"
Alexander Afanasyev9568f952012-04-05 16:09:14 -070029#include "ns3/nstime.h"
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070030
31#include <string>
32#include <vector>
33#include <list>
34
Ilya Moiseenkod26e6822011-08-23 17:48:38 -070035#include "ccnx-name-components.h"
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070036
37namespace ns3
38{
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070039
40/**
41 * CCNx XML definition of ContentObject
42 *
43 * Only few important fields are actually implemented in the simulation
44 *
45 *
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070046 * ContentObjectHeader serializes/deserializes header up-to and including <Content> tags
47 * Necessary closing tags should be added using ContentObjectTail
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070048 *
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070049 * This hacks are necessary to optimize memory use (i.e., virtual payload)
50 *
51 * "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>"
52 *
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070053 */
54
Alexander Afanasyeve275cf82012-04-18 14:25:02 -070055class CcnxContentObjectHeader : public SimpleRefCount<CcnxContentObjectHeader,Header>
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070056{
57public:
58 /**
59 * Constructor
60 *
61 * Creates a null header
62 **/
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070063 CcnxContentObjectHeader ();
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070064
65 /**
66 * \brief Set interest name
67 *
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070068 * Sets name of the interest. For example, SetName( CcnxNameComponents("prefix")("postfix") );
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070069 **/
70 void
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070071 SetName (const Ptr<CcnxNameComponents> &name);
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070072
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070073 const CcnxNameComponents&
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070074 GetName () const;
75
76 // void
77 // SetSignature ();
78
79 // ?
80 // GetSignature () const;
81
Alexander Afanasyev9568f952012-04-05 16:09:14 -070082 void
83 SetTimestamp (const Time &timestamp);
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070084
Alexander Afanasyev9568f952012-04-05 16:09:14 -070085 Time
86 GetTimestamp () const;
87
88 void
89 SetFreshness (const Time &freshness);
90
91 Time
92 GetFreshness () const;
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070093
94 //////////////////////////////////////////////////////////////////
95
96 static TypeId GetTypeId (void);
97 virtual TypeId GetInstanceTypeId (void) const;
98 virtual void Print (std::ostream &os) const;
99 virtual uint32_t GetSerializedSize (void) const;
100 virtual void Serialize (Buffer::Iterator start) const;
101 virtual uint32_t Deserialize (Buffer::Iterator start);
102
Alexander Afanasyev9568f952012-04-05 16:09:14 -0700103 struct SignedInfo
104 {
105 // PublisherPublicKeyDigest
106 Time m_timestamp;
107 // Type (ContentType)
108 Time m_freshness;
109 // FinalBlockID
110 // KeyLocator
111 };
112
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700113private:
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700114 // m_signature;
Alexander Afanasyev9568f952012-04-05 16:09:14 -0700115 Ptr<CcnxNameComponents> m_name;
116 SignedInfo m_signedInfo;
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700117};
118
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700119/**
120 * ContentObjectTail should always be 2 bytes, representing two closing tags:
121 * "</Content><ContentObject>"
122 */
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700123class CcnxContentObjectTail : public Trailer
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700124{
125public:
126 CcnxContentObjectTail ();
127 //////////////////////////////////////////////////////////////////
128
129 static TypeId GetTypeId (void);
130 virtual TypeId GetInstanceTypeId (void) const;
131 virtual void Print (std::ostream &os) const;
132 virtual uint32_t GetSerializedSize (void) const;
133 virtual void Serialize (Buffer::Iterator start) const;
134 virtual uint32_t Deserialize (Buffer::Iterator start);
135};
136
Alexander Afanasyeve91ab752011-08-31 19:13:40 -0700137class CcnxContentObjectHeaderException {};
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700138
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700139} // namespace ns3
140
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700141#endif // _CCNX_CONTENT_OBJECT_HEADER_H_