puzzle
diff --git a/include/ccnx-pco.h b/include/ccnx-pco.h
index 72a7289..8711a3e 100644
--- a/include/ccnx-pco.h
+++ b/include/ccnx-pco.h
@@ -26,9 +26,8 @@
name() const;
protected:
- ccn_parsed_ContentObject m_pco;
- ccn_indexbuf *m_comps;
- Bytes m_bytes;
+ Name m_name;
+ Bytes m_content;
};
typedef boost::shared_ptr<ParsedContentObject> PcoPtr;
diff --git a/src/ccnx-pco.cpp b/src/ccnx-pco.cpp
index dce3bcb..1d83b26 100644
--- a/src/ccnx-pco.cpp
+++ b/src/ccnx-pco.cpp
@@ -3,15 +3,27 @@
namespace Ccnx {
ParsedContentObject::ParsedContentObject(const unsigned char *data, size_t len)
- : m_comps(NULL)
{
- m_comps = ccn_indexbuf_create();
- int res = ccn_parse_ContentObject(data, len, &m_pco, m_comps);
+ ccn_indexbuf *comps = ccn_indexbuf_create();
+ ccn_parsed_ContentObject pco;
+ int res = ccn_parse_ContentObject(data, len, &pco, comps);
if (res < 0)
{
boost::throw_exception(MisformedContentObjectException());
}
- readRaw(m_bytes, data, len);
+
+ const unsigned char *content;
+ size_t length;
+ res = ccn_content_get_value(data, pco.offset[CCN_PCO_E], &pco, &content, &length);
+ if (res < 0)
+ {
+ boost::throw_exception(MisformedContentObjectException());
+ }
+ readRaw(m_content, content, length);
+
+ m_name = Name(data, comps);
+ cout << "in Constructor: name " << m_name << endl;
+ cout << "content : " << string((const char *)&m_content[0], m_content.size()) << endl;
}
ParsedContentObject::ParsedContentObject(const Bytes &bytes)
@@ -21,35 +33,26 @@
ParsedContentObject::ParsedContentObject(const ParsedContentObject &other)
{
- ParsedContentObject(other.m_bytes);
+ m_content = other.m_content;
+ m_name = other.m_name;
}
ParsedContentObject::~ParsedContentObject()
{
- ccn_indexbuf_destroy(&m_comps);
- m_comps = NULL;
}
Bytes
ParsedContentObject::content() const
{
- const unsigned char *content;
- size_t len;
- Bytes bytes;
- int res = ccn_content_get_value(head(m_bytes), m_pco.offset[CCN_PCO_E], &m_pco, &content, &len);
- if (res < 0)
- {
- boost::throw_exception(MisformedContentObjectException());
- }
-
- readRaw(bytes, content, len);
- return bytes;
+ cout << "content() : " << string((const char *)&m_content[0], m_content.size()) << endl;
+ return m_content;
}
Name
ParsedContentObject::name() const
{
- return Name(head(m_bytes), m_comps);
+ cout <<"name() : " << m_name << endl;
+ return m_name;
}
}
diff --git a/src/ccnx-tunnel.cpp b/src/ccnx-tunnel.cpp
index 9406474..36b8f6f 100644
--- a/src/ccnx-tunnel.cpp
+++ b/src/ccnx-tunnel.cpp
@@ -8,7 +8,7 @@
: CcnxWrapper()
, m_localPrefix("/")
{
- refreshLocalPrefix();
+ //refreshLocalPrefix();
}
CcnxTunnel::~CcnxTunnel()
@@ -32,13 +32,17 @@
{
Name tunneledInterest = queryRoutableName(interest);
Closure *cp = new TunnelClosure(closure, this, interest);
- sendInterest(tunneledInterest, cp, selectors);
+ cout << "send interest in Tunnel" << endl;
+ CcnxWrapper::sendInterest(tunneledInterest, cp, selectors);
}
void
CcnxTunnel::handleTunneledData(const Name &name, const Bytes &tunneledData, const Closure::DataCallback &originalDataCallback)
{
ParsedContentObject pco(tunneledData);
+ Name n = pco.name();
+ Bytes b = pco.content();
+ cout <<"Parsed ContentObject" << n << b.size() << endl;
originalDataCallback(pco.name(), pco.content());
}
diff --git a/test/test-ccnx-tunnel.cc b/test/test-ccnx-tunnel.cc
index fc1214a..03f4250 100644
--- a/test/test-ccnx-tunnel.cc
+++ b/test/test-ccnx-tunnel.cc
@@ -24,7 +24,7 @@
};
-DummyTunnel::DummyTunnel() : CcnxTunnel() {m_localPrefix = Name("/");}
+DummyTunnel::DummyTunnel() : CcnxTunnel() {m_localPrefix = Name("/local");}
Name
DummyTunnel::queryRoutableName (const Name &name)