ContentObject and Interest serialization and deserialization seem to
work normal now. Debug examples added to examples/ folder (they
probably should become a part of test suite).
diff --git a/model/ccnx-content-object-header.cc b/model/ccnx-content-object-header.cc
index 2a248e1..e871e23 100644
--- a/model/ccnx-content-object-header.cc
+++ b/model/ccnx-content-object-header.cc
@@ -57,6 +57,7 @@
const CcnxNameComponents&
CcnxContentObjectHeader::GetName () const
{
+ if (m_name==0) throw CcnxContentObjectHeaderException();
return *m_name;
}
@@ -88,10 +89,9 @@
void
CcnxContentObjectHeader::Print (std::ostream &os) const
{
- os << "<ContentObject><Name>" << *m_name << "</Name><Content>";
+ os << "<ContentObject><Name>" << GetName () << "</Name><Content>";
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
CcnxContentObjectTail::CcnxContentObjectTail ()
@@ -102,8 +102,8 @@
CcnxContentObjectTail::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::CcnxContentObjectTail")
- .SetParent<Header> ()
- .AddConstructor<CcnxContentObjectHeader> ()
+ .SetParent<Trailer> ()
+ .AddConstructor<CcnxContentObjectTail> ()
;
return tid;
}
@@ -130,6 +130,8 @@
CcnxContentObjectTail::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
+ i.Prev (2); // Trailer interface requires us to go backwards
+
i.WriteU8 (0x00); // </Content>
i.WriteU8 (0x00); // </ContentObject>
}
@@ -138,6 +140,8 @@
CcnxContentObjectTail::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
+ i.Prev (2); // Trailer interface requires us to go backwards
+
uint8_t __attribute__ ((unused)) closing_tag_content = i.ReadU8 ();
NS_ASSERT_MSG (closing_tag_content==0, "Should be a closing tag </Content> (0x00)");