blob: 26e83330c3083ab915f1752ebd6833f4ccd90d57 [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2011 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef _CCNX_CONTENT_OBJECT_HEADER_H_
#define _CCNX_CONTENT_OBJECT_HEADER_H_
#include "ns3/integer.h"
#include "ns3/header.h"
#include "ns3/simple-ref-count.h"
#include "ns3/trailer.h"
#include "ns3/nstime.h"
#include <string>
#include <vector>
#include <list>
#include "ccnx-name-components.h"
namespace ns3
{
/**
* CCNx XML definition of ContentObject
*
* Only few important fields are actually implemented in the simulation
*
*
* ContentObjectHeader serializes/deserializes header up-to and including <Content> tags
* Necessary closing tags should be added using ContentObjectTail
*
* This hacks are necessary to optimize memory use (i.e., virtual payload)
*
* "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>"
*
*/
class CcnxContentObjectHeader : public SimpleRefCount<CcnxContentObjectHeader,Header>
{
public:
/**
* Constructor
*
* Creates a null header
**/
CcnxContentObjectHeader ();
/**
* \brief Set interest name
*
* Sets name of the interest. For example, SetName( CcnxNameComponents("prefix")("postfix") );
**/
void
SetName (const Ptr<CcnxNameComponents> &name);
const CcnxNameComponents&
GetName () const;
// void
// SetSignature ();
// ?
// GetSignature () const;
void
SetTimestamp (const Time &timestamp);
Time
GetTimestamp () const;
void
SetFreshness (const Time &freshness);
Time
GetFreshness () const;
//////////////////////////////////////////////////////////////////
static TypeId GetTypeId (void);
virtual TypeId GetInstanceTypeId (void) const;
virtual void Print (std::ostream &os) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start);
struct SignedInfo
{
// PublisherPublicKeyDigest
Time m_timestamp;
// Type (ContentType)
Time m_freshness;
// FinalBlockID
// KeyLocator
};
private:
// m_signature;
Ptr<CcnxNameComponents> m_name;
SignedInfo m_signedInfo;
};
/**
* ContentObjectTail should always be 2 bytes, representing two closing tags:
* "</Content><ContentObject>"
*/
class CcnxContentObjectTail : public Trailer
{
public:
CcnxContentObjectTail ();
//////////////////////////////////////////////////////////////////
static TypeId GetTypeId (void);
virtual TypeId GetInstanceTypeId (void) const;
virtual void Print (std::ostream &os) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start);
};
class CcnxContentObjectHeaderException {};
} // namespace ns3
#endif // _CCNX_CONTENT_OBJECT_HEADER_H_