Adding support of more fields in ContentObject
All big fields (digest, signature, etc.) are represented with 32-bit
integers. Should be enough for simulation purposes.
Also. This commit contains a number of code reorganizations, so the code
may not work...
diff --git a/model/ccnx-content-object-header.cc b/model/ccnx-content-object-header.cc
index d858e04..05220f5 100644
--- a/model/ccnx-content-object-header.cc
+++ b/model/ccnx-content-object-header.cc
@@ -25,11 +25,29 @@
#include "../helper/ccnx-encoding-helper.h"
#include "../helper/ccnx-decoding-helper.h"
+#include "../helper/ccnb-parser/ccnb-parser-common.h"
+#include "../helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.h"
+#include "../helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.h"
+#include "../helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.h"
+#include "../helper/ccnb-parser/visitors/ccnb-parser-timestamp-visitor.h"
+#include "../helper/ccnb-parser/visitors/ccnb-parser-string-visitor.h"
+#include "../helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.h"
+#include "../helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.h"
+
+#include "../helper/ccnb-parser/syntax-tree/ccnb-parser-block.h"
+#include "../helper/ccnb-parser/syntax-tree/ccnb-parser-dtag.h"
+
+#include <boost/foreach.hpp>
+
NS_LOG_COMPONENT_DEFINE ("CcnxContentObjectHeader");
+using namespace ns3::CcnbParser;
+
namespace ns3
{
+const std::string CcnxContentObjectHeader::Signature::DefaultDigestAlgorithm = "2.16.840.1.101.3.4.2.1";
+
NS_OBJECT_ENSURE_REGISTERED (CcnxContentObjectHeader);
NS_OBJECT_ENSURE_REGISTERED (CcnxContentObjectTail);
@@ -61,48 +79,324 @@
return *m_name;
}
-void
-CcnxContentObjectHeader::SetTimestamp (const Time ×tamp)
-{
- m_signedInfo.m_timestamp = timestamp;
-}
+#define CCNB CcnxEncodingHelper // just to simplify writing
-Time
-CcnxContentObjectHeader::GetTimestamp () const
-{
- return m_signedInfo.m_timestamp;
-}
-
-void
-CcnxContentObjectHeader::SetFreshness (const Time &freshness)
-{
- m_signedInfo.m_freshness = freshness;
-}
-
-Time
-CcnxContentObjectHeader::GetFreshness () const
-{
- return m_signedInfo.m_freshness;
-}
-
-
-uint32_t
-CcnxContentObjectHeader::GetSerializedSize (void) const
-{
- // unfortunately, we don't know exact header size in advance
- return CcnxEncodingHelper::GetSerializedSize (*this);
-}
-
void
CcnxContentObjectHeader::Serialize (Buffer::Iterator start) const
{
- CcnxEncodingHelper::Serialize (start, *this);
+ size_t written = 0;
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_ContentObject, CcnbParser::CCN_DTAG); // <ContentObject>
+
+ // fake signature
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_Signature, CcnbParser::CCN_DTAG); // <Signature>
+ // Signature ::= √DigestAlgorithm?
+ // Witness?
+ // √SignatureBits
+ if (GetSignature ().GetDigestAlgorithm () != Signature::DefaultDigestAlgorithm)
+ {
+ written += CCNB::AppendString (start, CCN_DTAG_DigestAlgorithm, GetSignature ().GetDigestAlgorithm ());
+ }
+ written += CCNB::AppendTaggedBlob (start, CCN_DTAG_SignatureBits, GetSignature ().GetSignatureBits ()); // <SignatureBits />
+ written += CCNB::AppendCloser (start); // </Signature>
+
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_Name, CCN_DTAG); // <Name>
+ written += CCNB::AppendNameComponents (start, GetName()); // <Component>...</Component>...
+ written += CCNB::AppendCloser (start); // </Name>
+
+ // fake signature
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_SignedInfo, CCN_DTAG); // <SignedInfo>
+ // SignedInfo ::= √PublisherPublicKeyDigest
+ // √Timestamp
+ // √Type?
+ // √FreshnessSeconds?
+ // FinalBlockID?
+ // KeyLocator?
+ written += CCNB::AppendTaggedBlob (start, CCN_DTAG_PublisherPublicKeyDigest, // <PublisherPublicKeyDigest>...
+ GetSignedInfo ().GetPublisherPublicKeyDigest ());
+
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_Timestamp, CCN_DTAG); // <Timestamp>...
+ written += CCNB::AppendTimestampBlob (start, GetSignedInfo ().GetTimestamp ());
+ written += CCNB::AppendCloser (start);
+
+ if (GetSignedInfo ().GetContentType () != DATA)
+ {
+ uint8_t type[3];
+ type[0] = (GetSignedInfo ().GetContentType () >> 16) & 0xFF;
+ type[1] = (GetSignedInfo ().GetContentType () >> 8 ) & 0xFF;
+ type[2] = (GetSignedInfo ().GetContentType () ) & 0xFF;
+
+ written += CCNB::AppendTaggedBlob (start, CCN_DTAG_Type, type, 3);
+ }
+ if (GetSignedInfo ().GetFreshness () >= Seconds(0))
+ {
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_FreshnessSeconds, CCN_DTAG);
+ written += CCNB::AppendNumber (start, GetSignedInfo ().GetFreshness ().ToInteger (Time::S));
+ written += CCNB::AppendCloser (start);
+ }
+ if (GetSignedInfo ().GetKeyLocator ()->size () > 0)
+ {
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_KeyLocator, CCN_DTAG); // <KeyLocator>
+ {
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_KeyName, CCN_DTAG); // <KeyName>
+ {
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_Name, CCN_DTAG); // <Name>
+ written += CCNB::AppendNameComponents (start, GetName()); // <Component>...</Component>...
+ written += CCNB::AppendCloser (start); // </Name>
+ }
+ written += CCNB::AppendCloser (start); // </KeyName>
+ }
+ written += CCNB::AppendCloser (start); // </KeyLocator>
+ }
+
+ written += CCNB::AppendCloser (start); // </SignedInfo>
+
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_Content, CCN_DTAG); // <Content>
+
+ // there are no closing tags !!!
+ // The closing tag is handled by CcnxContentObjectTail
}
uint32_t
+CcnxContentObjectHeader::GetSerializedSize () const
+{
+ size_t written = 0;
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_ContentObject); // <ContentObject>
+
+ // fake signature
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_Signature); // <Signature>
+ // Signature ::= DigestAlgorithm?
+ // Witness?
+ // SignatureBits
+ if (GetSignature ().GetDigestAlgorithm () != Signature::DefaultDigestAlgorithm)
+ {
+ written += CCNB::EstimateString (CCN_DTAG_DigestAlgorithm, GetSignature ().GetDigestAlgorithm ());
+ }
+ written += CCNB::EstimateTaggedBlob (CCN_DTAG_SignatureBits,
+ sizeof (GetSignature ().GetSignatureBits ())); // <SignatureBits />
+ written += 1; // </Signature>
+
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_Name); // <Name>
+ written += CCNB::EstimateNameComponents (GetName()); // <Component>...</Component>...
+ written += 1; // </Name>
+
+ // fake signature
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_SignedInfo); // <SignedInfo>
+ // SignedInfo ::= √PublisherPublicKeyDigest
+ // √Timestamp
+ // √Type?
+ // √FreshnessSeconds?
+ // FinalBlockID?
+ // KeyLocator?
+
+ written += CCNB::EstimateTaggedBlob (CCN_DTAG_PublisherPublicKeyDigest, // <PublisherPublicKeyDigest>...
+ sizeof (GetSignedInfo ().GetPublisherPublicKeyDigest ()));
+
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_Timestamp); // <Timestamp>...
+ written += CCNB::EstimateTimestampBlob (GetSignedInfo ().GetTimestamp ());
+ written += 1;
+
+ if (GetSignedInfo ().GetContentType () != DATA)
+ {
+ written += CCNB::EstimateTaggedBlob (CCN_DTAG_Type, 3);
+ }
+ if (GetSignedInfo ().GetFreshness () >= Seconds(0))
+ {
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_FreshnessSeconds);
+ written += CCNB::EstimateNumber (GetSignedInfo ().GetFreshness ().ToInteger (Time::S));
+ written += 1;
+ }
+
+ if (GetSignedInfo ().GetKeyLocator ()->size () > 0)
+ {
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_KeyLocator); // <KeyLocator>
+ {
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_KeyName); // <KeyName>
+ {
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_Name); // <Name>
+ written += CCNB::EstimateNameComponents (GetName()); // <Component>...</Component>...
+ written += 1; // </Name>
+ }
+ written += 1; // </KeyName>
+ }
+ written += 1; // </KeyLocator>
+ }
+
+ written += 1; // </SignedInfo>
+
+ written += CCNB::EstimateBlockHeader (CCN_DTAG_Content); // <Content>
+
+ // there are no closing tags !!!
+ // The closing tag is handled by CcnxContentObjectTail
+ return written;
+}
+#undef CCNB
+
+class ContentObjectVisitor : public VoidDepthFirstVisitor
+{
+public:
+ virtual void visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader* */)
+ {
+ // uint32_t n.m_dtag;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ static NameComponentsVisitor nameComponentsVisitor;
+ static NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
+ static TimestampVisitor timestampVisitor;
+ static StringVisitor stringVisitor;
+ static Uint32tBlobVisitor uint32tBlobVisitor;
+ static ContentTypeVisitor contentTypeVisitor;
+
+ CcnxContentObjectHeader &contentObject = *(boost::any_cast<CcnxContentObjectHeader*> (param));
+
+ switch (n.m_dtag)
+ {
+ case CCN_DTAG_ContentObject:
+ // process nested blocks
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+ {
+ block->accept (*this, param);
+ }
+ break;
+ case CCN_DTAG_Name:
+ {
+ // process name components
+ Ptr<CcnxNameComponents> name = Create<CcnxNameComponents> ();
+
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+ {
+ block->accept (nameComponentsVisitor, &(*name));
+ }
+ contentObject.SetName (name);
+ break;
+ }
+
+ case CCN_DTAG_Signature:
+ // process nested blocks
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+ {
+ block->accept (*this, param);
+ }
+ break;
+
+ case CCN_DTAG_DigestAlgorithm:
+ NS_LOG_DEBUG ("DigestAlgorithm");
+ if (n.m_nestedTags.size ()!=1) // should be exactly one UDATA inside this tag
+ throw CcnbDecodingException ();
+
+ contentObject.GetSignature ().SetDigestAlgorithm
+ (boost::any_cast<std::string> ((*n.m_nestedTags.begin())->accept
+ (stringVisitor)));
+ break;
+
+ case CCN_DTAG_SignatureBits:
+ NS_LOG_DEBUG ("SignatureBits");
+ if (n.m_nestedTags.size ()!=1) // should be only one nested tag
+ throw CcnbDecodingException ();
+
+ contentObject.GetSignature ().SetSignatureBits
+ (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
+ (uint32tBlobVisitor)));
+ break;
+
+ case CCN_DTAG_SignedInfo:
+ // process nested blocks
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+ {
+ block->accept (*this, param);
+ }
+ break;
+
+ case CCN_DTAG_PublisherPublicKeyDigest:
+ NS_LOG_DEBUG ("PublisherPublicKeyDigest");
+ if (n.m_nestedTags.size ()!=1) // should be only one nested tag
+ throw CcnbDecodingException ();
+
+ contentObject.GetSignedInfo ().SetPublisherPublicKeyDigest
+ (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
+ (uint32tBlobVisitor)));
+ break;
+
+ case CCN_DTAG_Timestamp:
+ NS_LOG_DEBUG ("Timestamp");
+ if (n.m_nestedTags.size()!=1) // should be exactly one nested tag
+ throw CcnbDecodingException ();
+
+ contentObject.GetSignedInfo ().SetTimestamp
+ (boost::any_cast<Time> ((*n.m_nestedTags.begin())->accept
+ (timestampVisitor)));
+ break;
+
+ case CCN_DTAG_Type:
+ NS_LOG_DEBUG ("Type");
+ if (n.m_nestedTags.size ()!=1) // should be only one nested tag
+ throw CcnbDecodingException ();
+
+ contentObject.GetSignedInfo ().SetContentType
+ (static_cast<CcnxContentObjectHeader::ContentType>
+ (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
+ (contentTypeVisitor))));
+ break;
+
+ case CCN_DTAG_FreshnessSeconds:
+ NS_LOG_DEBUG ("FreshnessSeconds");
+
+ if (n.m_nestedTags.size()!=1) // should be exactly one nested tag
+ throw CcnbDecodingException ();
+
+ contentObject.GetSignedInfo ().SetFreshness
+ (Seconds
+ (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
+ (nonNegativeIntegerVisitor))));
+ break;
+
+ case CCN_DTAG_KeyLocator:
+ // process nested blocks
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+ {
+ block->accept (*this, param);
+ }
+ break;
+
+ case CCN_DTAG_KeyName:
+ {
+ if (n.m_nestedTags.size ()!=1) // should be exactly one nested tag
+ throw CcnbDecodingException ();
+
+ Ptr<BaseTag> nameTag = DynamicCast<BaseTag>(n.m_nestedTags.front ());
+ if (nameTag == 0)
+ throw CcnbDecodingException ();
+
+ // process name components
+ Ptr<CcnxNameComponents> name = Create<CcnxNameComponents> ();
+
+ BOOST_FOREACH (Ptr<Block> block, nameTag->m_nestedTags)
+ {
+ block->accept (nameComponentsVisitor, &(*name));
+ }
+ contentObject.GetSignedInfo ().SetKeyLocator (name);
+ break;
+ }
+
+ case CCN_DTAG_Content: // !!! HACK
+ // This hack was necessary for memory optimizations (i.e., content is virtual payload)
+ NS_ASSERT_MSG (n.m_nestedTags.size() == 0, "Parser should have stopped just after processing <Content> tag");
+ break;
+
+ default: // ignore all other stuff
+ break;
+ }
+ }
+};
+
+uint32_t
CcnxContentObjectHeader::Deserialize (Buffer::Iterator start)
{
- return CcnxDecodingHelper::Deserialize (start, *this); // \todo Debugging is necessary
+ static ContentObjectVisitor contentObjectVisitor;
+
+ Buffer::Iterator i = start;
+ Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+ root->accept (contentObjectVisitor, this);
+
+ return i.GetDistanceFrom (start);
}
TypeId
@@ -176,5 +470,79 @@
return 2;
}
-
+
+///////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////
+
+CcnxContentObjectHeader::SignedInfo::SignedInfo ()
+ : m_publisherPublicKeyDigest (0)
+ // , m_timestamp
+ , m_type (DATA)
+ // , m_freshness
+ // , FinalBlockID
+ // , KeyLocator
+{
+}
+
+void
+CcnxContentObjectHeader::SignedInfo::SetPublisherPublicKeyDigest (uint32_t digest)
+{
+ m_publisherPublicKeyDigest = digest;
+}
+
+uint32_t
+CcnxContentObjectHeader::SignedInfo::GetPublisherPublicKeyDigest () const
+{
+ return m_publisherPublicKeyDigest;
+}
+
+void
+CcnxContentObjectHeader::SignedInfo::SetTimestamp (const Time ×tamp)
+{
+ m_timestamp = timestamp;
+}
+
+Time
+CcnxContentObjectHeader::SignedInfo::GetTimestamp () const
+{
+ return m_timestamp;
+}
+
+void
+CcnxContentObjectHeader::SignedInfo::SetContentType (CcnxContentObjectHeader::ContentType type)
+{
+ m_type = type;
+}
+
+CcnxContentObjectHeader::ContentType
+CcnxContentObjectHeader::SignedInfo::GetContentType () const
+{
+ return m_type;
+}
+
+void
+CcnxContentObjectHeader::SignedInfo::SetFreshness (const Time &freshness)
+{
+ m_freshness = freshness;
+}
+
+Time
+CcnxContentObjectHeader::SignedInfo::GetFreshness () const
+{
+ return m_freshness;
+}
+
+void
+CcnxContentObjectHeader::SignedInfo::SetKeyLocator (Ptr<const CcnxNameComponents> keyLocator)
+{
+ m_keyLocator = keyLocator;
+}
+
+Ptr<const CcnxNameComponents>
+CcnxContentObjectHeader::SignedInfo::GetKeyLocator () const
+{
+ return m_keyLocator;
+}
+
} // namespace ns3
diff --git a/model/ccnx-content-object-header.h b/model/ccnx-content-object-header.h
index 26e8333..a7bad01 100644
--- a/model/ccnx-content-object-header.h
+++ b/model/ccnx-content-object-header.h
@@ -51,10 +51,158 @@
* "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>"
*
*/
-
class CcnxContentObjectHeader : public SimpleRefCount<CcnxContentObjectHeader,Header>
{
public:
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * @brief Class representing Signature section of the content object
+ */
+ class Signature
+ {
+ public:
+ /**
+ * @brief Default constructor. Creates a fake-type signature
+ */
+ inline Signature ();
+
+ inline const std::string &
+ GetDigestAlgorithm () const;
+
+ inline void
+ SetDigestAlgorithm (const std::string &digestAlgorithm);
+
+ inline uint32_t
+ GetSignatureBits () const;
+
+ inline void
+ SetSignatureBits (uint32_t signatureBits);
+
+ static const std::string DefaultDigestAlgorithm; // = "2.16.840.1.101.3.4.2.1";
+
+ private:
+ std::string m_digestAlgorithm; // if value is `2.16.840.1.101.3.4.2.1`, then SHA-256 (not supported)
+ // in NS-3 value `99.0` represents a fake digest
+ // Witness // not used in NS-3
+ uint32_t m_signatureBits; // in NS-3 a fake signature is a just 32-bits
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+
+ enum ContentType
+ {
+ DATA = 0x0C04C0, // default value. If ContentObject is type of DATA, then ContentType tag will be omitted
+ ENCR = 0x10D091,
+ GONE = 0x18E344,
+ KEY = 0x28463F,
+ LINK = 0x2C834A,
+ NACK = 0x34008A
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * @brief Class representing SignedInfo section of the content object
+ */
+ class SignedInfo
+ {
+ public:
+ /**
+ * @brief Default constructor
+ */
+ SignedInfo ();
+
+ /**
+ * @brief Set PublisherPublicKey digest
+ * @param digest a fake 32-bit digest is supported
+ */
+ void
+ SetPublisherPublicKeyDigest (uint32_t digest);
+
+ /**
+ * @brief Get PublisherPublicKey digest
+ */
+ uint32_t
+ GetPublisherPublicKeyDigest () const;
+
+ /**
+ * @brief Set content object timestamp
+ * @param timestamp timestamp
+ */
+ void
+ SetTimestamp (const Time ×tamp);
+
+ /**
+ * @brief Get timestamp of the content object
+ */
+ Time
+ GetTimestamp () const;
+
+ /**
+ * @brief Set ContentObject type
+ * @param type type of the content object
+ */
+ void
+ SetContentType (ContentType type);
+
+ /**
+ * @brief Get ContentObject type
+ */
+ ContentType
+ GetContentType () const;
+
+ /**
+ * @brief Set freshness of the content object
+ * @param freshness Freshness, 0s means infinity
+ */
+ void
+ SetFreshness (const Time &freshness);
+
+ /**
+ * @brief Get freshness of the content object
+ */
+ Time
+ GetFreshness () const;
+
+ /**
+ * @brief Set key locator
+ * @param keyLocator name of the key
+ *
+ * Note that only <KeyName> option for the key locator is supported
+ */
+ void
+ SetKeyLocator (Ptr<const CcnxNameComponents> keyLocator);
+
+ /**
+ * @brief Get key locator
+ *
+ * Note that only <KeyName> option for the key locator is supported
+ */
+ Ptr<const CcnxNameComponents>
+ GetKeyLocator () const;
+
+ private:
+ uint32_t m_publisherPublicKeyDigest; // fake publisher key digest
+ Time m_timestamp;
+ ContentType m_type;
+ Time m_freshness;
+ // FinalBlockID
+ Ptr<const CcnxNameComponents> m_keyLocator; // support only <KeyName> option for KeyLocator
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+
/**
* Constructor
*
@@ -63,33 +211,42 @@
CcnxContentObjectHeader ();
/**
- * \brief Set interest name
+ * \brief Set content object name
*
- * Sets name of the interest. For example, SetName( CcnxNameComponents("prefix")("postfix") );
+ * Sets name of the content object. For example, SetName( CcnxNameComponents("prefix")("postfix") );
**/
void
SetName (const Ptr<CcnxNameComponents> &name);
+ /**
+ * @brief Get name of the content object
+ */
const CcnxNameComponents&
GetName () const;
- // void
- // SetSignature ();
+ /**
+ * @brief Get editable reference to content object's Signature
+ */
+ inline Signature &
+ GetSignature ();
- // ?
- // GetSignature () const;
+ /**
+ * @brief Get read-only reference to content object's Signature
+ */
+ inline const Signature &
+ GetSignature () const;
- void
- SetTimestamp (const Time ×tamp);
+ /**
+ * @brief Get editable reference to content object's SignedInfo
+ */
+ inline SignedInfo &
+ GetSignedInfo ();
- Time
- GetTimestamp () const;
-
- void
- SetFreshness (const Time &freshness);
-
- Time
- GetFreshness () const;
+ /**
+ * @brief Get read-only reference to content object's SignedInfo
+ */
+ inline const SignedInfo &
+ GetSignedInfo () const;
//////////////////////////////////////////////////////////////////
@@ -99,19 +256,9 @@
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;
+ Signature m_signature;
Ptr<CcnxNameComponents> m_name;
SignedInfo m_signedInfo;
};
@@ -134,8 +281,64 @@
virtual uint32_t Deserialize (Buffer::Iterator start);
};
+
+CcnxContentObjectHeader::Signature::Signature ()
+ : m_digestAlgorithm ("99.0")
+ , m_signatureBits (0)
+{
+}
+
+const std::string &
+CcnxContentObjectHeader::Signature::GetDigestAlgorithm () const
+{
+ return m_digestAlgorithm;
+}
+
+void
+CcnxContentObjectHeader::Signature::SetDigestAlgorithm (const std::string &digestAlgorithm)
+{
+ m_digestAlgorithm = digestAlgorithm;
+}
+
+uint32_t
+CcnxContentObjectHeader::Signature::GetSignatureBits () const
+{
+ return m_signatureBits;
+}
+
+inline void
+CcnxContentObjectHeader::Signature::SetSignatureBits (uint32_t signature)
+{
+ m_signatureBits = signature;
+}
+
+
+CcnxContentObjectHeader::Signature &
+CcnxContentObjectHeader::GetSignature ()
+{
+ return m_signature;
+}
+
+const CcnxContentObjectHeader::Signature &
+CcnxContentObjectHeader::GetSignature () const
+{
+ return m_signature;
+}
+
+CcnxContentObjectHeader::SignedInfo &
+CcnxContentObjectHeader::GetSignedInfo ()
+{
+ return m_signedInfo;
+}
+
+const CcnxContentObjectHeader::SignedInfo &
+CcnxContentObjectHeader::GetSignedInfo () const
+{
+ return m_signedInfo;
+}
+
class CcnxContentObjectHeaderException {};
-
+
} // namespace ns3
#endif // _CCNX_CONTENT_OBJECT_HEADER_H_