Finalizing packet serialization. Set boost requirement (module will not be compiled without boost)
diff --git a/helper/ccnx-coding-helper.cc b/helper/ccnx-coding-helper.cc
index 6899543..7cab398 100644
--- a/helper/ccnx-coding-helper.cc
+++ b/helper/ccnx-coding-helper.cc
@@ -25,6 +25,7 @@
#include "ns3/ccnx-content-object-header.h"
#include <sstream>
+#include <boost/foreach.hpp>
namespace ns3 {
@@ -75,9 +76,15 @@
}
size_t
-CcnxCodingHelper::AppendName (Buffer::Iterator start, const Name::Components &name)
+CcnxCodingHelper::AppendNameComponents (Buffer::Iterator start, const Name::Components &name)
{
- return 0;
+ size_t written = 0;
+ BOOST_FOREACH (const std::string &component, name.GetComponents())
+ {
+ written += AppendTaggedBlob (start, CCN_DTAG_Component,
+ reinterpret_cast<const uint8_t*>(component.c_str()), component.size());
+ }
+ return written;
}
size_t
@@ -130,7 +137,7 @@
written += AppendBlockHeader (start, CCN_DTAG_Interest, CCN_DTAG); // <Interest>
written += AppendBlockHeader (start, CCN_DTAG_Name, CCN_DTAG); // <Name>
- written += AppendName (start, interest.GetName()); // <Component>...</Component>...
+ written += AppendNameComponents (start, interest.GetName()); // <Component>...</Component>...
written += AppendCloser (start); // </Name>
if (interest.GetMinSuffixComponents() >= 0)
@@ -148,7 +155,7 @@
if (interest.GetExclude().size() > 0)
{
written += AppendBlockHeader (start, CCN_DTAG_Exclude, CCN_DTAG); // <Exclude>
- written += AppendName (start, interest.GetExclude()); // <Component>...</Component>...
+ written += AppendNameComponents (start, interest.GetExclude()); // <Component>...</Component>...
written += AppendCloser (start); // </Exclude>
}
if (interest.IsEnabledChildSelector())
@@ -201,7 +208,9 @@
written += AppendTaggedBlob (start, CCN_DTAG_SignatureBits, 0, 0); // <SignatureBits />
written += AppendCloser (start); // </Signature>
- written += AppendName (start, contentObject.GetName()); // <Name><Component>...</Component>...</Name>
+ written += AppendBlockHeader (start, CCN_DTAG_Name, CCN_DTAG); // <Name>
+ written += AppendNameComponents (start, contentObject.GetName()); // <Component>...</Component>...
+ written += AppendCloser (start); // </Name>
// fake signature
written += AppendBlockHeader (start, CCN_DTAG_SignedInfo, CCN_DTAG); // <SignedInfo>
diff --git a/helper/ccnx-coding-helper.h b/helper/ccnx-coding-helper.h
index 3cafcbc..2d46a14 100644
--- a/helper/ccnx-coding-helper.h
+++ b/helper/ccnx-coding-helper.h
@@ -207,7 +207,7 @@
AppendCloser (Buffer::Iterator start);
static size_t
- AppendName (Buffer::Iterator start, const Name::Components &name);
+ AppendNameComponents (Buffer::Iterator start, const Name::Components &name);
/**
* Append a binary timestamp as a BLOB using the ccn binary
diff --git a/model/ccnx-content-object-header.cc b/model/ccnx-content-object-header.cc
index 46a1554..a3852a2 100644
--- a/model/ccnx-content-object-header.cc
+++ b/model/ccnx-content-object-header.cc
@@ -22,6 +22,7 @@
#include "ccnx-content-object-header.h"
#include "ns3/log.h"
+#include "ns3/ccnx-coding-helper.h"
NS_LOG_COMPONENT_DEFINE ("CcnxContentObjectHeader");
@@ -60,19 +61,22 @@
uint32_t
CcnxContentObjectHeader::GetSerializedSize (void) const
{
- return 0;
+ // Unfortunately, two serializations are required, unless we can pre-calculate header length... which is not trivial
+ Buffer tmp;
+
+ return CcnxCodingHelper::Serialize (tmp.Begin(), *this);
}
void
CcnxContentObjectHeader::Serialize (Buffer::Iterator start) const
{
- return;
+ CcnxCodingHelper::Serialize (start, *this);
}
uint32_t
CcnxContentObjectHeader::Deserialize (Buffer::Iterator start)
{
- return 0;
+ return 0; // the most complicated part is here
}
TypeId
diff --git a/model/ccnx-interest-header.cc b/model/ccnx-interest-header.cc
index 627946c..cab33ea 100644
--- a/model/ccnx-interest-header.cc
+++ b/model/ccnx-interest-header.cc
@@ -26,6 +26,7 @@
#include "ccnx-interest-header.h"
#include "ns3/log.h"
+#include "ns3/ccnx-coding-helper.h"
NS_LOG_COMPONENT_DEFINE ("CcnxInterestHeader");
@@ -167,19 +168,22 @@
uint32_t
CcnxInterestHeader::GetSerializedSize (void) const
{
- return 0;
+ // unfortunately, 2 serialization required...
+ Buffer tmp;
+
+ return CcnxCodingHelper::Serialize (tmp.Begin(), *this);
}
void
CcnxInterestHeader::Serialize (Buffer::Iterator start) const
{
- return;
+ CcnxCodingHelper::Serialize (start, *this);
}
uint32_t
CcnxInterestHeader::Deserialize (Buffer::Iterator start)
{
- return 0;
+ return 0; // the most complicated part is here
}
TypeId
@@ -191,7 +195,23 @@
void
CcnxInterestHeader::Print (std::ostream &os) const
{
- os << "Interest: " << *m_name;
+ os << "<Interest><Name>" << *m_name << "</Name>";
+ if (m_minSuffixComponents>=0)
+ os << "<MinSuffixComponents>" << m_minSuffixComponents << "</MinSuffixComponents>";
+ if (m_maxSuffixComponents>=0)
+ os << "<MaxSuffixComponents>" << m_maxSuffixComponents << "</MaxSuffixComponents>";
+ if (m_exclude->size()>0)
+ os << "<Exclude>" << *m_exclude << "</Exclude>";
+ if (m_childSelector)
+ os << "<ChildSelector />";
+ if (m_answerOriginKind)
+ os << "<AnswerOriginKind />";
+ if (m_scope>=0)
+ os << "<Scope>" << m_scope << "</Scope>";
+ if (!m_interestLifetime.IsZero())
+ os << "<InterestLifetime>" << m_interestLifetime << "</InterestLifetime>";
+ if (m_nonce>0)
+ os << "<Nonce>" << m_nonce << "</Nonce>";
}
}
diff --git a/model/name-components.cc b/model/name-components.cc
index 55e57c4..e1af1ee 100644
--- a/model/name-components.cc
+++ b/model/name-components.cc
@@ -20,9 +20,6 @@
#include "name-components.h"
-#include "ns3/ccn.h"
-#include "ns3/ccn_charbuf.h"
-
#include <iostream>
using namespace std;
@@ -49,6 +46,13 @@
// ccn_charbuf_destroy(&m_value);
}
+const std::list<std::string> &
+Components::GetComponents () const
+{
+ return m_prefix;
+}
+
+
// const ccn_charbuf*
// Components::GetName () const
// {
diff --git a/model/name-components.h b/model/name-components.h
index 8c124f8..d9b3f0a 100644
--- a/model/name-components.h
+++ b/model/name-components.h
@@ -37,6 +37,9 @@
~Components ();
Components& operator () (const std::string &s);
+
+ const std::list<std::string> &
+ GetComponents () const;
// virtual uint32_t
// GetSerializedSize (void) const;
diff --git a/wscript b/wscript
index e169e72..8f210c6 100644
--- a/wscript
+++ b/wscript
@@ -3,18 +3,38 @@
import os
import Logs
import Utils
+import Options
+
+def set_options(opt):
+ opt.tool_options('boost')
+
+def configure(conf):
+ conf.check_tool('boost')
+ conf.env['BOOST'] = conf.check_boost(lib = '', # need only base
+ min_version='1.40.0' )
+ if not conf.env['BOOST']:
+ conf.report_optional_feature("ndn-abstract", "NDN abstraction", False,
+ "Required boost libraries not found")
+ conf.env['ENABLE_NDN_ABSTRACT']=False;
+ return
+
+ conf.env['ENABLE_NDN_ABSTRACT']=True;
+
def build(bld):
module = bld.create_ns3_module ('NDNabstraction', ['applications', 'core', 'network', 'point-to-point'])
- module.find_sources_in_dirs (['model', 'apps', 'helper'],[],['.cc']);
-
tests = bld.create_ns3_module_test_library('NDNabstraction')
- tests.find_sources_in_dirs( ['test'], [], ['.cc'] );
-
headers = bld.new_task_gen('ns3header')
headers.module = 'NDNabstraction'
+
+ if not bld.env['ENABLE_NDN_ABSTRACT']:
+ return
+
+ module.find_sources_in_dirs (['model', 'apps', 'helper'],[],['.cc']);
+ tests.find_sources_in_dirs( ['test'], [], ['.cc'] );
headers.find_sources_in_dirs( ['model', 'apps', 'helper'], [], ['.h'] );
+
for path in ["examples"]:
anode = bld.path.find_dir (path)
if not anode or not anode.is_child_of(bld.srcnode):