model: Fixing bug with CCNb name encoding/decoding
Name object was not properly formatted using Wire::FromName call (was
missing outer Name block)
diff --git a/model/wire/ccnb/wire-ccnb-data.cc b/model/wire/ccnb/wire-ccnb-data.cc
index 6349971..0cb0b81 100644
--- a/model/wire/ccnb/wire-ccnb-data.cc
+++ b/model/wire/ccnb/wire-ccnb-data.cc
@@ -194,9 +194,9 @@
Ccnb::AppendTaggedBlobWithPadding (start, CcnbParser::CCN_DTAG_SignatureBits, 16, m_data->GetSignature ()); // <SignatureBits />
Ccnb::AppendCloser (start); // </Signature>
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
+ // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
Ccnb::SerializeName (start, m_data->GetName()); // <Component>...</Component>...
- Ccnb::AppendCloser (start); // </Name>
+ // Ccnb::AppendCloser (start); // </Name>
// fake signature
Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_SignedInfo, CcnbParser::CCN_DTAG); // <SignedInfo>
@@ -234,9 +234,9 @@
{
Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_KeyName, CcnbParser::CCN_DTAG); // <KeyName>
{
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
+ // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
Ccnb::SerializeName (start, *m_data->GetKeyLocator ()); // <Component>...</Component>...
- Ccnb::AppendCloser (start); // </Name>
+ // Ccnb::AppendCloser (start); // </Name>
}
Ccnb::AppendCloser (start); // </KeyName>
}
@@ -276,9 +276,9 @@
// written += Ccnb::EstimateTaggedBlob (CcnbParser::CCN_DTAG_SignatureBits, sizeof (m_data->GetSignature ())); // <SignatureBits />
written += 1; // </Signature>
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
+ //written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
written += Ccnb::SerializedSizeName (m_data->GetName ()); // <Component>...</Component>...
- written += 1; // </Name>
+ //written += 1; // </Name>
// fake signature
written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_SignedInfo); // <SignedInfo>
@@ -313,9 +313,9 @@
{
written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_KeyName); // <KeyName>
{
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
+ //written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
written += Ccnb::SerializedSizeName (*m_data->GetKeyLocator ()); // <Component>...</Component>...
- written += 1; // </Name>
+ //written += 1; // </Name>
}
written += 1; // </KeyName>
}
diff --git a/model/wire/ccnb/wire-ccnb-interest.cc b/model/wire/ccnb/wire-ccnb-interest.cc
index 8d622a4..f1711f8 100644
--- a/model/wire/ccnb/wire-ccnb-interest.cc
+++ b/model/wire/ccnb/wire-ccnb-interest.cc
@@ -115,9 +115,9 @@
{
Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Interest, CcnbParser::CCN_DTAG); // <Interest>
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
+ // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
Ccnb::SerializeName (start, m_interest->GetName()); // <Component>...</Component>...
- Ccnb::AppendCloser (start); // </Name>
+ // Ccnb::AppendCloser (start); // </Name>
// if (m_interest->GetMinSuffixComponents() >= 0)
// {
@@ -182,9 +182,9 @@
size_t written = 0;
written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Interest); // <Interest>
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
+ // written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
written += Ccnb::SerializedSizeName (m_interest->GetName()); // <Component>...</Component>...
- written += 1; // </Name>
+ // written += 1; // </Name>
// if (m_interest->GetMinSuffixComponents() >= 0)
// {
diff --git a/model/wire/ccnb/wire-ccnb.cc b/model/wire/ccnb/wire-ccnb.cc
index 7b92408..3403611 100644
--- a/model/wire/ccnb/wire-ccnb.cc
+++ b/model/wire/ccnb/wire-ccnb.cc
@@ -220,11 +220,13 @@
Ccnb::SerializeName (Buffer::Iterator &start, const Name &name)
{
size_t written = 0;
+ written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG);
BOOST_FOREACH (const name::Component &component, name)
{
written += AppendTaggedBlob (start, CcnbParser::CCN_DTAG_Component,
reinterpret_cast<const uint8_t*>(component.buf ()), component.size());
}
+ written += AppendCloser (start);
return written;
}
@@ -232,10 +234,12 @@
Ccnb::SerializedSizeName (const Name &name)
{
size_t written = 0;
+ written += EstimateBlockHeader (CcnbParser::CCN_DTAG_Name);
BOOST_FOREACH (const name::Component &component, name)
{
written += EstimateTaggedBlob (CcnbParser::CCN_DTAG_Component, component.size ());
}
+ written += 1;
return written;
}