blob: f71e4835b054ae60e6d34abf74c74bc7b3f6fe05 [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 Afanasyev8a677dd2011-08-12 13:08:15 -070028
29#include <string>
30#include <vector>
31#include <list>
32
Ilya Moiseenkod26e6822011-08-23 17:48:38 -070033#include "ccnx-name-components.h"
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070034
35namespace ns3
36{
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070037
38/**
39 * CCNx XML definition of ContentObject
40 *
41 * Only few important fields are actually implemented in the simulation
42 *
43 *
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070044 * ContentObjectHeader serializes/deserializes header up-to and including <Content> tags
45 * Necessary closing tags should be added using ContentObjectTail
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070046 *
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070047 * This hacks are necessary to optimize memory use (i.e., virtual payload)
48 *
49 * "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>"
50 *
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070051 */
52
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070053class CcnxContentObjectHeader : public Header
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070054{
55public:
56 /**
57 * Constructor
58 *
59 * Creates a null header
60 **/
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070061 CcnxContentObjectHeader ();
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070062
63 /**
64 * \brief Set interest name
65 *
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070066 * Sets name of the interest. For example, SetName( CcnxNameComponents("prefix")("postfix") );
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070067 **/
68 void
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070069 SetName (const Ptr<CcnxNameComponents> &name);
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070070
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070071 const CcnxNameComponents&
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070072 GetName () const;
73
74 // void
75 // SetSignature ();
76
77 // ?
78 // GetSignature () const;
79
80 // void
81 // SetSignedInfo ();
82
83 // ?
84 // GetSignedInfo () const;
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070085
86 //////////////////////////////////////////////////////////////////
87
88 static TypeId GetTypeId (void);
89 virtual TypeId GetInstanceTypeId (void) const;
90 virtual void Print (std::ostream &os) const;
91 virtual uint32_t GetSerializedSize (void) const;
92 virtual void Serialize (Buffer::Iterator start) const;
93 virtual uint32_t Deserialize (Buffer::Iterator start);
94
95private:
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070096 Ptr<CcnxNameComponents> m_name;
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070097 // m_signature;
98 // m_signedInfo;
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -070099};
100
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700101/**
102 * ContentObjectTail should always be 2 bytes, representing two closing tags:
103 * "</Content><ContentObject>"
104 */
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700105class CcnxContentObjectTail : public Trailer
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700106{
107public:
108 CcnxContentObjectTail ();
109 //////////////////////////////////////////////////////////////////
110
111 static TypeId GetTypeId (void);
112 virtual TypeId GetInstanceTypeId (void) const;
113 virtual void Print (std::ostream &os) const;
114 virtual uint32_t GetSerializedSize (void) const;
115 virtual void Serialize (Buffer::Iterator start) const;
116 virtual uint32_t Deserialize (Buffer::Iterator start);
117};
118
Alexander Afanasyeve91ab752011-08-31 19:13:40 -0700119class CcnxContentObjectHeaderException {};
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700120
Alexander Afanasyev8a677dd2011-08-12 13:08:15 -0700121} // namespace ns3
122
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700123#endif // _CCNX_CONTENT_OBJECT_HEADER_H_