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