Switch from NDNx to CCNx
Change-Id: Icc2e6dd95d9c4e0ba22b7efb9933c1db7194842e
diff --git a/adhoc/adhoc-osx.mm b/adhoc/adhoc-osx.mm
index c3116f4..7d2b1df 100644
--- a/adhoc/adhoc-osx.mm
+++ b/adhoc/adhoc-osx.mm
@@ -70,10 +70,10 @@
_LOG_DEBUG ("Creating face for the adhoc connection");
- // should do a better job later, when Ccnx::Control will be implemented
+ // should do a better job later, when Ndnx::Control will be implemented
ostringstream cmd;
- cmd << CCNX_PATH << "/bin/ccndc add / udp 169.254.255.255";
+ cmd << NDNX_PATH << "/bin/ndndc add / udp 169.254.255.255";
int ret = system (cmd.str ().c_str ());
if (ret == 0)
{
diff --git a/ccnx/ccnx-wrapper.cpp b/ccnx/ccnx-wrapper.cpp
deleted file mode 100644
index f91fafa..0000000
--- a/ccnx/ccnx-wrapper.cpp
+++ /dev/null
@@ -1,783 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ccnx-wrapper.h"
-extern "C" {
-#include <ccn/fetch.h>
-}
-#include <poll.h>
-#include <boost/throw_exception.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/random.hpp>
-#include <boost/make_shared.hpp>
-#include <boost/algorithm/string.hpp>
-#include <sstream>
-
-#include "ccnx-verifier.h"
-#include "logging.h"
-
-INIT_LOGGER ("Ccnx.Wrapper");
-
-typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
-typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
-
-using namespace std;
-using namespace boost;
-
-namespace Ccnx {
-
-// hack to enable fake signatures
-// min length for signature field is 16, as defined in ccn_buf_decoder.c:728
-const int DEFAULT_SIGNATURE_SIZE = 16;
-
-// Although ccn_buf_decoder.c:745 defines minimum length 16, something else is checking and only 32-byte fake value is accepted by ccnd
-const int PUBLISHER_KEY_SIZE = 32;
-
-static int
-ccn_encode_garbage_Signature(struct ccn_charbuf *buf)
-{
- int res = 0;
-
- res |= ccn_charbuf_append_tt(buf, CCN_DTAG_Signature, CCN_DTAG);
-
- // Let's cheat more. Default signing algorithm in ccnd is SHA256, so we just need add 32 bytes of garbage
- static char garbage [DEFAULT_SIGNATURE_SIZE];
-
- // digest and witness fields are optional, so use default ones
-
- res |= ccn_charbuf_append_tt(buf, CCN_DTAG_SignatureBits, CCN_DTAG);
- res |= ccn_charbuf_append_tt(buf, DEFAULT_SIGNATURE_SIZE, CCN_BLOB);
- res |= ccn_charbuf_append(buf, garbage, DEFAULT_SIGNATURE_SIZE);
- res |= ccn_charbuf_append_closer(buf);
-
- res |= ccn_charbuf_append_closer(buf);
-
- return(res == 0 ? 0 : -1);
-}
-
-static int
-ccn_pack_unsigned_ContentObject(struct ccn_charbuf *buf,
- const struct ccn_charbuf *Name,
- const struct ccn_charbuf *SignedInfo,
- const void *data,
- size_t size)
-{
- int res = 0;
- struct ccn_charbuf *content_header;
- size_t closer_start;
-
- content_header = ccn_charbuf_create();
- res |= ccn_charbuf_append_tt(content_header, CCN_DTAG_Content, CCN_DTAG);
- if (size != 0)
- res |= ccn_charbuf_append_tt(content_header, size, CCN_BLOB);
- closer_start = content_header->length;
- res |= ccn_charbuf_append_closer(content_header);
- if (res < 0)
- return(-1);
-
- res |= ccn_charbuf_append_tt(buf, CCN_DTAG_ContentObject, CCN_DTAG);
-
- res |= ccn_encode_garbage_Signature(buf);
-
- res |= ccn_charbuf_append_charbuf(buf, Name);
- res |= ccn_charbuf_append_charbuf(buf, SignedInfo);
- res |= ccnb_append_tagged_blob(buf, CCN_DTAG_Content, data, size);
- res |= ccn_charbuf_append_closer(buf);
-
- ccn_charbuf_destroy(&content_header);
- return(res == 0 ? 0 : -1);
-}
-
-CcnxWrapper::CcnxWrapper()
- : m_handle (0)
- , m_running (true)
- , m_connected (false)
- , m_executor (new Executor(1))
- , m_verifier(new Verifier(this))
-{
- start ();
-}
-
-void
-CcnxWrapper::connectCcnd()
-{
- if (m_handle != 0) {
- ccn_disconnect (m_handle);
- //ccn_destroy (&m_handle);
- }
- else
- {
- m_handle = ccn_create ();
- }
-
- UniqueRecLock lock(m_mutex);
- if (ccn_connect(m_handle, NULL) < 0)
- {
- BOOST_THROW_EXCEPTION (CcnxOperationException() << errmsg_info_str("connection to ccnd failed"));
- }
- m_connected = true;
-
- if (!m_registeredInterests.empty())
- {
- for (map<Name, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
- {
- clearInterestFilter(it->first, false);
- setInterestFilter(it->first, it->second, false);
- }
- }
-}
-
-CcnxWrapper::~CcnxWrapper()
-{
- shutdown ();
- if (m_verifier != 0)
- {
- delete m_verifier;
- m_verifier = 0;
- }
-}
-
-void
-CcnxWrapper::start () // called automatically in constructor
-{
- connectCcnd();
- m_thread = thread (&CcnxWrapper::ccnLoop, this);
- m_executor->start();
-}
-
-void
-CcnxWrapper::shutdown () // called in destructor, but can called manually
-{
- m_executor->shutdown();
-
- {
- UniqueRecLock lock(m_mutex);
- m_running = false;
- }
-
- _LOG_DEBUG ("+++++++++SHUTDOWN+++++++");
- if (m_connected)
- {
- m_thread.join ();
-
- ccn_disconnect (m_handle);
- //ccn_destroy (&m_handle);
- m_connected = false;
- }
-}
-
-void
-CcnxWrapper::ccnLoop ()
-{
- static boost::mt19937 randomGenerator (static_cast<unsigned int> (std::time (0)));
- static boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rangeUniformRandom (randomGenerator, uniform_int<> (0,1000));
-
- while (m_running)
- {
- try
- {
- int res = 0;
- {
- UniqueRecLock lock(m_mutex);
- res = ccn_run (m_handle, 0);
- }
-
- if (!m_running) break;
-
- if (res < 0) {
- _LOG_ERROR ("ccn_run returned negative status: " << res);
-
- BOOST_THROW_EXCEPTION (CcnxOperationException()
- << errmsg_info_str("ccn_run returned error"));
- }
-
-
- pollfd pfds[1];
- {
- UniqueRecLock lock(m_mutex);
-
- pfds[0].fd = ccn_get_connection_fd (m_handle);
- pfds[0].events = POLLIN;
- if (ccn_output_is_pending (m_handle))
- pfds[0].events |= POLLOUT;
- }
-
- int ret = poll (pfds, 1, 1);
- if (ret < 0)
- {
- BOOST_THROW_EXCEPTION (CcnxOperationException() << errmsg_info_str("ccnd socket failed (probably ccnd got stopped)"));
- }
- }
- catch (CcnxOperationException &e)
- {
- m_connected = false;
- // probably ccnd has been stopped
- // try reconnect with sleep
- int interval = 1;
- int maxInterval = 32;
- while (m_running)
- {
- try
- {
- this_thread::sleep (boost::get_system_time () + boost::posix_time::seconds (interval) + boost::posix_time::milliseconds (rangeUniformRandom ()));
-
- connectCcnd ();
- _LOG_DEBUG("reconnect to ccnd succeeded");
- break;
- }
- catch (CcnxOperationException &e)
- {
- this_thread::sleep (boost::get_system_time () + boost::posix_time::seconds (interval) + boost::posix_time::milliseconds (rangeUniformRandom ()));
-
- // do exponential backup for reconnect interval
- if (interval < maxInterval)
- {
- interval *= 2;
- }
- }
- }
- }
- catch (const std::exception &exc)
- {
- // catch anything thrown within try block that derives from std::exception
- std::cerr << exc.what();
- }
- catch (...)
- {
- cout << "UNKNOWN EXCEPTION !!!" << endl;
- }
- }
-}
-
-Bytes
-CcnxWrapper::createContentObject(const Name &name, const void *buf, size_t len, int freshness, const Name &keyNameParam)
-{
- {
- UniqueRecLock lock(m_mutex);
- if (!m_running || !m_connected)
- {
- _LOG_TRACE ("<< not running or connected");
- return Bytes ();
- }
- }
-
- CcnxCharbufPtr ptr = name.toCcnxCharbuf();
- ccn_charbuf *pname = ptr->getBuf();
- ccn_charbuf *content = ccn_charbuf_create();
-
- struct ccn_signing_params sp = CCN_SIGNING_PARAMS_INIT;
- sp.freshness = freshness;
-
- Name keyName;
-
- if (keyNameParam.size() == 0)
- {
- // use default key name
- CcnxCharbufPtr defaultKeyNamePtr = boost::make_shared<CcnxCharbuf>();
- ccn_get_public_key_and_name(m_handle, &sp, NULL, NULL, defaultKeyNamePtr->getBuf());
- keyName = Name(*defaultKeyNamePtr);
- }
- else
- {
- keyName = keyNameParam;
- }
-
- if (sp.template_ccnb == NULL)
- {
- sp.template_ccnb = ccn_charbuf_create();
- ccn_charbuf_append_tt(sp.template_ccnb, CCN_DTAG_SignedInfo, CCN_DTAG);
- }
- // no idea what the following 3 lines do, but it was there
- else if (sp.template_ccnb->length > 0) {
- sp.template_ccnb->length--;
- }
- ccn_charbuf_append_tt(sp.template_ccnb, CCN_DTAG_KeyLocator, CCN_DTAG);
- ccn_charbuf_append_tt(sp.template_ccnb, CCN_DTAG_KeyName, CCN_DTAG);
- CcnxCharbufPtr keyPtr = keyName.toCcnxCharbuf();
- ccn_charbuf *keyBuf = keyPtr->getBuf();
- ccn_charbuf_append(sp.template_ccnb, keyBuf->buf, keyBuf->length);
- ccn_charbuf_append_closer(sp.template_ccnb); // </KeyName>
- ccn_charbuf_append_closer(sp.template_ccnb); // </KeyLocator>
- sp.sp_flags |= CCN_SP_TEMPL_KEY_LOCATOR;
- ccn_charbuf_append_closer(sp.template_ccnb); // </SignedInfo>
-
- if (ccn_sign_content(m_handle, content, pname, &sp, buf, len) != 0)
- {
- BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("sign content failed"));
- }
-
- Bytes bytes;
- readRaw(bytes, content->buf, content->length);
-
- ccn_charbuf_destroy (&content);
- if (sp.template_ccnb != NULL)
- {
- ccn_charbuf_destroy (&sp.template_ccnb);
- }
-
- return bytes;
-}
-
-int
-CcnxWrapper::putToCcnd (const Bytes &contentObject)
-{
- _LOG_TRACE (">> putToCcnd");
- UniqueRecLock lock(m_mutex);
- if (!m_running || !m_connected)
- {
- _LOG_TRACE ("<< not running or connected");
- return -1;
- }
-
-
- if (ccn_put(m_handle, head(contentObject), contentObject.size()) < 0)
- {
- _LOG_ERROR ("ccn_put failed");
- // BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("ccnput failed"));
- }
- else
- {
- _LOG_DEBUG ("<< putToCcnd");
- }
-
- return 0;
-}
-
-int
-CcnxWrapper::publishData (const Name &name, const unsigned char *buf, size_t len, int freshness, const Name &keyName)
-{
- Bytes co = createContentObject(name, buf, len, freshness, keyName);
- return putToCcnd(co);
-}
-
-int
-CcnxWrapper::publishUnsignedData(const Name &name, const unsigned char *buf, size_t len, int freshness)
-{
- {
- UniqueRecLock lock(m_mutex);
- if (!m_running || !m_connected)
- {
- _LOG_TRACE ("<< not running or connected");
- return -1;
- }
- }
-
- CcnxCharbufPtr ptr = name.toCcnxCharbuf();
- ccn_charbuf *pname = ptr->getBuf();
- ccn_charbuf *content = ccn_charbuf_create();
- ccn_charbuf *signed_info = ccn_charbuf_create();
-
- static char fakeKey[PUBLISHER_KEY_SIZE];
-
- int res = ccn_signed_info_create(signed_info,
- fakeKey, PUBLISHER_KEY_SIZE,
- NULL,
- CCN_CONTENT_DATA,
- freshness,
- NULL,
- NULL // ccnd is happy with absent key locator and key itself... ha ha
- );
- ccn_pack_unsigned_ContentObject(content, pname, signed_info, buf, len);
-
- Bytes bytes;
- readRaw(bytes, content->buf, content->length);
-
- ccn_charbuf_destroy (&content);
- ccn_charbuf_destroy (&signed_info);
-
- return putToCcnd (bytes);
-}
-
-
-static void
-deleterInInterestTuple (tuple<CcnxWrapper::InterestCallback *, ExecutorPtr> *tuple)
-{
- delete tuple->get<0> ();
- delete tuple;
-}
-
-static ccn_upcall_res
-incomingInterest(ccn_closure *selfp,
- ccn_upcall_kind kind,
- ccn_upcall_info *info)
-{
- CcnxWrapper::InterestCallback *f;
- ExecutorPtr executor;
- tuple<CcnxWrapper::InterestCallback *, ExecutorPtr> *realData = reinterpret_cast< tuple<CcnxWrapper::InterestCallback *, ExecutorPtr>* > (selfp->data);
- tie (f, executor) = *realData;
-
- switch (kind)
- {
- case CCN_UPCALL_FINAL: // effective in unit tests
- // delete closure;
- executor->execute (bind (deleterInInterestTuple, realData));
-
- delete selfp;
- _LOG_TRACE ("<< incomingInterest with CCN_UPCALL_FINAL");
- return CCN_UPCALL_RESULT_OK;
-
- case CCN_UPCALL_INTEREST:
- _LOG_TRACE (">> incomingInterest upcall: " << Name(info->interest_ccnb, info->interest_comps));
- break;
-
- default:
- _LOG_TRACE ("<< incomingInterest with CCN_UPCALL_RESULT_OK: " << Name(info->interest_ccnb, info->interest_comps));
- return CCN_UPCALL_RESULT_OK;
- }
-
- Name interest(info->interest_ccnb, info->interest_comps);
- Selectors selectors(info->pi);
-
- executor->execute (bind (*f, interest, selectors));
- // this will be run in executor
- // (*f) (interest);
- // closure->runInterestCallback(interest);
-
- return CCN_UPCALL_RESULT_OK;
-}
-
-static void
-deleterInDataTuple (tuple<Closure *, ExecutorPtr, Selectors> *tuple)
-{
- delete tuple->get<0> ();
- delete tuple;
-}
-
-static ccn_upcall_res
-incomingData(ccn_closure *selfp,
- ccn_upcall_kind kind,
- ccn_upcall_info *info)
-{
- // Closure *cp = static_cast<Closure *> (selfp->data);
- Closure *cp;
- ExecutorPtr executor;
- Selectors selectors;
- tuple<Closure *, ExecutorPtr, Selectors> *realData = reinterpret_cast< tuple<Closure*, ExecutorPtr, Selectors>* > (selfp->data);
- tie (cp, executor, selectors) = *realData;
-
- switch (kind)
- {
- case CCN_UPCALL_FINAL: // effecitve in unit tests
- executor->execute (bind (deleterInDataTuple, realData));
-
- cp = NULL;
- delete selfp;
- _LOG_TRACE ("<< incomingData with CCN_UPCALL_FINAL");
- return CCN_UPCALL_RESULT_OK;
-
- case CCN_UPCALL_CONTENT:
- _LOG_TRACE (">> incomingData content upcall: " << Name (info->content_ccnb, info->content_comps));
- break;
-
- // this is the case where the intentionally unsigned packets coming (in Encapsulation case)
- case CCN_UPCALL_CONTENT_BAD:
- _LOG_TRACE (">> incomingData content bad upcall: " << Name (info->content_ccnb, info->content_comps));
- break;
-
- // always ask ccnd to try to fetch the key
- case CCN_UPCALL_CONTENT_UNVERIFIED:
- _LOG_TRACE (">> incomingData content unverified upcall: " << Name (info->content_ccnb, info->content_comps));
- break;
-
- case CCN_UPCALL_INTEREST_TIMED_OUT: {
- if (cp != NULL)
- {
- Name interest(info->interest_ccnb, info->interest_comps);
- _LOG_TRACE ("<< incomingData timeout: " << Name (info->interest_ccnb, info->interest_comps));
- executor->execute (bind (&Closure::runTimeoutCallback, cp, interest, *cp, selectors));
- }
- else
- {
- _LOG_TRACE ("<< incomingData timeout, but callback is not set...: " << Name (info->interest_ccnb, info->interest_comps));
- }
- return CCN_UPCALL_RESULT_OK;
- }
-
- default:
- _LOG_TRACE(">> unknown upcall type");
- return CCN_UPCALL_RESULT_OK;
- }
-
- PcoPtr pco = make_shared<ParsedContentObject> (info->content_ccnb, info->pco->offset[CCN_PCO_E]);
-
- // this will be run in executor
- executor->execute (bind (&Closure::runDataCallback, cp, pco->name (), pco));
- _LOG_TRACE (">> incomingData");
-
- return CCN_UPCALL_RESULT_OK;
-}
-
-int CcnxWrapper::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
-{
- _LOG_TRACE (">> sendInterest: " << interest);
- {
- UniqueRecLock lock(m_mutex);
- if (!m_running || !m_connected)
- {
- _LOG_ERROR ("<< sendInterest: not running or connected");
- return -1;
- }
- }
-
- CcnxCharbufPtr namePtr = interest.toCcnxCharbuf();
- ccn_charbuf *pname = namePtr->getBuf();
- ccn_closure *dataClosure = new ccn_closure;
-
- // Closure *myClosure = new ExecutorClosure(closure, m_executor);
- Closure *myClosure = closure.dup ();
- dataClosure->data = new tuple<Closure*, ExecutorPtr, Selectors> (myClosure, m_executor, selectors);
-
- dataClosure->p = &incomingData;
-
- CcnxCharbufPtr selectorsPtr = selectors.toCcnxCharbuf();
- ccn_charbuf *templ = NULL;
- if (selectorsPtr)
- {
- templ = selectorsPtr->getBuf();
- }
-
- UniqueRecLock lock(m_mutex);
- if (ccn_express_interest (m_handle, pname, dataClosure, templ) < 0)
- {
- _LOG_ERROR ("<< sendInterest: ccn_express_interest FAILED!!!");
- }
-
- return 0;
-}
-
-int CcnxWrapper::setInterestFilter (const Name &prefix, const InterestCallback &interestCallback, bool record/* = true*/)
-{
- _LOG_TRACE (">> setInterestFilter");
- UniqueRecLock lock(m_mutex);
- if (!m_running || !m_connected)
- {
- return -1;
- }
-
- CcnxCharbufPtr ptr = prefix.toCcnxCharbuf();
- ccn_charbuf *pname = ptr->getBuf();
- ccn_closure *interestClosure = new ccn_closure;
-
- // interestClosure->data = new ExecutorInterestClosure(interestCallback, m_executor);
-
- interestClosure->data = new tuple<CcnxWrapper::InterestCallback *, ExecutorPtr> (new InterestCallback (interestCallback), m_executor); // should be removed when closure is removed
- interestClosure->p = &incomingInterest;
-
- int ret = ccn_set_interest_filter (m_handle, pname, interestClosure);
- if (ret < 0)
- {
- _LOG_ERROR ("<< setInterestFilter: ccn_set_interest_filter FAILED");
- }
-
- if (record)
- {
- m_registeredInterests.insert(pair<Name, InterestCallback>(prefix, interestCallback));
- }
-
- _LOG_TRACE ("<< setInterestFilter");
-
- return ret;
-}
-
-void
-CcnxWrapper::clearInterestFilter (const Name &prefix, bool record/* = true*/)
-{
- _LOG_TRACE (">> clearInterestFilter");
- UniqueRecLock lock(m_mutex);
- if (!m_running || !m_connected)
- return;
-
- CcnxCharbufPtr ptr = prefix.toCcnxCharbuf();
- ccn_charbuf *pname = ptr->getBuf();
-
- int ret = ccn_set_interest_filter (m_handle, pname, 0);
- if (ret < 0)
- {
- }
-
- if (record)
- {
- m_registeredInterests.erase(prefix);
- }
-
- _LOG_TRACE ("<< clearInterestFilter");
-}
-
-Name
-CcnxWrapper::getLocalPrefix ()
-{
- struct ccn * tmp_handle = ccn_create ();
- int res = ccn_connect (tmp_handle, NULL);
- if (res < 0)
- {
- return Name();
- }
-
- string retval = "";
-
- struct ccn_charbuf *templ = ccn_charbuf_create();
- ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
- ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
- ccn_charbuf_append_closer(templ); /* </Name> */
- // XXX - use pubid if possible
- ccn_charbuf_append_tt(templ, CCN_DTAG_MaxSuffixComponents, CCN_DTAG);
- ccnb_append_number(templ, 1);
- ccn_charbuf_append_closer(templ); /* </MaxSuffixComponents> */
- ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", 2);
- ccn_charbuf_append_closer(templ); /* </Interest> */
-
- struct ccn_charbuf *name = ccn_charbuf_create ();
- res = ccn_name_from_uri (name, "/local/ndn/prefix");
- if (res < 0) {
- }
- else
- {
- struct ccn_fetch *fetch = ccn_fetch_new (tmp_handle);
-
- struct ccn_fetch_stream *stream = ccn_fetch_open (fetch, name, "/local/ndn/prefix",
- NULL, 4, CCN_V_HIGHEST, 0);
- if (stream == NULL) {
- }
- else
- {
- ostringstream os;
-
- int counter = 0;
- char buf[256];
- while (true) {
- res = ccn_fetch_read (stream, buf, sizeof(buf));
-
- if (res == 0) {
- break;
- }
-
- if (res > 0) {
- os << string(buf, res);
- } else if (res == CCN_FETCH_READ_NONE) {
- if (counter < 2)
- {
- ccn_run(tmp_handle, 1000);
- counter ++;
- }
- else
- {
- break;
- }
- } else if (res == CCN_FETCH_READ_END) {
- break;
- } else if (res == CCN_FETCH_READ_TIMEOUT) {
- break;
- } else {
- break;
- }
- }
- retval = os.str ();
- stream = ccn_fetch_close(stream);
- }
- fetch = ccn_fetch_destroy(fetch);
- }
-
- ccn_charbuf_destroy (&name);
-
- ccn_disconnect (tmp_handle);
- ccn_destroy (&tmp_handle);
-
- boost::algorithm::trim(retval);
- return Name(retval);
-}
-
-bool
-CcnxWrapper::verify(PcoPtr &pco, double maxWait)
-{
- return m_verifier->verify(pco, maxWait);
-}
-
-// This is needed just for get function implementation
-struct GetState
-{
- GetState (double maxWait)
- {
- double intPart, fraction;
- fraction = modf (std::abs(maxWait), &intPart);
-
- m_maxWait = date_time::second_clock<boost::posix_time::ptime>::universal_time()
- + boost::posix_time::seconds (intPart)
- + boost::posix_time::microseconds (fraction * 1000000);
- }
-
- PcoPtr
- WaitForResult ()
- {
- //_LOG_TRACE("GetState::WaitForResult start");
- boost::unique_lock<boost::mutex> lock (m_mutex);
- m_cond.timed_wait (lock, m_maxWait);
- //_LOG_TRACE("GetState::WaitForResult finish");
-
- return m_retval;
- }
-
- void
- DataCallback (Name name, PcoPtr pco)
- {
- //_LOG_TRACE("GetState::DataCallback, Name [" << name << "]");
- boost::unique_lock<boost::mutex> lock (m_mutex);
- m_retval = pco;
- m_cond.notify_one ();
- }
-
- void
- TimeoutCallback (Name name)
- {
- boost::unique_lock<boost::mutex> lock (m_mutex);
- m_cond.notify_one ();
- }
-
-private:
- boost::posix_time::ptime m_maxWait;
-
- boost::mutex m_mutex;
- boost::condition_variable m_cond;
-
- PcoPtr m_retval;
-};
-
-
-PcoPtr
-CcnxWrapper::get(const Name &interest, const Selectors &selectors, double maxWait/* = 4.0*/)
-{
- _LOG_TRACE (">> get: " << interest);
- {
- UniqueRecLock lock(m_mutex);
- if (!m_running || !m_connected)
- {
- _LOG_ERROR ("<< get: not running or connected");
- return PcoPtr ();
- }
- }
-
- GetState state (maxWait);
- this->sendInterest (interest, Closure (boost::bind (&GetState::DataCallback, &state, _1, _2),
- boost::bind (&GetState::TimeoutCallback, &state, _1)),
- selectors);
- return state.WaitForResult ();
-}
-
-}
diff --git a/cmd/csd.cc b/cmd/csd.cc
index 627f06d..8d9a9fb 100644
--- a/cmd/csd.cc
+++ b/cmd/csd.cc
@@ -23,13 +23,13 @@
#include "dispatcher.h"
#include "fs-watcher.h"
#include "logging.h"
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include <boost/make_shared.hpp>
using namespace boost;
using namespace std;
-using namespace Ccnx;
+using namespace Ndnx;
int main(int argc, char *argv[])
{
@@ -49,7 +49,7 @@
cout << "Starting ChronoShare for [" << username << "] shared-folder [" << sharedFolder << "] at [" << path << "]" << endl;
- Dispatcher dispatcher (username, sharedFolder, path, make_shared<CcnxWrapper> ());
+ Dispatcher dispatcher (username, sharedFolder, path, make_shared<NdnxWrapper> ());
FsWatcher watcher (path.c_str (),
bind (&Dispatcher::Did_LocalFile_AddOrModify, &dispatcher, _1),
diff --git a/cmd/dump-db.cc b/cmd/dump-db.cc
index ca8f89b..41b1285 100644
--- a/cmd/dump-db.cc
+++ b/cmd/dump-db.cc
@@ -21,14 +21,14 @@
#include "dispatcher.h"
#include "fs-watcher.h"
#include "logging.h"
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include <boost/make_shared.hpp>
#include <boost/lexical_cast.hpp>
using namespace boost;
using namespace std;
-using namespace Ccnx;
+using namespace Ndnx;
INIT_LOGGER ("DumpDb");
@@ -174,18 +174,18 @@
}
void
- DumpActionData(const Ccnx::Name &deviceName, int64_t seqno)
+ DumpActionData(const Ndnx::Name &deviceName, int64_t seqno)
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2 (m_db, "SELECT action_content_object, action_name FROM ActionLog WHERE device_name = ? and seq_no = ?", -1, &stmt, 0);
- Ccnx::CcnxCharbufPtr device_name = deviceName.toCcnxCharbuf();
+ Ndnx::NdnxCharbufPtr device_name = deviceName.toNdnxCharbuf();
sqlite3_bind_blob (stmt, 1, device_name->buf(), device_name->length(), SQLITE_STATIC);
sqlite3_bind_int64 (stmt, 2, seqno);
cout << "Dumping action data for: [" << deviceName << ", " << seqno << "]" <<endl;
if (sqlite3_step(stmt) == SQLITE_ROW)
{
PcoPtr pco = make_shared<ParsedContentObject> (reinterpret_cast<const unsigned char *> (sqlite3_column_blob (stmt, 0)), sqlite3_column_bytes (stmt, 0));
- Ccnx::Name actionName = Ccnx::Name(sqlite3_column_blob(stmt, 1), sqlite3_column_bytes(stmt, 0));
+ Ndnx::Name actionName = Ndnx::Name(sqlite3_column_blob(stmt, 1), sqlite3_column_bytes(stmt, 0));
if (pco)
{
ActionItemPtr action = deserializeMsg<ActionItem> (pco->content());
diff --git a/disabled/ccnx-tunnel.cpp b/disabled/ndnx-tunnel.cpp
similarity index 77%
rename from disabled/ccnx-tunnel.cpp
rename to disabled/ndnx-tunnel.cpp
index def125a..0984d26 100644
--- a/disabled/ccnx-tunnel.cpp
+++ b/disabled/ndnx-tunnel.cpp
@@ -19,41 +19,41 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-tunnel.h"
-#include "ccnx-pco.h"
+#include "ndnx-tunnel.h"
+#include "ndnx-pco.h"
-namespace Ccnx
+namespace Ndnx
{
-CcnxTunnel::CcnxTunnel()
- : CcnxWrapper()
+NdnxTunnel::NdnxTunnel()
+ : NdnxWrapper()
, m_localPrefix("/")
{
refreshLocalPrefix();
}
-CcnxTunnel::~CcnxTunnel()
+NdnxTunnel::~NdnxTunnel()
{
}
void
-CcnxTunnel::refreshLocalPrefix()
+NdnxTunnel::refreshLocalPrefix()
{
Name newPrefix = getLocalPrefix();
if (!newPrefix.toString().empty() && m_localPrefix != newPrefix)
{
- CcnxWrapper::clearInterestFilter(m_localPrefix);
- CcnxWrapper::setInterestFilter(newPrefix, bind(&CcnxTunnel::handleTunneledInterest, this, _1));
+ NdnxWrapper::clearInterestFilter(m_localPrefix);
+ NdnxWrapper::setInterestFilter(newPrefix, bind(&NdnxTunnel::handleTunneledInterest, this, _1));
m_localPrefix = newPrefix;
}
}
int
-CcnxTunnel::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
+NdnxTunnel::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
{
Name tunneledInterest = queryRoutableName(interest);
- CcnxWrapper::sendInterest(tunneledInterest,
+ NdnxWrapper::sendInterest(tunneledInterest,
TunnelClosure(closure, *this, interest),
selectors);
@@ -61,14 +61,14 @@
}
void
-CcnxTunnel::handleTunneledData(const Name &name, const Bytes &tunneledData, const Closure::DataCallback &originalDataCallback)
+NdnxTunnel::handleTunneledData(const Name &name, const Bytes &tunneledData, const Closure::DataCallback &originalDataCallback)
{
ParsedContentObject pco(tunneledData);
originalDataCallback(pco.name(), pco.content());
}
int
-CcnxTunnel::publishData(const Name &name, const unsigned char *buf, size_t len, int freshness)
+NdnxTunnel::publishData(const Name &name, const unsigned char *buf, size_t len, int freshness)
{
Bytes content = createContentObject(name, buf, len, freshness);
storeContentObject(name, content);
@@ -77,17 +77,17 @@
}
int
-CcnxTunnel::publishContentObject(const Name &name, const Bytes &contentObject, int freshness)
+NdnxTunnel::publishContentObject(const Name &name, const Bytes &contentObject, int freshness)
{
Name tunneledName = m_localPrefix + name;
Bytes tunneledCo = createContentObject(tunneledName, head(contentObject), contentObject.size(), freshness);
- return putToCcnd(tunneledCo);
+ return putToNdnd(tunneledCo);
}
void
-CcnxTunnel::handleTunneledInterest(const Name &tunneledInterest)
+NdnxTunnel::handleTunneledInterest(const Name &tunneledInterest)
{
- // The interest must have m_localPrefix as a prefix (component-wise), otherwise ccnd would not deliver it to us
+ // The interest must have m_localPrefix as a prefix (component-wise), otherwise ndnd would not deliver it to us
Name interest = tunneledInterest.getPartialName(m_localPrefix.size());
ReadLock lock(m_ritLock);
@@ -104,7 +104,7 @@
}
bool
-CcnxTunnel::isPrefix(const Name &prefix, const Name &name)
+NdnxTunnel::isPrefix(const Name &prefix, const Name &name)
{
if (prefix.size() > name.size())
{
@@ -124,7 +124,7 @@
}
int
-CcnxTunnel::setInterestFilter(const Name &prefix, const InterestCallback &interestCallback)
+NdnxTunnel::setInterestFilter(const Name &prefix, const InterestCallback &interestCallback)
{
WriteLock lock(m_ritLock);
// make sure copy constructor for boost::function works properly
@@ -133,14 +133,14 @@
}
void
-CcnxTunnel::clearInterestFilter(const Name &prefix)
+NdnxTunnel::clearInterestFilter(const Name &prefix)
{
WriteLock lock(m_ritLock);
// remove all
m_rit.erase(prefix);
}
-TunnelClosure::TunnelClosure(const DataCallback &dataCallback, CcnxTunnel &tunnel,
+TunnelClosure::TunnelClosure(const DataCallback &dataCallback, NdnxTunnel &tunnel,
const Name &originalInterest, const TimeoutCallback &timeoutCallback)
: Closure(dataCallback, timeoutCallback)
, m_tunnel(tunnel)
@@ -148,7 +148,7 @@
{
}
-TunnelClosure::TunnelClosure(const Closure &closure, CcnxTunnel &tunnel, const Name &originalInterest)
+TunnelClosure::TunnelClosure(const Closure &closure, NdnxTunnel &tunnel, const Name &originalInterest)
: Closure(closure)
, m_tunnel(tunnel)
{
@@ -172,4 +172,4 @@
return Closure::runTimeoutCallback(m_originalInterest);
}
-} // Ccnx
+} // Ndnx
diff --git a/disabled/ccnx-tunnel.h b/disabled/ndnx-tunnel.h
similarity index 88%
rename from disabled/ccnx-tunnel.h
rename to disabled/ndnx-tunnel.h
index 01dbf5e..1722eb1 100644
--- a/disabled/ccnx-tunnel.h
+++ b/disabled/ndnx-tunnel.h
@@ -19,10 +19,10 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_TUNNEL_H
-#define CCNX_TUNNEL_H
+#ifndef NDNX_TUNNEL_H
+#define NDNX_TUNNEL_H
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#define _OVERRIDE
#ifdef __GNUC__
@@ -32,20 +32,20 @@
#endif // __GNUC__ version
#endif // __GNUC__
-// Eventually, Sync::CcnxWrapper should be moved to this namespace.
+// Eventually, Sync::NdnxWrapper should be moved to this namespace.
// It has nothing to do with Sync.
-namespace Ccnx
+namespace Ndnx
{
-class CcnxTunnel : public CcnxWrapper
+class NdnxTunnel : public NdnxWrapper
{
public:
typedef std::multimap<Name, InterestCallback> RegisteredInterestTable;
typedef std::multimap<Name, InterestCallback>::iterator RitIter;
- CcnxTunnel();
- virtual ~CcnxTunnel();
+ NdnxTunnel();
+ virtual ~NdnxTunnel();
// name is topology-independent
virtual int
@@ -91,7 +91,7 @@
handleTunneledData(const Name &name, const Bytes &tunneledData, const Closure::DataCallback &originalDataCallback);
private:
- CcnxTunnel(const CcnxTunnel &other) {}
+ NdnxTunnel(const NdnxTunnel &other) {}
protected:
// need a way to update local prefix, perhaps using macports trick, but eventually we need something more portable
@@ -103,10 +103,10 @@
class TunnelClosure : public Closure
{
public:
- TunnelClosure(const DataCallback &dataCallback, CcnxTunnel &tunnel,
+ TunnelClosure(const DataCallback &dataCallback, NdnxTunnel &tunnel,
const Name &originalInterest, const TimeoutCallback &timeoutCallback = TimeoutCallback());
- TunnelClosure(const Closure &closure, CcnxTunnel &tunnel, const Name &originalInterest);
+ TunnelClosure(const Closure &closure, NdnxTunnel &tunnel, const Name &originalInterest);
virtual void
runDataCallback(const Name &name, const Bytes &content) _OVERRIDE;
@@ -118,7 +118,7 @@
dup() const;
private:
- CcnxTunnel &m_tunnel;
+ NdnxTunnel &m_tunnel;
Name m_originalInterest;
};
diff --git a/disabled/test-ccnx-tunnel.cc b/disabled/test-ndnx-tunnel.cc
similarity index 80%
rename from disabled/test-ccnx-tunnel.cc
rename to disabled/test-ndnx-tunnel.cc
index 724d6e5..baa3ec7 100644
--- a/disabled/test-ccnx-tunnel.cc
+++ b/disabled/test-ndnx-tunnel.cc
@@ -1,19 +1,19 @@
-#include "ccnx-tunnel.h"
-#include "ccnx-closure.h"
-#include "ccnx-name.h"
-#include "ccnx-pco.h"
+#include "ndnx-tunnel.h"
+#include "ndnx-closure.h"
+#include "ndnx-name.h"
+#include "ndnx-pco.h"
#include <unistd.h>
#include <boost/test/unit_test.hpp>
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
-BOOST_AUTO_TEST_SUITE(CcnxTunnelTests)
+BOOST_AUTO_TEST_SUITE(NdnxTunnelTests)
-class DummyTunnel : public CcnxTunnel
+class DummyTunnel : public NdnxTunnel
{
public:
DummyTunnel();
@@ -27,7 +27,7 @@
};
-DummyTunnel::DummyTunnel() : CcnxTunnel()
+DummyTunnel::DummyTunnel() : NdnxTunnel()
{
m_localPrefix = Name("/local");
}
@@ -35,7 +35,7 @@
void
DummyTunnel::overridePrefix()
{
- CcnxWrapper::setInterestFilter(m_localPrefix, bind(&DummyTunnel::handleTunneledInterest, this, _1));
+ NdnxWrapper::setInterestFilter(m_localPrefix, bind(&DummyTunnel::handleTunneledInterest, this, _1));
}
Name
@@ -44,9 +44,9 @@
return Name("/local") + name;
}
-CcnxWrapperPtr t1(new DummyTunnel());
-CcnxWrapperPtr t2(new DummyTunnel());
-CcnxWrapperPtr c1(new CcnxWrapper());
+NdnxWrapperPtr t1(new DummyTunnel());
+NdnxWrapperPtr t2(new DummyTunnel());
+NdnxWrapperPtr c1(new NdnxWrapper());
DummyTunnel t3;
@@ -74,7 +74,7 @@
g_ic++;
}
-BOOST_AUTO_TEST_CASE (CcnxTunnelTest)
+BOOST_AUTO_TEST_CASE (NdnxTunnelTest)
{
// test publish
string inner = "/hello";
@@ -94,7 +94,7 @@
BOOST_CHECK_EQUAL(g_dc_i, 1);
}
-BOOST_AUTO_TEST_CASE (CcnxTunnelRegister)
+BOOST_AUTO_TEST_CASE (NdnxTunnelRegister)
{
g_ic = 0;
diff --git a/gui/chronosharegui.cpp b/gui/chronosharegui.cpp
index 2ec6770..8405928 100644
--- a/gui/chronosharegui.cpp
+++ b/gui/chronosharegui.cpp
@@ -25,7 +25,7 @@
#include "config.h"
#include "logging.h"
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include <QValidator>
#include <QDir>
#include <QFileInfo>
@@ -34,7 +34,7 @@
#include <boost/make_shared.hpp>
using namespace boost;
-using namespace Ccnx;
+using namespace Ndnx;
static const string HTTP_SERVER_ADDRESS = "localhost";
static const string HTTP_SERVER_PORT = "9001";
@@ -168,7 +168,7 @@
realPathToFolder /= m_sharedFolderName.toStdString ();
m_dispatcher = new Dispatcher (m_username.toStdString (), m_sharedFolderName.toStdString (),
- realPathToFolder, make_shared<CcnxWrapper> ());
+ realPathToFolder, make_shared<NdnxWrapper> ());
// Alex: this **must** be here, otherwise m_dirPath will be uninitialized
m_watcher = new FsWatcher (realPathToFolder.string ().c_str (),
diff --git a/gui/html/js/ndn-js.js b/gui/html/js/ndn-js.js
index 169b946..63f1fef 100644
--- a/gui/html/js/ndn-js.js
+++ b/gui/html/js/ndn-js.js
@@ -2,7 +2,7 @@
* @author: Jeff Thompson
* See COPYING for copyright and distribution information.
* Provide the callback closure for the async communication methods in the NDN class.
- * This is a port of Closure.py from PyCCN, written by:
+ * This is a port of Closure.py from PyNDN, written by:
* Derek Kulinski <takeda@takeda.tk>
* Jeff Burke <jburke@ucla.edu>
*/
@@ -126,7 +126,7 @@
if (LOG > 3) console.log(ev);
if (LOG > 3) console.log('ws.onopen: WebSocket connection opened.');
if (LOG > 3) console.log('ws.onopen: ReadyState: ' + this.readyState);
- // NDN.registerPrefix will fetch the ccndid when needed.
+ // NDN.registerPrefix will fetch the ndndid when needed.
onopenCallback();
}
@@ -171,11 +171,11 @@
/**
* @author: Meki Cheraoui
* See COPYING for copyright and distribution information.
- * This class contains all CCNx tags
+ * This class contains all NDNx tags
*/
-var CCNProtocolDTags = {
+var NDNProtocolDTags = {
/**
* Note if you add one of these, add it to the reverse string map as well.
@@ -292,11 +292,11 @@
ConfigSliceOp : 126,
// Remember to keep in sync with schema/tagnames.csvsdict
- CCNProtocolDataUnit : 17702112,
- CCNPROTOCOL_DATA_UNIT : "CCNProtocolDataUnit"
+ NDNProtocolDataUnit : 17702112,
+ NDNPROTOCOL_DATA_UNIT : "NDNProtocolDataUnit"
};
-var CCNProtocolDTagsStrings = [
+var NDNProtocolDTagsStrings = [
null, null, null, null, null, null, null, null, null, null, null,
null, null,
"Any", "Name", "Component", "Certificate", "Collection", "CompleteName",
@@ -322,15 +322,15 @@
//TESTING
-//console.log(exports.CCNProtocolDTagsStrings[17]);
+//console.log(exports.NDNProtocolDTagsStrings[17]);
/**
* @author: Meki Cheraoui
* See COPYING for copyright and distribution information.
- * This class represents CCNTime Objects
+ * This class represents NDNTime Objects
*/
-var CCNTime = function CCNTime(
+var NDNTime = function NDNTime(
input) {
@@ -354,23 +354,23 @@
};
-CCNTime.prototype.getJavascriptDate = function(){
+NDNTime.prototype.getJavascriptDate = function(){
var d = new Date();
d.setTime( this.msec );
return d
};
/**
- * Create a CCNTime
+ * Create a NDNTime
* @param timestamp source timestamp to initialize from, some precision will be lost
*/
/**
- * Create a CCNTime from its binary encoding
- * @param binaryTime12 the binary representation of a CCNTime
+ * Create a NDNTime from its binary encoding
+ * @param binaryTime12 the binary representation of a NDNTime
*/
-/*CCNTime.prototype.setDateBinary = function(
+/*NDNTime.prototype.setDateBinary = function(
//byte []
binaryTime12) {
@@ -392,7 +392,7 @@
};
//byte[]
-CCNTime.prototype.toBinaryTime = function() {
+NDNTime.prototype.toBinaryTime = function() {
return this.msec; //unsignedLongToByteArray(this.date.getTime());
@@ -567,20 +567,20 @@
}
-Name.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
+Name.prototype.from_ndnb = function(/*XMLDecoder*/ decoder) {
decoder.readStartElement(this.getElementLabel());
this.components = new Array(); //new ArrayList<byte []>();
- while (decoder.peekStartElement(CCNProtocolDTags.Component)) {
- this.add(decoder.readBinaryElement(CCNProtocolDTags.Component));
+ while (decoder.peekStartElement(NDNProtocolDTags.Component)) {
+ this.add(decoder.readBinaryElement(NDNProtocolDTags.Component));
}
decoder.readEndElement();
};
-Name.prototype.to_ccnb = function(/*XMLEncoder*/ encoder) {
+Name.prototype.to_ndnb = function(/*XMLEncoder*/ encoder) {
if( this.components ==null )
throw new Error("CANNOT ENCODE EMPTY CONTENT NAME");
@@ -588,13 +588,13 @@
encoder.writeStartElement(this.getElementLabel());
var count = this.components.length;
for (var i=0; i < count; i++) {
- encoder.writeElement(CCNProtocolDTags.Component, this.components[i]);
+ encoder.writeElement(NDNProtocolDTags.Component, this.components[i]);
}
encoder.writeEndElement();
};
Name.prototype.getElementLabel = function(){
- return CCNProtocolDTags.Name;
+ return NDNProtocolDTags.Name;
};
/*
@@ -671,7 +671,7 @@
return this;
}
-// Return the escaped name string according to "CCNx URI Scheme".
+// Return the escaped name string according to "NDNx URI Scheme".
Name.prototype.to_uri = function() {
if (this.components.length == 0)
return "/";
@@ -803,7 +803,7 @@
Name.ContentDigestSuffix = new Uint8Array([0x00]);
/*
- * Return component as an escaped string according to "CCNx URI Scheme".
+ * Return component as an escaped string according to "NDNx URI Scheme".
* We can't use encodeURIComponent because that doesn't encode all the characters we want to.
*/
Name.toEscapedString = function(component) {
@@ -837,7 +837,7 @@
};
/*
- * Return component as a Uint8Array by decoding the escapedString according to "CCNx URI Scheme".
+ * Return component as a Uint8Array by decoding the escapedString according to "NDNx URI Scheme".
* If escapedString is "", "." or ".." then return null, which means to skip the component in the name.
*/
Name.fromEscapedString = function(escapedString) {
@@ -961,7 +961,7 @@
ContentObject.prototype.encodeObject = function encodeObject(obj){
var enc = new BinaryXMLEncoder();
- obj.to_ccnb(enc);
+ obj.to_ndnb(enc);
var num = enc.getReducedOstream();
@@ -973,7 +973,7 @@
ContentObject.prototype.encodeContent = function encodeContent(obj){
var enc = new BinaryXMLEncoder();
- enc.writeElement(CCNProtocolDTags.Content, this.content);
+ enc.writeElement(NDNProtocolDTags.Content, this.content);
var num = enc.getReducedOstream();
@@ -989,16 +989,16 @@
this.rawSignatureData = sigBits;
};
-ContentObject.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
+ContentObject.prototype.from_ndnb = function(/*XMLDecoder*/ decoder) {
// TODO VALIDATE THAT ALL FIELDS EXCEPT SIGNATURE ARE PRESENT
decoder.readStartElement(this.getElementLabel());
- if( decoder.peekStartElement(CCNProtocolDTags.Signature) ){
+ if( decoder.peekStartElement(NDNProtocolDTags.Signature) ){
this.signature = new Signature();
- this.signature.from_ccnb(decoder);
+ this.signature.from_ndnb(decoder);
}
//this.endSIG = decoder.offset;
@@ -1006,17 +1006,17 @@
this.startSIG = decoder.offset;
this.name = new Name();
- this.name.from_ccnb(decoder);
+ this.name.from_ndnb(decoder);
//this.startSignedInfo = decoder.offset;
- if( decoder.peekStartElement(CCNProtocolDTags.SignedInfo) ){
+ if( decoder.peekStartElement(NDNProtocolDTags.SignedInfo) ){
this.signedInfo = new SignedInfo();
- this.signedInfo.from_ccnb(decoder);
+ this.signedInfo.from_ndnb(decoder);
}
- this.content = decoder.readBinaryElement(CCNProtocolDTags.Content);
+ this.content = decoder.readBinaryElement(NDNProtocolDTags.Content);
//this.endContent = decoder.offset;
@@ -1028,7 +1028,7 @@
this.saveRawData(decoder.istream);
};
-ContentObject.prototype.to_ccnb = function(/*XMLEncoder*/ encoder) {
+ContentObject.prototype.to_ndnb = function(/*XMLEncoder*/ encoder) {
//TODO verify name, SignedInfo and Signature is present
@@ -1038,21 +1038,21 @@
- if(null!=this.signature) this.signature.to_ccnb(encoder);
+ if(null!=this.signature) this.signature.to_ndnb(encoder);
this.startSIG = encoder.offset;
- if(null!=this.name) this.name.to_ccnb(encoder);
+ if(null!=this.name) this.name.to_ndnb(encoder);
//this.endSIG = encoder.offset;
//this.startSignedInfo = encoder.offset;
- if(null!=this.signedInfo) this.signedInfo.to_ccnb(encoder);
+ if(null!=this.signedInfo) this.signedInfo.to_ndnb(encoder);
- encoder.writeElement(CCNProtocolDTags.Content, this.content);
+ encoder.writeElement(NDNProtocolDTags.Content, this.content);
this.endSIG = encoder.offset;
@@ -1066,7 +1066,7 @@
};
-ContentObject.prototype.getElementLabel= function(){return CCNProtocolDTags.ContentObject;};
+ContentObject.prototype.getElementLabel= function(){return NDNProtocolDTags.ContentObject;};
/**
* Signature
@@ -1078,31 +1078,31 @@
this.digestAlgorithm = _digestAlgorithm//String _digestAlgorithm;
};
-Signature.prototype.from_ccnb =function( decoder) {
+Signature.prototype.from_ndnb =function( decoder) {
decoder.readStartElement(this.getElementLabel());
if(LOG>4)console.log('STARTED DECODING SIGNATURE');
- if (decoder.peekStartElement(CCNProtocolDTags.DigestAlgorithm)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.DigestAlgorithm)) {
if(LOG>4)console.log('DIGIEST ALGORITHM FOUND');
- this.digestAlgorithm = decoder.readUTF8Element(CCNProtocolDTags.DigestAlgorithm);
+ this.digestAlgorithm = decoder.readUTF8Element(NDNProtocolDTags.DigestAlgorithm);
}
- if (decoder.peekStartElement(CCNProtocolDTags.Witness)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.Witness)) {
if(LOG>4)console.log('WITNESS FOUND');
- this.Witness = decoder.readBinaryElement(CCNProtocolDTags.Witness);
+ this.Witness = decoder.readBinaryElement(NDNProtocolDTags.Witness);
}
//FORCE TO READ A SIGNATURE
if(LOG>4)console.log('SIGNATURE FOUND');
- this.signature = decoder.readBinaryElement(CCNProtocolDTags.SignatureBits);
+ this.signature = decoder.readBinaryElement(NDNProtocolDTags.SignatureBits);
decoder.readEndElement();
};
-Signature.prototype.to_ccnb= function( encoder){
+Signature.prototype.to_ndnb= function( encoder){
if (!this.validate()) {
throw new Error("Cannot encode: field values missing.");
@@ -1110,21 +1110,21 @@
encoder.writeStartElement(this.getElementLabel());
- if ((null != this.digestAlgorithm) && (!this.digestAlgorithm.equals(CCNDigestHelper.DEFAULT_DIGEST_ALGORITHM))) {
- encoder.writeElement(CCNProtocolDTags.DigestAlgorithm, OIDLookup.getDigestOID(this.DigestAlgorithm));
+ if ((null != this.digestAlgorithm) && (!this.digestAlgorithm.equals(NDNDigestHelper.DEFAULT_DIGEST_ALGORITHM))) {
+ encoder.writeElement(NDNProtocolDTags.DigestAlgorithm, OIDLookup.getDigestOID(this.DigestAlgorithm));
}
if (null != this.Witness) {
// needs to handle null witness
- encoder.writeElement(CCNProtocolDTags.Witness, this.Witness);
+ encoder.writeElement(NDNProtocolDTags.Witness, this.Witness);
}
- encoder.writeElement(CCNProtocolDTags.SignatureBits, this.signature);
+ encoder.writeElement(NDNProtocolDTags.SignatureBits, this.signature);
encoder.writeEndElement();
};
-Signature.prototype.getElementLabel = function() { return CCNProtocolDTags.Signature; };
+Signature.prototype.getElementLabel = function() { return NDNProtocolDTags.Signature; };
Signature.prototype.validate = function() {
@@ -1144,7 +1144,7 @@
//TODO, Check types
this.publisher = _publisher; //publisherPublicKeyDigest
- this.timestamp=_timestamp; // CCN Time
+ this.timestamp=_timestamp; // NDN Time
this.type=_type; // ContentType
this.locator =_locator;//KeyLocator
this.freshnessSeconds =_freshnessSeconds; // Integer
@@ -1190,7 +1190,7 @@
var time = d.getTime();
- this.timestamp = new CCNTime( time );
+ this.timestamp = new NDNTime( time );
if(LOG>4)console.log('TIME msec is');
@@ -1210,23 +1210,23 @@
};
-SignedInfo.prototype.from_ccnb = function( decoder){
+SignedInfo.prototype.from_ndnb = function( decoder){
decoder.readStartElement( this.getElementLabel() );
- if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.PublisherPublicKeyDigest)) {
if(LOG>4)console.log('DECODING PUBLISHER KEY');
this.publisher = new PublisherPublicKeyDigest();
- this.publisher.from_ccnb(decoder);
+ this.publisher.from_ndnb(decoder);
}
- if (decoder.peekStartElement(CCNProtocolDTags.Timestamp)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.Timestamp)) {
if(LOG>4)console.log('DECODING TIMESTAMP');
- this.timestamp = decoder.readDateTime(CCNProtocolDTags.Timestamp);
+ this.timestamp = decoder.readDateTime(NDNProtocolDTags.Timestamp);
}
- if (decoder.peekStartElement(CCNProtocolDTags.Type)) {
- var binType = decoder.readBinaryElement(CCNProtocolDTags.Type);//byte []
+ if (decoder.peekStartElement(NDNProtocolDTags.Type)) {
+ var binType = decoder.readBinaryElement(NDNProtocolDTags.Type);//byte []
//TODO Implement type of Key Reading
@@ -1247,26 +1247,26 @@
this.type = ContentType.DATA; // default
}
- if (decoder.peekStartElement(CCNProtocolDTags.FreshnessSeconds)) {
- this.freshnessSeconds = decoder.readIntegerElement(CCNProtocolDTags.FreshnessSeconds);
+ if (decoder.peekStartElement(NDNProtocolDTags.FreshnessSeconds)) {
+ this.freshnessSeconds = decoder.readIntegerElement(NDNProtocolDTags.FreshnessSeconds);
if(LOG>4)console.log('FRESHNESS IN SECONDS IS '+ this.freshnessSeconds);
}
- if (decoder.peekStartElement(CCNProtocolDTags.FinalBlockID)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.FinalBlockID)) {
if(LOG>4)console.log('DECODING FINAL BLOCKID');
- this.finalBlockID = decoder.readBinaryElement(CCNProtocolDTags.FinalBlockID);
+ this.finalBlockID = decoder.readBinaryElement(NDNProtocolDTags.FinalBlockID);
}
- if (decoder.peekStartElement(CCNProtocolDTags.KeyLocator)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.KeyLocator)) {
if(LOG>4)console.log('DECODING KEY LOCATOR');
this.locator = new KeyLocator();
- this.locator.from_ccnb(decoder);
+ this.locator.from_ndnb(decoder);
}
decoder.readEndElement();
};
-SignedInfo.prototype.to_ccnb = function( encoder) {
+SignedInfo.prototype.to_ndnb = function( encoder) {
if (!this.validate()) {
throw new Error("Cannot encode : field values missing.");
}
@@ -1275,28 +1275,28 @@
if (null!=this.publisher) {
if(LOG>3) console.log('ENCODING PUBLISHER KEY' + this.publisher.publisherPublicKeyDigest);
- this.publisher.to_ccnb(encoder);
+ this.publisher.to_ndnb(encoder);
}
if (null!=this.timestamp) {
- encoder.writeDateTime(CCNProtocolDTags.Timestamp, this.timestamp );
+ encoder.writeDateTime(NDNProtocolDTags.Timestamp, this.timestamp );
}
if (null!=this.type && this.type !=0) {
- encoder.writeElement(CCNProtocolDTags.type, this.type);
+ encoder.writeElement(NDNProtocolDTags.type, this.type);
}
if (null!=this.freshnessSeconds) {
- encoder.writeElement(CCNProtocolDTags.FreshnessSeconds, this.freshnessSeconds);
+ encoder.writeElement(NDNProtocolDTags.FreshnessSeconds, this.freshnessSeconds);
}
if (null!=this.finalBlockID) {
- encoder.writeElement(CCNProtocolDTags.FinalBlockID, this.finalBlockID);
+ encoder.writeElement(NDNProtocolDTags.FinalBlockID, this.finalBlockID);
}
if (null!=this.locator) {
- this.locator.to_ccnb(encoder);
+ this.locator.to_ndnb(encoder);
}
encoder.writeEndElement();
@@ -1312,7 +1312,7 @@
};
SignedInfo.prototype.getElementLabel = function() {
- return CCNProtocolDTags.SignedInfo;
+ return NDNProtocolDTags.SignedInfo;
};
SignedInfo.prototype.validate = function() {
@@ -1484,82 +1484,82 @@
Interest.DEFAULT_ANSWER_ORIGIN_KIND = Interest.ANSWER_CONTENT_STORE | Interest.ANSWER_GENERATED;
-Interest.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
+Interest.prototype.from_ndnb = function(/*XMLDecoder*/ decoder) {
- decoder.readStartElement(CCNProtocolDTags.Interest);
+ decoder.readStartElement(NDNProtocolDTags.Interest);
this.name = new Name();
- this.name.from_ccnb(decoder);
+ this.name.from_ndnb(decoder);
- if (decoder.peekStartElement(CCNProtocolDTags.MinSuffixComponents))
- this.minSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MinSuffixComponents);
+ if (decoder.peekStartElement(NDNProtocolDTags.MinSuffixComponents))
+ this.minSuffixComponents = decoder.readIntegerElement(NDNProtocolDTags.MinSuffixComponents);
- if (decoder.peekStartElement(CCNProtocolDTags.MaxSuffixComponents))
- this.maxSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MaxSuffixComponents);
+ if (decoder.peekStartElement(NDNProtocolDTags.MaxSuffixComponents))
+ this.maxSuffixComponents = decoder.readIntegerElement(NDNProtocolDTags.MaxSuffixComponents);
- if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.PublisherPublicKeyDigest)) {
this.publisherPublicKeyDigest = new PublisherPublicKeyDigest();
- this.publisherPublicKeyDigest.from_ccnb(decoder);
+ this.publisherPublicKeyDigest.from_ndnb(decoder);
}
- if (decoder.peekStartElement(CCNProtocolDTags.Exclude)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.Exclude)) {
this.exclude = new Exclude();
- this.exclude.from_ccnb(decoder);
+ this.exclude.from_ndnb(decoder);
}
- if (decoder.peekStartElement(CCNProtocolDTags.ChildSelector))
- this.childSelector = decoder.readIntegerElement(CCNProtocolDTags.ChildSelector);
+ if (decoder.peekStartElement(NDNProtocolDTags.ChildSelector))
+ this.childSelector = decoder.readIntegerElement(NDNProtocolDTags.ChildSelector);
- if (decoder.peekStartElement(CCNProtocolDTags.AnswerOriginKind))
- this.answerOriginKind = decoder.readIntegerElement(CCNProtocolDTags.AnswerOriginKind);
+ if (decoder.peekStartElement(NDNProtocolDTags.AnswerOriginKind))
+ this.answerOriginKind = decoder.readIntegerElement(NDNProtocolDTags.AnswerOriginKind);
- if (decoder.peekStartElement(CCNProtocolDTags.Scope))
- this.scope = decoder.readIntegerElement(CCNProtocolDTags.Scope);
+ if (decoder.peekStartElement(NDNProtocolDTags.Scope))
+ this.scope = decoder.readIntegerElement(NDNProtocolDTags.Scope);
- if (decoder.peekStartElement(CCNProtocolDTags.InterestLifetime))
+ if (decoder.peekStartElement(NDNProtocolDTags.InterestLifetime))
this.interestLifetime = 1000.0 * DataUtils.bigEndianToUnsignedInt
- (decoder.readBinaryElement(CCNProtocolDTags.InterestLifetime)) / 4096;
+ (decoder.readBinaryElement(NDNProtocolDTags.InterestLifetime)) / 4096;
- if (decoder.peekStartElement(CCNProtocolDTags.Nonce))
- this.nonce = decoder.readBinaryElement(CCNProtocolDTags.Nonce);
+ if (decoder.peekStartElement(NDNProtocolDTags.Nonce))
+ this.nonce = decoder.readBinaryElement(NDNProtocolDTags.Nonce);
decoder.readEndElement();
};
-Interest.prototype.to_ccnb = function(/*XMLEncoder*/ encoder){
+Interest.prototype.to_ndnb = function(/*XMLEncoder*/ encoder){
//Could check if name is present
- encoder.writeStartElement(CCNProtocolDTags.Interest);
+ encoder.writeStartElement(NDNProtocolDTags.Interest);
- this.name.to_ccnb(encoder);
+ this.name.to_ndnb(encoder);
if (null != this.minSuffixComponents)
- encoder.writeElement(CCNProtocolDTags.MinSuffixComponents, this.minSuffixComponents);
+ encoder.writeElement(NDNProtocolDTags.MinSuffixComponents, this.minSuffixComponents);
if (null != this.maxSuffixComponents)
- encoder.writeElement(CCNProtocolDTags.MaxSuffixComponents, this.maxSuffixComponents);
+ encoder.writeElement(NDNProtocolDTags.MaxSuffixComponents, this.maxSuffixComponents);
if (null != this.publisherPublicKeyDigest)
- this.publisherPublicKeyDigest.to_ccnb(encoder);
+ this.publisherPublicKeyDigest.to_ndnb(encoder);
if (null != this.exclude)
- this.exclude.to_ccnb(encoder);
+ this.exclude.to_ndnb(encoder);
if (null != this.childSelector)
- encoder.writeElement(CCNProtocolDTags.ChildSelector, this.childSelector);
+ encoder.writeElement(NDNProtocolDTags.ChildSelector, this.childSelector);
if (this.DEFAULT_ANSWER_ORIGIN_KIND != this.answerOriginKind && this.answerOriginKind!=null)
- encoder.writeElement(CCNProtocolDTags.AnswerOriginKind, this.answerOriginKind);
+ encoder.writeElement(NDNProtocolDTags.AnswerOriginKind, this.answerOriginKind);
if (null != this.scope)
- encoder.writeElement(CCNProtocolDTags.Scope, this.scope);
+ encoder.writeElement(NDNProtocolDTags.Scope, this.scope);
if (null != this.interestLifetime)
- encoder.writeElement(CCNProtocolDTags.InterestLifetime,
+ encoder.writeElement(NDNProtocolDTags.InterestLifetime,
DataUtils.nonNegativeIntToBigEndian((this.interestLifetime / 1000.0) * 4096));
if (null != this.nonce)
- encoder.writeElement(CCNProtocolDTags.Nonce, this.nonce);
+ encoder.writeElement(NDNProtocolDTags.Nonce, this.nonce);
encoder.writeEndElement();
@@ -1608,20 +1608,20 @@
Exclude.ANY = "*";
-Exclude.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
- decoder.readStartElement(CCNProtocolDTags.Exclude);
+Exclude.prototype.from_ndnb = function(/*XMLDecoder*/ decoder) {
+ decoder.readStartElement(NDNProtocolDTags.Exclude);
while (true) {
- if (decoder.peekStartElement(CCNProtocolDTags.Component))
- this.values.push(decoder.readBinaryElement(CCNProtocolDTags.Component));
- else if (decoder.peekStartElement(CCNProtocolDTags.Any)) {
- decoder.readStartElement(CCNProtocolDTags.Any);
+ if (decoder.peekStartElement(NDNProtocolDTags.Component))
+ this.values.push(decoder.readBinaryElement(NDNProtocolDTags.Component));
+ else if (decoder.peekStartElement(NDNProtocolDTags.Any)) {
+ decoder.readStartElement(NDNProtocolDTags.Any);
decoder.readEndElement();
this.values.push(Exclude.ANY);
}
- else if (decoder.peekStartElement(CCNProtocolDTags.Bloom)) {
+ else if (decoder.peekStartElement(NDNProtocolDTags.Bloom)) {
// Skip the Bloom and treat it as Any.
- decoder.readBinaryElement(CCNProtocolDTags.Bloom);
+ decoder.readBinaryElement(NDNProtocolDTags.Bloom);
this.values.push(Exclude.ANY);
}
else
@@ -1631,20 +1631,20 @@
decoder.readEndElement();
};
-Exclude.prototype.to_ccnb = function(/*XMLEncoder*/ encoder) {
+Exclude.prototype.to_ndnb = function(/*XMLEncoder*/ encoder) {
if (this.values == null || this.values.length == 0)
return;
- encoder.writeStartElement(CCNProtocolDTags.Exclude);
+ encoder.writeStartElement(NDNProtocolDTags.Exclude);
// TODO: Do we want to order the components (except for ANY)?
for (var i = 0; i < this.values.length; ++i) {
if (this.values[i] == Exclude.ANY) {
- encoder.writeStartElement(CCNProtocolDTags.Any);
+ encoder.writeStartElement(NDNProtocolDTags.Any);
encoder.writeEndElement();
}
else
- encoder.writeElement(CCNProtocolDTags.Component, this.values[i]);
+ encoder.writeElement(NDNProtocolDTags.Component, this.values[i]);
}
encoder.writeEndElement();
@@ -1751,7 +1751,7 @@
*/
var Key = function Key(){
- /* TODO: Port from PyCCN:
+ /* TODO: Port from PyNDN:
generateRSA()
privateToDER()
publicToDER()
@@ -1790,13 +1790,13 @@
};
-KeyLocator.prototype.from_ccnb = function(decoder) {
+KeyLocator.prototype.from_ndnb = function(decoder) {
decoder.readStartElement(this.getElementLabel());
- if (decoder.peekStartElement(CCNProtocolDTags.Key)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.Key)) {
try {
- var encodedKey = decoder.readBinaryElement(CCNProtocolDTags.Key);
+ var encodedKey = decoder.readBinaryElement(NDNProtocolDTags.Key);
// This is a DER-encoded SubjectPublicKeyInfo.
//TODO FIX THIS, This should create a Key Object instead of keeping bytes
@@ -1817,9 +1817,9 @@
throw new Error("Cannot parse key: ");
}
- } else if ( decoder.peekStartElement(CCNProtocolDTags.Certificate)) {
+ } else if ( decoder.peekStartElement(NDNProtocolDTags.Certificate)) {
try {
- var encodedCert = decoder.readBinaryElement(CCNProtocolDTags.Certificate);
+ var encodedCert = decoder.readBinaryElement(NDNProtocolDTags.Certificate);
/*
* Certificates not yet working
@@ -1844,13 +1844,13 @@
this.type = KeyLocatorType.KEYNAME;
this.keyName = new KeyName();
- this.keyName.from_ccnb(decoder);
+ this.keyName.from_ndnb(decoder);
}
decoder.readEndElement();
};
-KeyLocator.prototype.to_ccnb = function( encoder) {
+KeyLocator.prototype.to_ndnb = function( encoder) {
if(LOG>4) console.log('type is is ' + this.type);
//TODO Check if Name is missing
@@ -1864,26 +1864,26 @@
if (this.type == KeyLocatorType.KEY) {
if(LOG>5)console.log('About to encode a public key' +this.publicKey);
- encoder.writeElement(CCNProtocolDTags.Key, this.publicKey);
+ encoder.writeElement(NDNProtocolDTags.Key, this.publicKey);
} else if (this.type == KeyLocatorType.CERTIFICATE) {
try {
- encoder.writeElement(CCNProtocolDTags.Certificate, this.certificate);
+ encoder.writeElement(NDNProtocolDTags.Certificate, this.certificate);
} catch ( e) {
throw new Error("CertificateEncodingException attempting to write key locator: " + e);
}
} else if (this.type == KeyLocatorType.KEYNAME) {
- this.keyName.to_ccnb(encoder);
+ this.keyName.to_ndnb(encoder);
}
encoder.writeEndElement();
};
KeyLocator.prototype.getElementLabel = function() {
- return CCNProtocolDTags.KeyLocator;
+ return NDNProtocolDTags.KeyLocator;
};
KeyLocator.prototype.validate = function() {
@@ -1899,39 +1899,39 @@
};
-KeyName.prototype.from_ccnb=function( decoder){
+KeyName.prototype.from_ndnb=function( decoder){
decoder.readStartElement(this.getElementLabel());
this.contentName = new Name();
- this.contentName.from_ccnb(decoder);
+ this.contentName.from_ndnb(decoder);
if(LOG>4) console.log('KEY NAME FOUND: ');
if ( PublisherID.peek(decoder) ) {
this.publisherID = new PublisherID();
- this.publisherID.from_ccnb(decoder);
+ this.publisherID.from_ndnb(decoder);
}
decoder.readEndElement();
};
-KeyName.prototype.to_ccnb = function( encoder) {
+KeyName.prototype.to_ndnb = function( encoder) {
if (!this.validate()) {
throw new Error("Cannot encode : field values missing.");
}
encoder.writeStartElement(this.getElementLabel());
- this.contentName.to_ccnb(encoder);
+ this.contentName.to_ndnb(encoder);
if (null != this.publisherID)
- this.publisherID.to_ccnb(encoder);
+ this.publisherID.to_ndnb(encoder);
encoder.writeEndElement();
};
-KeyName.prototype.getElementLabel = function() { return CCNProtocolDTags.KeyName; };
+KeyName.prototype.getElementLabel = function() { return NDNProtocolDTags.KeyName; };
KeyName.prototype.validate = function() {
// DKS -- do we do recursive validation?
@@ -1947,19 +1947,19 @@
var PublisherType = function PublisherType(_tag){
- this.KEY =(CCNProtocolDTags.PublisherPublicKeyDigest);
- this.CERTIFICATE= (CCNProtocolDTags.PublisherCertificateDigest);
- this.ISSUER_KEY= (CCNProtocolDTags.PublisherIssuerKeyDigest);
- this.ISSUER_CERTIFICATE =(CCNProtocolDTags.PublisherIssuerCertificateDigest);
+ this.KEY =(NDNProtocolDTags.PublisherPublicKeyDigest);
+ this.CERTIFICATE= (NDNProtocolDTags.PublisherCertificateDigest);
+ this.ISSUER_KEY= (NDNProtocolDTags.PublisherIssuerKeyDigest);
+ this.ISSUER_CERTIFICATE =(NDNProtocolDTags.PublisherIssuerCertificateDigest);
this.Tag = _tag;
};
var isTypeTagVal = function(tagVal) {
- if ((tagVal == CCNProtocolDTags.PublisherPublicKeyDigest) ||
- (tagVal == CCNProtocolDTags.PublisherCertificateDigest) ||
- (tagVal == CCNProtocolDTags.PublisherIssuerKeyDigest) ||
- (tagVal == CCNProtocolDTags.PublisherIssuerCertificateDigest)) {
+ if ((tagVal == NDNProtocolDTags.PublisherPublicKeyDigest) ||
+ (tagVal == NDNProtocolDTags.PublisherCertificateDigest) ||
+ (tagVal == NDNProtocolDTags.PublisherIssuerKeyDigest) ||
+ (tagVal == NDNProtocolDTags.PublisherIssuerCertificateDigest)) {
return true;
}
return false;
@@ -1985,7 +1985,7 @@
};
-PublisherID.prototype.from_ccnb = function(decoder) {
+PublisherID.prototype.from_ndnb = function(decoder) {
// We have a choice here of one of 4 binary element types.
var nextTag = decoder.peekStartElementAsLong();
@@ -2005,7 +2005,7 @@
}
};
-PublisherID.prototype.to_ccnb = function(encoder) {
+PublisherID.prototype.to_ndnb = function(encoder) {
if (!this.validate()) {
throw new Error("Cannot encode " + this.getClass().getName() + ": field values missing.");
}
@@ -2052,7 +2052,7 @@
};
-PublisherPublicKeyDigest.prototype.from_ccnb = function( decoder) {
+PublisherPublicKeyDigest.prototype.from_ndnb = function( decoder) {
this.publisherPublicKeyDigest = decoder.readBinaryElement(this.getElementLabel());
@@ -2072,7 +2072,7 @@
}
};
-PublisherPublicKeyDigest.prototype.to_ccnb= function( encoder) {
+PublisherPublicKeyDigest.prototype.to_ndnb= function( encoder) {
//TODO Check that the ByteArray for the key is present
if (!this.validate()) {
throw new Error("Cannot encode : field values missing.");
@@ -2081,7 +2081,7 @@
encoder.writeElement(this.getElementLabel(), this.publisherPublicKeyDigest);
};
-PublisherPublicKeyDigest.prototype.getElementLabel = function() { return CCNProtocolDTags.PublisherPublicKeyDigest; };
+PublisherPublicKeyDigest.prototype.getElementLabel = function() { return NDNProtocolDTags.PublisherPublicKeyDigest; };
PublisherPublicKeyDigest.prototype.validate =function() {
return (null != this.publisherPublicKeyDigest);
@@ -2131,31 +2131,31 @@
/**
* Used by NetworkObject to decode the object from a network stream.
*/
-FaceInstance.prototype.from_ccnb = function(//XMLDecoder
+FaceInstance.prototype.from_ndnb = function(//XMLDecoder
decoder) {
decoder.readStartElement(this.getElementLabel());
- if (decoder.peekStartElement(CCNProtocolDTags.Action)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.Action)) {
- this.action = decoder.readUTF8Element(CCNProtocolDTags.Action);
+ this.action = decoder.readUTF8Element(NDNProtocolDTags.Action);
}
- if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.PublisherPublicKeyDigest)) {
this.publisherPublicKeyDigest = new PublisherPublicKeyDigest();
- this.publisherPublicKeyDigest.from_ccnb(decoder);
+ this.publisherPublicKeyDigest.from_ndnb(decoder);
}
- if (decoder.peekStartElement(CCNProtocolDTags.FaceID)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.FaceID)) {
- this.faceID = decoder.readIntegerElement(CCNProtocolDTags.FaceID);
+ this.faceID = decoder.readIntegerElement(NDNProtocolDTags.FaceID);
}
- if (decoder.peekStartElement(CCNProtocolDTags.IPProto)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.IPProto)) {
//int
- var pI = decoder.readIntegerElement(CCNProtocolDTags.IPProto);
+ var pI = decoder.readIntegerElement(NDNProtocolDTags.IPProto);
this.ipProto = null;
@@ -2170,31 +2170,31 @@
} else {
throw new Error("FaceInstance.decoder. Invalid " +
- CCNProtocolDTags.tagToString(CCNProtocolDTags.IPProto) + " field: " + pI);
+ NDNProtocolDTags.tagToString(NDNProtocolDTags.IPProto) + " field: " + pI);
}
}
- if (decoder.peekStartElement(CCNProtocolDTags.Host)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.Host)) {
- this.host = decoder.readUTF8Element(CCNProtocolDTags.Host);
+ this.host = decoder.readUTF8Element(NDNProtocolDTags.Host);
}
- if (decoder.peekStartElement(CCNProtocolDTags.Port)) {
- this.Port = decoder.readIntegerElement(CCNProtocolDTags.Port);
+ if (decoder.peekStartElement(NDNProtocolDTags.Port)) {
+ this.Port = decoder.readIntegerElement(NDNProtocolDTags.Port);
}
- if (decoder.peekStartElement(CCNProtocolDTags.MulticastInterface)) {
- this.multicastInterface = decoder.readUTF8Element(CCNProtocolDTags.MulticastInterface);
+ if (decoder.peekStartElement(NDNProtocolDTags.MulticastInterface)) {
+ this.multicastInterface = decoder.readUTF8Element(NDNProtocolDTags.MulticastInterface);
}
- if (decoder.peekStartElement(CCNProtocolDTags.MulticastTTL)) {
- this.multicastTTL = decoder.readIntegerElement(CCNProtocolDTags.MulticastTTL);
+ if (decoder.peekStartElement(NDNProtocolDTags.MulticastTTL)) {
+ this.multicastTTL = decoder.readIntegerElement(NDNProtocolDTags.MulticastTTL);
}
- if (decoder.peekStartElement(CCNProtocolDTags.FreshnessSeconds)) {
- this.freshnessSeconds = decoder.readIntegerElement(CCNProtocolDTags.FreshnessSeconds);
+ if (decoder.peekStartElement(NDNProtocolDTags.FreshnessSeconds)) {
+ this.freshnessSeconds = decoder.readIntegerElement(NDNProtocolDTags.FreshnessSeconds);
}
decoder.readEndElement();
}
@@ -2202,7 +2202,7 @@
/**
* Used by NetworkObject to encode the object to a network stream.
*/
-FaceInstance.prototype.to_ccnb = function(//XMLEncoder
+FaceInstance.prototype.to_ndnb = function(//XMLEncoder
encoder){
//if (!this.validate()) {
@@ -2212,38 +2212,38 @@
encoder.writeStartElement(this.getElementLabel());
if (null != this.action && this.action.length != 0)
- encoder.writeElement(CCNProtocolDTags.Action, this.action);
+ encoder.writeElement(NDNProtocolDTags.Action, this.action);
if (null != this.publisherPublicKeyDigest) {
- this.publisherPublicKeyDigest.to_ccnb(encoder);
+ this.publisherPublicKeyDigest.to_ndnb(encoder);
}
if (null != this.faceID) {
- encoder.writeElement(CCNProtocolDTags.FaceID, this.faceID);
+ encoder.writeElement(NDNProtocolDTags.FaceID, this.faceID);
}
if (null != this.ipProto) {
- //encoder.writeElement(CCNProtocolDTags.IPProto, this.IpProto.value());
- encoder.writeElement(CCNProtocolDTags.IPProto, this.ipProto);
+ //encoder.writeElement(NDNProtocolDTags.IPProto, this.IpProto.value());
+ encoder.writeElement(NDNProtocolDTags.IPProto, this.ipProto);
}
if (null != this.host && this.host.length != 0) {
- encoder.writeElement(CCNProtocolDTags.Host, this.host);
+ encoder.writeElement(NDNProtocolDTags.Host, this.host);
}
if (null != this.Port) {
- encoder.writeElement(CCNProtocolDTags.Port, this.Port);
+ encoder.writeElement(NDNProtocolDTags.Port, this.Port);
}
if (null != this.multicastInterface && this.multicastInterface.length != 0) {
- encoder.writeElement(CCNProtocolDTags.MulticastInterface, this.multicastInterface);
+ encoder.writeElement(NDNProtocolDTags.MulticastInterface, this.multicastInterface);
}
if (null != this.multicastTTL) {
- encoder.writeElement(CCNProtocolDTags.MulticastTTL, this.multicastTTL);
+ encoder.writeElement(NDNProtocolDTags.MulticastTTL, this.multicastTTL);
}
if (null != this.freshnessSeconds) {
- encoder.writeElement(CCNProtocolDTags.FreshnessSeconds, this.freshnessSeconds);
+ encoder.writeElement(NDNProtocolDTags.FreshnessSeconds, this.freshnessSeconds);
}
encoder.writeEndElement();
}
-FaceInstance.prototype.getElementLabel= function(){return CCNProtocolDTags.FaceInstance;};
+FaceInstance.prototype.getElementLabel= function(){return NDNProtocolDTags.FaceInstance;};
/**
* @author: Meki Cheraoui
@@ -2257,7 +2257,7 @@
//Name
_prefixName,
//PublisherPublicKeyDigest
- _ccndId,
+ _ndndId,
//Integer
_faceID,
//Integer
@@ -2272,7 +2272,7 @@
//Name\
this.prefixName = _prefixName;
//PublisherPublicKeyDigest
- this.ccndID = _ccndId;
+ this.ndndID = _ndndId;
//Integer
this.faceID = _faceID;
//Integer
@@ -2282,31 +2282,31 @@
};
-ForwardingEntry.prototype.from_ccnb =function(
+ForwardingEntry.prototype.from_ndnb =function(
//XMLDecoder
decoder)
//throws ContentDecodingException
{
decoder.readStartElement(this.getElementLabel());
- if (decoder.peekStartElement(CCNProtocolDTags.Action)) {
- this.action = decoder.readUTF8Element(CCNProtocolDTags.Action);
+ if (decoder.peekStartElement(NDNProtocolDTags.Action)) {
+ this.action = decoder.readUTF8Element(NDNProtocolDTags.Action);
}
- if (decoder.peekStartElement(CCNProtocolDTags.Name)) {
+ if (decoder.peekStartElement(NDNProtocolDTags.Name)) {
this.prefixName = new Name();
- this.prefixName.from_ccnb(decoder) ;
+ this.prefixName.from_ndnb(decoder) ;
}
- if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
- this.CcndId = new PublisherPublicKeyDigest();
- this.CcndId.from_ccnb(decoder);
+ if (decoder.peekStartElement(NDNProtocolDTags.PublisherPublicKeyDigest)) {
+ this.NdndId = new PublisherPublicKeyDigest();
+ this.NdndId.from_ndnb(decoder);
}
- if (decoder.peekStartElement(CCNProtocolDTags.FaceID)) {
- this.faceID = decoder.readIntegerElement(CCNProtocolDTags.FaceID);
+ if (decoder.peekStartElement(NDNProtocolDTags.FaceID)) {
+ this.faceID = decoder.readIntegerElement(NDNProtocolDTags.FaceID);
}
- if (decoder.peekStartElement(CCNProtocolDTags.ForwardingFlags)) {
- this.flags = decoder.readIntegerElement(CCNProtocolDTags.ForwardingFlags);
+ if (decoder.peekStartElement(NDNProtocolDTags.ForwardingFlags)) {
+ this.flags = decoder.readIntegerElement(NDNProtocolDTags.ForwardingFlags);
}
- if (decoder.peekStartElement(CCNProtocolDTags.FreshnessSeconds)) {
- this.lifetime = decoder.readIntegerElement(CCNProtocolDTags.FreshnessSeconds);
+ if (decoder.peekStartElement(NDNProtocolDTags.FreshnessSeconds)) {
+ this.lifetime = decoder.readIntegerElement(NDNProtocolDTags.FreshnessSeconds);
}
decoder.readEndElement();
};
@@ -2314,7 +2314,7 @@
/**
* Used by NetworkObject to encode the object to a network stream.
*/
-ForwardingEntry.prototype.to_ccnb =function(
+ForwardingEntry.prototype.to_ndnb =function(
//XMLEncoder
encoder)
{
@@ -2325,26 +2325,26 @@
//}
encoder.writeStartElement(this.getElementLabel());
if (null != this.action && this.action.length != 0)
- encoder.writeElement(CCNProtocolDTags.Action, this.action);
+ encoder.writeElement(NDNProtocolDTags.Action, this.action);
if (null != this.prefixName) {
- this.prefixName.to_ccnb(encoder);
+ this.prefixName.to_ndnb(encoder);
}
- if (null != this.CcndId) {
- this.CcndId.to_ccnb(encoder);
+ if (null != this.NdndId) {
+ this.NdndId.to_ndnb(encoder);
}
if (null != this.faceID) {
- encoder.writeElement(CCNProtocolDTags.FaceID, this.faceID);
+ encoder.writeElement(NDNProtocolDTags.FaceID, this.faceID);
}
if (null != this.flags) {
- encoder.writeElement(CCNProtocolDTags.ForwardingFlags, this.flags);
+ encoder.writeElement(NDNProtocolDTags.ForwardingFlags, this.flags);
}
if (null != this.lifetime) {
- encoder.writeElement(CCNProtocolDTags.FreshnessSeconds, this.lifetime);
+ encoder.writeElement(NDNProtocolDTags.FreshnessSeconds, this.lifetime);
}
encoder.writeEndElement();
};
-ForwardingEntry.prototype.getElementLabel = function() { return CCNProtocolDTags.ForwardingEntry; }
+ForwardingEntry.prototype.getElementLabel = function() { return NDNProtocolDTags.ForwardingEntry; }
/**
* @author: Jeff Thompson
* See COPYING for copyright and distribution information.
@@ -2400,7 +2400,7 @@
return this.array.subarray(begin, end);
}
/**
- * This class is used to encode ccnb binary elements (blob, type/value pairs).
+ * This class is used to encode ndnb binary elements (blob, type/value pairs).
*
* @author: Meki Cheraoui
* See COPYING for copyright and distribution information.
@@ -2521,10 +2521,10 @@
//returns a string
stringToTag = function(/*long*/ tagVal) {
- if ((tagVal >= 0) && (tagVal < CCNProtocolDTagsStrings.length)) {
- return CCNProtocolDTagsStrings[tagVal];
- } else if (tagVal == CCNProtocolDTags.CCNProtocolDataUnit) {
- return CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT;
+ if ((tagVal >= 0) && (tagVal < NDNProtocolDTagsStrings.length)) {
+ return NDNProtocolDTagsStrings[tagVal];
+ } else if (tagVal == NDNProtocolDTags.NDNProtocolDataUnit) {
+ return NDNProtocolDTags.NDNPROTOCOL_DATA_UNIT;
}
return null;
};
@@ -2532,13 +2532,13 @@
//returns a Long
tagToString = function(/*String*/ tagName) {
// the slow way, but right now we don't care.... want a static lookup for the forward direction
- for (var i=0; i < CCNProtocolDTagsStrings.length; ++i) {
- if ((null != CCNProtocolDTagsStrings[i]) && (CCNProtocolDTagsStrings[i] == tagName)) {
+ for (var i=0; i < NDNProtocolDTagsStrings.length; ++i) {
+ if ((null != NDNProtocolDTagsStrings[i]) && (NDNProtocolDTagsStrings[i] == tagName)) {
return i;
}
}
- if (CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT == tagName) {
- return CCNProtocolDTags.CCNProtocolDataUnit;
+ if (NDNProtocolDTags.NDNPROTOCOL_DATA_UNIT == tagName) {
+ return NDNProtocolDTags.NDNProtocolDataUnit;
}
return null;
};
@@ -2720,7 +2720,7 @@
BinaryXMLEncoder.prototype.writeDateTime = function(
//String
tag,
- //CCNTime
+ //NDNTime
dateTime) {
if(LOG>4)console.log('ENCODING DATE with LONG VALUE');
@@ -2787,7 +2787,7 @@
};
/**
- * This class is used to decode ccnb binary elements (blob, type/value pairs).
+ * This class is used to decode ndnb binary elements (blob, type/value pairs).
*
* @author: Meki Cheraoui
* See COPYING for copyright and distribution information.
@@ -2831,10 +2831,10 @@
//returns a string
tagToString = function(/*long*/ tagVal) {
- if ((tagVal >= 0) && (tagVal < CCNProtocolDTagsStrings.length)) {
- return CCNProtocolDTagsStrings[tagVal];
- } else if (tagVal == CCNProtocolDTags.CCNProtocolDataUnit) {
- return CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT;
+ if ((tagVal >= 0) && (tagVal < NDNProtocolDTagsStrings.length)) {
+ return NDNProtocolDTagsStrings[tagVal];
+ } else if (tagVal == NDNProtocolDTags.NDNProtocolDataUnit) {
+ return NDNProtocolDTags.NDNPROTOCOL_DATA_UNIT;
}
return null;
};
@@ -2842,13 +2842,13 @@
//returns a Long
stringToTag = function(/*String*/ tagName) {
// the slow way, but right now we don't care.... want a static lookup for the forward direction
- for (var i=0; i < CCNProtocolDTagsStrings.length; ++i) {
- if ((null != CCNProtocolDTagsStrings[i]) && (CCNProtocolDTagsStrings[i] == tagName)) {
+ for (var i=0; i < NDNProtocolDTagsStrings.length; ++i) {
+ if ((null != NDNProtocolDTagsStrings[i]) && (NDNProtocolDTagsStrings[i] == tagName)) {
return i;
}
}
- if (CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT == tagName) {
- return CCNProtocolDTags.CCNProtocolDataUnit;
+ if (NDNProtocolDTags.NDNPROTOCOL_DATA_UNIT == tagName) {
+ return NDNProtocolDTags.NDNProtocolDataUnit;
}
return null;
};
@@ -3182,7 +3182,7 @@
};
-//CCNTime
+//NDNTime
BinaryXMLDecoder.prototype.readDateTime = function(
//long
startTag) {
@@ -3205,8 +3205,8 @@
if(LOG>3) console.log(lontimestamp);
- //CCNTime
- var timestamp = new CCNTime(lontimestamp);
+ //NDNTime
+ var timestamp = new NDNTime(lontimestamp);
//timestamp.setDateBinary(byteTimestamp);
if (null == timestamp) {
@@ -3409,7 +3409,7 @@
ContentDecodingException.prototype.name = "ContentDecodingException";
/**
- * This class uses BinaryXMLDecoder to follow the structure of a ccnb binary element to
+ * This class uses BinaryXMLDecoder to follow the structure of a ndnb binary element to
* determine its end.
*
* @author: Jeff Thompson
@@ -3435,7 +3435,7 @@
* which started at offset 0 then return true, else false.
* If this returns false, you should read more into input and call again.
* You have to pass in input each time because the array could be reallocated.
- * This throws an exception for badly formed ccnb.
+ * This throws an exception for badly formed ndnb.
*/
BinaryXMLStructureDecoder.prototype.findElementEnd = function(
// Uint8Array
@@ -3512,7 +3512,7 @@
var type = typeAndVal.t;
if (type == XML_DATTR)
// We already consumed the item. READ_HEADER_OR_CLOSE again.
- // ccnb has rules about what must follow an attribute, but we are just scanning.
+ // ndnb has rules about what must follow an attribute, but we are just scanning.
this.startHeader();
else if (type == XML_DTAG || type == XML_EXT) {
// Start a new level and READ_HEADER_OR_CLOSE again.
@@ -3526,7 +3526,7 @@
// Minimum tag or attribute length is 1.
this.nBytesToRead = typeAndVal.v + 1;
this.state = BinaryXMLStructureDecoder.READ_BYTES;
- // ccnb has rules about what must follow an attribute, but we are just scanning.
+ // ndnb has rules about what must follow an attribute, but we are just scanning.
}
else if (type == XML_BLOB || type == XML_UDATA) {
this.nBytesToRead = typeAndVal.v;
@@ -4031,7 +4031,7 @@
function encodeToBinaryInterest(interest) {
var enc = new BinaryXMLEncoder();
- interest.to_ccnb(enc);
+ interest.to_ndnb(enc);
return enc.getReducedOstream();
}
@@ -4043,7 +4043,7 @@
function encodeToBinaryContentObject(co){
var enc = new BinaryXMLEncoder();
- co.to_ccnb(enc);
+ co.to_ndnb(enc);
return enc.getReducedOstream();
}
@@ -4051,7 +4051,7 @@
function encodeForwardingEntry(co){
var enc = new BinaryXMLEncoder();
- co.to_ccnb(enc);
+ co.to_ndnb(enc);
var bytes = enc.getReducedOstream();
@@ -4073,7 +4073,7 @@
var faceInstance = new FaceInstance();
- faceInstance.from_ccnb(decoder);
+ faceInstance.from_ndnb(decoder);
return faceInstance;
@@ -4090,7 +4090,7 @@
var interest = new Interest();
- interest.from_ccnb(decoder);
+ interest.from_ndnb(decoder);
return interest;
@@ -4107,7 +4107,7 @@
var co = new ContentObject();
- co.from_ccnb(decoder);
+ co.from_ndnb(decoder);
return co;
@@ -4124,7 +4124,7 @@
var forwardingEntry = new ForwardingEntry();
- forwardingEntry.from_ccnb(decoder);
+ forwardingEntry.from_ndnb(decoder);
return forwardingEntry;
@@ -7629,12 +7629,12 @@
// Event handler
this.onopen = (settings.onopen || function() { if (LOG > 3) console.log("NDN connection established."); });
this.onclose = (settings.onclose || function() { if (LOG > 3) console.log("NDN connection closed."); });
- this.ccndid = null;
+ this.ndndid = null;
};
NDN.UNOPEN = 0; // created but not opened yet
-NDN.OPENED = 1; // connection to ccnd opened
-NDN.CLOSED = 2; // connection to ccnd closed
+NDN.OPENED = 1; // connection to ndnd opened
+NDN.CLOSED = 2; // connection to ndnd closed
/*
* Return true if necessary JavaScript support is available, else log an error and return false.
@@ -7652,7 +7652,7 @@
NDN.supported = NDN.getSupported();
-NDN.ccndIdFetcher = new Name('/%C1.M.S.localhost/%C1.M.SRV/ccnd/KEY');
+NDN.ndndIdFetcher = new Name('/%C1.M.S.localhost/%C1.M.SRV/ndnd/KEY');
NDN.prototype.createRoute = function(host, port) {
this.host=host;
@@ -7847,13 +7847,13 @@
NDN.prototype.registerPrefix = function(name, closure, flag) {
var thisNDN = this;
var onConnected = function() {
- if (thisNDN.ccndid == null) {
- // Fetch ccndid first, then register.
- var interest = new Interest(NDN.ccndIdFetcher);
+ if (thisNDN.ndndid == null) {
+ // Fetch ndndid first, then register.
+ var interest = new Interest(NDN.ndndIdFetcher);
interest.interestLifetime = 4000; // milliseconds
- if (LOG>3) console.log('Expressing interest for ccndid from ccnd.');
+ if (LOG>3) console.log('Expressing interest for ndndid from ndnd.');
thisNDN.reconnectAndExpressInterest
- (interest, new NDN.FetchCcndidClosure(thisNDN, name, closure, flag));
+ (interest, new NDN.FetchNdndidClosure(thisNDN, name, closure, flag));
}
else
thisNDN.registerPrefixHelper(name, closure, flag);
@@ -7870,10 +7870,10 @@
};
/*
- * This is a closure to receive the ContentObject for NDN.ccndIdFetcher and call
+ * This is a closure to receive the ContentObject for NDN.ndndIdFetcher and call
* registerPrefixHelper(name, callerClosure, flag).
*/
-NDN.FetchCcndidClosure = function FetchCcndidClosure(ndn, name, callerClosure, flag) {
+NDN.FetchNdndidClosure = function FetchNdndidClosure(ndn, name, callerClosure, flag) {
// Inherit from Closure.
Closure.call(this);
@@ -7883,9 +7883,9 @@
this.flag = flag;
};
-NDN.FetchCcndidClosure.prototype.upcall = function(kind, upcallInfo) {
+NDN.FetchNdndidClosure.prototype.upcall = function(kind, upcallInfo) {
if (kind == Closure.UPCALL_INTEREST_TIMED_OUT) {
- console.log("Timeout while requesting the ccndid. Cannot registerPrefix for " +
+ console.log("Timeout while requesting the ndndid. Cannot registerPrefix for " +
this.name.to_uri() + " .");
return Closure.RESULT_OK;
}
@@ -7898,12 +7898,12 @@
if (!co.signedInfo || !co.signedInfo.publisher
|| !co.signedInfo.publisher.publisherPublicKeyDigest)
console.log
- ("ContentObject doesn't have a publisherPublicKeyDigest. Cannot set ccndid and registerPrefix for "
+ ("ContentObject doesn't have a publisherPublicKeyDigest. Cannot set ndndid and registerPrefix for "
+ this.name.to_uri() + " .");
else {
- if (LOG>3) console.log('Got ccndid from ccnd.');
- this.ndn.ccndid = co.signedInfo.publisher.publisherPublicKeyDigest;
- if (LOG>3) console.log(this.ndn.ccndid);
+ if (LOG>3) console.log('Got ndndid from ndnd.');
+ this.ndn.ndndid = co.signedInfo.publisher.publisherPublicKeyDigest;
+ if (LOG>3) console.log(this.ndn.ndndid);
this.ndn.registerPrefixHelper(this.name, this.callerClosure, this.flag);
}
@@ -7912,7 +7912,7 @@
};
/*
- * Do the work of registerPrefix once we know we are connected with a ccndid.
+ * Do the work of registerPrefix once we know we are connected with a ndndid.
*/
NDN.prototype.registerPrefixHelper = function(name, closure, flag) {
var fe = new ForwardingEntry('selfreg', name, null, null, 3, 2147483647);
@@ -7926,8 +7926,8 @@
var coBinary = encodeToBinaryContentObject(co);
//var nodename = unescape('%00%88%E2%F4%9C%91%16%16%D6%21%8E%A0c%95%A5%A6r%11%E0%A0%82%89%A6%A9%85%AB%D6%E2%065%DB%AF');
- var nodename = this.ccndid;
- var interestName = new Name(['ccnx', nodename, 'selfreg', coBinary]);
+ var nodename = this.ndndid;
+ var interestName = new Name(['ndnx', nodename, 'selfreg', coBinary]);
var interest = new Interest(interestName);
interest.scope = 1;
@@ -7947,11 +7947,11 @@
if (LOG>3) console.log('Complete element received. Length ' + element.length + '. Start decoding.');
var decoder = new BinaryXMLDecoder(element);
// Dispatch according to packet type
- if (decoder.peekStartElement(CCNProtocolDTags.Interest)) { // Interest packet
+ if (decoder.peekStartElement(NDNProtocolDTags.Interest)) { // Interest packet
if (LOG > 3) console.log('Interest packet received.');
var interest = new Interest();
- interest.from_ccnb(decoder);
+ interest.from_ndnb(decoder);
if (LOG > 3) console.log(interest);
var nameStr = escape(interest.name.getName());
if (LOG > 3) console.log(nameStr);
@@ -7964,11 +7964,11 @@
if (ret == Closure.RESULT_INTEREST_CONSUMED && info.contentObject != null)
this.transport.send(encodeToBinaryContentObject(info.contentObject));
}
- } else if (decoder.peekStartElement(CCNProtocolDTags.ContentObject)) { // Content packet
+ } else if (decoder.peekStartElement(NDNProtocolDTags.ContentObject)) { // Content packet
if (LOG > 3) console.log('ContentObject packet received.');
var co = new ContentObject();
- co.from_ccnb(decoder);
+ co.from_ndnb(decoder);
var pitEntry = NDN.getEntryForExpressedInterest(co.name);
if (pitEntry != null) {
@@ -8179,7 +8179,7 @@
BinaryXmlElementReader.prototype.onReceivedData = function(/* Uint8Array */ rawData) {
// Process multiple objects in the data.
while(true) {
- // Scan the input to check if a whole ccnb object has been read.
+ // Scan the input to check if a whole ndnb object has been read.
this.structureDecoder.seek(0);
if (this.structureDecoder.findElementEnd(rawData)) {
// Got the remainder of an object. Report to the caller.
diff --git a/gui/html/js/ndn-js.min.js b/gui/html/js/ndn-js.min.js
index 5f578a7..092e995 100644
--- a/gui/html/js/ndn-js.min.js
+++ b/gui/html/js/ndn-js.min.js
@@ -4,19 +4,19 @@
WebSocketTransport.prototype.connect=function(a,b){null!=this.ws&&delete this.ws;this.ws=new WebSocket("ws://"+a.host+":"+a.port);0<LOG&&console.log("ws connection created.");this.connectedHost=a.host;this.connectedPort=a.port;this.ws.binaryType="arraybuffer";this.elementReader=new BinaryXmlElementReader(a);var c=this;this.ws.onmessage=function(a){a=a.data;if(null==a||void 0==a||""==a)console.log("INVALID ANSWER");else if(a instanceof ArrayBuffer){a=new Uint8Array(a);3<LOG&&console.log("BINARY RESPONSE IS "+
DataUtils.toHex(a));try{c.elementReader.onReceivedData(a)}catch(b){console.log("NDN.ws.onmessage exception: "+b)}}};this.ws.onopen=function(a){3<LOG&&console.log(a);3<LOG&&console.log("ws.onopen: WebSocket connection opened.");3<LOG&&console.log("ws.onopen: ReadyState: "+this.readyState);b()};this.ws.onerror=function(a){console.log("ws.onerror: ReadyState: "+this.readyState);console.log(a);console.log("ws.onerror: WebSocket error: "+a.data)};this.ws.onclose=function(){console.log("ws.onclose: WebSocket connection closed.");
c.ws=null;a.readyStatus=NDN.CLOSED;a.onclose()}};WebSocketTransport.prototype.send=function(a){if(null!=this.ws){var b=new Uint8Array(a.length);b.set(a);this.ws.send(b.buffer);3<LOG&&console.log("ws.send() returned.")}else console.log("WebSocket connection is not established.")};
-var CCNProtocolDTags={Any:13,Name:14,Component:15,Certificate:16,Collection:17,CompleteName:18,Content:19,SignedInfo:20,ContentDigest:21,ContentHash:22,Count:24,Header:25,Interest:26,Key:27,KeyLocator:28,KeyName:29,Length:30,Link:31,LinkAuthenticator:32,NameComponentCount:33,RootDigest:36,Signature:37,Start:38,Timestamp:39,Type:40,Nonce:41,Scope:42,Exclude:43,Bloom:44,BloomSeed:45,AnswerOriginKind:47,InterestLifetime:48,Witness:53,SignatureBits:54,DigestAlgorithm:55,BlockSize:56,FreshnessSeconds:58,
+var NDNProtocolDTags={Any:13,Name:14,Component:15,Certificate:16,Collection:17,CompleteName:18,Content:19,SignedInfo:20,ContentDigest:21,ContentHash:22,Count:24,Header:25,Interest:26,Key:27,KeyLocator:28,KeyName:29,Length:30,Link:31,LinkAuthenticator:32,NameComponentCount:33,RootDigest:36,Signature:37,Start:38,Timestamp:39,Type:40,Nonce:41,Scope:42,Exclude:43,Bloom:44,BloomSeed:45,AnswerOriginKind:47,InterestLifetime:48,Witness:53,SignatureBits:54,DigestAlgorithm:55,BlockSize:56,FreshnessSeconds:58,
FinalBlockID:59,PublisherPublicKeyDigest:60,PublisherCertificateDigest:61,PublisherIssuerKeyDigest:62,PublisherIssuerCertificateDigest:63,ContentObject:64,WrappedKey:65,WrappingKeyIdentifier:66,WrapAlgorithm:67,KeyAlgorithm:68,Label:69,EncryptedKey:70,EncryptedNonceKey:71,WrappingKeyName:72,Action:73,FaceID:74,IPProto:75,Host:76,Port:77,MulticastInterface:78,ForwardingFlags:79,FaceInstance:80,ForwardingEntry:81,MulticastTTL:82,MinSuffixComponents:83,MaxSuffixComponents:84,ChildSelector:85,RepositoryInfo:86,
Version:87,RepositoryVersion:88,GlobalPrefix:89,LocalName:90,Policy:91,Namespace:92,GlobalPrefixName:93,PolicyVersion:94,KeyValueSet:95,KeyValuePair:96,IntegerValue:97,DecimalValue:98,StringValue:99,BinaryValue:100,NameValue:101,Entry:102,ACL:103,ParameterizedName:104,Prefix:105,Suffix:106,Root:107,ProfileName:108,Parameters:109,InfoString:110,StatusResponse:112,StatusCode:113,StatusText:114,SyncNode:115,SyncNodeKind:116,SyncNodeElement:117,SyncVersion:118,SyncNodeElements:119,SyncContentHash:120,
-SyncLeafCount:121,SyncTreeDepth:122,SyncByteCount:123,ConfigSlice:124,ConfigSliceList:125,ConfigSliceOp:126,CCNProtocolDataUnit:17702112,CCNPROTOCOL_DATA_UNIT:"CCNProtocolDataUnit"},CCNProtocolDTagsStrings=[null,null,null,null,null,null,null,null,null,null,null,null,null,"Any","Name","Component","Certificate","Collection","CompleteName","Content","SignedInfo","ContentDigest","ContentHash",null,"Count","Header","Interest","Key","KeyLocator","KeyName","Length","Link","LinkAuthenticator","NameComponentCount",
+SyncLeafCount:121,SyncTreeDepth:122,SyncByteCount:123,ConfigSlice:124,ConfigSliceList:125,ConfigSliceOp:126,NDNProtocolDataUnit:17702112,NDNPROTOCOL_DATA_UNIT:"NDNProtocolDataUnit"},NDNProtocolDTagsStrings=[null,null,null,null,null,null,null,null,null,null,null,null,null,"Any","Name","Component","Certificate","Collection","CompleteName","Content","SignedInfo","ContentDigest","ContentHash",null,"Count","Header","Interest","Key","KeyLocator","KeyName","Length","Link","LinkAuthenticator","NameComponentCount",
null,null,"RootDigest","Signature","Start","Timestamp","Type","Nonce","Scope","Exclude","Bloom","BloomSeed",null,"AnswerOriginKind","InterestLifetime",null,null,null,null,"Witness","SignatureBits","DigestAlgorithm","BlockSize",null,"FreshnessSeconds","FinalBlockID","PublisherPublicKeyDigest","PublisherCertificateDigest","PublisherIssuerKeyDigest","PublisherIssuerCertificateDigest","ContentObject","WrappedKey","WrappingKeyIdentifier","WrapAlgorithm","KeyAlgorithm","Label","EncryptedKey","EncryptedNonceKey",
"WrappingKeyName","Action","FaceID","IPProto","Host","Port","MulticastInterface","ForwardingFlags","FaceInstance","ForwardingEntry","MulticastTTL","MinSuffixComponents","MaxSuffixComponents","ChildSelector","RepositoryInfo","Version","RepositoryVersion","GlobalPrefix","LocalName","Policy","Namespace","GlobalPrefixName","PolicyVersion","KeyValueSet","KeyValuePair","IntegerValue","DecimalValue","StringValue","BinaryValue","NameValue","Entry","ACL","ParameterizedName","Prefix","Suffix","Root","ProfileName",
-"Parameters","InfoString",null,"StatusResponse","StatusCode","StatusText","SyncNode","SyncNodeKind","SyncNodeElement","SyncVersion","SyncNodeElements","SyncContentHash","SyncLeafCount","SyncTreeDepth","SyncByteCount","ConfigSlice","ConfigSliceList","ConfigSliceOp"],CCNTime=function(a){this.NANOS_MAX=999877929;"number"==typeof a?this.msec=a:1<LOG&&console.log("UNRECOGNIZED TYPE FOR TIME")};CCNTime.prototype.getJavascriptDate=function(){var a=new Date;a.setTime(this.msec);return a};
+"Parameters","InfoString",null,"StatusResponse","StatusCode","StatusText","SyncNode","SyncNodeKind","SyncNodeElement","SyncVersion","SyncNodeElements","SyncContentHash","SyncLeafCount","SyncTreeDepth","SyncByteCount","ConfigSlice","ConfigSliceList","ConfigSliceOp"],NDNTime=function(a){this.NANOS_MAX=999877929;"number"==typeof a?this.msec=a:1<LOG&&console.log("UNRECOGNIZED TYPE FOR TIME")};NDNTime.prototype.getJavascriptDate=function(){var a=new Date;a.setTime(this.msec);return a};
var ExponentialReExpressClosure=function(a,b){Closure.call(this);this.callerClosure=a;b=b||{};this.maxInterestLifetime=b.maxInterestLifetime||16E3};
ExponentialReExpressClosure.prototype.upcall=function(a,b){try{if(a==Closure.UPCALL_INTEREST_TIMED_OUT){var c=b.interest.interestLifetime;if(null==c)return this.callerClosure.upcall(Closure.UPCALL_INTEREST_TIMED_OUT,b);c*=2;if(c>this.maxInterestLifetime)return this.callerClosure.upcall(Closure.UPCALL_INTEREST_TIMED_OUT,b);var d=b.interest.clone();d.interestLifetime=c;b.ndn.expressInterest(d.name,this,d);return Closure.RESULT_OK}return this.callerClosure.upcall(a,b)}catch(e){return console.log("ExponentialReExpressClosure.upcall exception: "+
e),Closure.RESULT_ERR}};var Name=function Name(b){if("string"==typeof b)3<LOG&&console.log("Content Name String "+b),this.components=Name.createNameArray(b);else if("object"===typeof b)if(this.components=[],b instanceof Name)this.add(b);else for(var c=0;c<b.length;++c)this.add(b[c]);else null==b?this.components=[]:1<LOG&&console.log("NO CONTENT NAME GIVEN")};Name.prototype.getName=function(){return this.to_uri()};
Name.createNameArray=function(a){a=a.trim();if(0>=a.length)return[];var b=a.indexOf(":");if(0<=b){var c=a.indexOf("/");if(0>c||b<c)a=a.substr(b+1,a.length-b-1).trim()}if("/"==a[0])if(2<=a.length&&"/"==a[1]){b=a.indexOf("/",2);if(0>b)return[];a=a.substr(b+1,a.length-b-1).trim()}else a=a.substr(1,a.length-1).trim();a=a.split("/");for(b=0;b<a.length;++b)c=Name.fromEscapedString(a[b]),null==c?(a.splice(b,1),--b):a[b]=c;return a};
-Name.prototype.from_ccnb=function(a){a.readStartElement(this.getElementLabel());for(this.components=[];a.peekStartElement(CCNProtocolDTags.Component);)this.add(a.readBinaryElement(CCNProtocolDTags.Component));a.readEndElement()};Name.prototype.to_ccnb=function(a){if(null==this.components)throw Error("CANNOT ENCODE EMPTY CONTENT NAME");a.writeStartElement(this.getElementLabel());for(var b=this.components.length,c=0;c<b;c++)a.writeElement(CCNProtocolDTags.Component,this.components[c]);a.writeEndElement()};
-Name.prototype.getElementLabel=function(){return CCNProtocolDTags.Name};
+Name.prototype.from_ndnb=function(a){a.readStartElement(this.getElementLabel());for(this.components=[];a.peekStartElement(NDNProtocolDTags.Component);)this.add(a.readBinaryElement(NDNProtocolDTags.Component));a.readEndElement()};Name.prototype.to_ndnb=function(a){if(null==this.components)throw Error("CANNOT ENCODE EMPTY CONTENT NAME");a.writeStartElement(this.getElementLabel());for(var b=this.components.length,c=0;c<b;c++)a.writeElement(NDNProtocolDTags.Component,this.components[c]);a.writeEndElement()};
+Name.prototype.getElementLabel=function(){return NDNProtocolDTags.Name};
Name.prototype.add=function(a){var b;if("string"==typeof a)b=DataUtils.stringToUtf8Array(a);else if("object"==typeof a&&a instanceof Uint8Array)b=new Uint8Array(a);else if("object"==typeof a&&a instanceof ArrayBuffer)b=new Uint8Array(new ArrayBuffer(a.byteLength)),b.set(new Uint8Array(a));else{if("object"==typeof a&&a instanceof Name){a=a==this?this.components.slice(0,this.components.length):a.components;for(b=0;b<a.length;++b)this.components.push(new Uint8Array(a[b]));return this}if("object"==typeof a)b=
new Uint8Array(a);else throw Error("Cannot add Name element at index "+this.components.length+": Invalid type");}this.components.push(b);return this};Name.prototype.addSegment=function(a){for(var b=1,c=a;0<c;)b++,c>>=8;b=new Uint8Array(b);c=0;b[c]=0;for(c++;0<a;)b[c]=a&255,a>>=8,c++;this.components.push(b);return this};Name.prototype.to_uri=function(){if(0==this.components.length)return"/";for(var a="",b=0;b<this.components.length;++b)a+="/"+Name.toEscapedString(this.components[b]);return a};
Name.prototype.addSegment=function(a){a=DataUtils.nonNegativeIntToBigEndian(a);var b=new Uint8Array(a.length+1);b.set(a,1);this.components.push(b);return this};Name.prototype.getPrefix=function(a){return new Name(this.components.slice(0,a))};Name.prototype.cut=function(){return new Name(this.components.slice(0,this.components.length-1))};Name.prototype.getComponent=function(a){var b=new ArrayBuffer(this.components[a].length);(new Uint8Array(b)).set(this.components[a]);return b};
@@ -27,71 +27,71 @@
Name.fromEscapedString=function(a){a=unescape(a.trim());return null==a.match(/[^.]/)?2>=a.length?null:DataUtils.toNumbersFromString(a.substr(3,a.length-3)):DataUtils.toNumbersFromString(a)};Name.prototype.match=function(a){var b=this.components;a=a.components;if(b.length>a.length)return!1;for(var c=0;c<b.length;++c)if(!DataUtils.arraysEqual(b[c],a[c]))return!1;return!0};
var ContentObject=function(a,b,c,d){this.name="string"==typeof a?new Name(a):a;this.signedInfo=b;this.content="string"==typeof c?DataUtils.toNumbersFromString(c):c;this.signature=d;this.rawSignatureData=this.endContent=this.endSIG=this.startSIG=null};
ContentObject.prototype.sign=function(){var a=this.encodeObject(this.name),b=this.encodeObject(this.signedInfo),c=this.encodeContent(),d=new ArrayBuffer(a.length+b.length+c.length),d=new Uint8Array(d);d.set(a,0);d.set(b,a.length);d.set(c,a.length+b.length);4<LOG&&console.log("Signature Data is (binary) "+d);4<LOG&&console.log("Signature Data is (RawString)");4<LOG&&console.log(DataUtils.toString(d));a=new RSAKey;a.readPrivateKeyFromPEMString(globalKeyManager.privateKey);a=a.signByteArrayWithSHA256(d);
-4<LOG&&console.log("SIGNATURE SAVED IS");4<LOG&&console.log(a);4<LOG&&console.log(DataUtils.toNumbers(a.trim()));this.signature.signature=DataUtils.toNumbers(a.trim())};ContentObject.prototype.encodeObject=function(a){var b=new BinaryXMLEncoder;a.to_ccnb(b);return b.getReducedOstream()};ContentObject.prototype.encodeContent=function(){var a=new BinaryXMLEncoder;a.writeElement(CCNProtocolDTags.Content,this.content);return a.getReducedOstream()};
+4<LOG&&console.log("SIGNATURE SAVED IS");4<LOG&&console.log(a);4<LOG&&console.log(DataUtils.toNumbers(a.trim()));this.signature.signature=DataUtils.toNumbers(a.trim())};ContentObject.prototype.encodeObject=function(a){var b=new BinaryXMLEncoder;a.to_ndnb(b);return b.getReducedOstream()};ContentObject.prototype.encodeContent=function(){var a=new BinaryXMLEncoder;a.writeElement(NDNProtocolDTags.Content,this.content);return a.getReducedOstream()};
ContentObject.prototype.saveRawData=function(a){this.rawSignatureData=a.subarray(this.startSIG,this.endSIG)};
-ContentObject.prototype.from_ccnb=function(a){a.readStartElement(this.getElementLabel());a.peekStartElement(CCNProtocolDTags.Signature)&&(this.signature=new Signature,this.signature.from_ccnb(a));this.startSIG=a.offset;this.name=new Name;this.name.from_ccnb(a);a.peekStartElement(CCNProtocolDTags.SignedInfo)&&(this.signedInfo=new SignedInfo,this.signedInfo.from_ccnb(a));this.content=a.readBinaryElement(CCNProtocolDTags.Content);this.endSIG=a.offset;a.readEndElement();this.saveRawData(a.istream)};
-ContentObject.prototype.to_ccnb=function(a){a.writeStartElement(this.getElementLabel());null!=this.signature&&this.signature.to_ccnb(a);this.startSIG=a.offset;null!=this.name&&this.name.to_ccnb(a);null!=this.signedInfo&&this.signedInfo.to_ccnb(a);a.writeElement(CCNProtocolDTags.Content,this.content);this.endSIG=a.offset;a.writeEndElement();this.saveRawData(a.ostream)};ContentObject.prototype.getElementLabel=function(){return CCNProtocolDTags.ContentObject};
+ContentObject.prototype.from_ndnb=function(a){a.readStartElement(this.getElementLabel());a.peekStartElement(NDNProtocolDTags.Signature)&&(this.signature=new Signature,this.signature.from_ndnb(a));this.startSIG=a.offset;this.name=new Name;this.name.from_ndnb(a);a.peekStartElement(NDNProtocolDTags.SignedInfo)&&(this.signedInfo=new SignedInfo,this.signedInfo.from_ndnb(a));this.content=a.readBinaryElement(NDNProtocolDTags.Content);this.endSIG=a.offset;a.readEndElement();this.saveRawData(a.istream)};
+ContentObject.prototype.to_ndnb=function(a){a.writeStartElement(this.getElementLabel());null!=this.signature&&this.signature.to_ndnb(a);this.startSIG=a.offset;null!=this.name&&this.name.to_ndnb(a);null!=this.signedInfo&&this.signedInfo.to_ndnb(a);a.writeElement(NDNProtocolDTags.Content,this.content);this.endSIG=a.offset;a.writeEndElement();this.saveRawData(a.ostream)};ContentObject.prototype.getElementLabel=function(){return NDNProtocolDTags.ContentObject};
var Signature=function(a,b,c){this.Witness=a;this.signature=b;this.digestAlgorithm=c};
-Signature.prototype.from_ccnb=function(a){a.readStartElement(this.getElementLabel());4<LOG&&console.log("STARTED DECODING SIGNATURE");a.peekStartElement(CCNProtocolDTags.DigestAlgorithm)&&(4<LOG&&console.log("DIGIEST ALGORITHM FOUND"),this.digestAlgorithm=a.readUTF8Element(CCNProtocolDTags.DigestAlgorithm));a.peekStartElement(CCNProtocolDTags.Witness)&&(4<LOG&&console.log("WITNESS FOUND"),this.Witness=a.readBinaryElement(CCNProtocolDTags.Witness));4<LOG&&console.log("SIGNATURE FOUND");this.signature=
-a.readBinaryElement(CCNProtocolDTags.SignatureBits);a.readEndElement()};
-Signature.prototype.to_ccnb=function(a){if(!this.validate())throw Error("Cannot encode: field values missing.");a.writeStartElement(this.getElementLabel());null!=this.digestAlgorithm&&!this.digestAlgorithm.equals(CCNDigestHelper.DEFAULT_DIGEST_ALGORITHM)&&a.writeElement(CCNProtocolDTags.DigestAlgorithm,OIDLookup.getDigestOID(this.DigestAlgorithm));null!=this.Witness&&a.writeElement(CCNProtocolDTags.Witness,this.Witness);a.writeElement(CCNProtocolDTags.SignatureBits,this.signature);a.writeEndElement()};
-Signature.prototype.getElementLabel=function(){return CCNProtocolDTags.Signature};Signature.prototype.validate=function(){return null!=this.signature};
+Signature.prototype.from_ndnb=function(a){a.readStartElement(this.getElementLabel());4<LOG&&console.log("STARTED DECODING SIGNATURE");a.peekStartElement(NDNProtocolDTags.DigestAlgorithm)&&(4<LOG&&console.log("DIGIEST ALGORITHM FOUND"),this.digestAlgorithm=a.readUTF8Element(NDNProtocolDTags.DigestAlgorithm));a.peekStartElement(NDNProtocolDTags.Witness)&&(4<LOG&&console.log("WITNESS FOUND"),this.Witness=a.readBinaryElement(NDNProtocolDTags.Witness));4<LOG&&console.log("SIGNATURE FOUND");this.signature=
+a.readBinaryElement(NDNProtocolDTags.SignatureBits);a.readEndElement()};
+Signature.prototype.to_ndnb=function(a){if(!this.validate())throw Error("Cannot encode: field values missing.");a.writeStartElement(this.getElementLabel());null!=this.digestAlgorithm&&!this.digestAlgorithm.equals(NDNDigestHelper.DEFAULT_DIGEST_ALGORITHM)&&a.writeElement(NDNProtocolDTags.DigestAlgorithm,OIDLookup.getDigestOID(this.DigestAlgorithm));null!=this.Witness&&a.writeElement(NDNProtocolDTags.Witness,this.Witness);a.writeElement(NDNProtocolDTags.SignatureBits,this.signature);a.writeEndElement()};
+Signature.prototype.getElementLabel=function(){return NDNProtocolDTags.Signature};Signature.prototype.validate=function(){return null!=this.signature};
var ContentType={DATA:0,ENCR:1,GONE:2,KEY:3,LINK:4,NACK:5},ContentTypeValue={"0":787648,1:1101969,2:1631044,3:2639423,4:2917194,5:3408010},ContentTypeValueReverse={787648:0,1101969:1,1631044:2,2639423:3,2917194:4,3408010:5},SignedInfo=function(a,b,c,d,e,f){this.publisher=a;this.timestamp=b;this.type=c;this.locator=d;this.freshnessSeconds=e;this.finalBlockID=f;this.setFields()};
-SignedInfo.prototype.setFields=function(){var a=globalKeyManager.publicKey;4<LOG&&console.log("PUBLIC KEY TO WRITE TO CONTENT OBJECT IS ");4<LOG&&console.log(a);var a=DataUtils.toNumbers(globalKeyManager.publicKey),b=hex_sha256_from_bytes(a);this.publisher=new PublisherPublicKeyDigest(DataUtils.toNumbers(b));b=(new Date).getTime();this.timestamp=new CCNTime(b);4<LOG&&console.log("TIME msec is");4<LOG&&console.log(this.timestamp.msec);this.type=0;4<LOG&&console.log("PUBLIC KEY TO WRITE TO CONTENT OBJECT IS ");
+SignedInfo.prototype.setFields=function(){var a=globalKeyManager.publicKey;4<LOG&&console.log("PUBLIC KEY TO WRITE TO CONTENT OBJECT IS ");4<LOG&&console.log(a);var a=DataUtils.toNumbers(globalKeyManager.publicKey),b=hex_sha256_from_bytes(a);this.publisher=new PublisherPublicKeyDigest(DataUtils.toNumbers(b));b=(new Date).getTime();this.timestamp=new NDNTime(b);4<LOG&&console.log("TIME msec is");4<LOG&&console.log(this.timestamp.msec);this.type=0;4<LOG&&console.log("PUBLIC KEY TO WRITE TO CONTENT OBJECT IS ");
4<LOG&&console.log(a);this.locator=new KeyLocator(a,KeyLocatorType.KEY)};
-SignedInfo.prototype.from_ccnb=function(a){a.readStartElement(this.getElementLabel());a.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)&&(4<LOG&&console.log("DECODING PUBLISHER KEY"),this.publisher=new PublisherPublicKeyDigest,this.publisher.from_ccnb(a));a.peekStartElement(CCNProtocolDTags.Timestamp)&&(4<LOG&&console.log("DECODING TIMESTAMP"),this.timestamp=a.readDateTime(CCNProtocolDTags.Timestamp));if(a.peekStartElement(CCNProtocolDTags.Type)){var b=a.readBinaryElement(CCNProtocolDTags.Type);
-4<LOG&&console.log("Binary Type of of Signed Info is "+b);this.type=b;if(null==this.type)throw Error("Cannot parse signedInfo type: bytes.");}else this.type=ContentType.DATA;a.peekStartElement(CCNProtocolDTags.FreshnessSeconds)&&(this.freshnessSeconds=a.readIntegerElement(CCNProtocolDTags.FreshnessSeconds),4<LOG&&console.log("FRESHNESS IN SECONDS IS "+this.freshnessSeconds));a.peekStartElement(CCNProtocolDTags.FinalBlockID)&&(4<LOG&&console.log("DECODING FINAL BLOCKID"),this.finalBlockID=a.readBinaryElement(CCNProtocolDTags.FinalBlockID));
-a.peekStartElement(CCNProtocolDTags.KeyLocator)&&(4<LOG&&console.log("DECODING KEY LOCATOR"),this.locator=new KeyLocator,this.locator.from_ccnb(a));a.readEndElement()};
-SignedInfo.prototype.to_ccnb=function(a){if(!this.validate())throw Error("Cannot encode : field values missing.");a.writeStartElement(this.getElementLabel());null!=this.publisher&&(3<LOG&&console.log("ENCODING PUBLISHER KEY"+this.publisher.publisherPublicKeyDigest),this.publisher.to_ccnb(a));null!=this.timestamp&&a.writeDateTime(CCNProtocolDTags.Timestamp,this.timestamp);null!=this.type&&0!=this.type&&a.writeElement(CCNProtocolDTags.type,this.type);null!=this.freshnessSeconds&&a.writeElement(CCNProtocolDTags.FreshnessSeconds,
-this.freshnessSeconds);null!=this.finalBlockID&&a.writeElement(CCNProtocolDTags.FinalBlockID,this.finalBlockID);null!=this.locator&&this.locator.to_ccnb(a);a.writeEndElement()};SignedInfo.prototype.valueToType=function(){return null};SignedInfo.prototype.getElementLabel=function(){return CCNProtocolDTags.SignedInfo};SignedInfo.prototype.validate=function(){return null==this.publisher||null==this.timestamp||null==this.locator?!1:!0};
+SignedInfo.prototype.from_ndnb=function(a){a.readStartElement(this.getElementLabel());a.peekStartElement(NDNProtocolDTags.PublisherPublicKeyDigest)&&(4<LOG&&console.log("DECODING PUBLISHER KEY"),this.publisher=new PublisherPublicKeyDigest,this.publisher.from_ndnb(a));a.peekStartElement(NDNProtocolDTags.Timestamp)&&(4<LOG&&console.log("DECODING TIMESTAMP"),this.timestamp=a.readDateTime(NDNProtocolDTags.Timestamp));if(a.peekStartElement(NDNProtocolDTags.Type)){var b=a.readBinaryElement(NDNProtocolDTags.Type);
+4<LOG&&console.log("Binary Type of of Signed Info is "+b);this.type=b;if(null==this.type)throw Error("Cannot parse signedInfo type: bytes.");}else this.type=ContentType.DATA;a.peekStartElement(NDNProtocolDTags.FreshnessSeconds)&&(this.freshnessSeconds=a.readIntegerElement(NDNProtocolDTags.FreshnessSeconds),4<LOG&&console.log("FRESHNESS IN SECONDS IS "+this.freshnessSeconds));a.peekStartElement(NDNProtocolDTags.FinalBlockID)&&(4<LOG&&console.log("DECODING FINAL BLOCKID"),this.finalBlockID=a.readBinaryElement(NDNProtocolDTags.FinalBlockID));
+a.peekStartElement(NDNProtocolDTags.KeyLocator)&&(4<LOG&&console.log("DECODING KEY LOCATOR"),this.locator=new KeyLocator,this.locator.from_ndnb(a));a.readEndElement()};
+SignedInfo.prototype.to_ndnb=function(a){if(!this.validate())throw Error("Cannot encode : field values missing.");a.writeStartElement(this.getElementLabel());null!=this.publisher&&(3<LOG&&console.log("ENCODING PUBLISHER KEY"+this.publisher.publisherPublicKeyDigest),this.publisher.to_ndnb(a));null!=this.timestamp&&a.writeDateTime(NDNProtocolDTags.Timestamp,this.timestamp);null!=this.type&&0!=this.type&&a.writeElement(NDNProtocolDTags.type,this.type);null!=this.freshnessSeconds&&a.writeElement(NDNProtocolDTags.FreshnessSeconds,
+this.freshnessSeconds);null!=this.finalBlockID&&a.writeElement(NDNProtocolDTags.FinalBlockID,this.finalBlockID);null!=this.locator&&this.locator.to_ndnb(a);a.writeEndElement()};SignedInfo.prototype.valueToType=function(){return null};SignedInfo.prototype.getElementLabel=function(){return NDNProtocolDTags.SignedInfo};SignedInfo.prototype.validate=function(){return null==this.publisher||null==this.timestamp||null==this.locator?!1:!0};
var DateFormat=function(){var a=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,b=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,c=/[^-+\dA-Z]/g,d=function(a,b){a=String(a);for(b=b||2;a.length<b;)a="0"+a;return a};return function(e,f,g){var h=dateFormat;1==arguments.length&&("[object String]"==Object.prototype.toString.call(e)&&!/\d/.test(e))&&(f=e,e=void 0);e=e?new Date(e):new Date;if(isNaN(e))throw SyntaxError("invalid date");
f=String(h.masks[f]||f||h.masks["default"]);"UTC:"==f.slice(0,4)&&(f=f.slice(4),g=!0);var j=g?"getUTC":"get",l=e[j+"Date"](),n=e[j+"Day"](),m=e[j+"Month"](),p=e[j+"FullYear"](),k=e[j+"Hours"](),q=e[j+"Minutes"](),s=e[j+"Seconds"](),j=e[j+"Milliseconds"](),r=g?0:e.getTimezoneOffset(),t={d:l,dd:d(l),ddd:h.i18n.dayNames[n],dddd:h.i18n.dayNames[n+7],m:m+1,mm:d(m+1),mmm:h.i18n.monthNames[m],mmmm:h.i18n.monthNames[m+12],yy:String(p).slice(2),yyyy:p,h:k%12||12,hh:d(k%12||12),H:k,HH:d(k),M:q,MM:d(q),s:s,
ss:d(s),l:d(j,3),L:d(99<j?Math.round(j/10):j),t:12>k?"a":"p",tt:12>k?"am":"pm",T:12>k?"A":"P",TT:12>k?"AM":"PM",Z:g?"UTC":(String(e).match(b)||[""]).pop().replace(c,""),o:(0<r?"-":"+")+d(100*Math.floor(Math.abs(r)/60)+Math.abs(r)%60,4),S:["th","st","nd","rd"][3<l%10?0:(10!=l%100-l%10)*l%10]};return f.replace(a,function(a){return a in t?t[a]:a.slice(1,a.length-1)})}}();
DateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};DateFormat.i18n={dayNames:"Sun Mon Tue Wed Thu Fri Sat Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),monthNames:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec January February March April May June July August September October November December".split(" ")};
Date.prototype.format=function(a,b){return dateFormat(this,a,b)};var Interest=function(a,b,c,d,e,f,g,h,j,l,n){this.name=a;this.faceInstance=b;this.maxSuffixComponents=d;this.minSuffixComponents=c;this.publisherPublicKeyDigest=e;this.exclude=f;this.childSelector=g;this.answerOriginKind=h;this.scope=j;this.interestLifetime=l;this.nonce=n};Interest.RECURSIVE_POSTFIX="*";Interest.CHILD_SELECTOR_LEFT=0;Interest.CHILD_SELECTOR_RIGHT=1;Interest.ANSWER_CONTENT_STORE=1;Interest.ANSWER_GENERATED=2;
Interest.ANSWER_STALE=4;Interest.MARK_STALE=16;Interest.DEFAULT_ANSWER_ORIGIN_KIND=Interest.ANSWER_CONTENT_STORE|Interest.ANSWER_GENERATED;
-Interest.prototype.from_ccnb=function(a){a.readStartElement(CCNProtocolDTags.Interest);this.name=new Name;this.name.from_ccnb(a);a.peekStartElement(CCNProtocolDTags.MinSuffixComponents)&&(this.minSuffixComponents=a.readIntegerElement(CCNProtocolDTags.MinSuffixComponents));a.peekStartElement(CCNProtocolDTags.MaxSuffixComponents)&&(this.maxSuffixComponents=a.readIntegerElement(CCNProtocolDTags.MaxSuffixComponents));a.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)&&(this.publisherPublicKeyDigest=
-new PublisherPublicKeyDigest,this.publisherPublicKeyDigest.from_ccnb(a));a.peekStartElement(CCNProtocolDTags.Exclude)&&(this.exclude=new Exclude,this.exclude.from_ccnb(a));a.peekStartElement(CCNProtocolDTags.ChildSelector)&&(this.childSelector=a.readIntegerElement(CCNProtocolDTags.ChildSelector));a.peekStartElement(CCNProtocolDTags.AnswerOriginKind)&&(this.answerOriginKind=a.readIntegerElement(CCNProtocolDTags.AnswerOriginKind));a.peekStartElement(CCNProtocolDTags.Scope)&&(this.scope=a.readIntegerElement(CCNProtocolDTags.Scope));
-a.peekStartElement(CCNProtocolDTags.InterestLifetime)&&(this.interestLifetime=1E3*DataUtils.bigEndianToUnsignedInt(a.readBinaryElement(CCNProtocolDTags.InterestLifetime))/4096);a.peekStartElement(CCNProtocolDTags.Nonce)&&(this.nonce=a.readBinaryElement(CCNProtocolDTags.Nonce));a.readEndElement()};
-Interest.prototype.to_ccnb=function(a){a.writeStartElement(CCNProtocolDTags.Interest);this.name.to_ccnb(a);null!=this.minSuffixComponents&&a.writeElement(CCNProtocolDTags.MinSuffixComponents,this.minSuffixComponents);null!=this.maxSuffixComponents&&a.writeElement(CCNProtocolDTags.MaxSuffixComponents,this.maxSuffixComponents);null!=this.publisherPublicKeyDigest&&this.publisherPublicKeyDigest.to_ccnb(a);null!=this.exclude&&this.exclude.to_ccnb(a);null!=this.childSelector&&a.writeElement(CCNProtocolDTags.ChildSelector,
-this.childSelector);this.DEFAULT_ANSWER_ORIGIN_KIND!=this.answerOriginKind&&null!=this.answerOriginKind&&a.writeElement(CCNProtocolDTags.AnswerOriginKind,this.answerOriginKind);null!=this.scope&&a.writeElement(CCNProtocolDTags.Scope,this.scope);null!=this.interestLifetime&&a.writeElement(CCNProtocolDTags.InterestLifetime,DataUtils.nonNegativeIntToBigEndian(4096*(this.interestLifetime/1E3)));null!=this.nonce&&a.writeElement(CCNProtocolDTags.Nonce,this.nonce);a.writeEndElement()};
+Interest.prototype.from_ndnb=function(a){a.readStartElement(NDNProtocolDTags.Interest);this.name=new Name;this.name.from_ndnb(a);a.peekStartElement(NDNProtocolDTags.MinSuffixComponents)&&(this.minSuffixComponents=a.readIntegerElement(NDNProtocolDTags.MinSuffixComponents));a.peekStartElement(NDNProtocolDTags.MaxSuffixComponents)&&(this.maxSuffixComponents=a.readIntegerElement(NDNProtocolDTags.MaxSuffixComponents));a.peekStartElement(NDNProtocolDTags.PublisherPublicKeyDigest)&&(this.publisherPublicKeyDigest=
+new PublisherPublicKeyDigest,this.publisherPublicKeyDigest.from_ndnb(a));a.peekStartElement(NDNProtocolDTags.Exclude)&&(this.exclude=new Exclude,this.exclude.from_ndnb(a));a.peekStartElement(NDNProtocolDTags.ChildSelector)&&(this.childSelector=a.readIntegerElement(NDNProtocolDTags.ChildSelector));a.peekStartElement(NDNProtocolDTags.AnswerOriginKind)&&(this.answerOriginKind=a.readIntegerElement(NDNProtocolDTags.AnswerOriginKind));a.peekStartElement(NDNProtocolDTags.Scope)&&(this.scope=a.readIntegerElement(NDNProtocolDTags.Scope));
+a.peekStartElement(NDNProtocolDTags.InterestLifetime)&&(this.interestLifetime=1E3*DataUtils.bigEndianToUnsignedInt(a.readBinaryElement(NDNProtocolDTags.InterestLifetime))/4096);a.peekStartElement(NDNProtocolDTags.Nonce)&&(this.nonce=a.readBinaryElement(NDNProtocolDTags.Nonce));a.readEndElement()};
+Interest.prototype.to_ndnb=function(a){a.writeStartElement(NDNProtocolDTags.Interest);this.name.to_ndnb(a);null!=this.minSuffixComponents&&a.writeElement(NDNProtocolDTags.MinSuffixComponents,this.minSuffixComponents);null!=this.maxSuffixComponents&&a.writeElement(NDNProtocolDTags.MaxSuffixComponents,this.maxSuffixComponents);null!=this.publisherPublicKeyDigest&&this.publisherPublicKeyDigest.to_ndnb(a);null!=this.exclude&&this.exclude.to_ndnb(a);null!=this.childSelector&&a.writeElement(NDNProtocolDTags.ChildSelector,
+this.childSelector);this.DEFAULT_ANSWER_ORIGIN_KIND!=this.answerOriginKind&&null!=this.answerOriginKind&&a.writeElement(NDNProtocolDTags.AnswerOriginKind,this.answerOriginKind);null!=this.scope&&a.writeElement(NDNProtocolDTags.Scope,this.scope);null!=this.interestLifetime&&a.writeElement(NDNProtocolDTags.InterestLifetime,DataUtils.nonNegativeIntToBigEndian(4096*(this.interestLifetime/1E3)));null!=this.nonce&&a.writeElement(NDNProtocolDTags.Nonce,this.nonce);a.writeEndElement()};
Interest.prototype.matches_name=function(a){return!this.name.match(a)||null!=this.minSuffixComponents&&!(a.components.length+1-this.name.components.length>=this.minSuffixComponents)||null!=this.maxSuffixComponents&&!(a.components.length+1-this.name.components.length<=this.maxSuffixComponents)||null!=this.exclude&&a.components.length>this.name.components.length&&this.exclude.matches(a.components[this.name.components.length])?!1:!0};
Interest.prototype.clone=function(){return new Interest(this.name,this.faceInstance,this.minSuffixComponents,this.maxSuffixComponents,this.publisherPublicKeyDigest,this.exclude,this.childSelector,this.answerOriginKind,this.scope,this.interestLifetime,this.nonce)};var Exclude=function(a){this.values=a||[]};Exclude.ANY="*";
-Exclude.prototype.from_ccnb=function(a){for(a.readStartElement(CCNProtocolDTags.Exclude);;)if(a.peekStartElement(CCNProtocolDTags.Component))this.values.push(a.readBinaryElement(CCNProtocolDTags.Component));else if(a.peekStartElement(CCNProtocolDTags.Any))a.readStartElement(CCNProtocolDTags.Any),a.readEndElement(),this.values.push(Exclude.ANY);else if(a.peekStartElement(CCNProtocolDTags.Bloom))a.readBinaryElement(CCNProtocolDTags.Bloom),this.values.push(Exclude.ANY);else break;a.readEndElement()};
-Exclude.prototype.to_ccnb=function(a){if(!(null==this.values||0==this.values.length)){a.writeStartElement(CCNProtocolDTags.Exclude);for(var b=0;b<this.values.length;++b)this.values[b]==Exclude.ANY?(a.writeStartElement(CCNProtocolDTags.Any),a.writeEndElement()):a.writeElement(CCNProtocolDTags.Component,this.values[b]);a.writeEndElement()}};
+Exclude.prototype.from_ndnb=function(a){for(a.readStartElement(NDNProtocolDTags.Exclude);;)if(a.peekStartElement(NDNProtocolDTags.Component))this.values.push(a.readBinaryElement(NDNProtocolDTags.Component));else if(a.peekStartElement(NDNProtocolDTags.Any))a.readStartElement(NDNProtocolDTags.Any),a.readEndElement(),this.values.push(Exclude.ANY);else if(a.peekStartElement(NDNProtocolDTags.Bloom))a.readBinaryElement(NDNProtocolDTags.Bloom),this.values.push(Exclude.ANY);else break;a.readEndElement()};
+Exclude.prototype.to_ndnb=function(a){if(!(null==this.values||0==this.values.length)){a.writeStartElement(NDNProtocolDTags.Exclude);for(var b=0;b<this.values.length;++b)this.values[b]==Exclude.ANY?(a.writeStartElement(NDNProtocolDTags.Any),a.writeEndElement()):a.writeElement(NDNProtocolDTags.Component,this.values[b]);a.writeEndElement()}};
Exclude.prototype.to_uri=function(){if(null==this.values||0==this.values.length)return"";for(var a="",b=0;b<this.values.length;++b)0<b&&(a+=","),a=this.values[b]==Exclude.ANY?a+"*":a+Name.toEscapedString(this.values[b]);return a};
Exclude.prototype.matches=function(a){for(var b=0;b<this.values.length;++b)if(this.values[b]==Exclude.ANY){var c=null;0<b&&(c=this.values[b-1]);var d,e=null;for(d=b+1;d<this.values.length;++d)if(this.values[d]!=Exclude.ANY){e=this.values[d];break}if(null!=e){if(null!=c){if(0<Exclude.compareComponents(a,c)&&0>Exclude.compareComponents(a,e))return!0}else if(0>Exclude.compareComponents(a,e))return!0;b=d-1}else if(null!=c){if(0<Exclude.compareComponents(a,c))return!0}else return!0}else if(DataUtils.arraysEqual(a,
this.values[b]))return!0;return!1};Exclude.compareComponents=function(a,b){if(a.length<b.length)return-1;if(a.length>b.length)return 1;for(var c=0;c<a.length;++c){if(a[c]<b[c])return-1;if(a[c]>b[c])return 1}return 0};
var Key=function(){},KeyLocatorType={KEY:1,CERTIFICATE:2,KEYNAME:3},KeyLocator=function(a,b){this.type=b;b==KeyLocatorType.KEYNAME?(3<LOG&&console.log("KeyLocator: SET KEYNAME"),this.keyName=a):b==KeyLocatorType.KEY?(3<LOG&&console.log("KeyLocator: SET KEY"),this.publicKey=a):b==KeyLocatorType.CERTIFICATE&&(3<LOG&&console.log("KeyLocator: SET CERTIFICATE"),this.certificate=a)};
-KeyLocator.prototype.from_ccnb=function(a){a.readStartElement(this.getElementLabel());if(a.peekStartElement(CCNProtocolDTags.Key)){try{this.publicKey=a.readBinaryElement(CCNProtocolDTags.Key),this.type=KeyLocatorType.KEY,4<LOG&&console.log("PUBLIC KEY FOUND: "+this.publicKey)}catch(b){throw Error("Cannot parse key: ",b);}if(null==this.publicKey)throw Error("Cannot parse key: ");}else if(a.peekStartElement(CCNProtocolDTags.Certificate)){try{this.certificate=a.readBinaryElement(CCNProtocolDTags.Certificate),
-this.type=KeyLocatorType.CERTIFICATE,4<LOG&&console.log("CERTIFICATE FOUND: "+this.certificate)}catch(c){throw Error("Cannot decode certificate: "+c);}if(null==this.certificate)throw Error("Cannot parse certificate! ");}else this.type=KeyLocatorType.KEYNAME,this.keyName=new KeyName,this.keyName.from_ccnb(a);a.readEndElement()};
-KeyLocator.prototype.to_ccnb=function(a){4<LOG&&console.log("type is is "+this.type);if(!this.validate())throw new ContentEncodingException("Cannot encode "+this.getClass().getName()+": field values missing.");a.writeStartElement(this.getElementLabel());if(this.type==KeyLocatorType.KEY)5<LOG&&console.log("About to encode a public key"+this.publicKey),a.writeElement(CCNProtocolDTags.Key,this.publicKey);else if(this.type==KeyLocatorType.CERTIFICATE)try{a.writeElement(CCNProtocolDTags.Certificate,this.certificate)}catch(b){throw Error("CertificateEncodingException attempting to write key locator: "+
-b);}else this.type==KeyLocatorType.KEYNAME&&this.keyName.to_ccnb(a);a.writeEndElement()};KeyLocator.prototype.getElementLabel=function(){return CCNProtocolDTags.KeyLocator};KeyLocator.prototype.validate=function(){return null!=this.keyName||null!=this.publicKey||null!=this.certificate};var KeyName=function(){this.contentName=this.contentName;this.publisherID=this.publisherID};
-KeyName.prototype.from_ccnb=function(a){a.readStartElement(this.getElementLabel());this.contentName=new Name;this.contentName.from_ccnb(a);4<LOG&&console.log("KEY NAME FOUND: ");PublisherID.peek(a)&&(this.publisherID=new PublisherID,this.publisherID.from_ccnb(a));a.readEndElement()};
-KeyName.prototype.to_ccnb=function(a){if(!this.validate())throw Error("Cannot encode : field values missing.");a.writeStartElement(this.getElementLabel());this.contentName.to_ccnb(a);null!=this.publisherID&&this.publisherID.to_ccnb(a);a.writeEndElement()};KeyName.prototype.getElementLabel=function(){return CCNProtocolDTags.KeyName};KeyName.prototype.validate=function(){return null!=this.contentName};
-var PublisherType=function(a){this.KEY=CCNProtocolDTags.PublisherPublicKeyDigest;this.CERTIFICATE=CCNProtocolDTags.PublisherCertificateDigest;this.ISSUER_KEY=CCNProtocolDTags.PublisherIssuerKeyDigest;this.ISSUER_CERTIFICATE=CCNProtocolDTags.PublisherIssuerCertificateDigest;this.Tag=a},isTypeTagVal=function(a){return a==CCNProtocolDTags.PublisherPublicKeyDigest||a==CCNProtocolDTags.PublisherCertificateDigest||a==CCNProtocolDTags.PublisherIssuerKeyDigest||a==CCNProtocolDTags.PublisherIssuerCertificateDigest?
+KeyLocator.prototype.from_ndnb=function(a){a.readStartElement(this.getElementLabel());if(a.peekStartElement(NDNProtocolDTags.Key)){try{this.publicKey=a.readBinaryElement(NDNProtocolDTags.Key),this.type=KeyLocatorType.KEY,4<LOG&&console.log("PUBLIC KEY FOUND: "+this.publicKey)}catch(b){throw Error("Cannot parse key: ",b);}if(null==this.publicKey)throw Error("Cannot parse key: ");}else if(a.peekStartElement(NDNProtocolDTags.Certificate)){try{this.certificate=a.readBinaryElement(NDNProtocolDTags.Certificate),
+this.type=KeyLocatorType.CERTIFICATE,4<LOG&&console.log("CERTIFICATE FOUND: "+this.certificate)}catch(c){throw Error("Cannot decode certificate: "+c);}if(null==this.certificate)throw Error("Cannot parse certificate! ");}else this.type=KeyLocatorType.KEYNAME,this.keyName=new KeyName,this.keyName.from_ndnb(a);a.readEndElement()};
+KeyLocator.prototype.to_ndnb=function(a){4<LOG&&console.log("type is is "+this.type);if(!this.validate())throw new ContentEncodingException("Cannot encode "+this.getClass().getName()+": field values missing.");a.writeStartElement(this.getElementLabel());if(this.type==KeyLocatorType.KEY)5<LOG&&console.log("About to encode a public key"+this.publicKey),a.writeElement(NDNProtocolDTags.Key,this.publicKey);else if(this.type==KeyLocatorType.CERTIFICATE)try{a.writeElement(NDNProtocolDTags.Certificate,this.certificate)}catch(b){throw Error("CertificateEncodingException attempting to write key locator: "+
+b);}else this.type==KeyLocatorType.KEYNAME&&this.keyName.to_ndnb(a);a.writeEndElement()};KeyLocator.prototype.getElementLabel=function(){return NDNProtocolDTags.KeyLocator};KeyLocator.prototype.validate=function(){return null!=this.keyName||null!=this.publicKey||null!=this.certificate};var KeyName=function(){this.contentName=this.contentName;this.publisherID=this.publisherID};
+KeyName.prototype.from_ndnb=function(a){a.readStartElement(this.getElementLabel());this.contentName=new Name;this.contentName.from_ndnb(a);4<LOG&&console.log("KEY NAME FOUND: ");PublisherID.peek(a)&&(this.publisherID=new PublisherID,this.publisherID.from_ndnb(a));a.readEndElement()};
+KeyName.prototype.to_ndnb=function(a){if(!this.validate())throw Error("Cannot encode : field values missing.");a.writeStartElement(this.getElementLabel());this.contentName.to_ndnb(a);null!=this.publisherID&&this.publisherID.to_ndnb(a);a.writeEndElement()};KeyName.prototype.getElementLabel=function(){return NDNProtocolDTags.KeyName};KeyName.prototype.validate=function(){return null!=this.contentName};
+var PublisherType=function(a){this.KEY=NDNProtocolDTags.PublisherPublicKeyDigest;this.CERTIFICATE=NDNProtocolDTags.PublisherCertificateDigest;this.ISSUER_KEY=NDNProtocolDTags.PublisherIssuerKeyDigest;this.ISSUER_CERTIFICATE=NDNProtocolDTags.PublisherIssuerCertificateDigest;this.Tag=a},isTypeTagVal=function(a){return a==NDNProtocolDTags.PublisherPublicKeyDigest||a==NDNProtocolDTags.PublisherCertificateDigest||a==NDNProtocolDTags.PublisherIssuerKeyDigest||a==NDNProtocolDTags.PublisherIssuerCertificateDigest?
!0:!1},PublisherID=function(){this.PUBLISHER_ID_DIGEST_ALGORITHM="SHA-256";this.PUBLISHER_ID_LEN=32;this.publisherType=this.publisherID=null};
-PublisherID.prototype.from_ccnb=function(a){var b=a.peekStartElementAsLong();if(null==b)throw Error("Cannot parse publisher ID.");this.publisherType=new PublisherType(b);if(!isTypeTagVal(b))throw Error("Invalid publisher ID, got unexpected type: "+b);this.publisherID=a.readBinaryElement(b);if(null==this.publisherID)throw new ContentDecodingException(Error("Cannot parse publisher ID of type : "+b+"."));};
-PublisherID.prototype.to_ccnb=function(a){if(!this.validate())throw Error("Cannot encode "+this.getClass().getName()+": field values missing.");a.writeElement(this.getElementLabel(),this.publisherID)};PublisherID.peek=function(a){a=a.peekStartElementAsLong();return null==a?!1:isTypeTagVal(a)};PublisherID.prototype.getElementLabel=function(){return this.publisherType.Tag};PublisherID.prototype.validate=function(){return null!=id()&&null!=type()};
+PublisherID.prototype.from_ndnb=function(a){var b=a.peekStartElementAsLong();if(null==b)throw Error("Cannot parse publisher ID.");this.publisherType=new PublisherType(b);if(!isTypeTagVal(b))throw Error("Invalid publisher ID, got unexpected type: "+b);this.publisherID=a.readBinaryElement(b);if(null==this.publisherID)throw new ContentDecodingException(Error("Cannot parse publisher ID of type : "+b+"."));};
+PublisherID.prototype.to_ndnb=function(a){if(!this.validate())throw Error("Cannot encode "+this.getClass().getName()+": field values missing.");a.writeElement(this.getElementLabel(),this.publisherID)};PublisherID.peek=function(a){a=a.peekStartElementAsLong();return null==a?!1:isTypeTagVal(a)};PublisherID.prototype.getElementLabel=function(){return this.publisherType.Tag};PublisherID.prototype.validate=function(){return null!=id()&&null!=type()};
var PublisherPublicKeyDigest=function(a){this.PUBLISHER_ID_LEN=64;this.publisherPublicKeyDigest=a};
-PublisherPublicKeyDigest.prototype.from_ccnb=function(a){this.publisherPublicKeyDigest=a.readBinaryElement(this.getElementLabel());4<LOG&&console.log("Publisher public key digest is "+this.publisherPublicKeyDigest);if(null==this.publisherPublicKeyDigest)throw Error("Cannot parse publisher key digest.");this.publisherPublicKeyDigest.length!=this.PUBLISHER_ID_LEN&&0<LOG&&console.log("LENGTH OF PUBLISHER ID IS WRONG! Expected "+this.PUBLISHER_ID_LEN+", got "+this.publisherPublicKeyDigest.length)};
-PublisherPublicKeyDigest.prototype.to_ccnb=function(a){if(!this.validate())throw Error("Cannot encode : field values missing.");3<LOG&&console.log("PUBLISHER KEY DIGEST IS"+this.publisherPublicKeyDigest);a.writeElement(this.getElementLabel(),this.publisherPublicKeyDigest)};PublisherPublicKeyDigest.prototype.getElementLabel=function(){return CCNProtocolDTags.PublisherPublicKeyDigest};PublisherPublicKeyDigest.prototype.validate=function(){return null!=this.publisherPublicKeyDigest};
+PublisherPublicKeyDigest.prototype.from_ndnb=function(a){this.publisherPublicKeyDigest=a.readBinaryElement(this.getElementLabel());4<LOG&&console.log("Publisher public key digest is "+this.publisherPublicKeyDigest);if(null==this.publisherPublicKeyDigest)throw Error("Cannot parse publisher key digest.");this.publisherPublicKeyDigest.length!=this.PUBLISHER_ID_LEN&&0<LOG&&console.log("LENGTH OF PUBLISHER ID IS WRONG! Expected "+this.PUBLISHER_ID_LEN+", got "+this.publisherPublicKeyDigest.length)};
+PublisherPublicKeyDigest.prototype.to_ndnb=function(a){if(!this.validate())throw Error("Cannot encode : field values missing.");3<LOG&&console.log("PUBLISHER KEY DIGEST IS"+this.publisherPublicKeyDigest);a.writeElement(this.getElementLabel(),this.publisherPublicKeyDigest)};PublisherPublicKeyDigest.prototype.getElementLabel=function(){return NDNProtocolDTags.PublisherPublicKeyDigest};PublisherPublicKeyDigest.prototype.validate=function(){return null!=this.publisherPublicKeyDigest};
var NetworkProtocol={TCP:6,UDP:17},FaceInstance=function(a,b,c,d,e,f,g,h,j){this.action=a;this.publisherPublicKeyDigest=b;this.faceID=c;this.ipProto=d;this.host=e;this.Port=f;this.multicastInterface=g;this.multicastTTL=h;this.freshnessSeconds=j};
-FaceInstance.prototype.from_ccnb=function(a){a.readStartElement(this.getElementLabel());a.peekStartElement(CCNProtocolDTags.Action)&&(this.action=a.readUTF8Element(CCNProtocolDTags.Action));a.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)&&(this.publisherPublicKeyDigest=new PublisherPublicKeyDigest,this.publisherPublicKeyDigest.from_ccnb(a));a.peekStartElement(CCNProtocolDTags.FaceID)&&(this.faceID=a.readIntegerElement(CCNProtocolDTags.FaceID));if(a.peekStartElement(CCNProtocolDTags.IPProto)){var b=
-a.readIntegerElement(CCNProtocolDTags.IPProto);this.ipProto=null;if(NetworkProtocol.TCP==b)this.ipProto=NetworkProtocol.TCP;else if(NetworkProtocol.UDP==b)this.ipProto=NetworkProtocol.UDP;else throw Error("FaceInstance.decoder. Invalid "+CCNProtocolDTags.tagToString(CCNProtocolDTags.IPProto)+" field: "+b);}a.peekStartElement(CCNProtocolDTags.Host)&&(this.host=a.readUTF8Element(CCNProtocolDTags.Host));a.peekStartElement(CCNProtocolDTags.Port)&&(this.Port=a.readIntegerElement(CCNProtocolDTags.Port));
-a.peekStartElement(CCNProtocolDTags.MulticastInterface)&&(this.multicastInterface=a.readUTF8Element(CCNProtocolDTags.MulticastInterface));a.peekStartElement(CCNProtocolDTags.MulticastTTL)&&(this.multicastTTL=a.readIntegerElement(CCNProtocolDTags.MulticastTTL));a.peekStartElement(CCNProtocolDTags.FreshnessSeconds)&&(this.freshnessSeconds=a.readIntegerElement(CCNProtocolDTags.FreshnessSeconds));a.readEndElement()};
-FaceInstance.prototype.to_ccnb=function(a){a.writeStartElement(this.getElementLabel());null!=this.action&&0!=this.action.length&&a.writeElement(CCNProtocolDTags.Action,this.action);null!=this.publisherPublicKeyDigest&&this.publisherPublicKeyDigest.to_ccnb(a);null!=this.faceID&&a.writeElement(CCNProtocolDTags.FaceID,this.faceID);null!=this.ipProto&&a.writeElement(CCNProtocolDTags.IPProto,this.ipProto);null!=this.host&&0!=this.host.length&&a.writeElement(CCNProtocolDTags.Host,this.host);null!=this.Port&&
-a.writeElement(CCNProtocolDTags.Port,this.Port);null!=this.multicastInterface&&0!=this.multicastInterface.length&&a.writeElement(CCNProtocolDTags.MulticastInterface,this.multicastInterface);null!=this.multicastTTL&&a.writeElement(CCNProtocolDTags.MulticastTTL,this.multicastTTL);null!=this.freshnessSeconds&&a.writeElement(CCNProtocolDTags.FreshnessSeconds,this.freshnessSeconds);a.writeEndElement()};FaceInstance.prototype.getElementLabel=function(){return CCNProtocolDTags.FaceInstance};
-var ForwardingEntry=function(a,b,c,d,e,f){this.action=a;this.prefixName=b;this.ccndID=c;this.faceID=d;this.flags=e;this.lifetime=f};
-ForwardingEntry.prototype.from_ccnb=function(a){a.readStartElement(this.getElementLabel());a.peekStartElement(CCNProtocolDTags.Action)&&(this.action=a.readUTF8Element(CCNProtocolDTags.Action));a.peekStartElement(CCNProtocolDTags.Name)&&(this.prefixName=new Name,this.prefixName.from_ccnb(a));a.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)&&(this.CcndId=new PublisherPublicKeyDigest,this.CcndId.from_ccnb(a));a.peekStartElement(CCNProtocolDTags.FaceID)&&(this.faceID=a.readIntegerElement(CCNProtocolDTags.FaceID));
-a.peekStartElement(CCNProtocolDTags.ForwardingFlags)&&(this.flags=a.readIntegerElement(CCNProtocolDTags.ForwardingFlags));a.peekStartElement(CCNProtocolDTags.FreshnessSeconds)&&(this.lifetime=a.readIntegerElement(CCNProtocolDTags.FreshnessSeconds));a.readEndElement()};
-ForwardingEntry.prototype.to_ccnb=function(a){a.writeStartElement(this.getElementLabel());null!=this.action&&0!=this.action.length&&a.writeElement(CCNProtocolDTags.Action,this.action);null!=this.prefixName&&this.prefixName.to_ccnb(a);null!=this.CcndId&&this.CcndId.to_ccnb(a);null!=this.faceID&&a.writeElement(CCNProtocolDTags.FaceID,this.faceID);null!=this.flags&&a.writeElement(CCNProtocolDTags.ForwardingFlags,this.flags);null!=this.lifetime&&a.writeElement(CCNProtocolDTags.FreshnessSeconds,this.lifetime);
-a.writeEndElement()};ForwardingEntry.prototype.getElementLabel=function(){return CCNProtocolDTags.ForwardingEntry};var DynamicUint8Array=function(a){a||(a=16);this.array=new Uint8Array(a);this.length=a};DynamicUint8Array.prototype.ensureLength=function(a){if(!(this.array.length>=a)){var b=2*this.array.length;a>b&&(b=a);a=new Uint8Array(b);a.set(this.array);this.array=a;this.length=b}};DynamicUint8Array.prototype.set=function(a,b){this.ensureLength(a.length+b);this.array.set(a,b)};
+FaceInstance.prototype.from_ndnb=function(a){a.readStartElement(this.getElementLabel());a.peekStartElement(NDNProtocolDTags.Action)&&(this.action=a.readUTF8Element(NDNProtocolDTags.Action));a.peekStartElement(NDNProtocolDTags.PublisherPublicKeyDigest)&&(this.publisherPublicKeyDigest=new PublisherPublicKeyDigest,this.publisherPublicKeyDigest.from_ndnb(a));a.peekStartElement(NDNProtocolDTags.FaceID)&&(this.faceID=a.readIntegerElement(NDNProtocolDTags.FaceID));if(a.peekStartElement(NDNProtocolDTags.IPProto)){var b=
+a.readIntegerElement(NDNProtocolDTags.IPProto);this.ipProto=null;if(NetworkProtocol.TCP==b)this.ipProto=NetworkProtocol.TCP;else if(NetworkProtocol.UDP==b)this.ipProto=NetworkProtocol.UDP;else throw Error("FaceInstance.decoder. Invalid "+NDNProtocolDTags.tagToString(NDNProtocolDTags.IPProto)+" field: "+b);}a.peekStartElement(NDNProtocolDTags.Host)&&(this.host=a.readUTF8Element(NDNProtocolDTags.Host));a.peekStartElement(NDNProtocolDTags.Port)&&(this.Port=a.readIntegerElement(NDNProtocolDTags.Port));
+a.peekStartElement(NDNProtocolDTags.MulticastInterface)&&(this.multicastInterface=a.readUTF8Element(NDNProtocolDTags.MulticastInterface));a.peekStartElement(NDNProtocolDTags.MulticastTTL)&&(this.multicastTTL=a.readIntegerElement(NDNProtocolDTags.MulticastTTL));a.peekStartElement(NDNProtocolDTags.FreshnessSeconds)&&(this.freshnessSeconds=a.readIntegerElement(NDNProtocolDTags.FreshnessSeconds));a.readEndElement()};
+FaceInstance.prototype.to_ndnb=function(a){a.writeStartElement(this.getElementLabel());null!=this.action&&0!=this.action.length&&a.writeElement(NDNProtocolDTags.Action,this.action);null!=this.publisherPublicKeyDigest&&this.publisherPublicKeyDigest.to_ndnb(a);null!=this.faceID&&a.writeElement(NDNProtocolDTags.FaceID,this.faceID);null!=this.ipProto&&a.writeElement(NDNProtocolDTags.IPProto,this.ipProto);null!=this.host&&0!=this.host.length&&a.writeElement(NDNProtocolDTags.Host,this.host);null!=this.Port&&
+a.writeElement(NDNProtocolDTags.Port,this.Port);null!=this.multicastInterface&&0!=this.multicastInterface.length&&a.writeElement(NDNProtocolDTags.MulticastInterface,this.multicastInterface);null!=this.multicastTTL&&a.writeElement(NDNProtocolDTags.MulticastTTL,this.multicastTTL);null!=this.freshnessSeconds&&a.writeElement(NDNProtocolDTags.FreshnessSeconds,this.freshnessSeconds);a.writeEndElement()};FaceInstance.prototype.getElementLabel=function(){return NDNProtocolDTags.FaceInstance};
+var ForwardingEntry=function(a,b,c,d,e,f){this.action=a;this.prefixName=b;this.ndndID=c;this.faceID=d;this.flags=e;this.lifetime=f};
+ForwardingEntry.prototype.from_ndnb=function(a){a.readStartElement(this.getElementLabel());a.peekStartElement(NDNProtocolDTags.Action)&&(this.action=a.readUTF8Element(NDNProtocolDTags.Action));a.peekStartElement(NDNProtocolDTags.Name)&&(this.prefixName=new Name,this.prefixName.from_ndnb(a));a.peekStartElement(NDNProtocolDTags.PublisherPublicKeyDigest)&&(this.NdndId=new PublisherPublicKeyDigest,this.NdndId.from_ndnb(a));a.peekStartElement(NDNProtocolDTags.FaceID)&&(this.faceID=a.readIntegerElement(NDNProtocolDTags.FaceID));
+a.peekStartElement(NDNProtocolDTags.ForwardingFlags)&&(this.flags=a.readIntegerElement(NDNProtocolDTags.ForwardingFlags));a.peekStartElement(NDNProtocolDTags.FreshnessSeconds)&&(this.lifetime=a.readIntegerElement(NDNProtocolDTags.FreshnessSeconds));a.readEndElement()};
+ForwardingEntry.prototype.to_ndnb=function(a){a.writeStartElement(this.getElementLabel());null!=this.action&&0!=this.action.length&&a.writeElement(NDNProtocolDTags.Action,this.action);null!=this.prefixName&&this.prefixName.to_ndnb(a);null!=this.NdndId&&this.NdndId.to_ndnb(a);null!=this.faceID&&a.writeElement(NDNProtocolDTags.FaceID,this.faceID);null!=this.flags&&a.writeElement(NDNProtocolDTags.ForwardingFlags,this.flags);null!=this.lifetime&&a.writeElement(NDNProtocolDTags.FreshnessSeconds,this.lifetime);
+a.writeEndElement()};ForwardingEntry.prototype.getElementLabel=function(){return NDNProtocolDTags.ForwardingEntry};var DynamicUint8Array=function(a){a||(a=16);this.array=new Uint8Array(a);this.length=a};DynamicUint8Array.prototype.ensureLength=function(a){if(!(this.array.length>=a)){var b=2*this.array.length;a>b&&(b=a);a=new Uint8Array(b);a.set(this.array);this.array=a;this.length=b}};DynamicUint8Array.prototype.set=function(a,b){this.ensureLength(a.length+b);this.array.set(a,b)};
DynamicUint8Array.prototype.subarray=function(a,b){return this.array.subarray(a,b)};
var XML_EXT=0,XML_TAG=1,XML_DTAG=2,XML_ATTR=3,XML_DATTR=4,XML_BLOB=5,XML_UDATA=6,XML_CLOSE=0,XML_SUBTYPE_PROCESSING_INSTRUCTIONS=16,XML_TT_BITS=3,XML_TT_MASK=(1<<XML_TT_BITS)-1,XML_TT_VAL_BITS=XML_TT_BITS+1,XML_TT_VAL_MASK=(1<<XML_TT_VAL_BITS)-1,XML_REG_VAL_BITS=7,XML_REG_VAL_MASK=(1<<XML_REG_VAL_BITS)-1,XML_TT_NO_MORE=1<<XML_REG_VAL_BITS,BYTE_MASK=255,LONG_BYTES=8,LONG_BITS=64,bits_11=2047,bits_18=262143,bits_32=4294967295,BinaryXMLEncoder=function(){this.ostream=new DynamicUint8Array(100);this.offset=
0;this.CODEC_NAME="Binary"};BinaryXMLEncoder.prototype.writeUString=function(a){this.encodeUString(a,XML_UDATA)};BinaryXMLEncoder.prototype.writeBlob=function(a){3<LOG&&console.log(a);this.encodeBlob(a,a.length)};BinaryXMLEncoder.prototype.writeStartElement=function(a,b){null==a?this.encodeUString(a,XML_TAG):this.encodeTypeAndVal(XML_DTAG,a);null!=b&&this.writeAttributes(b)};
BinaryXMLEncoder.prototype.writeEndElement=function(){this.ostream.ensureLength(this.offset+1);this.ostream.array[this.offset]=XML_CLOSE;this.offset+=1};BinaryXMLEncoder.prototype.writeAttributes=function(a){if(null!=a)for(var b=0;b<a.length;b++){var c=a[b].k,d=a[b].v,e=stringToTag(c);null==e?this.encodeUString(c,XML_ATTR):this.encodeTypeAndVal(XML_DATTR,e);this.encodeUString(d)}};
-stringToTag=function(a){return 0<=a&&a<CCNProtocolDTagsStrings.length?CCNProtocolDTagsStrings[a]:a==CCNProtocolDTags.CCNProtocolDataUnit?CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT:null};tagToString=function(a){for(var b=0;b<CCNProtocolDTagsStrings.length;++b)if(null!=CCNProtocolDTagsStrings[b]&&CCNProtocolDTagsStrings[b]==a)return b;return CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT==a?CCNProtocolDTags.CCNProtocolDataUnit:null};
+stringToTag=function(a){return 0<=a&&a<NDNProtocolDTagsStrings.length?NDNProtocolDTagsStrings[a]:a==NDNProtocolDTags.NDNProtocolDataUnit?NDNProtocolDTags.NDNPROTOCOL_DATA_UNIT:null};tagToString=function(a){for(var b=0;b<NDNProtocolDTagsStrings.length;++b)if(null!=NDNProtocolDTagsStrings[b]&&NDNProtocolDTagsStrings[b]==a)return b;return NDNProtocolDTags.NDNPROTOCOL_DATA_UNIT==a?NDNProtocolDTags.NDNProtocolDataUnit:null};
BinaryXMLEncoder.prototype.writeElement=function(a,b,c){this.writeStartElement(a,c);"number"===typeof b?(4<LOG&&console.log("GOING TO WRITE THE NUMBER .charCodeAt(0) "+b.toString().charCodeAt(0)),4<LOG&&console.log("GOING TO WRITE THE NUMBER "+b.toString()),4<LOG&&console.log("type of number is "+typeof b.toString()),this.writeUString(b.toString())):"string"===typeof b?(4<LOG&&console.log("GOING TO WRITE THE STRING "+b),4<LOG&&console.log("type of STRING is "+typeof b),this.writeUString(b)):(4<LOG&&
console.log("GOING TO WRITE A BLOB "+b),this.writeBlob(b));this.writeEndElement()};var TypeAndVal=function(a,b){this.type=a;this.val=b};
BinaryXMLEncoder.prototype.encodeTypeAndVal=function(a,b){4<LOG&&console.log("Encoding type "+a+" and value "+b);4<LOG&&console.log("OFFSET IS "+this.offset);if(a>XML_UDATA||0>a||0>b)throw Error("Tag and value must be positive, and tag valid.");var c=this.numEncodingBytes(b);this.ostream.ensureLength(this.offset+c);this.ostream.array[this.offset+c-1]=BYTE_MASK&(XML_TT_MASK&a|(XML_TT_VAL_MASK&b)<<XML_TT_BITS)|XML_TT_NO_MORE;b>>>=XML_TT_VAL_BITS;for(var d=this.offset+c-2;0!=b&&d>=this.offset;)this.ostream.array[d]=
@@ -102,8 +102,8 @@
BinaryXMLEncoder.prototype.writeDateTime=function(a,b){4<LOG&&console.log("ENCODING DATE with LONG VALUE");4<LOG&&console.log(b.msec);var c=Math.round(4096*(b.msec/1E3)).toString(16),c=DataUtils.toNumbers("0".concat(c,"0"));4<LOG&&console.log("ENCODING DATE with BINARY VALUE");4<LOG&&console.log(c);4<LOG&&console.log("ENCODING DATE with BINARY VALUE(HEX)");4<LOG&&console.log(DataUtils.toHex(c));this.writeElement(a,c)};
BinaryXMLEncoder.prototype.writeString=function(a){if("string"===typeof a){4<LOG&&console.log("GOING TO WRITE A STRING");4<LOG&&console.log(a);this.ostream.ensureLength(this.offset+a.length);for(var b=0;b<a.length;b++)4<LOG&&console.log("input.charCodeAt(i)="+a.charCodeAt(b)),this.ostream.array[this.offset+b]=a.charCodeAt(b)}else 4<LOG&&console.log("GOING TO WRITE A STRING IN BINARY FORM"),4<LOG&&console.log(a),this.writeBlobArray(a)};
BinaryXMLEncoder.prototype.writeBlobArray=function(a){4<LOG&&console.log("GOING TO WRITE A BLOB");this.ostream.set(a,this.offset)};BinaryXMLEncoder.prototype.getReducedOstream=function(){return this.ostream.subarray(0,this.offset)};XML_EXT=0;XML_TAG=1;XML_DTAG=2;XML_ATTR=3;XML_DATTR=4;XML_BLOB=5;XML_UDATA=6;XML_CLOSE=0;XML_SUBTYPE_PROCESSING_INSTRUCTIONS=16;XML_TT_BITS=3;XML_TT_MASK=(1<<XML_TT_BITS)-1;XML_TT_VAL_BITS=XML_TT_BITS+1;XML_TT_VAL_MASK=(1<<XML_TT_VAL_BITS)-1;XML_REG_VAL_BITS=7;
-XML_REG_VAL_MASK=(1<<XML_REG_VAL_BITS)-1;XML_TT_NO_MORE=1<<XML_REG_VAL_BITS;BYTE_MASK=255;LONG_BYTES=8;LONG_BITS=64;bits_11=2047;bits_18=262143;bits_32=4294967295;tagToString=function(a){return 0<=a&&a<CCNProtocolDTagsStrings.length?CCNProtocolDTagsStrings[a]:a==CCNProtocolDTags.CCNProtocolDataUnit?CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT:null};
-stringToTag=function(a){for(var b=0;b<CCNProtocolDTagsStrings.length;++b)if(null!=CCNProtocolDTagsStrings[b]&&CCNProtocolDTagsStrings[b]==a)return b;return CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT==a?CCNProtocolDTags.CCNProtocolDataUnit:null};var BinaryXMLDecoder=function(a){this.istream=a;this.offset=0};BinaryXMLDecoder.prototype.initializeDecoding=function(){};BinaryXMLDecoder.prototype.readStartDocument=function(){};BinaryXMLDecoder.prototype.readEndDocument=function(){};
+XML_REG_VAL_MASK=(1<<XML_REG_VAL_BITS)-1;XML_TT_NO_MORE=1<<XML_REG_VAL_BITS;BYTE_MASK=255;LONG_BYTES=8;LONG_BITS=64;bits_11=2047;bits_18=262143;bits_32=4294967295;tagToString=function(a){return 0<=a&&a<NDNProtocolDTagsStrings.length?NDNProtocolDTagsStrings[a]:a==NDNProtocolDTags.NDNProtocolDataUnit?NDNProtocolDTags.NDNPROTOCOL_DATA_UNIT:null};
+stringToTag=function(a){for(var b=0;b<NDNProtocolDTagsStrings.length;++b)if(null!=NDNProtocolDTagsStrings[b]&&NDNProtocolDTagsStrings[b]==a)return b;return NDNProtocolDTags.NDNPROTOCOL_DATA_UNIT==a?NDNProtocolDTags.NDNProtocolDataUnit:null};var BinaryXMLDecoder=function(a){this.istream=a;this.offset=0};BinaryXMLDecoder.prototype.initializeDecoding=function(){};BinaryXMLDecoder.prototype.readStartDocument=function(){};BinaryXMLDecoder.prototype.readEndDocument=function(){};
BinaryXMLDecoder.prototype.readStartElement=function(a,b){var c=this.decodeTypeAndVal();if(null==c)throw new ContentDecodingException(Error("Expected start element: "+a+" got something not a tag."));var d=null;c.type()==XML_TAG?(d="string"==typeof c.val()?parseInt(c.val())+1:c.val()+1,d=this.decodeUString(d)):c.type()==XML_DTAG&&(d=c.val());if(null==d||d!=a)throw console.log("expecting "+a+" but got "+d),new ContentDecodingException(Error("Expected start element: "+a+" got: "+d+"("+c.val()+")"));
null!=b&&readAttributes(b)};
BinaryXMLDecoder.prototype.readAttributes=function(a){if(null!=a)try{for(var b=this.peekTypeAndVal();null!=b&&(XML_ATTR==b.type()||XML_DATTR==b.type());){var c=this.decodeTypeAndVal(),d=null;if(XML_ATTR==c.type()){var e;e="string"==typeof c.val()?parseInt(c.val())+1:c.val()+1;d=this.decodeUString(e)}else if(XML_DATTR==c.type()&&(d=tagToString(c.val()),null==d))throw new ContentDecodingException(Error("Unknown DATTR value"+c.val()));var f=this.decodeUString();a.push([d,f]);b=this.peekTypeAndVal()}}catch(g){throw new ContentDecodingException(Error("readStartElement",
@@ -112,7 +112,7 @@
BinaryXMLDecoder.prototype.peekStartElementAsLong=function(){var a=null,b=this.offset;try{var c=this.decodeTypeAndVal();if(null!=c)if(c.type()==XML_TAG){if(c.val()+1>DEBUG_MAX_LEN)throw new ContentDecodingException(Error("Decoding error: length "+c.val()+1+" longer than expected maximum length!"));var d;d="string"==typeof c.val()?parseInt(c.val())+1:c.val()+1;var e=this.decodeUString(d),a=stringToTag(e)}else c.type()==XML_DTAG&&(a=c.val())}catch(f){}finally{try{this.offset=b}catch(g){throw Log.logStackTrace(Log.FAC_ENCODING,
Level.WARNING,g),Error("Cannot reset stream! "+g.getMessage(),g);}}return a};BinaryXMLDecoder.prototype.readBinaryElement=function(a,b){var c=null;this.readStartElement(a,b);return c=this.readBlob()};
BinaryXMLDecoder.prototype.readEndElement=function(){4<LOG&&console.log("this.offset is "+this.offset);var a=this.istream[this.offset];this.offset++;4<LOG&&console.log("XML_CLOSE IS "+XML_CLOSE);4<LOG&&console.log("next is "+a);if(a!=XML_CLOSE)throw console.log("Expected end element, got: "+a),new ContentDecodingException(Error("Expected end element, got: "+a));};BinaryXMLDecoder.prototype.readUString=function(){var a=this.decodeUString();this.readEndElement();return a};
-BinaryXMLDecoder.prototype.readBlob=function(){var a=this.decodeBlob();this.readEndElement();return a};BinaryXMLDecoder.prototype.readDateTime=function(a){a=this.readBinaryElement(a);a=DataUtils.toHex(a);a=parseInt(a,16);var b=1E3*(a/4096);3<LOG&&console.log("DECODED DATE WITH VALUE");3<LOG&&console.log(b);b=new CCNTime(b);if(null==b)throw new ContentDecodingException(Error("Cannot parse timestamp: "+DataUtils.printHexBytes(a)));return b};
+BinaryXMLDecoder.prototype.readBlob=function(){var a=this.decodeBlob();this.readEndElement();return a};BinaryXMLDecoder.prototype.readDateTime=function(a){a=this.readBinaryElement(a);a=DataUtils.toHex(a);a=parseInt(a,16);var b=1E3*(a/4096);3<LOG&&console.log("DECODED DATE WITH VALUE");3<LOG&&console.log(b);b=new NDNTime(b);if(null==b)throw new ContentDecodingException(Error("Cannot parse timestamp: "+DataUtils.printHexBytes(a)));return b};
BinaryXMLDecoder.prototype.decodeTypeAndVal=function(){var a=-1,b=0,c=!0;do{var d=this.istream[this.offset];if(0>d||0==d&&0==b)return null;(c=0==(d&XML_TT_NO_MORE))?(b<<=XML_REG_VAL_BITS,b|=d&XML_REG_VAL_MASK):(a=d&XML_TT_MASK,b<<=XML_TT_VAL_BITS,b|=d>>>XML_TT_BITS&XML_TT_VAL_MASK);this.offset++}while(c);3<LOG&&console.log("TYPE is "+a+" VAL is "+b);return new TypeAndVal(a,b)};BinaryXMLDecoder.peekTypeAndVal=function(){var a=null,b=this.offset;try{a=this.decodeTypeAndVal()}finally{this.offset=b}return a};
BinaryXMLDecoder.prototype.decodeBlob=function(a){if(null==a)return a=this.decodeTypeAndVal(),a="string"==typeof a.val()?parseInt(a.val()):a.val(),this.decodeBlob(a);var b=this.istream.subarray(this.offset,this.offset+a);this.offset+=a;return b};
BinaryXMLDecoder.prototype.decodeUString=function(a){if(null==a){a=this.offset;var b=this.decodeTypeAndVal();3<LOG&&console.log("TV is "+b);3<LOG&&console.log(b);3<LOG&&console.log("Type of TV is "+typeof b);return null==b||XML_UDATA!=b.type()?(this.offset=a,""):this.decodeUString(b.val())}a=this.decodeBlob(a);return DataUtils.toString(a)};TypeAndVal=function(a,b){this.t=a;this.v=b};TypeAndVal.prototype.type=function(){return this.t};TypeAndVal.prototype.val=function(){return this.v};
@@ -129,9 +129,9 @@
DataUtils.toNumbersFromString=function(a){for(var b=new Uint8Array(a.length),c=0;c<a.length;c++)b[c]=a.charCodeAt(c);return b};DataUtils.stringToUtf8Array=function(a){return DataUtils.toNumbersFromString(str2rstr_utf8(a))};DataUtils.concatArrays=function(a){for(var b=0,c=0;c<a.length;++c)b+=a[c].length;for(var b=new Uint8Array(b),d=0,c=0;c<a.length;++c)b.set(a[c],d),d+=a[c].length;return b};
DataUtils.decodeUtf8=function(a){for(var b="",c=0,d=0,e=0;c<a.length;)if(d=a.charCodeAt(c),128>d)b+=String.fromCharCode(d),c++;else if(191<d&&224>d)e=a.charCodeAt(c+1),b+=String.fromCharCode((d&31)<<6|e&63),c+=2;else var e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b=b+String.fromCharCode((d&15)<<12|(e&63)<<6|f&63),c=c+3;return b};DataUtils.arraysEqual=function(a,b){if(a.length!=b.length)return!1;for(var c=0;c<a.length;++c)if(a[c]!=b[c])return!1;return!0};
DataUtils.bigEndianToUnsignedInt=function(a){for(var b=0,c=0;c<a.length;++c)b<<=8,b+=a[c];return b};DataUtils.nonNegativeIntToBigEndian=function(a){a=Math.round(a);if(0>=a)return new Uint8Array(0);for(var b=new Uint8Array(8),c=0;0!=a;)++c,b[8-c]=a&255,a>>=8;return b.subarray(8-c,8)};DataUtils.shuffle=function(a){for(var b=a.length-1;1<=b;--b){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c];a[c]=d}};function encodeToHexInterest(a){return DataUtils.toHex(encodeToBinaryInterest(a))}
-function encodeToBinaryInterest(a){var b=new BinaryXMLEncoder;a.to_ccnb(b);return b.getReducedOstream()}function encodeToHexContentObject(a){return DataUtils.toHex(encodeToBinaryContentObject(a))}function encodeToBinaryContentObject(a){var b=new BinaryXMLEncoder;a.to_ccnb(b);return b.getReducedOstream()}function encodeForwardingEntry(a){var b=new BinaryXMLEncoder;a.to_ccnb(b);return b.getReducedOstream()}
-function decodeHexFaceInstance(a){var b=DataUtils.toNumbers(a);a=new BinaryXMLDecoder(b);3<LOG&&console.log("DECODING HEX FACE INSTANCE \n"+b);b=new FaceInstance;b.from_ccnb(a);return b}function decodeHexInterest(a){var b=DataUtils.toNumbers(a);a=new BinaryXMLDecoder(b);3<LOG&&console.log("DECODING HEX INTERST \n"+b);b=new Interest;b.from_ccnb(a);return b}
-function decodeHexContentObject(a){var b=DataUtils.toNumbers(a);a=new BinaryXMLDecoder(b);3<LOG&&console.log("DECODED HEX CONTENT OBJECT \n"+b);b=new ContentObject;b.from_ccnb(a);return b}function decodeHexForwardingEntry(a){var b=DataUtils.toNumbers(a);a=new BinaryXMLDecoder(b);3<LOG&&console.log("DECODED HEX FORWARDING ENTRY \n"+b);b=new ForwardingEntry;b.from_ccnb(a);return b}
+function encodeToBinaryInterest(a){var b=new BinaryXMLEncoder;a.to_ndnb(b);return b.getReducedOstream()}function encodeToHexContentObject(a){return DataUtils.toHex(encodeToBinaryContentObject(a))}function encodeToBinaryContentObject(a){var b=new BinaryXMLEncoder;a.to_ndnb(b);return b.getReducedOstream()}function encodeForwardingEntry(a){var b=new BinaryXMLEncoder;a.to_ndnb(b);return b.getReducedOstream()}
+function decodeHexFaceInstance(a){var b=DataUtils.toNumbers(a);a=new BinaryXMLDecoder(b);3<LOG&&console.log("DECODING HEX FACE INSTANCE \n"+b);b=new FaceInstance;b.from_ndnb(a);return b}function decodeHexInterest(a){var b=DataUtils.toNumbers(a);a=new BinaryXMLDecoder(b);3<LOG&&console.log("DECODING HEX INTERST \n"+b);b=new Interest;b.from_ndnb(a);return b}
+function decodeHexContentObject(a){var b=DataUtils.toNumbers(a);a=new BinaryXMLDecoder(b);3<LOG&&console.log("DECODED HEX CONTENT OBJECT \n"+b);b=new ContentObject;b.from_ndnb(a);return b}function decodeHexForwardingEntry(a){var b=DataUtils.toNumbers(a);a=new BinaryXMLDecoder(b);3<LOG&&console.log("DECODED HEX FORWARDING ENTRY \n"+b);b=new ForwardingEntry;b.from_ndnb(a);return b}
function decodeSubjectPublicKeyInfo(a){a=DataUtils.toHex(a).toLowerCase();a=_x509_getPublicKeyHexArrayFromCertHex(a,_x509_getSubjectPublicKeyPosFromCertHex(a,0));var b=new RSAKey;b.setPublic(a[0],a[1]);return b}
function contentObjectToHtml(a){var b="";if(-1==a)b+="NO CONTENT FOUND";else if(-2==a)b+="CONTENT NAME IS EMPTY";else{null!=a.name&&null!=a.name.components&&(b+="NAME: "+a.name.to_uri(),b+="<br /><br />");null!=a.content&&(b+="CONTENT(ASCII): "+DataUtils.toString(a.content),b+="<br />",b+="<br />");null!=a.content&&(b+="CONTENT(hex): "+DataUtils.toHex(a.content),b+="<br />",b+="<br />");null!=a.signature&&null!=a.signature.signature&&(b+="SIGNATURE(hex): "+DataUtils.toHex(a.signature.signature),b+=
"<br />",b+="<br />");null!=a.signedInfo&&(null!=a.signedInfo.publisher&&null!=a.signedInfo.publisher.publisherPublicKeyDigest)&&(b+="Publisher Public Key Digest(hex): "+DataUtils.toHex(a.signedInfo.publisher.publisherPublicKeyDigest),b+="<br />",b+="<br />");if(null!=a.signedInfo&&null!=a.signedInfo.timestamp){var c=new Date;c.setTime(a.signedInfo.timestamp.msec);b+="TimeStamp: "+c;b+="<br />";b+="TimeStamp(number): "+a.signedInfo.timestamp.msec;b+="<br />"}null!=a.signedInfo&&null!=a.signedInfo.finalBlockID&&
@@ -256,7 +256,7 @@
BigInteger.prototype.andNot=bnAndNot;BigInteger.prototype.not=bnNot;BigInteger.prototype.shiftLeft=bnShiftLeft;BigInteger.prototype.shiftRight=bnShiftRight;BigInteger.prototype.getLowestSetBit=bnGetLowestSetBit;BigInteger.prototype.bitCount=bnBitCount;BigInteger.prototype.testBit=bnTestBit;BigInteger.prototype.setBit=bnSetBit;BigInteger.prototype.clearBit=bnClearBit;BigInteger.prototype.flipBit=bnFlipBit;BigInteger.prototype.add=bnAdd;BigInteger.prototype.subtract=bnSubtract;
BigInteger.prototype.multiply=bnMultiply;BigInteger.prototype.divide=bnDivide;BigInteger.prototype.remainder=bnRemainder;BigInteger.prototype.divideAndRemainder=bnDivideAndRemainder;BigInteger.prototype.modPow=bnModPow;BigInteger.prototype.modInverse=bnModInverse;BigInteger.prototype.pow=bnPow;BigInteger.prototype.gcd=bnGCD;BigInteger.prototype.isProbablePrime=bnIsProbablePrime;
var LOG=0,NDN=function NDN(b){if(!NDN.supported)throw Error("The necessary JavaScript support is not available on this platform.");b=b||{};this.transport=(b.getTransport||function(){return new WebSocketTransport})();this.getHostAndPort=b.getHostAndPort||this.transport.defaultGetHostAndPort;this.host=void 0!==b.host?b.host:null;this.port=b.port||9696;this.readyStatus=NDN.UNOPEN;this.verify=void 0!==b.verify?b.verify:!0;this.onopen=b.onopen||function(){3<LOG&&console.log("NDN connection established.")};
-this.onclose=b.onclose||function(){3<LOG&&console.log("NDN connection closed.")};this.ccndid=null};NDN.UNOPEN=0;NDN.OPENED=1;NDN.CLOSED=2;NDN.getSupported=function(){try{(new Uint8Array(1)).subarray(0,1)}catch(a){return console.log("NDN not available: Uint8Array not supported. "+a),!1}return!0};NDN.supported=NDN.getSupported();NDN.ccndIdFetcher=new Name("/%C1.M.S.localhost/%C1.M.SRV/ccnd/KEY");NDN.prototype.createRoute=function(a,b){this.host=a;this.port=b};NDN.KeyStore=[];
+this.onclose=b.onclose||function(){3<LOG&&console.log("NDN connection closed.")};this.ndndid=null};NDN.UNOPEN=0;NDN.OPENED=1;NDN.CLOSED=2;NDN.getSupported=function(){try{(new Uint8Array(1)).subarray(0,1)}catch(a){return console.log("NDN not available: Uint8Array not supported. "+a),!1}return!0};NDN.supported=NDN.getSupported();NDN.ndndIdFetcher=new Name("/%C1.M.S.localhost/%C1.M.SRV/ndnd/KEY");NDN.prototype.createRoute=function(a,b){this.host=a;this.port=b};NDN.KeyStore=[];
var KeyStoreEntry=function(a,b,c){this.keyName=a;this.rsaKey=b;this.timeStamp=c};NDN.addKeyEntry=function(a){null==NDN.getKeyByName(a.keyName)&&NDN.KeyStore.push(a)};NDN.getKeyByName=function(a){for(var b=null,c=0;c<NDN.KeyStore.length;c++)if(NDN.KeyStore[c].keyName.contentName.match(a.contentName)&&(null==b||NDN.KeyStore[c].keyName.contentName.components.length>b.keyName.contentName.components.length))b=NDN.KeyStore[c];return b};NDN.PITTable=[];
var PITEntry=function(a,b){this.interest=a;this.closure=b;this.timerID=-1};NDN.getEntryForExpressedInterest=function(a){for(var b=null,c=0;c<NDN.PITTable.length;c++)if(NDN.PITTable[c].interest.matches_name(a)&&(null==b||NDN.PITTable[c].interest.name.components.length>b.interest.name.components.length))b=NDN.PITTable[c];return b};NDN.CSTable=[];var CSEntry=function(a,b){this.name=a;this.closure=b};
function getEntryForRegisteredPrefix(a){for(var b=0;b<NDN.CSTable.length;b++)if(null!=NDN.CSTable[b].name.match(a))return NDN.CSTable[b];return null}NDN.makeShuffledGetHostAndPort=function(a,b){a=a.slice(0,a.length);DataUtils.shuffle(a);return function(){return 0==a.length?null:{host:a.splice(0,1)[0],port:b}}};
@@ -264,13 +264,13 @@
this;this.connectAndExecute(function(){e.reconnectAndExpressInterest(d,b)})}else this.reconnectAndExpressInterest(d,b)};NDN.prototype.reconnectAndExpressInterest=function(a,b){if(this.transport.connectedHost!=this.host||this.transport.connectedPort!=this.port){var c=this;this.transport.connect(c,function(){c.expressInterestHelper(a,b)})}else this.expressInterestHelper(a,b)};
NDN.prototype.expressInterestHelper=function(a,b){var c=encodeToBinaryInterest(a),d=this;if(null!=b){var e=new PITEntry(a,b);NDN.PITTable.push(e);b.pitEntry=e;var f=a.interestLifetime||4E3,g=function(){3<LOG&&console.log("Interest time out: "+a.name.to_uri());var h=NDN.PITTable.indexOf(e);0<=h&&NDN.PITTable.splice(h,1);b.upcall(Closure.UPCALL_INTEREST_TIMED_OUT,new UpcallInfo(d,a,0,null))==Closure.RESULT_REEXPRESS&&(3<LOG&&console.log("Re-express interest: "+a.name.to_uri()),e.timerID=setTimeout(g,
f),NDN.PITTable.push(e),d.transport.send(c))};e.timerID=setTimeout(g,f)}this.transport.send(c)};
-NDN.prototype.registerPrefix=function(a,b,c){var d=this,e=function(){if(null==d.ccndid){var e=new Interest(NDN.ccndIdFetcher);e.interestLifetime=4E3;3<LOG&&console.log("Expressing interest for ccndid from ccnd.");d.reconnectAndExpressInterest(e,new NDN.FetchCcndidClosure(d,a,b,c))}else d.registerPrefixHelper(a,b,c)};null==this.host||null==this.port?null==this.getHostAndPort?console.log("ERROR: host OR port NOT SET"):this.connectAndExecute(e):e()};
-NDN.FetchCcndidClosure=function(a,b,c,d){Closure.call(this);this.ndn=a;this.name=b;this.callerClosure=c;this.flag=d};
-NDN.FetchCcndidClosure.prototype.upcall=function(a,b){if(a==Closure.UPCALL_INTEREST_TIMED_OUT)return console.log("Timeout while requesting the ccndid. Cannot registerPrefix for "+this.name.to_uri()+" ."),Closure.RESULT_OK;if(!(a==Closure.UPCALL_CONTENT||a==Closure.UPCALL_CONTENT_UNVERIFIED))return Closure.RESULT_ERR;var c=b.contentObject;!c.signedInfo||!c.signedInfo.publisher||!c.signedInfo.publisher.publisherPublicKeyDigest?console.log("ContentObject doesn't have a publisherPublicKeyDigest. Cannot set ccndid and registerPrefix for "+
-this.name.to_uri()+" ."):(3<LOG&&console.log("Got ccndid from ccnd."),this.ndn.ccndid=c.signedInfo.publisher.publisherPublicKeyDigest,3<LOG&&console.log(this.ndn.ccndid),this.ndn.registerPrefixHelper(this.name,this.callerClosure,this.flag));return Closure.RESULT_OK};
-NDN.prototype.registerPrefixHelper=function(a,b){var c=new ForwardingEntry("selfreg",a,null,null,3,2147483647),c=encodeForwardingEntry(c),d=new SignedInfo;d.setFields();c=new ContentObject(new Name,d,c,new Signature);c.sign();c=encodeToBinaryContentObject(c);c=new Name(["ccnx",this.ccndid,"selfreg",c]);c=new Interest(c);c.scope=1;3<LOG&&console.log("Send Interest registration packet.");d=new CSEntry(a.getName(),b);NDN.CSTable.push(d);this.transport.send(encodeToBinaryInterest(c))};
-NDN.prototype.onReceivedElement=function(a){3<LOG&&console.log("Complete element received. Length "+a.length+". Start decoding.");var b=new BinaryXMLDecoder(a);if(b.peekStartElement(CCNProtocolDTags.Interest))3<LOG&&console.log("Interest packet received."),a=new Interest,a.from_ccnb(b),3<LOG&&console.log(a),b=escape(a.name.getName()),3<LOG&&console.log(b),b=getEntryForRegisteredPrefix(b),null!=b&&(a=new UpcallInfo(this,a,0,null),b.closure.upcall(Closure.UPCALL_INTEREST,a)==Closure.RESULT_INTEREST_CONSUMED&&
-null!=a.contentObject&&this.transport.send(encodeToBinaryContentObject(a.contentObject)));else if(b.peekStartElement(CCNProtocolDTags.ContentObject)){if(3<LOG&&console.log("ContentObject packet received."),a=new ContentObject,a.from_ccnb(b),b=NDN.getEntryForExpressedInterest(a.name),null!=b){clearTimeout(b.timerID);var c=NDN.PITTable.indexOf(b);0<=c&&NDN.PITTable.splice(c,1);c=b.closure;if(!1==this.verify)c.upcall(Closure.UPCALL_CONTENT_UNVERIFIED,new UpcallInfo(this,b.interest,0,a));else{var d=function(a,
+NDN.prototype.registerPrefix=function(a,b,c){var d=this,e=function(){if(null==d.ndndid){var e=new Interest(NDN.ndndIdFetcher);e.interestLifetime=4E3;3<LOG&&console.log("Expressing interest for ndndid from ndnd.");d.reconnectAndExpressInterest(e,new NDN.FetchNdndidClosure(d,a,b,c))}else d.registerPrefixHelper(a,b,c)};null==this.host||null==this.port?null==this.getHostAndPort?console.log("ERROR: host OR port NOT SET"):this.connectAndExecute(e):e()};
+NDN.FetchNdndidClosure=function(a,b,c,d){Closure.call(this);this.ndn=a;this.name=b;this.callerClosure=c;this.flag=d};
+NDN.FetchNdndidClosure.prototype.upcall=function(a,b){if(a==Closure.UPCALL_INTEREST_TIMED_OUT)return console.log("Timeout while requesting the ndndid. Cannot registerPrefix for "+this.name.to_uri()+" ."),Closure.RESULT_OK;if(!(a==Closure.UPCALL_CONTENT||a==Closure.UPCALL_CONTENT_UNVERIFIED))return Closure.RESULT_ERR;var c=b.contentObject;!c.signedInfo||!c.signedInfo.publisher||!c.signedInfo.publisher.publisherPublicKeyDigest?console.log("ContentObject doesn't have a publisherPublicKeyDigest. Cannot set ndndid and registerPrefix for "+
+this.name.to_uri()+" ."):(3<LOG&&console.log("Got ndndid from ndnd."),this.ndn.ndndid=c.signedInfo.publisher.publisherPublicKeyDigest,3<LOG&&console.log(this.ndn.ndndid),this.ndn.registerPrefixHelper(this.name,this.callerClosure,this.flag));return Closure.RESULT_OK};
+NDN.prototype.registerPrefixHelper=function(a,b){var c=new ForwardingEntry("selfreg",a,null,null,3,2147483647),c=encodeForwardingEntry(c),d=new SignedInfo;d.setFields();c=new ContentObject(new Name,d,c,new Signature);c.sign();c=encodeToBinaryContentObject(c);c=new Name(["ndnx",this.ndndid,"selfreg",c]);c=new Interest(c);c.scope=1;3<LOG&&console.log("Send Interest registration packet.");d=new CSEntry(a.getName(),b);NDN.CSTable.push(d);this.transport.send(encodeToBinaryInterest(c))};
+NDN.prototype.onReceivedElement=function(a){3<LOG&&console.log("Complete element received. Length "+a.length+". Start decoding.");var b=new BinaryXMLDecoder(a);if(b.peekStartElement(NDNProtocolDTags.Interest))3<LOG&&console.log("Interest packet received."),a=new Interest,a.from_ndnb(b),3<LOG&&console.log(a),b=escape(a.name.getName()),3<LOG&&console.log(b),b=getEntryForRegisteredPrefix(b),null!=b&&(a=new UpcallInfo(this,a,0,null),b.closure.upcall(Closure.UPCALL_INTEREST,a)==Closure.RESULT_INTEREST_CONSUMED&&
+null!=a.contentObject&&this.transport.send(encodeToBinaryContentObject(a.contentObject)));else if(b.peekStartElement(NDNProtocolDTags.ContentObject)){if(3<LOG&&console.log("ContentObject packet received."),a=new ContentObject,a.from_ndnb(b),b=NDN.getEntryForExpressedInterest(a.name),null!=b){clearTimeout(b.timerID);var c=NDN.PITTable.indexOf(b);0<=c&&NDN.PITTable.splice(c,1);c=b.closure;if(!1==this.verify)c.upcall(Closure.UPCALL_CONTENT_UNVERIFIED,new UpcallInfo(this,b.interest,0,a));else{var d=function(a,
b,c,d,e){this.contentObject=a;this.closure=b;this.keyName=c;this.sigHex=d;this.witness=e;Closure.call(this)},e=this;d.prototype.upcall=function(a,b){if(a==Closure.UPCALL_INTEREST_TIMED_OUT)console.log("In KeyFetchClosure.upcall: interest time out."),console.log(this.keyName.contentName.getName());else if(a==Closure.UPCALL_CONTENT){var c=decodeSubjectPublicKeyInfo(b.contentObject.content),d=!0==c.verifyByteArray(this.contentObject.rawSignatureData,this.witness,this.sigHex)?Closure.UPCALL_CONTENT:Closure.UPCALL_CONTENT_BAD;
this.closure.upcall(d,new UpcallInfo(e,null,0,this.contentObject));c=new KeyStoreEntry(h.keyName,c,(new Date).getTime());NDN.addKeyEntry(c)}else a==Closure.UPCALL_CONTENT_BAD&&console.log("In KeyFetchClosure.upcall: signature verification failed")};if(a.signedInfo&&a.signedInfo.locator&&a.signature){3<LOG&&console.log("Key verification...");var f=DataUtils.toHex(a.signature.signature).toLowerCase(),g=null;null!=a.signature.Witness&&(g=new Witness,g.decode(a.signature.Witness));var h=a.signedInfo.locator;
if(h.type==KeyLocatorType.KEYNAME)if(3<LOG&&console.log("KeyLocator contains KEYNAME"),h.keyName.contentName.match(a.name))3<LOG&&console.log("Content is key itself"),d=decodeSubjectPublicKeyInfo(a.content),f=d.verifyByteArray(a.rawSignatureData,g,f),f=!0==f?Closure.UPCALL_CONTENT:Closure.UPCALL_CONTENT_BAD,c.upcall(f,new UpcallInfo(this,b.interest,0,a));else{var j=NDN.getKeyByName(h.keyName);j?(3<LOG&&console.log("Local key cache hit"),d=j.rsaKey,f=d.verifyByteArray(a.rawSignatureData,g,f),f=!0==
diff --git a/ccnx/ccnx-cert.cpp b/ndnx/ndnx-cert.cpp
similarity index 94%
rename from ccnx/ccnx-cert.cpp
rename to ndnx/ndnx-cert.cpp
index fc83c66..8dacd60 100644
--- a/ccnx/ccnx-cert.cpp
+++ b/ndnx/ndnx-cert.cpp
@@ -18,16 +18,16 @@
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-cert.h"
+#include "ndnx-cert.h"
#include <tinyxml.h>
#include <boost/lexical_cast.hpp>
#include "logging.h"
-INIT_LOGGER ("Ccnx.Cert");
+INIT_LOGGER ("Ndnx.Cert");
using namespace std;
-namespace Ccnx {
+namespace Ndnx {
Cert::Cert()
: m_pkey(0)
@@ -42,7 +42,7 @@
m_name = keyObject->name();
m_rawKeyBytes = keyObject->content();
m_keyHash = *(Hash::FromBytes(m_rawKeyBytes));
- m_pkey = ccn_d2i_pubkey(head(m_rawKeyBytes), m_rawKeyBytes.size());
+ m_pkey = ndn_d2i_pubkey(head(m_rawKeyBytes), m_rawKeyBytes.size());
updateMeta(metaObject);
}
@@ -50,7 +50,7 @@
{
if (m_pkey != 0)
{
- ccn_pubkey_free(m_pkey);
+ ndn_pubkey_free(m_pkey);
m_pkey = 0;
}
}
@@ -124,4 +124,4 @@
return WITHIN_VALID_TIME_SPAN;
}
-} // Ccnx
+} // Ndnx
diff --git a/ccnx/ccnx-cert.h b/ndnx/ndnx-cert.h
similarity index 91%
rename from ccnx/ccnx-cert.h
rename to ndnx/ndnx-cert.h
index d2399e6..17f06d5 100644
--- a/ccnx/ccnx-cert.h
+++ b/ndnx/ndnx-cert.h
@@ -19,16 +19,16 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_CERT_H
-#define CCNX_CERT_H
+#ifndef NDNX_CERT_H
+#define NDNX_CERT_H
-#include "ccnx-common.h"
-#include "ccnx-name.h"
-#include "ccnx-pco.h"
+#include "ndnx-common.h"
+#include "ndnx-name.h"
+#include "ndnx-pco.h"
#include "hash-helper.h"
#include <boost/shared_ptr.hpp>
-namespace Ccnx {
+namespace Ndnx {
class Cert
{
@@ -63,7 +63,7 @@
std::string
affilication() { return m_meta.affiliation; }
- ccn_pkey *
+ ndn_pkey *
pkey() { return m_pkey; }
VALIDITY
@@ -88,7 +88,7 @@
Name m_name;
Hash m_keyHash; // publisherPublicKeyHash
Bytes m_rawKeyBytes;
- ccn_pkey *m_pkey;
+ ndn_pkey *m_pkey;
Meta m_meta;
};
@@ -96,4 +96,4 @@
}
-#endif // CCNX_CERT_H
+#endif // NDNX_CERT_H
diff --git a/ccnx/ccnx-charbuf.cc b/ndnx/ndnx-charbuf.cc
similarity index 71%
rename from ccnx/ccnx-charbuf.cc
rename to ndnx/ndnx-charbuf.cc
index 0ba328f..842c840 100644
--- a/ccnx/ccnx-charbuf.cc
+++ b/ndnx/ndnx-charbuf.cc
@@ -19,53 +19,53 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-charbuf.h"
+#include "ndnx-charbuf.h"
using namespace std;
-namespace Ccnx {
+namespace Ndnx {
void
-CcnxCharbuf::init(ccn_charbuf *buf)
+NdnxCharbuf::init(ndn_charbuf *buf)
{
if (buf != NULL)
{
- m_buf = ccn_charbuf_create();
- ccn_charbuf_reserve(m_buf, buf->length);
+ m_buf = ndn_charbuf_create();
+ ndn_charbuf_reserve(m_buf, buf->length);
memcpy(m_buf->buf, buf->buf, buf->length);
m_buf->length = buf->length;
}
}
-CcnxCharbuf::CcnxCharbuf()
+NdnxCharbuf::NdnxCharbuf()
: m_buf(NULL)
{
- m_buf = ccn_charbuf_create();
+ m_buf = ndn_charbuf_create();
}
-CcnxCharbuf::CcnxCharbuf(ccn_charbuf *buf)
+NdnxCharbuf::NdnxCharbuf(ndn_charbuf *buf)
: m_buf(NULL)
{
init(buf);
}
-CcnxCharbuf::CcnxCharbuf(const CcnxCharbuf &other)
+NdnxCharbuf::NdnxCharbuf(const NdnxCharbuf &other)
: m_buf (NULL)
{
init(other.m_buf);
}
-CcnxCharbuf::CcnxCharbuf(const void *buf, size_t length)
+NdnxCharbuf::NdnxCharbuf(const void *buf, size_t length)
{
- m_buf = ccn_charbuf_create ();
- ccn_charbuf_reserve (m_buf, length);
+ m_buf = ndn_charbuf_create ();
+ ndn_charbuf_reserve (m_buf, length);
memcpy (m_buf->buf, buf, length);
m_buf->length = length;
}
-CcnxCharbuf::~CcnxCharbuf()
+NdnxCharbuf::~NdnxCharbuf()
{
- ccn_charbuf_destroy(&m_buf);
+ ndn_charbuf_destroy(&m_buf);
}
}
diff --git a/ccnx/ccnx-charbuf.h b/ndnx/ndnx-charbuf.h
similarity index 71%
rename from ccnx/ccnx-charbuf.h
rename to ndnx/ndnx-charbuf.h
index fbb9588..3007eee 100644
--- a/ccnx/ccnx-charbuf.h
+++ b/ndnx/ndnx-charbuf.h
@@ -19,33 +19,33 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_CCNX_CHARBUF_H
-#define CCNX_CCNX_CHARBUF_H
+#ifndef NDNX_NDNX_CHARBUF_H
+#define NDNX_NDNX_CHARBUF_H
-#include "ccnx-common.h"
+#include "ndnx-common.h"
#include <boost/shared_ptr.hpp>
-namespace Ccnx {
+namespace Ndnx {
-class CcnxCharbuf;
-typedef boost::shared_ptr<CcnxCharbuf> CcnxCharbufPtr;
+class NdnxCharbuf;
+typedef boost::shared_ptr<NdnxCharbuf> NdnxCharbufPtr;
-// This class is mostly used in CcnxWrapper; users should not be directly using this class
+// This class is mostly used in NdnxWrapper; users should not be directly using this class
// The main purpose of this class to is avoid manually create and destroy charbuf everytime
-class CcnxCharbuf
+class NdnxCharbuf
{
public:
- CcnxCharbuf();
- CcnxCharbuf(ccn_charbuf *buf);
- CcnxCharbuf(const CcnxCharbuf &other);
- CcnxCharbuf(const void *buf, size_t length);
- ~CcnxCharbuf();
+ NdnxCharbuf();
+ NdnxCharbuf(ndn_charbuf *buf);
+ NdnxCharbuf(const NdnxCharbuf &other);
+ NdnxCharbuf(const void *buf, size_t length);
+ ~NdnxCharbuf();
// expose internal data structure, use with caution!!
- ccn_charbuf *
+ ndn_charbuf *
getBuf() { return m_buf; }
- const ccn_charbuf *
+ const ndn_charbuf *
getBuf() const { return m_buf; }
const unsigned char *
@@ -57,12 +57,12 @@
{ return m_buf->length; }
private:
- void init(ccn_charbuf *buf);
+ void init(ndn_charbuf *buf);
protected:
- ccn_charbuf *m_buf;
+ ndn_charbuf *m_buf;
};
}
-#endif // CCNX_CCNX_CHARBUF_H
+#endif // NDNX_NDNX_CHARBUF_H
diff --git a/ccnx/ccnx-closure.cpp b/ndnx/ndnx-closure.cpp
similarity index 98%
rename from ccnx/ccnx-closure.cpp
rename to ndnx/ndnx-closure.cpp
index 5736511..1a96582 100644
--- a/ccnx/ccnx-closure.cpp
+++ b/ndnx/ndnx-closure.cpp
@@ -19,9 +19,9 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-closure.h"
+#include "ndnx-closure.h"
-namespace Ccnx {
+namespace Ndnx {
Closure::Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback)
: m_timeoutCallback (timeoutCallback)
@@ -109,4 +109,4 @@
// }
// }
-} // Ccnx
+} // Ndnx
diff --git a/ccnx/ccnx-closure.h b/ndnx/ndnx-closure.h
similarity index 91%
rename from ccnx/ccnx-closure.h
rename to ndnx/ndnx-closure.h
index 6a1b8d8..91e723a 100644
--- a/ccnx/ccnx-closure.h
+++ b/ndnx/ndnx-closure.h
@@ -19,15 +19,15 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_CLOSURE_H
-#define CCNX_CLOSURE_H
+#ifndef NDNX_CLOSURE_H
+#define NDNX_CLOSURE_H
-#include "ccnx-common.h"
-#include "ccnx-name.h"
-#include "ccnx-selectors.h"
+#include "ndnx-common.h"
+#include "ndnx-name.h"
+#include "ndnx-selectors.h"
#include "executor.h"
-namespace Ccnx {
+namespace Ndnx {
class ParsedContentObject;
typedef boost::shared_ptr<ParsedContentObject> PcoPtr;
@@ -43,7 +43,7 @@
virtual ~Closure();
virtual void
- runDataCallback(Name name, Ccnx::PcoPtr pco);
+ runDataCallback(Name name, Ndnx::PcoPtr pco);
virtual void
runTimeoutCallback(Name interest, const Closure &closure, Selectors selectors);
@@ -91,6 +91,6 @@
// ExecutorPtr m_executor;
// };
-} // Ccnx
+} // Ndnx
#endif
diff --git a/ccnx/ccnx-common.h b/ndnx/ndnx-common.h
similarity index 94%
rename from ccnx/ccnx-common.h
rename to ndnx/ndnx-common.h
index 579128f..fae1569 100644
--- a/ccnx/ccnx-common.h
+++ b/ndnx/ndnx-common.h
@@ -19,16 +19,16 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_COMMON_H
-#define CCNX_COMMON_H
+#ifndef NDNX_COMMON_H
+#define NDNX_COMMON_H
extern "C" {
-#include <ccn/ccn.h>
-#include <ccn/charbuf.h>
-#include <ccn/keystore.h>
-#include <ccn/uri.h>
-#include <ccn/bloom.h>
-#include <ccn/signing.h>
+#include <ndn/ndn.h>
+#include <ndn/charbuf.h>
+#include <ndn/keystore.h>
+#include <ndn/uri.h>
+#include <ndn/bloom.h>
+#include <ndn/signing.h>
}
#include <vector>
#include <boost/shared_ptr.hpp>
@@ -47,7 +47,7 @@
namespace io = boost::iostreams;
-namespace Ccnx {
+namespace Ndnx {
typedef std::vector<unsigned char> Bytes;
typedef std::vector<std::string>Comps;
@@ -172,5 +172,5 @@
// Exceptions
typedef boost::error_info<struct tag_errmsg, std::string> error_info_str;
-} // Ccnx
-#endif // CCNX_COMMON_H
+} // Ndnx
+#endif // NDNX_COMMON_H
diff --git a/ccnx/ccnx-discovery.cpp b/ndnx/ndnx-discovery.cpp
similarity index 73%
rename from ccnx/ccnx-discovery.cpp
rename to ndnx/ndnx-discovery.cpp
index e6c4e84..dce0d98 100644
--- a/ccnx/ccnx-discovery.cpp
+++ b/ndnx/ndnx-discovery.cpp
@@ -1,4 +1,4 @@
-#include "ccnx-discovery.h"
+#include "ndnx-discovery.h"
#include "simple-interval-generator.h"
#include "task.h"
#include "periodic-task.h"
@@ -6,7 +6,7 @@
#include <boost/make_shared.hpp>
#include <boost/bind.hpp>
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
const string
@@ -41,40 +41,40 @@
}
const double
-CcnxDiscovery::INTERVAL = 15.0;
+NdnxDiscovery::INTERVAL = 15.0;
-CcnxDiscovery *
-CcnxDiscovery::instance = NULL;
+NdnxDiscovery *
+NdnxDiscovery::instance = NULL;
boost::mutex
-CcnxDiscovery::mutex;
+NdnxDiscovery::mutex;
-CcnxDiscovery::CcnxDiscovery()
+NdnxDiscovery::NdnxDiscovery()
: m_scheduler(new Scheduler())
, m_localPrefix("/")
{
m_scheduler->start();
Scheduler::scheduleOneTimeTask (m_scheduler, 0,
- boost::bind(&CcnxDiscovery::poll, this), "Initial-Local-Prefix-Check");
+ boost::bind(&NdnxDiscovery::poll, this), "Initial-Local-Prefix-Check");
Scheduler::schedulePeriodicTask (m_scheduler,
boost::make_shared<SimpleIntervalGenerator>(INTERVAL),
- boost::bind(&CcnxDiscovery::poll, this), "Local-Prefix-Check");
+ boost::bind(&NdnxDiscovery::poll, this), "Local-Prefix-Check");
}
-CcnxDiscovery::~CcnxDiscovery()
+NdnxDiscovery::~NdnxDiscovery()
{
m_scheduler->shutdown();
}
void
-CcnxDiscovery::addCallback(const TaggedFunction &callback)
+NdnxDiscovery::addCallback(const TaggedFunction &callback)
{
m_callbacks.push_back(callback);
}
int
-CcnxDiscovery::deleteCallback(const TaggedFunction &callback)
+NdnxDiscovery::deleteCallback(const TaggedFunction &callback)
{
List::iterator it = m_callbacks.begin();
while (it != m_callbacks.end())
@@ -92,9 +92,9 @@
}
void
-CcnxDiscovery::poll()
+NdnxDiscovery::poll()
{
- Name localPrefix = CcnxWrapper::getLocalPrefix();
+ Name localPrefix = NdnxWrapper::getLocalPrefix();
if (localPrefix != m_localPrefix)
{
Lock lock(mutex);
@@ -107,24 +107,24 @@
}
void
-CcnxDiscovery::registerCallback(const TaggedFunction &callback)
+NdnxDiscovery::registerCallback(const TaggedFunction &callback)
{
Lock lock(mutex);
if (instance == NULL)
{
- instance = new CcnxDiscovery();
+ instance = new NdnxDiscovery();
}
instance->addCallback(callback);
}
void
-CcnxDiscovery::deregisterCallback(const TaggedFunction &callback)
+NdnxDiscovery::deregisterCallback(const TaggedFunction &callback)
{
Lock lock(mutex);
if (instance == NULL)
{
- cerr << "CcnxDiscovery::deregisterCallback called without instance" << endl;
+ cerr << "NdnxDiscovery::deregisterCallback called without instance" << endl;
}
else
{
diff --git a/ccnx/ccnx-discovery.h b/ndnx/ndnx-discovery.h
similarity index 87%
rename from ccnx/ccnx-discovery.h
rename to ndnx/ndnx-discovery.h
index b03a937..e273364 100644
--- a/ccnx/ccnx-discovery.h
+++ b/ndnx/ndnx-discovery.h
@@ -19,12 +19,12 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_DISCOVERY_H
-#define CCNX_DISCOVERY_H
+#ifndef NDNX_DISCOVERY_H
+#define NDNX_DISCOVERY_H
-#include "ccnx-wrapper.h"
-#include "ccnx-common.h"
-#include "ccnx-name.h"
+#include "ndnx-wrapper.h"
+#include "ndnx-common.h"
+#include "ndnx-name.h"
#include "scheduler.h"
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
@@ -33,11 +33,11 @@
#include <boost/thread/locks.hpp>
#include <list>
-namespace Ccnx
+namespace Ndnx
{
-class CcnxDiscovery;
-typedef boost::shared_ptr<CcnxDiscovery> CcnxDiscoveryPtr;
+class NdnxDiscovery;
+typedef boost::shared_ptr<NdnxDiscovery> NdnxDiscoveryPtr;
class TaggedFunction
{
@@ -64,7 +64,7 @@
std::string m_tag;
};
-class CcnxDiscovery
+class NdnxDiscovery
{
public:
const static double INTERVAL;
@@ -80,8 +80,8 @@
deregisterCallback(const TaggedFunction &callback);
private:
- CcnxDiscovery();
- ~CcnxDiscovery();
+ NdnxDiscovery();
+ ~NdnxDiscovery();
void
poll();
@@ -97,12 +97,12 @@
typedef boost::unique_lock<Mutex> Lock;
typedef std::list<TaggedFunction> List;
- static CcnxDiscovery *instance;
+ static NdnxDiscovery *instance;
static Mutex mutex;
List m_callbacks;
SchedulerPtr m_scheduler;
Name m_localPrefix;
};
-} // Ccnx
-#endif // CCNX_DISCOVERY_H
+} // Ndnx
+#endif // NDNX_DISCOVERY_H
diff --git a/ccnx/ccnx-name.cpp b/ndnx/ndnx-name.cpp
similarity index 84%
rename from ccnx/ccnx-name.cpp
rename to ndnx/ndnx-name.cpp
index 00fbe11..dcf762e 100644
--- a/ccnx/ccnx-name.cpp
+++ b/ndnx/ndnx-name.cpp
@@ -19,7 +19,7 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-name.h"
+#include "ndnx-name.h"
#include <boost/lexical_cast.hpp>
#include <ctype.h>
#include <boost/algorithm/string/join.hpp>
@@ -27,7 +27,7 @@
using namespace std;
-namespace Ccnx{
+namespace Ndnx{
Name::Name()
{
@@ -61,13 +61,13 @@
m_comps = other.m_comps;
}
-Name::Name(const unsigned char *data, const ccn_indexbuf *comps)
+Name::Name(const unsigned char *data, const ndn_indexbuf *comps)
{
for (unsigned int i = 0; i < comps->n - 1; i++)
{
const unsigned char *compPtr;
size_t size;
- ccn_name_comp_get(data, comps, i, &compPtr, &size);
+ ndn_name_comp_get(data, comps, i, &compPtr, &size);
Bytes comp;
readRaw(comp, compPtr, size);
m_comps.push_back(comp);
@@ -76,57 +76,57 @@
Name::Name (const void *buf, const size_t length)
{
- ccn_indexbuf *idx = ccn_indexbuf_create();
- const ccn_charbuf namebuf = { length, length, const_cast<unsigned char *> (reinterpret_cast<const unsigned char *> (buf)) };
- ccn_name_split (&namebuf, idx);
+ ndn_indexbuf *idx = ndn_indexbuf_create();
+ const ndn_charbuf namebuf = { length, length, const_cast<unsigned char *> (reinterpret_cast<const unsigned char *> (buf)) };
+ ndn_name_split (&namebuf, idx);
const unsigned char *compPtr = NULL;
size_t size = 0;
int i = 0;
- while (ccn_name_comp_get(namebuf.buf, idx, i, &compPtr, &size) == 0)
+ while (ndn_name_comp_get(namebuf.buf, idx, i, &compPtr, &size) == 0)
{
Bytes comp;
readRaw (comp, compPtr, size);
m_comps.push_back(comp);
i++;
}
- ccn_indexbuf_destroy(&idx);
+ ndn_indexbuf_destroy(&idx);
}
-Name::Name (const CcnxCharbuf &buf)
+Name::Name (const NdnxCharbuf &buf)
{
- ccn_indexbuf *idx = ccn_indexbuf_create();
- ccn_name_split (buf.getBuf (), idx);
+ ndn_indexbuf *idx = ndn_indexbuf_create();
+ ndn_name_split (buf.getBuf (), idx);
const unsigned char *compPtr = NULL;
size_t size = 0;
int i = 0;
- while (ccn_name_comp_get(buf.getBuf ()->buf, idx, i, &compPtr, &size) == 0)
+ while (ndn_name_comp_get(buf.getBuf ()->buf, idx, i, &compPtr, &size) == 0)
{
Bytes comp;
readRaw (comp, compPtr, size);
m_comps.push_back(comp);
i++;
}
- ccn_indexbuf_destroy(&idx);
+ ndn_indexbuf_destroy(&idx);
}
-Name::Name (const ccn_charbuf *buf)
+Name::Name (const ndn_charbuf *buf)
{
- ccn_indexbuf *idx = ccn_indexbuf_create();
- ccn_name_split (buf, idx);
+ ndn_indexbuf *idx = ndn_indexbuf_create();
+ ndn_name_split (buf, idx);
const unsigned char *compPtr = NULL;
size_t size = 0;
int i = 0;
- while (ccn_name_comp_get(buf->buf, idx, i, &compPtr, &size) == 0)
+ while (ndn_name_comp_get(buf->buf, idx, i, &compPtr, &size) == 0)
{
Bytes comp;
readRaw (comp, compPtr, size);
m_comps.push_back(comp);
i++;
}
- ccn_indexbuf_destroy(&idx);
+ ndn_indexbuf_destroy(&idx);
}
Name &
@@ -163,26 +163,26 @@
return ss.str();
}
-CcnxCharbuf*
-Name::toCcnxCharbufRaw () const
+NdnxCharbuf*
+Name::toNdnxCharbufRaw () const
{
- CcnxCharbuf *ptr = new CcnxCharbuf ();
+ NdnxCharbuf *ptr = new NdnxCharbuf ();
- ccn_charbuf *cbuf = ptr->getBuf();
- ccn_name_init(cbuf);
+ ndn_charbuf *cbuf = ptr->getBuf();
+ ndn_name_init(cbuf);
int size = m_comps.size();
for (int i = 0; i < size; i++)
{
- ccn_name_append(cbuf, head(m_comps[i]), m_comps[i].size());
+ ndn_name_append(cbuf, head(m_comps[i]), m_comps[i].size());
}
return ptr;
}
-CcnxCharbufPtr
-Name::toCcnxCharbuf () const
+NdnxCharbufPtr
+Name::toNdnxCharbuf () const
{
- return CcnxCharbufPtr (toCcnxCharbufRaw ());
+ return NdnxCharbufPtr (toNdnxCharbufRaw ());
}
Name &
@@ -358,4 +358,4 @@
}
-} // Ccnx
+} // Ndnx
diff --git a/ccnx/ccnx-name.h b/ndnx/ndnx-name.h
similarity index 89%
rename from ccnx/ccnx-name.h
rename to ndnx/ndnx-name.h
index 8e3ca6e..2fde71b 100644
--- a/ccnx/ccnx-name.h
+++ b/ndnx/ndnx-name.h
@@ -19,13 +19,13 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_NAME_H
-#define CCNX_NAME_H
+#ifndef NDNX_NAME_H
+#define NDNX_NAME_H
#include <boost/shared_ptr.hpp>
-#include "ccnx-common.h"
-#include "ccnx-charbuf.h"
+#include "ndnx-common.h"
+#include "ndnx-charbuf.h"
-namespace Ccnx {
+namespace Ndnx {
struct NameException:
virtual boost::exception, virtual std::exception {};
@@ -37,19 +37,19 @@
Name(const std::string &name);
Name(const std::vector<Bytes> &comps);
Name(const Name &other);
- Name(const unsigned char *data, const ccn_indexbuf *comps);
+ Name(const unsigned char *data, const ndn_indexbuf *comps);
Name (const void *buf, const size_t length);
- Name (const CcnxCharbuf &buf);
- Name (const ccn_charbuf *buf);
+ Name (const NdnxCharbuf &buf);
+ Name (const ndn_charbuf *buf);
virtual ~Name() {}
- CcnxCharbufPtr
- toCcnxCharbuf() const;
+ NdnxCharbufPtr
+ toNdnxCharbuf() const;
- CcnxCharbuf*
- toCcnxCharbufRaw () const;
+ NdnxCharbuf*
+ toNdnxCharbufRaw () const;
- operator CcnxCharbufPtr () const { return toCcnxCharbuf (); }
+ operator NdnxCharbufPtr () const { return toNdnxCharbuf (); }
Name &
appendComp(const Name &comp);
@@ -169,5 +169,5 @@
}
-} // Ccnx
+} // Ndnx
#endif
diff --git a/ccnx/ccnx-pco.cpp b/ndnx/ndnx-pco.cpp
similarity index 73%
rename from ccnx/ccnx-pco.cpp
rename to ndnx/ndnx-pco.cpp
index b66b184..01c78da 100644
--- a/ccnx/ccnx-pco.cpp
+++ b/ndnx/ndnx-pco.cpp
@@ -19,18 +19,19 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-pco.h"
-#include "ccnx-cert.h"
+#include "ndnx-pco.h"
+#include "ndnx-cert.h"
+#include "hash-helper.h"
-namespace Ccnx {
+namespace Ndnx {
void
ParsedContentObject::init(const unsigned char *data, size_t len)
{
readRaw(m_bytes, data, len);
- m_comps = ccn_indexbuf_create();
- int res = ccn_parse_ContentObject(head (m_bytes), len, &m_pco, m_comps);
+ m_comps = ndn_indexbuf_create();
+ int res = ndn_parse_ContentObject(head (m_bytes), len, &m_pco, m_comps);
if (res < 0)
{
boost::throw_exception(MisformedContentObjectException());
@@ -61,7 +62,7 @@
ParsedContentObject::~ParsedContentObject()
{
- ccn_indexbuf_destroy(&m_comps);
+ ndn_indexbuf_destroy(&m_comps);
m_comps = NULL;
}
@@ -70,7 +71,7 @@
{
const unsigned char *content;
size_t len;
- int res = ccn_content_get_value(head(m_bytes), m_pco.offset[CCN_PCO_E], &m_pco, &content, &len);
+ int res = ndn_content_get_value(head(m_bytes), m_pco.offset[NDN_PCO_E], &m_pco, &content, &len);
if (res < 0)
{
boost::throw_exception(MisformedContentObjectException());
@@ -86,7 +87,7 @@
{
const unsigned char *content;
size_t len;
- int res = ccn_content_get_value(head(m_bytes), m_pco.offset[CCN_PCO_E], &m_pco, &content, &len);
+ int res = ndn_content_get_value(head(m_bytes), m_pco.offset[NDN_PCO_E], &m_pco, &content, &len);
if (res < 0)
{
boost::throw_exception(MisformedContentObjectException());
@@ -104,13 +105,13 @@
Name
ParsedContentObject::keyName() const
{
- if (m_pco.offset[CCN_PCO_E_KeyName_Name] > m_pco.offset[CCN_PCO_B_KeyName_Name])
+ if (m_pco.offset[NDN_PCO_E_KeyName_Name] > m_pco.offset[NDN_PCO_B_KeyName_Name])
{
- CcnxCharbufPtr ptr = boost::make_shared<CcnxCharbuf>();
- ccn_charbuf_append(ptr->getBuf(), head(m_bytes) + m_pco.offset[CCN_PCO_B_KeyName_Name], m_pco.offset[CCN_PCO_E_KeyName_Name] - m_pco.offset[CCN_PCO_B_KeyName_Name]);
+ NdnxCharbufPtr ptr = boost::make_shared<NdnxCharbuf>();
+ ndn_charbuf_append(ptr->getBuf(), head(m_bytes) + m_pco.offset[NDN_PCO_B_KeyName_Name], m_pco.offset[NDN_PCO_E_KeyName_Name] - m_pco.offset[NDN_PCO_B_KeyName_Name]);
return Name(*ptr);
- }
+}
else
{
return Name();
@@ -122,7 +123,7 @@
{
const unsigned char *buf = NULL;
size_t size = 0;
- ccn_ref_tagged_BLOB(CCN_DTAG_PublisherPublicKeyDigest, head(m_bytes), m_pco.offset[CCN_PCO_B_PublisherPublicKeyDigest], m_pco.offset[CCN_PCO_E_PublisherPublicKeyDigest], &buf, &size);
+ ndn_ref_tagged_BLOB(NDN_DTAG_PublisherPublicKeyDigest, head(m_bytes), m_pco.offset[NDN_PCO_B_PublisherPublicKeyDigest], m_pco.offset[NDN_PCO_E_PublisherPublicKeyDigest], &buf, &size);
return boost::make_shared<Hash>(buf, size);
}
@@ -132,8 +133,8 @@
{
switch (m_pco.type)
{
- case CCN_CONTENT_DATA: return DATA;
- case CCN_CONTENT_KEY: return KEY;
+ case NDN_CONTENT_DATA: return DATA;
+ case NDN_CONTENT_KEY: return KEY;
default: break;
}
return OTHER;
@@ -142,7 +143,7 @@
void
ParsedContentObject::verifySignature(const CertPtr &cert)
{
- m_verified = (ccn_verify_signature(head(m_bytes), m_pco.offset[CCN_PCO_E], &m_pco, cert->pkey()) == 1);
+ m_verified = (ndn_verify_signature(head(m_bytes), m_pco.offset[NDN_PCO_E], &m_pco, cert->pkey()) == 1);
}
}
diff --git a/ccnx/ccnx-pco.h b/ndnx/ndnx-pco.h
similarity index 84%
rename from ccnx/ccnx-pco.h
rename to ndnx/ndnx-pco.h
index 7532630..6af0f73 100644
--- a/ccnx/ccnx-pco.h
+++ b/ndnx/ndnx-pco.h
@@ -19,15 +19,17 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_CONTENT_OBJECT_H
-#define CCNX_CONTENT_OBJECT_H
+#ifndef NDNX_CONTENT_OBJECT_H
+#define NDNX_CONTENT_OBJECT_H
-#include "ccnx-wrapper.h"
-#include "ccnx-common.h"
-#include "ccnx-name.h"
-#include "hash-helper.h"
+#include "ndnx-wrapper.h"
+#include "ndnx-common.h"
+#include "ndnx-name.h"
-namespace Ccnx {
+class Hash;
+typedef boost::shared_ptr<Hash> HashPtr;
+
+namespace Ndnx {
struct MisformedContentObjectException : virtual boost::exception, virtual std::exception { };
@@ -44,7 +46,7 @@
OTHER
};
ParsedContentObject(const unsigned char *data, size_t len, bool verified = false);
- ParsedContentObject(const unsigned char *data, const ccn_parsed_ContentObject &pco, bool verified = false);
+ ParsedContentObject(const unsigned char *data, const ndn_parsed_ContentObject &pco, bool verified = false);
ParsedContentObject(const Bytes &bytes, bool verified = false);
ParsedContentObject(const ParsedContentObject &other, bool verified = false);
virtual ~ParsedContentObject();
@@ -79,7 +81,7 @@
const unsigned char *
msg() const { return head(m_bytes); }
- const ccn_parsed_ContentObject *
+ const ndn_parsed_ContentObject *
pco() const { return &m_pco; }
private:
@@ -87,8 +89,8 @@
init(const unsigned char *data, size_t len);
protected:
- ccn_parsed_ContentObject m_pco;
- ccn_indexbuf *m_comps;
+ ndn_parsed_ContentObject m_pco;
+ ndn_indexbuf *m_comps;
Bytes m_bytes;
bool m_verified;
bool m_integrityChecked;
@@ -105,4 +107,4 @@
}
-#endif // CCNX_CONTENT_OBJECT_H
+#endif // NDNX_CONTENT_OBJECT_H
diff --git a/ccnx/ccnx-selectors.cpp b/ndnx/ndnx-selectors.cpp
similarity index 73%
rename from ccnx/ccnx-selectors.cpp
rename to ndnx/ndnx-selectors.cpp
index 4e9b440..3006d0e 100644
--- a/ccnx/ccnx-selectors.cpp
+++ b/ndnx/ndnx-selectors.cpp
@@ -1,10 +1,10 @@
-#include "ccnx-selectors.h"
-#include "ccnx-common.h"
+#include "ndnx-selectors.h"
+#include "ndnx-common.h"
#include <boost/lexical_cast.hpp>
using namespace std;
-namespace Ccnx {
+namespace Ndnx {
Selectors::Selectors()
: m_maxSuffixComps(-1)
@@ -27,7 +27,7 @@
m_publisherPublicKeyDigest = other.m_publisherPublicKeyDigest;
}
-Selectors::Selectors(const ccn_parsed_interest *pi)
+Selectors::Selectors(const ndn_parsed_interest *pi)
: m_maxSuffixComps(-1)
, m_minSuffixComps(-1)
, m_answerOriginKind(AOK_DEFAULT)
@@ -82,18 +82,18 @@
}
-CcnxCharbufPtr
-Selectors::toCcnxCharbuf() const
+NdnxCharbufPtr
+Selectors::toNdnxCharbuf() const
{
if (isEmpty())
{
- return CcnxCharbufPtr ();
+ return NdnxCharbufPtr ();
}
- CcnxCharbufPtr ptr(new CcnxCharbuf());
- ccn_charbuf *cbuf = ptr->getBuf();
- ccn_charbuf_append_tt(cbuf, CCN_DTAG_Interest, CCN_DTAG);
- ccn_charbuf_append_tt(cbuf, CCN_DTAG_Name, CCN_DTAG);
- ccn_charbuf_append_closer(cbuf); // </Name>
+ NdnxCharbufPtr ptr(new NdnxCharbuf());
+ ndn_charbuf *cbuf = ptr->getBuf();
+ ndn_charbuf_append_tt(cbuf, NDN_DTAG_Interest, NDN_DTAG);
+ ndn_charbuf_append_tt(cbuf, NDN_DTAG_Name, NDN_DTAG);
+ ndn_charbuf_append_closer(cbuf); // </Name>
if (m_maxSuffixComps < m_minSuffixComps)
{
@@ -102,12 +102,12 @@
if (m_minSuffixComps > 0)
{
- ccnb_tagged_putf(cbuf, CCN_DTAG_MinSuffixComponents, "%d", m_minSuffixComps);
+ ndnb_tagged_putf(cbuf, NDN_DTAG_MinSuffixComponents, "%d", m_minSuffixComps);
}
if (m_maxSuffixComps > 0)
{
- ccnb_tagged_putf(cbuf, CCN_DTAG_MaxSuffixComponents, "%d", m_maxSuffixComps);
+ ndnb_tagged_putf(cbuf, NDN_DTAG_MaxSuffixComponents, "%d", m_maxSuffixComps);
}
// publisher digest
@@ -116,42 +116,42 @@
if (m_childSelector != DEFAULT)
{
- ccnb_tagged_putf(cbuf, CCN_DTAG_ChildSelector, "%d", (int)m_childSelector);
+ ndnb_tagged_putf(cbuf, NDN_DTAG_MinSuffixComponents, "%d", (int)m_minSuffixComps);
}
-
+
if (m_answerOriginKind != AOK_DEFAULT)
{
- // it was not using "ccnb_tagged_putf" in ccnx c code, no idea why
- ccn_charbuf_append_tt(cbuf, CCN_DTAG_AnswerOriginKind, CCN_DTAG);
- ccnb_append_number(cbuf, m_answerOriginKind);
- ccn_charbuf_append_closer(cbuf); // <AnswerOriginKind>
+ // it was not using "ndnb_tagged_putf" in ndnx c code, no idea why
+ ndn_charbuf_append_tt(cbuf, NDN_DTAG_AnswerOriginKind, NDN_DTAG);
+ ndnb_append_number(cbuf, m_answerOriginKind);
+ ndn_charbuf_append_closer(cbuf); // <AnswerOriginKind>
}
if (m_scope != NO_SCOPE)
{
- ccnb_tagged_putf(cbuf, CCN_DTAG_Scope, "%d", m_scope);
+ ndnb_tagged_putf(cbuf, NDN_DTAG_Scope, "%d", m_scope);
}
if (m_interestLifetime > 0.0)
{
- // Ccnx timestamp unit is weird 1/4096 second
+ // Ndnx timestamp unit is weird 1/4096 second
// this is from their code
unsigned lifetime = 4096 * (m_interestLifetime + 1.0/8192.0);
if (lifetime == 0 || lifetime > (30 << 12))
{
- boost::throw_exception(InterestSelectorException() << error_info_str("Ccnx requires 0 < lifetime < 30.0. lifetime= " + boost::lexical_cast<string>(m_interestLifetime)));
+ boost::throw_exception(InterestSelectorException() << error_info_str("Ndnx requires 0 < lifetime < 30.0. lifetime= " + boost::lexical_cast<string>(m_interestLifetime)));
}
unsigned char buf[3] = {0};
for (int i = sizeof(buf) - 1; i >= 0; i--, lifetime >>= 8)
{
buf[i] = lifetime & 0xff;
}
- ccnb_append_tagged_blob(cbuf, CCN_DTAG_InterestLifetime, buf, sizeof(buf));
+ ndnb_append_tagged_blob(cbuf, NDN_DTAG_InterestLifetime, buf, sizeof(buf));
}
- ccn_charbuf_append_closer(cbuf); // </Interest>
+ ndn_charbuf_append_closer(cbuf); // </Interest>
return ptr;
}
-} // Ccnx
+} // Ndnx
diff --git a/ccnx/ccnx-selectors.h b/ndnx/ndnx-selectors.h
similarity index 90%
rename from ccnx/ccnx-selectors.h
rename to ndnx/ndnx-selectors.h
index 3a04ff5..f75647d 100644
--- a/ccnx/ccnx-selectors.h
+++ b/ndnx/ndnx-selectors.h
@@ -18,13 +18,13 @@
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_SELECTORS_H
-#define CCNX_SELECTORS_H
+#ifndef NDNX_SELECTORS_H
+#define NDNX_SELECTORS_H
-#include "ccnx-common.h"
-#include "ccnx-name.h"
+#include "ndnx-common.h"
+#include "ndnx-name.h"
-namespace Ccnx {
+namespace Ndnx {
struct InterestSelectorException:
virtual boost::exception, virtual std::exception {};
@@ -33,7 +33,7 @@
{
public:
Selectors();
- Selectors(const ccn_parsed_interest *);
+ Selectors(const ndn_parsed_interest *);
Selectors(const Selectors &other);
~Selectors(){};
@@ -56,7 +56,7 @@
enum Scope
{
NO_SCOPE = -1,
- SCOPE_LOCAL_CCND = 0,
+ SCOPE_LOCAL_NDND = 0,
SCOPE_LOCAL_HOST = 1,
SCOPE_NEXT_HOST = 2
};
@@ -83,8 +83,8 @@
inline Selectors &
publisherPublicKeyDigest(const Bytes &digest) {m_publisherPublicKeyDigest = digest; return *this;}
- CcnxCharbufPtr
- toCcnxCharbuf() const;
+ NdnxCharbufPtr
+ toNdnxCharbuf() const;
bool
isEmpty() const;
@@ -103,6 +103,6 @@
Bytes m_publisherPublicKeyDigest;
};
-} // Ccnx
+} // Ndnx
#endif
diff --git a/ccnx/ccnx-verifier.cpp b/ndnx/ndnx-verifier.cpp
similarity index 93%
rename from ccnx/ccnx-verifier.cpp
rename to ndnx/ndnx-verifier.cpp
index d5a4b6b..1bcfad0 100644
--- a/ccnx/ccnx-verifier.cpp
+++ b/ndnx/ndnx-verifier.cpp
@@ -19,19 +19,19 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-verifier.h"
-#include "ccnx-wrapper.h"
+#include "ndnx-verifier.h"
+#include "ndnx-wrapper.h"
-INIT_LOGGER ("Ccnx.Verifier");
-namespace Ccnx {
+INIT_LOGGER ("Ndnx.Verifier");
+namespace Ndnx {
static const size_t ROOT_KEY_DIGEST_LEN = 32; // SHA-256
static const unsigned char ROOT_KEY_DIGEST[ROOT_KEY_DIGEST_LEN] = {0xa7, 0xd9, 0x8b, 0x81, 0xde, 0x13, 0xfc,
0x56, 0xc5, 0xa6, 0x92, 0xb4, 0x44, 0x93, 0x6e, 0x56, 0x70, 0x9d, 0x52, 0x6f, 0x70,
0xed, 0x39, 0xef, 0xb5, 0xe2, 0x3, 0x29, 0xa5, 0x53, 0x3e, 0x68};
-Verifier::Verifier(CcnxWrapper *ccnx)
- : m_ccnx(ccnx)
+Verifier::Verifier(NdnxWrapper *ndnx)
+ : m_ndnx(ndnx)
, m_rootKeyDigest(ROOT_KEY_DIGEST, ROOT_KEY_DIGEST_LEN)
{
}
@@ -99,8 +99,8 @@
selectors.childSelector(Selectors::RIGHT)
.interestLifetime(maxWait);
- PcoPtr keyObject = m_ccnx->get(keyName, selectors, maxWait);
- PcoPtr metaObject = m_ccnx->get(metaName, selectors, maxWait);
+ PcoPtr keyObject = m_ndnx->get(keyName, selectors, maxWait);
+ PcoPtr metaObject = m_ndnx->get(metaName, selectors, maxWait);
if (!keyObject || !metaObject )
{
_LOG_ERROR("can not fetch key or meta");
@@ -124,7 +124,7 @@
return false;
}
- // check pco is actually signed by this key (i.e. we don't trust the publisherPublicKeyDigest given by ccnx c lib)
+ // check pco is actually signed by this key (i.e. we don't trust the publisherPublicKeyDigest given by ndnx c lib)
if (! (*pco->publisherPublicKeyDigest() == cert->keyDigest()))
{
_LOG_ERROR("key digest does not match the publisher public key digest of the content object");
@@ -166,4 +166,4 @@
return pco->verified();
}
-} // Ccnx
+} // Ndnx
diff --git a/ccnx/ccnx-verifier.h b/ndnx/ndnx-verifier.h
similarity index 83%
rename from ccnx/ccnx-verifier.h
rename to ndnx/ndnx-verifier.h
index cb57952..ce3d450 100644
--- a/ccnx/ccnx-verifier.h
+++ b/ndnx/ndnx-verifier.h
@@ -19,26 +19,26 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_VERIFIER_H
-#define CCNX_VERIFIER_H
+#ifndef NDNX_VERIFIER_H
+#define NDNX_VERIFIER_H
-#include "ccnx-common.h"
-#include "ccnx-name.h"
-#include "ccnx-cert.h"
-#include "ccnx-pco.h"
+#include "ndnx-common.h"
+#include "ndnx-name.h"
+#include "ndnx-cert.h"
+#include "ndnx-pco.h"
#include <map>
#include <boost/thread/locks.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
-namespace Ccnx {
+namespace Ndnx {
-class CcnxWrapper;
+class NdnxWrapper;
class Verifier
{
public:
- Verifier(CcnxWrapper *ccnx);
+ Verifier(NdnxWrapper *ndnx);
~Verifier();
bool verify(const PcoPtr &pco, double maxWait);
@@ -46,7 +46,7 @@
private:
private:
- CcnxWrapper *m_ccnx;
+ NdnxWrapper *m_ndnx;
Hash m_rootKeyDigest;
typedef std::map<Hash, CertPtr> CertCache;
CertCache m_certCache;
@@ -55,6 +55,6 @@
RecLock m_cacheLock;
};
-} // Ccnx
+} // Ndnx
-#endif // CCNX_VERIFIER_H
+#endif // NDNX_VERIFIER_H
diff --git a/ndnx/ndnx-wrapper.cpp b/ndnx/ndnx-wrapper.cpp
new file mode 100644
index 0000000..ab177ce
--- /dev/null
+++ b/ndnx/ndnx-wrapper.cpp
@@ -0,0 +1,783 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ndnx-wrapper.h"
+extern "C" {
+#include <ndn/fetch.h>
+}
+#include <poll.h>
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/random.hpp>
+#include <boost/make_shared.hpp>
+#include <boost/algorithm/string.hpp>
+#include <sstream>
+
+#include "ndnx-verifier.h"
+#include "logging.h"
+
+INIT_LOGGER ("Ndnx.Wrapper");
+
+typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
+typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
+
+using namespace std;
+using namespace boost;
+
+namespace Ndnx {
+
+// hack to enable fake signatures
+// min length for signature field is 16, as defined in ndn_buf_decoder.c:728
+const int DEFAULT_SIGNATURE_SIZE = 16;
+
+// Although ndn_buf_decoder.c:745 defines minimum length 16, something else is checking and only 32-byte fake value is accepted by ndnd
+const int PUBLISHER_KEY_SIZE = 32;
+
+static int
+ndn_encode_garbage_Signature(struct ndn_charbuf *buf)
+{
+ int res = 0;
+
+ res |= ndn_charbuf_append_tt(buf, NDN_DTAG_Signature, NDN_DTAG);
+
+ // Let's cheat more. Default signing algorithm in ndnd is SHA256, so we just need add 32 bytes of garbage
+ static char garbage [DEFAULT_SIGNATURE_SIZE];
+
+ // digest and witness fields are optional, so use default ones
+
+ res |= ndn_charbuf_append_tt(buf, NDN_DTAG_SignatureBits, NDN_DTAG);
+ res |= ndn_charbuf_append_tt(buf, DEFAULT_SIGNATURE_SIZE, NDN_BLOB);
+ res |= ndn_charbuf_append(buf, garbage, DEFAULT_SIGNATURE_SIZE);
+ res |= ndn_charbuf_append_closer(buf);
+
+ res |= ndn_charbuf_append_closer(buf);
+
+ return(res == 0 ? 0 : -1);
+}
+
+static int
+ndn_pack_unsigned_ContentObject(struct ndn_charbuf *buf,
+ const struct ndn_charbuf *Name,
+ const struct ndn_charbuf *SignedInfo,
+ const void *data,
+ size_t size)
+{
+ int res = 0;
+ struct ndn_charbuf *content_header;
+ size_t closer_start;
+
+ content_header = ndn_charbuf_create();
+ res |= ndn_charbuf_append_tt(content_header, NDN_DTAG_Content, NDN_DTAG);
+ if (size != 0)
+ res |= ndn_charbuf_append_tt(content_header, size, NDN_BLOB);
+ closer_start = content_header->length;
+ res |= ndn_charbuf_append_closer(content_header);
+ if (res < 0)
+ return(-1);
+
+ res |= ndn_charbuf_append_tt(buf, NDN_DTAG_ContentObject, NDN_DTAG);
+
+ res |= ndn_encode_garbage_Signature(buf);
+
+ res |= ndn_charbuf_append_charbuf(buf, Name);
+ res |= ndn_charbuf_append_charbuf(buf, SignedInfo);
+ res |= ndnb_append_tagged_blob(buf, NDN_DTAG_Content, data, size);
+ res |= ndn_charbuf_append_closer(buf);
+
+ ndn_charbuf_destroy(&content_header);
+ return(res == 0 ? 0 : -1);
+}
+
+NdnxWrapper::NdnxWrapper()
+ : m_handle (0)
+ , m_running (true)
+ , m_connected (false)
+ , m_executor (new Executor(1))
+ , m_verifier(new Verifier(this))
+{
+ start ();
+}
+
+void
+NdnxWrapper::connectNdnd()
+{
+ if (m_handle != 0) {
+ ndn_disconnect (m_handle);
+ //ndn_destroy (&m_handle);
+ }
+ else
+ {
+ m_handle = ndn_create ();
+ }
+
+ UniqueRecLock lock(m_mutex);
+ if (ndn_connect(m_handle, NULL) < 0)
+ {
+ BOOST_THROW_EXCEPTION (NdnxOperationException() << errmsg_info_str("connection to ndnd failed"));
+ }
+ m_connected = true;
+
+ if (!m_registeredInterests.empty())
+ {
+ for (map<Name, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
+ {
+ clearInterestFilter(it->first, false);
+ setInterestFilter(it->first, it->second, false);
+ }
+ }
+}
+
+NdnxWrapper::~NdnxWrapper()
+{
+ shutdown ();
+ if (m_verifier != 0)
+ {
+ delete m_verifier;
+ m_verifier = 0;
+}
+}
+
+void
+NdnxWrapper::start () // called automatically in constructor
+{
+ connectNdnd();
+ m_thread = thread (&NdnxWrapper::ndnLoop, this);
+ m_executor->start();
+}
+
+void
+NdnxWrapper::shutdown () // called in destructor, but can called manually
+{
+ m_executor->shutdown();
+
+ {
+ UniqueRecLock lock(m_mutex);
+ m_running = false;
+ }
+
+ _LOG_DEBUG ("+++++++++SHUTDOWN+++++++");
+ if (m_connected)
+ {
+ m_thread.join ();
+
+ ndn_disconnect (m_handle);
+ //ndn_destroy (&m_handle);
+ m_connected = false;
+ }
+}
+
+void
+NdnxWrapper::ndnLoop ()
+{
+ static boost::mt19937 randomGenerator (static_cast<unsigned int> (std::time (0)));
+ static boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rangeUniformRandom (randomGenerator, uniform_int<> (0,1000));
+
+ while (m_running)
+ {
+ try
+ {
+ int res = 0;
+ {
+ UniqueRecLock lock(m_mutex);
+ res = ndn_run (m_handle, 0);
+ }
+
+ if (!m_running) break;
+
+ if (res < 0) {
+ _LOG_ERROR ("ndn_run returned negative status: " << res);
+
+ BOOST_THROW_EXCEPTION (NdnxOperationException()
+ << errmsg_info_str("ndn_run returned error"));
+ }
+
+
+ pollfd pfds[1];
+ {
+ UniqueRecLock lock(m_mutex);
+
+ pfds[0].fd = ndn_get_connection_fd (m_handle);
+ pfds[0].events = POLLIN;
+ if (ndn_output_is_pending (m_handle))
+ pfds[0].events |= POLLOUT;
+ }
+
+ int ret = poll (pfds, 1, 1);
+ if (ret < 0)
+ {
+ BOOST_THROW_EXCEPTION (NdnxOperationException() << errmsg_info_str("ndnd socket failed (probably ndnd got stopped)"));
+ }
+ }
+ catch (NdnxOperationException &e)
+ {
+ m_connected = false;
+ // probably ndnd has been stopped
+ // try reconnect with sleep
+ int interval = 1;
+ int maxInterval = 32;
+ while (m_running)
+ {
+ try
+ {
+ this_thread::sleep (boost::get_system_time () + boost::posix_time::seconds (interval) + boost::posix_time::milliseconds (rangeUniformRandom ()));
+
+ connectNdnd ();
+ _LOG_DEBUG("reconnect to ndnd succeeded");
+ break;
+ }
+ catch (NdnxOperationException &e)
+ {
+ this_thread::sleep (boost::get_system_time () + boost::posix_time::seconds (interval) + boost::posix_time::milliseconds (rangeUniformRandom ()));
+
+ // do exponential backup for reconnect interval
+ if (interval < maxInterval)
+ {
+ interval *= 2;
+ }
+ }
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ // catch anything thrown within try block that derives from std::exception
+ std::cerr << exc.what();
+ }
+ catch (...)
+ {
+ cout << "UNKNOWN EXCEPTION !!!" << endl;
+ }
+ }
+}
+
+Bytes
+NdnxWrapper::createContentObject(const Name &name, const void *buf, size_t len, int freshness, const Name &keyNameParam)
+{
+ {
+ UniqueRecLock lock(m_mutex);
+ if (!m_running || !m_connected)
+ {
+ _LOG_TRACE ("<< not running or connected");
+ return Bytes ();
+ }
+ }
+
+ NdnxCharbufPtr ptr = name.toNdnxCharbuf();
+ ndn_charbuf *pname = ptr->getBuf();
+ ndn_charbuf *content = ndn_charbuf_create();
+
+ struct ndn_signing_params sp = NDN_SIGNING_PARAMS_INIT;
+ sp.freshness = freshness;
+
+ Name keyName;
+
+ if (keyNameParam.size() == 0)
+ {
+ // use default key name
+ NdnxCharbufPtr defaultKeyNamePtr = boost::make_shared<NdnxCharbuf>();
+ ndn_get_public_key_and_name(m_handle, &sp, NULL, NULL, defaultKeyNamePtr->getBuf());
+ keyName = Name(*defaultKeyNamePtr);
+ }
+ else
+ {
+ keyName = keyNameParam;
+ }
+
+ if (sp.template_ndnb == NULL)
+ {
+ sp.template_ndnb = ndn_charbuf_create();
+ ndn_charbuf_append_tt(sp.template_ndnb, NDN_DTAG_SignedInfo, NDN_DTAG);
+ }
+ // no idea what the following 3 lines do, but it was there
+ else if (sp.template_ndnb->length > 0) {
+ sp.template_ndnb->length--;
+ }
+ ndn_charbuf_append_tt(sp.template_ndnb, NDN_DTAG_KeyLocator, NDN_DTAG);
+ ndn_charbuf_append_tt(sp.template_ndnb, NDN_DTAG_KeyName, NDN_DTAG);
+ NdnxCharbufPtr keyPtr = keyName.toNdnxCharbuf();
+ ndn_charbuf *keyBuf = keyPtr->getBuf();
+ ndn_charbuf_append(sp.template_ndnb, keyBuf->buf, keyBuf->length);
+ ndn_charbuf_append_closer(sp.template_ndnb); // </KeyName>
+ ndn_charbuf_append_closer(sp.template_ndnb); // </KeyLocator>
+ sp.sp_flags |= NDN_SP_TEMPL_KEY_LOCATOR;
+ ndn_charbuf_append_closer(sp.template_ndnb); // </SignedInfo>
+
+ if (ndn_sign_content(m_handle, content, pname, &sp, buf, len) != 0)
+ {
+ BOOST_THROW_EXCEPTION(NdnxOperationException() << errmsg_info_str("sign content failed"));
+ }
+
+ Bytes bytes;
+ readRaw(bytes, content->buf, content->length);
+
+ ndn_charbuf_destroy (&content);
+ if (sp.template_ndnb != NULL)
+ {
+ ndn_charbuf_destroy (&sp.template_ndnb);
+ }
+
+ return bytes;
+}
+
+int
+NdnxWrapper::putToNdnd (const Bytes &contentObject)
+{
+ _LOG_TRACE (">> putToNdnd");
+ UniqueRecLock lock(m_mutex);
+ if (!m_running || !m_connected)
+ {
+ _LOG_TRACE ("<< not running or connected");
+ return -1;
+ }
+
+
+ if (ndn_put(m_handle, head(contentObject), contentObject.size()) < 0)
+ {
+ _LOG_ERROR ("ndn_put failed");
+ // BOOST_THROW_EXCEPTION(NdnxOperationException() << errmsg_info_str("ndnput failed"));
+ }
+ else
+ {
+ _LOG_DEBUG ("<< putToNdnd");
+ }
+
+ return 0;
+}
+
+int
+NdnxWrapper::publishData (const Name &name, const unsigned char *buf, size_t len, int freshness, const Name &keyName)
+{
+ Bytes co = createContentObject(name, buf, len, freshness, keyName);
+ return putToNdnd(co);
+}
+
+int
+NdnxWrapper::publishUnsignedData(const Name &name, const unsigned char *buf, size_t len, int freshness)
+{
+ {
+ UniqueRecLock lock(m_mutex);
+ if (!m_running || !m_connected)
+ {
+ _LOG_TRACE ("<< not running or connected");
+ return -1;
+ }
+ }
+
+ NdnxCharbufPtr ptr = name.toNdnxCharbuf();
+ ndn_charbuf *pname = ptr->getBuf();
+ ndn_charbuf *content = ndn_charbuf_create();
+ ndn_charbuf *signed_info = ndn_charbuf_create();
+
+ static char fakeKey[PUBLISHER_KEY_SIZE];
+
+ int res = ndn_signed_info_create(signed_info,
+ fakeKey, PUBLISHER_KEY_SIZE,
+ NULL,
+ NDN_CONTENT_DATA,
+ freshness,
+ NULL,
+ NULL // ndnd is happy with absent key locator and key itself... ha ha
+ );
+ ndn_pack_unsigned_ContentObject(content, pname, signed_info, buf, len);
+
+ Bytes bytes;
+ readRaw(bytes, content->buf, content->length);
+
+ ndn_charbuf_destroy (&content);
+ ndn_charbuf_destroy (&signed_info);
+
+ return putToNdnd (bytes);
+}
+
+
+static void
+deleterInInterestTuple (tuple<NdnxWrapper::InterestCallback *, ExecutorPtr> *tuple)
+{
+ delete tuple->get<0> ();
+ delete tuple;
+}
+
+static ndn_upcall_res
+incomingInterest(ndn_closure *selfp,
+ ndn_upcall_kind kind,
+ ndn_upcall_info *info)
+{
+ NdnxWrapper::InterestCallback *f;
+ ExecutorPtr executor;
+ tuple<NdnxWrapper::InterestCallback *, ExecutorPtr> *realData = reinterpret_cast< tuple<NdnxWrapper::InterestCallback *, ExecutorPtr>* > (selfp->data);
+ tie (f, executor) = *realData;
+
+ switch (kind)
+ {
+ case NDN_UPCALL_FINAL: // effective in unit tests
+ // delete closure;
+ executor->execute (bind (deleterInInterestTuple, realData));
+
+ delete selfp;
+ _LOG_TRACE ("<< incomingInterest with NDN_UPCALL_FINAL");
+ return NDN_UPCALL_RESULT_OK;
+
+ case NDN_UPCALL_INTEREST:
+ _LOG_TRACE (">> incomingInterest upcall: " << Name(info->interest_ndnb, info->interest_comps));
+ break;
+
+ default:
+ _LOG_TRACE ("<< incomingInterest with NDN_UPCALL_RESULT_OK: " << Name(info->interest_ndnb, info->interest_comps));
+ return NDN_UPCALL_RESULT_OK;
+ }
+
+ Name interest(info->interest_ndnb, info->interest_comps);
+ Selectors selectors(info->pi);
+
+ executor->execute (bind (*f, interest, selectors));
+ // this will be run in executor
+ // (*f) (interest);
+ // closure->runInterestCallback(interest);
+
+ return NDN_UPCALL_RESULT_OK;
+}
+
+static void
+deleterInDataTuple (tuple<Closure *, ExecutorPtr, Selectors> *tuple)
+{
+ delete tuple->get<0> ();
+ delete tuple;
+}
+
+static ndn_upcall_res
+incomingData(ndn_closure *selfp,
+ ndn_upcall_kind kind,
+ ndn_upcall_info *info)
+{
+ // Closure *cp = static_cast<Closure *> (selfp->data);
+ Closure *cp;
+ ExecutorPtr executor;
+ Selectors selectors;
+ tuple<Closure *, ExecutorPtr, Selectors> *realData = reinterpret_cast< tuple<Closure*, ExecutorPtr, Selectors>* > (selfp->data);
+ tie (cp, executor, selectors) = *realData;
+
+ switch (kind)
+ {
+ case NDN_UPCALL_FINAL: // effecitve in unit tests
+ executor->execute (bind (deleterInDataTuple, realData));
+
+ cp = NULL;
+ delete selfp;
+ _LOG_TRACE ("<< incomingData with NDN_UPCALL_FINAL");
+ return NDN_UPCALL_RESULT_OK;
+
+ case NDN_UPCALL_CONTENT:
+ _LOG_TRACE (">> incomingData content upcall: " << Name (info->content_ndnb, info->content_comps));
+ break;
+
+ // this is the case where the intentionally unsigned packets coming (in Encapsulation case)
+ case NDN_UPCALL_CONTENT_BAD:
+ _LOG_TRACE (">> incomingData content bad upcall: " << Name (info->content_ndnb, info->content_comps));
+ break;
+
+ // always ask ndnd to try to fetch the key
+ case NDN_UPCALL_CONTENT_UNVERIFIED:
+ _LOG_TRACE (">> incomingData content unverified upcall: " << Name (info->content_ndnb, info->content_comps));
+ break;
+
+ case NDN_UPCALL_INTEREST_TIMED_OUT: {
+ if (cp != NULL)
+ {
+ Name interest(info->interest_ndnb, info->interest_comps);
+ _LOG_TRACE ("<< incomingData timeout: " << Name (info->interest_ndnb, info->interest_comps));
+ executor->execute (bind (&Closure::runTimeoutCallback, cp, interest, *cp, selectors));
+ }
+ else
+ {
+ _LOG_TRACE ("<< incomingData timeout, but callback is not set...: " << Name (info->interest_ndnb, info->interest_comps));
+ }
+ return NDN_UPCALL_RESULT_OK;
+ }
+
+ default:
+ _LOG_TRACE(">> unknown upcall type");
+ return NDN_UPCALL_RESULT_OK;
+ }
+
+ PcoPtr pco = make_shared<ParsedContentObject> (info->content_ndnb, info->pco->offset[NDN_PCO_E]);
+
+ // this will be run in executor
+ executor->execute (bind (&Closure::runDataCallback, cp, pco->name (), pco));
+ _LOG_TRACE (">> incomingData");
+
+ return NDN_UPCALL_RESULT_OK;
+}
+
+int NdnxWrapper::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
+{
+ _LOG_TRACE (">> sendInterest: " << interest);
+ {
+ UniqueRecLock lock(m_mutex);
+ if (!m_running || !m_connected)
+ {
+ _LOG_ERROR ("<< sendInterest: not running or connected");
+ return -1;
+ }
+ }
+
+ NdnxCharbufPtr namePtr = interest.toNdnxCharbuf();
+ ndn_charbuf *pname = namePtr->getBuf();
+ ndn_closure *dataClosure = new ndn_closure;
+
+ // Closure *myClosure = new ExecutorClosure(closure, m_executor);
+ Closure *myClosure = closure.dup ();
+ dataClosure->data = new tuple<Closure*, ExecutorPtr, Selectors> (myClosure, m_executor, selectors);
+
+ dataClosure->p = &incomingData;
+
+ NdnxCharbufPtr selectorsPtr = selectors.toNdnxCharbuf();
+ ndn_charbuf *templ = NULL;
+ if (selectorsPtr)
+ {
+ templ = selectorsPtr->getBuf();
+ }
+
+ UniqueRecLock lock(m_mutex);
+ if (ndn_express_interest (m_handle, pname, dataClosure, templ) < 0)
+ {
+ _LOG_ERROR ("<< sendInterest: ndn_express_interest FAILED!!!");
+ }
+
+ return 0;
+}
+
+int NdnxWrapper::setInterestFilter (const Name &prefix, const InterestCallback &interestCallback, bool record/* = true*/)
+{
+ _LOG_TRACE (">> setInterestFilter");
+ UniqueRecLock lock(m_mutex);
+ if (!m_running || !m_connected)
+ {
+ return -1;
+ }
+
+ NdnxCharbufPtr ptr = prefix.toNdnxCharbuf();
+ ndn_charbuf *pname = ptr->getBuf();
+ ndn_closure *interestClosure = new ndn_closure;
+
+ // interestClosure->data = new ExecutorInterestClosure(interestCallback, m_executor);
+
+ interestClosure->data = new tuple<NdnxWrapper::InterestCallback *, ExecutorPtr> (new InterestCallback (interestCallback), m_executor); // should be removed when closure is removed
+ interestClosure->p = &incomingInterest;
+
+ int ret = ndn_set_interest_filter (m_handle, pname, interestClosure);
+ if (ret < 0)
+ {
+ _LOG_ERROR ("<< setInterestFilter: ndn_set_interest_filter FAILED");
+ }
+
+ if (record)
+ {
+ m_registeredInterests.insert(pair<Name, InterestCallback>(prefix, interestCallback));
+ }
+
+ _LOG_TRACE ("<< setInterestFilter");
+
+ return ret;
+}
+
+void
+NdnxWrapper::clearInterestFilter (const Name &prefix, bool record/* = true*/)
+{
+ _LOG_TRACE (">> clearInterestFilter");
+ UniqueRecLock lock(m_mutex);
+ if (!m_running || !m_connected)
+ return;
+
+ NdnxCharbufPtr ptr = prefix.toNdnxCharbuf();
+ ndn_charbuf *pname = ptr->getBuf();
+
+ int ret = ndn_set_interest_filter (m_handle, pname, 0);
+ if (ret < 0)
+ {
+ }
+
+ if (record)
+ {
+ m_registeredInterests.erase(prefix);
+ }
+
+ _LOG_TRACE ("<< clearInterestFilter");
+}
+
+Name
+NdnxWrapper::getLocalPrefix ()
+{
+ struct ndn * tmp_handle = ndn_create ();
+ int res = ndn_connect (tmp_handle, NULL);
+ if (res < 0)
+ {
+ return Name();
+ }
+
+ string retval = "";
+
+ struct ndn_charbuf *templ = ndn_charbuf_create();
+ ndn_charbuf_append_tt(templ, NDN_DTAG_Interest, NDN_DTAG);
+ ndn_charbuf_append_tt(templ, NDN_DTAG_Name, NDN_DTAG);
+ ndn_charbuf_append_closer(templ); /* </Name> */
+ // XXX - use pubid if possible
+ ndn_charbuf_append_tt(templ, NDN_DTAG_MaxSuffixComponents, NDN_DTAG);
+ ndnb_append_number(templ, 1);
+ ndn_charbuf_append_closer(templ); /* </MaxSuffixComponents> */
+ ndnb_tagged_putf(templ, NDN_DTAG_Scope, "%d", 2);
+ ndn_charbuf_append_closer(templ); /* </Interest> */
+
+ struct ndn_charbuf *name = ndn_charbuf_create ();
+ res = ndn_name_from_uri (name, "/local/ndn/prefix");
+ if (res < 0) {
+ }
+ else
+ {
+ struct ndn_fetch *fetch = ndn_fetch_new (tmp_handle);
+
+ struct ndn_fetch_stream *stream = ndn_fetch_open (fetch, name, "/local/ndn/prefix",
+ NULL, 4, NDN_V_HIGHEST, 0);
+ if (stream == NULL) {
+ }
+ else
+ {
+ ostringstream os;
+
+ int counter = 0;
+ char buf[256];
+ while (true) {
+ res = ndn_fetch_read (stream, buf, sizeof(buf));
+
+ if (res == 0) {
+ break;
+ }
+
+ if (res > 0) {
+ os << string(buf, res);
+ } else if (res == NDN_FETCH_READ_NONE) {
+ if (counter < 2)
+ {
+ ndn_run(tmp_handle, 1000);
+ counter ++;
+ }
+ else
+ {
+ break;
+ }
+ } else if (res == NDN_FETCH_READ_END) {
+ break;
+ } else if (res == NDN_FETCH_READ_TIMEOUT) {
+ break;
+ } else {
+ break;
+ }
+ }
+ retval = os.str ();
+ stream = ndn_fetch_close(stream);
+ }
+ fetch = ndn_fetch_destroy(fetch);
+ }
+
+ ndn_charbuf_destroy (&name);
+
+ ndn_disconnect (tmp_handle);
+ ndn_destroy (&tmp_handle);
+
+ boost::algorithm::trim(retval);
+ return Name(retval);
+}
+
+bool
+NdnxWrapper::verify(PcoPtr &pco, double maxWait)
+{
+ return m_verifier->verify(pco, maxWait);
+}
+
+// This is needed just for get function implementation
+struct GetState
+{
+ GetState (double maxWait)
+ {
+ double intPart, fraction;
+ fraction = modf (std::abs(maxWait), &intPart);
+
+ m_maxWait = date_time::second_clock<boost::posix_time::ptime>::universal_time()
+ + boost::posix_time::seconds (intPart)
+ + boost::posix_time::microseconds (fraction * 1000000);
+ }
+
+ PcoPtr
+ WaitForResult ()
+ {
+ //_LOG_TRACE("GetState::WaitForResult start");
+ boost::unique_lock<boost::mutex> lock (m_mutex);
+ m_cond.timed_wait (lock, m_maxWait);
+ //_LOG_TRACE("GetState::WaitForResult finish");
+
+ return m_retval;
+ }
+
+ void
+ DataCallback (Name name, PcoPtr pco)
+ {
+ //_LOG_TRACE("GetState::DataCallback, Name [" << name << "]");
+ boost::unique_lock<boost::mutex> lock (m_mutex);
+ m_retval = pco;
+ m_cond.notify_one ();
+ }
+
+ void
+ TimeoutCallback (Name name)
+ {
+ boost::unique_lock<boost::mutex> lock (m_mutex);
+ m_cond.notify_one ();
+ }
+
+private:
+ boost::posix_time::ptime m_maxWait;
+
+ boost::mutex m_mutex;
+ boost::condition_variable m_cond;
+
+ PcoPtr m_retval;
+};
+
+
+PcoPtr
+NdnxWrapper::get(const Name &interest, const Selectors &selectors, double maxWait/* = 4.0*/)
+{
+ _LOG_TRACE (">> get: " << interest);
+ {
+ UniqueRecLock lock(m_mutex);
+ if (!m_running || !m_connected)
+ {
+ _LOG_ERROR ("<< get: not running or connected");
+ return PcoPtr ();
+ }
+ }
+
+ GetState state (maxWait);
+ this->sendInterest (interest, Closure (boost::bind (&GetState::DataCallback, &state, _1, _2),
+ boost::bind (&GetState::TimeoutCallback, &state, _1)),
+ selectors);
+ return state.WaitForResult ();
+}
+
+}
diff --git a/ccnx/ccnx-wrapper.h b/ndnx/ndnx-wrapper.h
similarity index 82%
rename from ccnx/ccnx-wrapper.h
rename to ndnx/ndnx-wrapper.h
index a49b2a8..9da54f6 100644
--- a/ccnx/ccnx-wrapper.h
+++ b/ndnx/ndnx-wrapper.h
@@ -19,34 +19,34 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#ifndef CCNX_WRAPPER_H
-#define CCNX_WRAPPER_H
+#ifndef NDNX_WRAPPER_H
+#define NDNX_WRAPPER_H
#include <boost/thread/locks.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
-#include "ccnx-common.h"
-#include "ccnx-name.h"
-#include "ccnx-selectors.h"
-#include "ccnx-closure.h"
-#include "ccnx-pco.h"
+#include "ndnx-common.h"
+#include "ndnx-name.h"
+#include "ndnx-selectors.h"
+#include "ndnx-closure.h"
+#include "ndnx-pco.h"
#include "executor.h"
-namespace Ccnx {
+namespace Ndnx {
-struct CcnxOperationException : boost::exception, std::exception { };
+struct NdnxOperationException : boost::exception, std::exception { };
class Verifier;
-class CcnxWrapper
+class NdnxWrapper
{
public:
- const static int MAX_FRESHNESS = 2147; // max value for ccnx
+ const static int MAX_FRESHNESS = 2147; // max value for ndnx
const static int DEFAULT_FRESHNESS = 60;
typedef boost::function<void (Name, Selectors)> InterestCallback;
- CcnxWrapper();
- ~CcnxWrapper();
+ NdnxWrapper();
+ ~NdnxWrapper();
void
start (); // called automatically in constructor
@@ -91,7 +91,7 @@
createContentObject(const Name &name, const void *buf, size_t len, int freshness = DEFAULT_FRESHNESS, const Name &keyNameParam=Name());
int
- putToCcnd (const Bytes &contentObject);
+ putToNdnd (const Bytes &contentObject);
bool
verify(PcoPtr &pco, double maxWait = 1 /*seconds*/);
@@ -100,15 +100,15 @@
get (const Name &interest, const Selectors &selector = Selectors(), double maxWait = 4.0/*seconds*/);
private:
- CcnxWrapper(const CcnxWrapper &other) {}
+ NdnxWrapper(const NdnxWrapper &other) {}
protected:
void
- connectCcnd();
+ connectNdnd();
/// @cond include_hidden
void
- ccnLoop ();
+ ndnLoop ();
/// @endcond
@@ -120,7 +120,7 @@
typedef boost::recursive_mutex RecLock;
typedef boost::unique_lock<RecLock> UniqueRecLock;
- ccn* m_handle;
+ ndn* m_handle;
RecLock m_mutex;
boost::thread m_thread;
bool m_running;
@@ -130,33 +130,33 @@
Verifier *m_verifier;
};
-typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;
+typedef boost::shared_ptr<NdnxWrapper> NdnxWrapperPtr;
inline int
-CcnxWrapper::publishData (const Name &name, const Bytes &content, int freshness, const Name &keyName)
+NdnxWrapper::publishData (const Name &name, const Bytes &content, int freshness, const Name &keyName)
{
return publishData(name, head(content), content.size(), freshness, keyName);
}
inline int
-CcnxWrapper::publishData (const Name &name, const std::string &content, int freshness, const Name &keyName)
+NdnxWrapper::publishData (const Name &name, const std::string &content, int freshness, const Name &keyName)
{
return publishData(name, reinterpret_cast<const unsigned char *> (content.c_str ()), content.size (), freshness, keyName);
}
inline int
-CcnxWrapper::publishUnsignedData(const Name &name, const Bytes &content, int freshness)
+NdnxWrapper::publishUnsignedData(const Name &name, const Bytes &content, int freshness)
{
return publishUnsignedData(name, head(content), content.size(), freshness);
}
inline int
-CcnxWrapper::publishUnsignedData(const Name &name, const std::string &content, int freshness)
+NdnxWrapper::publishUnsignedData(const Name &name, const std::string &content, int freshness)
{
return publishUnsignedData(name, reinterpret_cast<const unsigned char *> (content.c_str ()), content.size (), freshness);
}
-} // Ccnx
+} // Ndnx
#endif
diff --git a/src/action-log.cc b/src/action-log.cc
index eb21b0d..a680dbe 100644
--- a/src/action-log.cc
+++ b/src/action-log.cc
@@ -26,7 +26,7 @@
using namespace boost;
using namespace std;
-using namespace Ccnx;
+using namespace Ndnx;
INIT_LOGGER ("ActionLog");
@@ -88,13 +88,13 @@
// _LOG_TRACE ("SQLITE: " << q);
// }
-ActionLog::ActionLog (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &path,
+ActionLog::ActionLog (Ndnx::NdnxWrapperPtr ndnx, const boost::filesystem::path &path,
SyncLogPtr syncLog,
const std::string &sharedFolder, const std::string &appName,
OnFileAddedOrChangedCallback onFileAddedOrChanged, OnFileRemovedCallback onFileRemoved)
: DbHelper (path / ".chronoshare", "action-log.db")
, m_syncLog (syncLog)
- , m_ccnx (ccnx)
+ , m_ndnx (ndnx)
, m_sharedFolderName (sharedFolder)
, m_appName (appName)
, m_onFileAddedOrChanged (onFileAddedOrChanged)
@@ -118,7 +118,7 @@
m_fileState = make_shared<FileState> (path);
}
-tuple<sqlite3_int64 /*version*/, Ccnx::CcnxCharbufPtr /*device name*/, sqlite3_int64 /*seq_no*/>
+tuple<sqlite3_int64 /*version*/, Ndnx::NdnxCharbufPtr /*device name*/, sqlite3_int64 /*seq_no*/>
ActionLog::GetLatestActionForFile (const std::string &filename)
{
// check if something already exists
@@ -134,7 +134,7 @@
}
sqlite3_int64 version = -1;
- CcnxCharbufPtr parent_device_name;
+ NdnxCharbufPtr parent_device_name;
sqlite3_int64 parent_seq_no = -1;
sqlite3_bind_text (stmt, 1, filename.c_str (), filename.size (), SQLITE_STATIC);
@@ -144,7 +144,7 @@
if (sqlite3_column_int (stmt, 3) == 0) // prevent "linking" if the file was previously deleted
{
- parent_device_name = make_shared<CcnxCharbuf> (sqlite3_column_blob (stmt, 1), sqlite3_column_bytes (stmt, 1));
+ parent_device_name = make_shared<NdnxCharbuf> (sqlite3_column_blob (stmt, 1), sqlite3_column_bytes (stmt, 1));
parent_seq_no = sqlite3_column_int64 (stmt, 2);
}
}
@@ -163,10 +163,10 @@
{
sqlite3_exec (m_db, "BEGIN TRANSACTION;", 0,0,0);
- CcnxCharbufPtr device_name = m_syncLog->GetLocalName ().toCcnxCharbuf ();
+ NdnxCharbufPtr device_name = m_syncLog->GetLocalName ().toNdnxCharbuf ();
sqlite3_int64 seq_no = m_syncLog->GetNextLocalSeqNo ();
sqlite3_int64 version;
- CcnxCharbufPtr parent_device_name;
+ NdnxCharbufPtr parent_device_name;
sqlite3_int64 parent_seq_no = -1;
sqlite3_int64 action_time = time (0);
@@ -245,8 +245,8 @@
Name actionName = Name ("/")(m_syncLog->GetLocalName ())(m_appName)("action")(m_sharedFolderName)(seq_no);
_LOG_DEBUG ("ActionName: " << actionName);
- Bytes actionData = m_ccnx->createContentObject (actionName, item_msg.c_str (), item_msg.size ());
- CcnxCharbufPtr namePtr = actionName.toCcnxCharbuf ();
+ Bytes actionData = m_ndnx->createContentObject (actionName, item_msg.c_str (), item_msg.size ());
+ NdnxCharbufPtr namePtr = actionName.toNdnxCharbuf ();
// _LOG_DEBUG (" >>>>>>> " << Name (namePtr->buf () << " " << namePtr->length ());
@@ -293,9 +293,9 @@
sqlite3_exec (m_db, "BEGIN TRANSACTION;", 0,0,0);
- CcnxCharbufPtr device_name = m_syncLog->GetLocalName ().toCcnxCharbuf ();
+ NdnxCharbufPtr device_name = m_syncLog->GetLocalName ().toNdnxCharbuf ();
sqlite3_int64 version;
- CcnxCharbufPtr parent_device_name;
+ NdnxCharbufPtr parent_device_name;
sqlite3_int64 parent_seq_no = -1;
sqlite3_int64 action_time = time (0);
@@ -358,8 +358,8 @@
Name actionName = Name ("/")(m_syncLog->GetLocalName ())(m_appName)("action")(m_sharedFolderName)(seq_no);
_LOG_DEBUG ("ActionName: " << actionName);
- Bytes actionData = m_ccnx->createContentObject (actionName, item_msg.c_str (), item_msg.size ());
- CcnxCharbufPtr namePtr = actionName.toCcnxCharbuf ();
+ Bytes actionData = m_ndnx->createContentObject (actionName, item_msg.c_str (), item_msg.size ());
+ NdnxCharbufPtr namePtr = actionName.toNdnxCharbuf ();
sqlite3_bind_blob (stmt, 9, namePtr->buf (), namePtr->length (), SQLITE_STATIC);
sqlite3_bind_blob (stmt, 10, &actionData[0], actionData.size (), SQLITE_STATIC);
@@ -368,7 +368,7 @@
_LOG_DEBUG_COND (sqlite3_errcode (m_db) != SQLITE_DONE, sqlite3_errmsg (m_db));
- // cout << Ccnx::Name (parent_device_name) << endl;
+ // cout << Ndnx::Name (parent_device_name) << endl;
// assign name to the action, serialize action, and create content object
@@ -392,12 +392,12 @@
PcoPtr
-ActionLog::LookupActionPco (const Ccnx::Name &deviceName, sqlite3_int64 seqno)
+ActionLog::LookupActionPco (const Ndnx::Name &deviceName, sqlite3_int64 seqno)
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2 (m_db, "SELECT action_content_object FROM ActionLog WHERE device_name=? AND seq_no=?", -1, &stmt, 0);
- CcnxCharbufPtr name = deviceName.toCcnxCharbuf ();
+ NdnxCharbufPtr name = deviceName.toNdnxCharbuf ();
sqlite3_bind_blob (stmt, 1, name->buf (), name->length (), SQLITE_STATIC);
sqlite3_bind_int64 (stmt, 2, seqno);
@@ -419,7 +419,7 @@
}
ActionItemPtr
-ActionLog::LookupAction (const Ccnx::Name &deviceName, sqlite3_int64 seqno)
+ActionLog::LookupAction (const Ndnx::Name &deviceName, sqlite3_int64 seqno)
{
PcoPtr pco = LookupActionPco (deviceName, seqno);
if (!pco) return ActionItemPtr ();
@@ -429,14 +429,14 @@
return action;
}
-Ccnx::PcoPtr
-ActionLog::LookupActionPco (const Ccnx::Name &actionName)
+Ndnx::PcoPtr
+ActionLog::LookupActionPco (const Ndnx::Name &actionName)
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2 (m_db, "SELECT action_content_object FROM ActionLog WHERE action_name=?", -1, &stmt, 0);
_LOG_DEBUG (actionName);
- CcnxCharbufPtr name = actionName.toCcnxCharbuf ();
+ NdnxCharbufPtr name = actionName.toNdnxCharbuf ();
_LOG_DEBUG (" <<<<<<< " << name->buf () << " " << name->length ());
@@ -459,7 +459,7 @@
}
ActionItemPtr
-ActionLog::LookupAction (const Ccnx::Name &actionName)
+ActionLog::LookupAction (const Ndnx::Name &actionName)
{
PcoPtr pco = LookupActionPco (actionName);
if (!pco) return ActionItemPtr ();
@@ -508,7 +508,7 @@
ActionItemPtr
-ActionLog::AddRemoteAction (const Ccnx::Name &deviceName, sqlite3_int64 seqno, Ccnx::PcoPtr actionPco)
+ActionLog::AddRemoteAction (const Ndnx::Name &deviceName, sqlite3_int64 seqno, Ndnx::PcoPtr actionPco)
{
if (!actionPco)
{
@@ -537,7 +537,7 @@
" ?, ?);", -1, &stmt, 0);
_LOG_DEBUG_COND (sqlite3_errcode (m_db) != SQLITE_OK, sqlite3_errmsg (m_db));
- CcnxCharbufPtr device_name = deviceName.toCcnxCharbuf ();
+ NdnxCharbufPtr device_name = deviceName.toNdnxCharbuf ();
sqlite3_bind_blob (stmt, 1, device_name->buf (), device_name->length (), SQLITE_STATIC);
sqlite3_bind_int64 (stmt, 2, seqno);
@@ -565,7 +565,7 @@
}
Name actionName = Name (deviceName)("action")(m_sharedFolderName)(seqno);
- CcnxCharbufPtr namePtr = actionName.toCcnxCharbuf ();
+ NdnxCharbufPtr namePtr = actionName.toNdnxCharbuf ();
sqlite3_bind_blob (stmt, 15, namePtr->buf (), namePtr->length (), SQLITE_STATIC);
sqlite3_bind_blob (stmt, 16, head (actionPco->buf ()), actionPco->buf ().size (), SQLITE_STATIC);
@@ -592,7 +592,7 @@
}
ActionItemPtr
-ActionLog::AddRemoteAction (Ccnx::PcoPtr actionPco)
+ActionLog::AddRemoteAction (Ndnx::PcoPtr actionPco)
{
Name name = actionPco->name ();
// action name: /<device_name>/<appname>/action/<shared-folder>/<action-seq>
@@ -645,7 +645,7 @@
bool
-ActionLog::LookupActionsInFolderRecursively (const boost::function<void (const Ccnx::Name &name, sqlite3_int64 seq_no, const ActionItem &)> &visitor,
+ActionLog::LookupActionsInFolderRecursively (const boost::function<void (const Ndnx::Name &name, sqlite3_int64 seq_no, const ActionItem &)> &visitor,
const std::string &folder, int offset/*=0*/, int limit/*=-1*/)
{
_LOG_DEBUG ("LookupActionsInFolderRecursively: [" << folder << "]");
@@ -696,7 +696,7 @@
ActionItem action;
- Ccnx::Name device_name (sqlite3_column_blob (stmt, 0), sqlite3_column_bytes (stmt, 0));
+ Ndnx::Name device_name (sqlite3_column_blob (stmt, 0), sqlite3_column_bytes (stmt, 0));
sqlite3_int64 seq_no = sqlite3_column_int64 (stmt, 1);
action.set_action (static_cast<ActionItem_ActionType> (sqlite3_column_int (stmt, 2)));
action.set_filename (reinterpret_cast<const char *> (sqlite3_column_text (stmt, 3)), sqlite3_column_bytes (stmt, 3));
@@ -732,7 +732,7 @@
* @todo Figure out the way to minimize code duplication
*/
bool
-ActionLog::LookupActionsForFile (const boost::function<void (const Ccnx::Name &name, sqlite3_int64 seq_no, const ActionItem &)> &visitor,
+ActionLog::LookupActionsForFile (const boost::function<void (const Ndnx::Name &name, sqlite3_int64 seq_no, const ActionItem &)> &visitor,
const std::string &file, int offset/*=0*/, int limit/*=-1*/)
{
_LOG_DEBUG ("LookupActionsInFolderRecursively: [" << file << "]");
@@ -768,7 +768,7 @@
ActionItem action;
- Ccnx::Name device_name (sqlite3_column_blob (stmt, 0), sqlite3_column_bytes (stmt, 0));
+ Ndnx::Name device_name (sqlite3_column_blob (stmt, 0), sqlite3_column_bytes (stmt, 0));
sqlite3_int64 seq_no = sqlite3_column_int64 (stmt, 1);
action.set_action (static_cast<ActionItem_ActionType> (sqlite3_column_int (stmt, 2)));
action.set_filename (reinterpret_cast<const char *> (sqlite3_column_text (stmt, 3)), sqlite3_column_bytes (stmt, 3));
@@ -849,7 +849,7 @@
return;
}
- CcnxCharbuf device_name (sqlite3_value_blob (argv[0]), sqlite3_value_bytes (argv[0]));
+ NdnxCharbuf device_name (sqlite3_value_blob (argv[0]), sqlite3_value_bytes (argv[0]));
sqlite3_int64 seq_no = sqlite3_value_int64 (argv[1]);
int action = sqlite3_value_int (argv[2]);
string filename = reinterpret_cast<const char*> (sqlite3_value_text (argv[3]));
diff --git a/src/action-log.h b/src/action-log.h
index 96ccd51..2002b4c 100644
--- a/src/action-log.h
+++ b/src/action-log.h
@@ -27,8 +27,8 @@
#include "sync-log.h"
#include "action-item.pb.h"
#include "file-item.pb.h"
-#include "ccnx-wrapper.h"
-#include "ccnx-pco.h"
+#include "ndnx-wrapper.h"
+#include "ndnx-pco.h"
#include <boost/tuple/tuple.hpp>
@@ -39,13 +39,13 @@
class ActionLog : public DbHelper
{
public:
- typedef boost::function<void (std::string /*filename*/, Ccnx::Name /*device_name*/, sqlite3_int64 /*seq_no*/,
+ typedef boost::function<void (std::string /*filename*/, Ndnx::Name /*device_name*/, sqlite3_int64 /*seq_no*/,
HashPtr /*hash*/, time_t /*m_time*/, int /*mode*/, int /*seg_num*/)> OnFileAddedOrChangedCallback;
typedef boost::function<void (std::string /*filename*/)> OnFileRemovedCallback;
public:
- ActionLog (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &path,
+ ActionLog (Ndnx::NdnxWrapperPtr ndnx, const boost::filesystem::path &path,
SyncLogPtr syncLog,
const std::string &sharedFolder, const std::string &appName,
OnFileAddedOrChangedCallback onFileAddedOrChanged, OnFileRemovedCallback onFileRemoved);
@@ -73,7 +73,7 @@
//////////////////////////
ActionItemPtr
- AddRemoteAction (const Ccnx::Name &deviceName, sqlite3_int64 seqno, Ccnx::PcoPtr actionPco);
+ AddRemoteAction (const Ndnx::Name &deviceName, sqlite3_int64 seqno, Ndnx::PcoPtr actionPco);
/**
* @brief Add remote action using just action's parsed content object
@@ -81,23 +81,23 @@
* This function extracts device name and sequence number from the content object's and calls the overloaded method
*/
ActionItemPtr
- AddRemoteAction (Ccnx::PcoPtr actionPco);
+ AddRemoteAction (Ndnx::PcoPtr actionPco);
///////////////////////////
// General operations //
///////////////////////////
- Ccnx::PcoPtr
- LookupActionPco (const Ccnx::Name &deviceName, sqlite3_int64 seqno);
+ Ndnx::PcoPtr
+ LookupActionPco (const Ndnx::Name &deviceName, sqlite3_int64 seqno);
- Ccnx::PcoPtr
- LookupActionPco (const Ccnx::Name &actionName);
+ Ndnx::PcoPtr
+ LookupActionPco (const Ndnx::Name &actionName);
ActionItemPtr
- LookupAction (const Ccnx::Name &deviceName, sqlite3_int64 seqno);
+ LookupAction (const Ndnx::Name &deviceName, sqlite3_int64 seqno);
ActionItemPtr
- LookupAction (const Ccnx::Name &actionName);
+ LookupAction (const Ndnx::Name &actionName);
FileItemPtr
LookupAction (const std::string &filename, sqlite3_int64 version, const Hash &filehash);
@@ -106,11 +106,11 @@
* @brief Lookup up to [limit] actions starting [offset] in decreasing order (by timestamp) and calling visitor(device_name,seqno,action) for each action
*/
bool
- LookupActionsInFolderRecursively (const boost::function<void (const Ccnx::Name &name, sqlite3_int64 seq_no, const ActionItem &)> &visitor,
+ LookupActionsInFolderRecursively (const boost::function<void (const Ndnx::Name &name, sqlite3_int64 seq_no, const ActionItem &)> &visitor,
const std::string &folder, int offset=0, int limit=-1);
bool
- LookupActionsForFile (const boost::function<void (const Ccnx::Name &name, sqlite3_int64 seq_no, const ActionItem &)> &visitor,
+ LookupActionsForFile (const boost::function<void (const Ndnx::Name &name, sqlite3_int64 seq_no, const ActionItem &)> &visitor,
const std::string &file, int offset=0, int limit=-1);
void
@@ -126,7 +126,7 @@
LogSize ();
private:
- boost::tuple<sqlite3_int64 /*version*/, Ccnx::CcnxCharbufPtr /*device name*/, sqlite3_int64 /*seq_no*/>
+ boost::tuple<sqlite3_int64 /*version*/, Ndnx::NdnxCharbufPtr /*device name*/, sqlite3_int64 /*seq_no*/>
GetLatestActionForFile (const std::string &filename);
static void
@@ -136,7 +136,7 @@
SyncLogPtr m_syncLog;
FileStatePtr m_fileState;
- Ccnx::CcnxWrapperPtr m_ccnx;
+ Ndnx::NdnxWrapperPtr m_ndnx;
std::string m_sharedFolderName;
std::string m_appName;
diff --git a/src/content-server.cc b/src/content-server.cc
index 7199222..850803e 100644
--- a/src/content-server.cc
+++ b/src/content-server.cc
@@ -30,18 +30,18 @@
INIT_LOGGER ("ContentServer");
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
static const int DB_CACHE_LIFETIME = 60;
-ContentServer::ContentServer(CcnxWrapperPtr ccnx, ActionLogPtr actionLog,
+ContentServer::ContentServer(NdnxWrapperPtr ndnx, ActionLogPtr actionLog,
const boost::filesystem::path &rootDir,
- const Ccnx::Name &userName, const std::string &sharedFolderName,
+ const Ndnx::Name &userName, const std::string &sharedFolderName,
const std::string &appName,
int freshness)
- : m_ccnx(ccnx)
+ : m_ndnx(ndnx)
, m_actionLog(actionLog)
, m_dbFolder(rootDir / ".chronoshare")
, m_freshness(freshness)
@@ -62,7 +62,7 @@
ScopedLock lock (m_mutex);
for (PrefixIt forwardingHint = m_prefixes.begin(); forwardingHint != m_prefixes.end(); ++forwardingHint)
{
- m_ccnx->clearInterestFilter (*forwardingHint);
+ m_ndnx->clearInterestFilter (*forwardingHint);
}
m_prefixes.clear ();
@@ -76,7 +76,7 @@
_LOG_DEBUG (">> content server: register " << forwardingHint);
- m_ccnx->setInterestFilter (forwardingHint, bind(&ContentServer::filterAndServe, this, forwardingHint, _1));
+ m_ndnx->setInterestFilter (forwardingHint, bind(&ContentServer::filterAndServe, this, forwardingHint, _1));
ScopedLock lock (m_mutex);
m_prefixes.insert(forwardingHint);
@@ -86,7 +86,7 @@
ContentServer::deregisterPrefix (const Name &forwardingHint)
{
_LOG_DEBUG ("<< content server: deregister " << forwardingHint);
- m_ccnx->clearInterestFilter(forwardingHint);
+ m_ndnx->clearInterestFilter(forwardingHint);
ScopedLock lock (m_mutex);
m_prefixes.erase (forwardingHint);
@@ -121,10 +121,10 @@
}
}
}
- catch (Ccnx::NameException &ne)
+ catch (Ndnx::NameException &ne)
{
// ignore any unexpected interests and errors
- _LOG_ERROR(boost::get_error_info<Ccnx::error_info_str>(ne));
+ _LOG_ERROR(boost::get_error_info<Ndnx::error_info_str>(ne));
}
}
@@ -142,10 +142,10 @@
filterAndServeImpl (forwardingHint, interest.getPartialName (forwardingHint.size()), interest); // always try with hint... :( have to
}
- catch (Ccnx::NameException &ne)
+ catch (Ndnx::NameException &ne)
{
// ignore any unexpected interests and errors
- _LOG_ERROR(boost::get_error_info<Ccnx::error_info_str>(ne));
+ _LOG_ERROR(boost::get_error_info<Ndnx::error_info_str>(ne));
}
}
@@ -154,7 +154,7 @@
{
_LOG_DEBUG (">> content server serving ACTION, hint: " << forwardingHint << ", interest: " << interest);
m_scheduler->scheduleOneTimeTask (m_scheduler, 0, bind (&ContentServer::serve_Action_Execute, this, forwardingHint, name, interest), boost::lexical_cast<string>(name));
- // need to unlock ccnx mutex... or at least don't lock it
+ // need to unlock ndnx mutex... or at least don't lock it
}
void
@@ -163,7 +163,7 @@
_LOG_DEBUG (">> content server serving FILE, hint: " << forwardingHint << ", interest: " << interest);
m_scheduler->scheduleOneTimeTask (m_scheduler, 0, bind (&ContentServer::serve_File_Execute, this, forwardingHint, name, interest), boost::lexical_cast<string>(name));
- // need to unlock ccnx mutex... or at least don't lock it
+ // need to unlock ndnx mutex... or at least don't lock it
}
void
@@ -212,17 +212,17 @@
if (forwardingHint.size () == 0)
{
_LOG_DEBUG (ParsedContentObject (*co).name ());
- m_ccnx->putToCcnd (*co);
+ m_ndnx->putToNdnd (*co);
}
else
{
if (m_freshness > 0)
{
- m_ccnx->publishData(interest, *co, m_freshness);
+ m_ndnx->publishData(interest, *co, m_freshness);
}
else
{
- m_ccnx->publishData(interest, *co);
+ m_ndnx->publishData(interest, *co);
}
}
@@ -252,18 +252,18 @@
{
if (forwardingHint.size () == 0)
{
- m_ccnx->putToCcnd (pco->buf ());
+ m_ndnx->putToNdnd (pco->buf ());
}
else
{
const Bytes &content = pco->buf ();
if (m_freshness > 0)
{
- m_ccnx->publishData(interest, content, m_freshness);
+ m_ndnx->publishData(interest, content, m_freshness);
}
else
{
- m_ccnx->publishData(interest, content);
+ m_ndnx->publishData(interest, content);
}
}
}
diff --git a/src/content-server.h b/src/content-server.h
index 55037b7..84a0bc7 100644
--- a/src/content-server.h
+++ b/src/content-server.h
@@ -22,7 +22,7 @@
#ifndef CONTENT_SERVER_H
#define CONTENT_SERVER_H
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include "object-db.h"
#include "action-log.h"
#include <set>
@@ -34,8 +34,8 @@
class ContentServer
{
public:
- ContentServer(Ccnx::CcnxWrapperPtr ccnx, ActionLogPtr actionLog, const boost::filesystem::path &rootDir,
- const Ccnx::Name &userName, const std::string &sharedFolderName, const std::string &appName,
+ ContentServer(Ndnx::NdnxWrapperPtr ndnx, ActionLogPtr actionLog, const boost::filesystem::path &rootDir,
+ const Ndnx::Name &userName, const std::string &sharedFolderName, const std::string &appName,
int freshness = -1);
~ContentServer();
@@ -43,39 +43,39 @@
// /some-prefix/topology-independent-name
// currently /topology-independent-name must begin with /action or /file
// so that ContentServer knows where to look for the content object
- void registerPrefix(const Ccnx::Name &prefix);
- void deregisterPrefix(const Ccnx::Name &prefix);
+ void registerPrefix(const Ndnx::Name &prefix);
+ void deregisterPrefix(const Ndnx::Name &prefix);
private:
void
- filterAndServe (Ccnx::Name forwardingHint, const Ccnx::Name &interest);
+ filterAndServe (Ndnx::Name forwardingHint, const Ndnx::Name &interest);
void
- filterAndServeImpl (const Ccnx::Name &forwardingHint, const Ccnx::Name &name, const Ccnx::Name &interest);
+ filterAndServeImpl (const Ndnx::Name &forwardingHint, const Ndnx::Name &name, const Ndnx::Name &interest);
void
- serve_Action (const Ccnx::Name &forwardingHint, const Ccnx::Name &name, const Ccnx::Name &interest);
+ serve_Action (const Ndnx::Name &forwardingHint, const Ndnx::Name &name, const Ndnx::Name &interest);
void
- serve_File (const Ccnx::Name &forwardingHint, const Ccnx::Name &name, const Ccnx::Name &interest);
+ serve_File (const Ndnx::Name &forwardingHint, const Ndnx::Name &name, const Ndnx::Name &interest);
void
- serve_Action_Execute(const Ccnx::Name &forwardingHint, const Ccnx::Name &name, const Ccnx::Name &interest);
+ serve_Action_Execute(const Ndnx::Name &forwardingHint, const Ndnx::Name &name, const Ndnx::Name &interest);
void
- serve_File_Execute(const Ccnx::Name &forwardingHint, const Ccnx::Name &name, const Ccnx::Name &interest);
+ serve_File_Execute(const Ndnx::Name &forwardingHint, const Ndnx::Name &name, const Ndnx::Name &interest);
void
flushStaleDbCache();
private:
- Ccnx::CcnxWrapperPtr m_ccnx;
+ Ndnx::NdnxWrapperPtr m_ndnx;
ActionLogPtr m_actionLog;
typedef boost::shared_mutex Mutex;
typedef boost::unique_lock<Mutex> ScopedLock;
- typedef std::set<Ccnx::Name>::iterator PrefixIt;
- std::set<Ccnx::Name> m_prefixes;
+ typedef std::set<Ndnx::Name>::iterator PrefixIt;
+ std::set<Ndnx::Name> m_prefixes;
Mutex m_mutex;
boost::filesystem::path m_dbFolder;
int m_freshness;
@@ -85,7 +85,7 @@
DbCache m_dbCache;
Mutex m_dbCacheMutex;
- Ccnx::Name m_userName;
+ Ndnx::Name m_userName;
std::string m_sharedFolderName;
std::string m_appName;
};
diff --git a/src/dispatcher.cc b/src/dispatcher.cc
index 46e0e1b..98613cf 100644
--- a/src/dispatcher.cc
+++ b/src/dispatcher.cc
@@ -21,13 +21,13 @@
#include "dispatcher.h"
#include "logging.h"
-#include "ccnx-discovery.h"
+#include "ndnx-discovery.h"
#include "fetch-task-db.h"
#include <boost/make_shared.hpp>
#include <boost/lexical_cast.hpp>
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
@@ -42,21 +42,21 @@
Dispatcher::Dispatcher(const std::string &localUserName
, const std::string &sharedFolder
, const filesystem::path &rootDir
- , Ccnx::CcnxWrapperPtr ccnx
+ , Ndnx::NdnxWrapperPtr ndnx
, bool enablePrefixDiscovery
)
- : m_ccnx(ccnx)
+ : m_ndnx(ndnx)
, m_core(NULL)
, m_rootDir(rootDir)
, m_executor(1) // creates problems with file assembly. need to ensure somehow that FinishExectute is called after all Segment_Execute finished
- , m_objectManager(ccnx, rootDir, CHRONOSHARE_APP)
+ , m_objectManager(ndnx, rootDir, CHRONOSHARE_APP)
, m_localUserName(localUserName)
, m_sharedFolder(sharedFolder)
, m_server(NULL)
, m_enablePrefixDiscovery(enablePrefixDiscovery)
{
m_syncLog = make_shared<SyncLog>(m_rootDir, localUserName);
- m_actionLog = make_shared<ActionLog>(m_ccnx, m_rootDir, m_syncLog, sharedFolder, CHRONOSHARE_APP,
+ m_actionLog = make_shared<ActionLog>(m_ndnx, m_rootDir, m_syncLog, sharedFolder, CHRONOSHARE_APP,
// bind (&Dispatcher::Did_ActionLog_ActionApply_AddOrModify, this, _1, _2, _3, _4, _5, _6, _7),
ActionLog::OnFileAddedOrChangedCallback (), // don't really need this callback
bind (&Dispatcher::Did_ActionLog_ActionApply_Delete, this, _1));
@@ -65,25 +65,25 @@
Name syncPrefix = Name(BROADCAST_DOMAIN)(CHRONOSHARE_APP)(sharedFolder);
- // m_server needs a different ccnx face
- m_server = new ContentServer(make_shared<CcnxWrapper>(), m_actionLog, rootDir, m_localUserName, m_sharedFolder, CHRONOSHARE_APP, CONTENT_FRESHNESS);
+ // m_server needs a different ndnx face
+ m_server = new ContentServer(make_shared<NdnxWrapper>(), m_actionLog, rootDir, m_localUserName, m_sharedFolder, CHRONOSHARE_APP, CONTENT_FRESHNESS);
m_server->registerPrefix(Name("/"));
m_server->registerPrefix(Name(BROADCAST_DOMAIN));
- m_stateServer = new StateServer (make_shared<CcnxWrapper>(), m_actionLog, rootDir, m_localUserName, m_sharedFolder, CHRONOSHARE_APP, m_objectManager, CONTENT_FRESHNESS);
+ m_stateServer = new StateServer (make_shared<NdnxWrapper>(), m_actionLog, rootDir, m_localUserName, m_sharedFolder, CHRONOSHARE_APP, m_objectManager, CONTENT_FRESHNESS);
// no need to register, right now only listening on localhost prefix
m_core = new SyncCore (m_syncLog, localUserName, Name("/"), syncPrefix,
- bind(&Dispatcher::Did_SyncLog_StateChange, this, _1), ccnx, DEFAULT_SYNC_INTEREST_INTERVAL);
+ bind(&Dispatcher::Did_SyncLog_StateChange, this, _1), ndnx, DEFAULT_SYNC_INTEREST_INTERVAL);
FetchTaskDbPtr actionTaskDb = make_shared<FetchTaskDb>(m_rootDir, "action");
- m_actionFetcher = make_shared<FetchManager> (m_ccnx, bind (&SyncLog::LookupLocator, &*m_syncLog, _1),
+ m_actionFetcher = make_shared<FetchManager> (m_ndnx, bind (&SyncLog::LookupLocator, &*m_syncLog, _1),
Name(BROADCAST_DOMAIN), // no appname suffix now
3,
bind (&Dispatcher::Did_FetchManager_ActionFetch, this, _1, _2, _3, _4), FetchManager::FinishCallback(), actionTaskDb);
FetchTaskDbPtr fileTaskDb = make_shared<FetchTaskDb>(m_rootDir, "file");
- m_fileFetcher = make_shared<FetchManager> (m_ccnx, bind (&SyncLog::LookupLocator, &*m_syncLog, _1),
+ m_fileFetcher = make_shared<FetchManager> (m_ndnx, bind (&SyncLog::LookupLocator, &*m_syncLog, _1),
Name(BROADCAST_DOMAIN), // no appname suffix now
3,
bind (&Dispatcher::Did_FetchManager_FileSegmentFetch, this, _1, _2, _3, _4),
@@ -95,7 +95,7 @@
{
_LOG_DEBUG("registering prefix discovery in Dispatcher");
string tag = "dispatcher" + m_localUserName.toString();
- Ccnx::CcnxDiscovery::registerCallback (TaggedFunction (bind (&Dispatcher::Did_LocalPrefix_Updated, this, _1), tag));
+ Ndnx::NdnxDiscovery::registerCallback (TaggedFunction (bind (&Dispatcher::Did_LocalPrefix_Updated, this, _1), tag));
}
m_executor.start ();
@@ -112,7 +112,7 @@
{
_LOG_DEBUG("deregistering prefix discovery in Dispatcher");
string tag = "dispatcher" + m_localUserName.toString();
- Ccnx::CcnxDiscovery::deregisterCallback (TaggedFunction (bind (&Dispatcher::Did_LocalPrefix_Updated, this, _1), tag));
+ Ndnx::NdnxDiscovery::deregisterCallback (TaggedFunction (bind (&Dispatcher::Did_LocalPrefix_Updated, this, _1), tag));
}
if (m_core != NULL)
@@ -135,7 +135,7 @@
}
void
-Dispatcher::Did_LocalPrefix_Updated (const Ccnx::Name &forwardingHint)
+Dispatcher::Did_LocalPrefix_Updated (const Ndnx::Name &forwardingHint)
{
Name effectiveForwardingHint;
if (m_localUserName.size () >= forwardingHint.size () &&
@@ -323,7 +323,7 @@
void
-Dispatcher::Did_FetchManager_ActionFetch (const Ccnx::Name &deviceName, const Ccnx::Name &actionBaseName, uint32_t seqno, Ccnx::PcoPtr actionPco)
+Dispatcher::Did_FetchManager_ActionFetch (const Ndnx::Name &deviceName, const Ndnx::Name &actionBaseName, uint32_t seqno, Ndnx::PcoPtr actionPco)
{
/// @todo Errors and exception checking
_LOG_DEBUG ("Received action deviceName: " << deviceName << ", actionBaseName: " << actionBaseName << ", seqno: " << seqno);
@@ -406,13 +406,13 @@
}
void
-Dispatcher::Did_FetchManager_FileSegmentFetch (const Ccnx::Name &deviceName, const Ccnx::Name &fileSegmentBaseName, uint32_t segment, Ccnx::PcoPtr fileSegmentPco)
+Dispatcher::Did_FetchManager_FileSegmentFetch (const Ndnx::Name &deviceName, const Ndnx::Name &fileSegmentBaseName, uint32_t segment, Ndnx::PcoPtr fileSegmentPco)
{
m_executor.execute (bind (&Dispatcher::Did_FetchManager_FileSegmentFetch_Execute, this, deviceName, fileSegmentBaseName, segment, fileSegmentPco));
}
void
-Dispatcher::Did_FetchManager_FileSegmentFetch_Execute (Ccnx::Name deviceName, Ccnx::Name fileSegmentBaseName, uint32_t segment, Ccnx::PcoPtr fileSegmentPco)
+Dispatcher::Did_FetchManager_FileSegmentFetch_Execute (Ndnx::Name deviceName, Ndnx::Name fileSegmentBaseName, uint32_t segment, Ndnx::PcoPtr fileSegmentPco)
{
// fileSegmentBaseName: /<device_name>/<appname>/file/<hash>
@@ -438,13 +438,13 @@
}
void
-Dispatcher::Did_FetchManager_FileFetchComplete (const Ccnx::Name &deviceName, const Ccnx::Name &fileBaseName)
+Dispatcher::Did_FetchManager_FileFetchComplete (const Ndnx::Name &deviceName, const Ndnx::Name &fileBaseName)
{
m_executor.execute (bind (&Dispatcher::Did_FetchManager_FileFetchComplete_Execute, this, deviceName, fileBaseName));
}
void
-Dispatcher::Did_FetchManager_FileFetchComplete_Execute (Ccnx::Name deviceName, Ccnx::Name fileBaseName)
+Dispatcher::Did_FetchManager_FileFetchComplete_Execute (Ndnx::Name deviceName, Ndnx::Name fileBaseName)
{
// fileBaseName: /<device_name>/<appname>/file/<hash>
@@ -472,7 +472,7 @@
{
m_fileStateCow->UpdateFile (file->filename(), file->version(),
Hash(file->file_hash ().c_str(), file->file_hash ().size ()),
- CcnxCharbuf (file->device_name().c_str(), file->device_name().size()), file->seq_no(),
+ NdnxCharbuf (file->device_name().c_str(), file->device_name().size()), file->seq_no(),
file->mtime(), file->mtime(), file->mtime(),
file->mode(), file->seg_num());
diff --git a/src/dispatcher.h b/src/dispatcher.h
index d5c0f30..4938174 100644
--- a/src/dispatcher.h
+++ b/src/dispatcher.h
@@ -24,7 +24,7 @@
#include "action-log.h"
#include "sync-core.h"
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include "executor.h"
#include "object-db.h"
#include "object-manager.h"
@@ -50,7 +50,7 @@
Dispatcher(const std::string &localUserName
, const std::string &sharedFolder
, const boost::filesystem::path &rootDir
- , Ccnx::CcnxWrapperPtr ccnx
+ , Ndnx::NdnxWrapperPtr ndnx
, bool enablePrefixDiscovery = true
);
~Dispatcher();
@@ -113,7 +113,7 @@
Did_SyncLog_StateChange_Execute (SyncStateMsgPtr stateMsg);
void
- Did_FetchManager_ActionFetch (const Ccnx::Name &deviceName, const Ccnx::Name &actionName, uint32_t seqno, Ccnx::PcoPtr actionPco);
+ Did_FetchManager_ActionFetch (const Ndnx::Name &deviceName, const Ndnx::Name &actionName, uint32_t seqno, Ndnx::PcoPtr actionPco);
void
Did_ActionLog_ActionApply_Delete (const std::string &filename);
@@ -122,27 +122,27 @@
Did_ActionLog_ActionApply_Delete_Execute (std::string filename);
// void
- // Did_ActionLog_ActionApply_AddOrModify (const std::string &filename, Ccnx::Name device_name, sqlite3_int64 seq_no,
+ // Did_ActionLog_ActionApply_AddOrModify (const std::string &filename, Ndnx::Name device_name, sqlite3_int64 seq_no,
// HashPtr hash, time_t m_time, int mode, int seg_num);
void
- Did_FetchManager_FileSegmentFetch (const Ccnx::Name &deviceName, const Ccnx::Name &fileSegmentName, uint32_t segment, Ccnx::PcoPtr fileSegmentPco);
+ Did_FetchManager_FileSegmentFetch (const Ndnx::Name &deviceName, const Ndnx::Name &fileSegmentName, uint32_t segment, Ndnx::PcoPtr fileSegmentPco);
void
- Did_FetchManager_FileSegmentFetch_Execute (Ccnx::Name deviceName, Ccnx::Name fileSegmentName, uint32_t segment, Ccnx::PcoPtr fileSegmentPco);
+ Did_FetchManager_FileSegmentFetch_Execute (Ndnx::Name deviceName, Ndnx::Name fileSegmentName, uint32_t segment, Ndnx::PcoPtr fileSegmentPco);
void
- Did_FetchManager_FileFetchComplete (const Ccnx::Name &deviceName, const Ccnx::Name &fileBaseName);
+ Did_FetchManager_FileFetchComplete (const Ndnx::Name &deviceName, const Ndnx::Name &fileBaseName);
void
- Did_FetchManager_FileFetchComplete_Execute (Ccnx::Name deviceName, Ccnx::Name fileBaseName);
+ Did_FetchManager_FileFetchComplete_Execute (Ndnx::Name deviceName, Ndnx::Name fileBaseName);
void
- Did_LocalPrefix_Updated (const Ccnx::Name &prefix);
+ Did_LocalPrefix_Updated (const Ndnx::Name &prefix);
private:
void
- AssembleFile_Execute (const Ccnx::Name &deviceName, const Hash &filehash, const boost::filesystem::path &relativeFilepath);
+ AssembleFile_Execute (const Ndnx::Name &deviceName, const Hash &filehash, const boost::filesystem::path &relativeFilepath);
// void
// fileChanged(const boost::filesystem::path &relativeFilepath, ActionType type);
@@ -154,13 +154,13 @@
// actionReceived(const ActionItemPtr &actionItem);
// void
- // fileSegmentReceived(const Ccnx::Name &name, const Ccnx::Bytes &content);
+ // fileSegmentReceived(const Ndnx::Name &name, const Ndnx::Bytes &content);
// void
- // fileReady(const Ccnx::Name &fileNamePrefix);
+ // fileReady(const Ndnx::Name &fileNamePrefix);
private:
- Ccnx::CcnxWrapperPtr m_ccnx;
+ Ndnx::NdnxWrapperPtr m_ndnx;
SyncCore *m_core;
SyncLogPtr m_syncLog;
ActionLogPtr m_actionLog;
@@ -170,7 +170,7 @@
boost::filesystem::path m_rootDir;
Executor m_executor;
ObjectManager m_objectManager;
- Ccnx::Name m_localUserName;
+ Ndnx::Name m_localUserName;
// maintain object db ptrs so that we don't need to create them
// for every fetched segment of a file
diff --git a/src/fetch-manager.cc b/src/fetch-manager.cc
index a5a2bc2..034b9d6 100644
--- a/src/fetch-manager.cc
+++ b/src/fetch-manager.cc
@@ -32,14 +32,14 @@
using namespace boost;
using namespace std;
-using namespace Ccnx;
+using namespace Ndnx;
//The disposer object function
struct fetcher_disposer { void operator() (Fetcher *delete_this) { delete delete_this; } };
static const string SCHEDULE_FETCHES_TAG = "ScheduleFetches";
-FetchManager::FetchManager (Ccnx::CcnxWrapperPtr ccnx,
+FetchManager::FetchManager (Ndnx::NdnxWrapperPtr ndnx,
const Mapping &mapping,
const Name &broadcastForwardingHint,
uint32_t parallelFetches, // = 3
@@ -47,7 +47,7 @@
const FinishCallback &defaultFinishCallback,
const FetchTaskDbPtr &taskDb
)
- : m_ccnx (ccnx)
+ : m_ndnx (ndnx)
, m_mapping (mapping)
, m_maxParallelFetches (parallelFetches)
, m_currentParallelFetches (0)
@@ -76,21 +76,21 @@
m_scheduler->shutdown ();
m_executor->shutdown();
- m_ccnx.reset ();
+ m_ndnx.reset ();
m_fetchList.clear_and_dispose (fetcher_disposer ());
}
// Enqueue using default callbacks
void
-FetchManager::Enqueue (const Ccnx::Name &deviceName, const Ccnx::Name &baseName,
+FetchManager::Enqueue (const Ndnx::Name &deviceName, const Ndnx::Name &baseName,
uint64_t minSeqNo, uint64_t maxSeqNo, int priority)
{
Enqueue(deviceName, baseName, m_defaultSegmentCallback, m_defaultFinishCallback, minSeqNo, maxSeqNo, priority);
}
void
-FetchManager::Enqueue (const Ccnx::Name &deviceName, const Ccnx::Name &baseName,
+FetchManager::Enqueue (const Ndnx::Name &deviceName, const Ndnx::Name &baseName,
const SegmentCallback &segmentCallback, const FinishCallback &finishCallback,
uint64_t minSeqNo, uint64_t maxSeqNo, int priority/*PRIORITY_NORMAL*/)
{
@@ -112,7 +112,7 @@
unique_lock<mutex> lock (m_parellelFetchMutex);
_LOG_TRACE ("++++ Create fetcher: " << baseName);
- Fetcher *fetcher = new Fetcher (m_ccnx,
+ Fetcher *fetcher = new Fetcher (m_ndnx,
m_executor,
segmentCallback,
finishCallback,
diff --git a/src/fetch-manager.h b/src/fetch-manager.h
index ecf2286..06f6687 100644
--- a/src/fetch-manager.h
+++ b/src/fetch-manager.h
@@ -30,7 +30,7 @@
#include <stdint.h>
#include "scheduler.h"
#include "executor.h"
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include "fetch-task-db.h"
#include "fetcher.h"
@@ -44,12 +44,12 @@
PRIORITY_HIGH
};
- typedef boost::function<Ccnx::Name(const Ccnx::Name &)> Mapping;
- typedef boost::function<void(Ccnx::Name &deviceName, Ccnx::Name &baseName, uint64_t seq, Ccnx::PcoPtr pco)> SegmentCallback;
- typedef boost::function<void(Ccnx::Name &deviceName, Ccnx::Name &baseName)> FinishCallback;
- FetchManager (Ccnx::CcnxWrapperPtr ccnx,
+ typedef boost::function<Ndnx::Name(const Ndnx::Name &)> Mapping;
+ typedef boost::function<void(Ndnx::Name &deviceName, Ndnx::Name &baseName, uint64_t seq, Ndnx::PcoPtr pco)> SegmentCallback;
+ typedef boost::function<void(Ndnx::Name &deviceName, Ndnx::Name &baseName)> FinishCallback;
+ FetchManager (Ndnx::NdnxWrapperPtr ndnx,
const Mapping &mapping,
- const Ccnx::Name &broadcastForwardingHint,
+ const Ndnx::Name &broadcastForwardingHint,
uint32_t parallelFetches = 3,
const SegmentCallback &defaultSegmentCallback = SegmentCallback(),
const FinishCallback &defaultFinishCallback = FinishCallback(),
@@ -58,30 +58,30 @@
virtual ~FetchManager ();
void
- Enqueue (const Ccnx::Name &deviceName, const Ccnx::Name &baseName,
+ Enqueue (const Ndnx::Name &deviceName, const Ndnx::Name &baseName,
const SegmentCallback &segmentCallback, const FinishCallback &finishCallback,
uint64_t minSeqNo, uint64_t maxSeqNo, int priority=PRIORITY_NORMAL);
// Enqueue using default callbacks
void
- Enqueue (const Ccnx::Name &deviceName, const Ccnx::Name &baseName,
+ Enqueue (const Ndnx::Name &deviceName, const Ndnx::Name &baseName,
uint64_t minSeqNo, uint64_t maxSeqNo, int priority=PRIORITY_NORMAL);
// only for Fetcher
- inline Ccnx::CcnxWrapperPtr
- GetCcnx ();
+ inline Ndnx::NdnxWrapperPtr
+ GetNdnx ();
private:
// Fetch Events
void
- DidDataSegmentFetched (Fetcher &fetcher, uint64_t seqno, const Ccnx::Name &basename,
- const Ccnx::Name &name, Ccnx::PcoPtr data);
+ DidDataSegmentFetched (Fetcher &fetcher, uint64_t seqno, const Ndnx::Name &basename,
+ const Ndnx::Name &name, Ndnx::PcoPtr data);
void
DidNoDataTimeout (Fetcher &fetcher);
void
- DidFetchComplete (Fetcher &fetcher, const Ccnx::Name &deviceName, const Ccnx::Name &baseName);
+ DidFetchComplete (Fetcher &fetcher, const Ndnx::Name &deviceName, const Ndnx::Name &baseName);
void
ScheduleFetches ();
@@ -90,7 +90,7 @@
TimedWait (Fetcher &fetcher);
private:
- Ccnx::CcnxWrapperPtr m_ccnx;
+ Ndnx::NdnxWrapperPtr m_ndnx;
Mapping m_mapping;
uint32_t m_maxParallelFetches;
@@ -110,13 +110,13 @@
FinishCallback m_defaultFinishCallback;
FetchTaskDbPtr m_taskDb;
- const Ccnx::Name m_broadcastHint;
+ const Ndnx::Name m_broadcastHint;
};
-Ccnx::CcnxWrapperPtr
-FetchManager::GetCcnx ()
+Ndnx::NdnxWrapperPtr
+FetchManager::GetNdnx ()
{
- return m_ccnx;
+ return m_ndnx;
}
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
diff --git a/src/fetch-task-db.cc b/src/fetch-task-db.cc
index 11ae6c9..3141048 100644
--- a/src/fetch-task-db.cc
+++ b/src/fetch-task-db.cc
@@ -23,7 +23,7 @@
using namespace std;
using namespace boost;
-using namespace Ccnx;
+using namespace Ndnx;
namespace fs = boost::filesystem;
const string INIT_DATABASE = "\
@@ -76,8 +76,8 @@
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2(m_db, "INSERT OR IGNORE INTO Task (deviceName, baseName, minSeqNo, maxSeqNo, priority) VALUES (?, ?, ?, ?, ?)", -1, &stmt, 0);
- CcnxCharbufPtr deviceBuf = CcnxCharbufPtr(deviceName);
- CcnxCharbufPtr baseBuf = CcnxCharbufPtr(baseName);
+ NdnxCharbufPtr deviceBuf = NdnxCharbufPtr(deviceName);
+ NdnxCharbufPtr baseBuf = NdnxCharbufPtr(baseName);
sqlite3_bind_blob(stmt, 1, deviceBuf->buf(), deviceBuf->length(), SQLITE_STATIC);
sqlite3_bind_blob(stmt, 2, baseBuf->buf(), baseBuf->length(), SQLITE_STATIC);
sqlite3_bind_int64(stmt, 3, minSeqNo);
@@ -96,8 +96,8 @@
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2(m_db, "DELETE FROM Task WHERE deviceName = ? AND baseName = ?;", -1, &stmt, 0);
- CcnxCharbufPtr deviceBuf = CcnxCharbufPtr(deviceName);
- CcnxCharbufPtr baseBuf = CcnxCharbufPtr(baseName);
+ NdnxCharbufPtr deviceBuf = NdnxCharbufPtr(deviceName);
+ NdnxCharbufPtr baseBuf = NdnxCharbufPtr(baseName);
sqlite3_bind_blob(stmt, 1, deviceBuf->buf(), deviceBuf->length(), SQLITE_STATIC);
sqlite3_bind_blob(stmt, 2, baseBuf->buf(), baseBuf->length(), SQLITE_STATIC);
int res = sqlite3_step(stmt);
diff --git a/src/fetch-task-db.h b/src/fetch-task-db.h
index 1f8e16a..46140d6 100644
--- a/src/fetch-task-db.h
+++ b/src/fetch-task-db.h
@@ -22,8 +22,8 @@
#define FETCH_TASK_DB_H
#include <sqlite3.h>
-#include <ccnx-common.h>
-#include <ccnx-name.h>
+#include <ndnx-common.h>
+#include <ndnx-name.h>
#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>
@@ -36,12 +36,12 @@
// task with same deviceName and baseName combination will be added only once
// if task already exists, this call does nothing
void
- addTask(const Ccnx::Name &deviceName, const Ccnx::Name &baseName, uint64_t minSeqNo, uint64_t maxSeqNo, int priority);
+ addTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName, uint64_t minSeqNo, uint64_t maxSeqNo, int priority);
void
- deleteTask(const Ccnx::Name &deviceName, const Ccnx::Name &baseName);
+ deleteTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName);
- typedef boost::function<void(const Ccnx::Name &, const Ccnx::Name &, uint64_t, uint64_t, int)> FetchTaskCallback;
+ typedef boost::function<void(const Ndnx::Name &, const Ndnx::Name &, uint64_t, uint64_t, int)> FetchTaskCallback;
void
foreachTask(const FetchTaskCallback &callback);
diff --git a/src/fetcher.cc b/src/fetcher.cc
index 87b0898..0991bbe 100644
--- a/src/fetcher.cc
+++ b/src/fetcher.cc
@@ -21,7 +21,7 @@
#include "fetcher.h"
#include "fetch-manager.h"
-#include "ccnx-pco.h"
+#include "ndnx-pco.h"
#include "logging.h"
#include <boost/make_shared.hpp>
@@ -33,17 +33,17 @@
using namespace boost;
using namespace std;
-using namespace Ccnx;
+using namespace Ndnx;
-Fetcher::Fetcher (Ccnx::CcnxWrapperPtr ccnx,
+Fetcher::Fetcher (Ndnx::NdnxWrapperPtr ndnx,
ExecutorPtr executor,
const SegmentCallback &segmentCallback,
const FinishCallback &finishCallback,
OnFetchCompleteCallback onFetchComplete, OnFetchFailedCallback onFetchFailed,
- const Ccnx::Name &deviceName, const Ccnx::Name &name, int64_t minSeqNo, int64_t maxSeqNo,
+ const Ndnx::Name &deviceName, const Ndnx::Name &name, int64_t minSeqNo, int64_t maxSeqNo,
boost::posix_time::time_duration timeout/* = boost::posix_time::seconds (30)*/,
- const Ccnx::Name &forwardingHint/* = Ccnx::Name ()*/)
- : m_ccnx (ccnx)
+ const Ndnx::Name &forwardingHint/* = Ndnx::Name ()*/)
+ : m_ndnx (ndnx)
, m_segmentCallback (segmentCallback)
, m_onFetchComplete (onFetchComplete)
@@ -93,7 +93,7 @@
}
void
-Fetcher::SetForwardingHint (const Ccnx::Name &forwardingHint)
+Fetcher::SetForwardingHint (const Ndnx::Name &forwardingHint)
{
m_forwardingHint = forwardingHint;
}
@@ -116,7 +116,7 @@
_LOG_DEBUG (" >>> i " << Name (m_forwardingHint)(m_name) << ", seq = " << (m_minSendSeqNo + 1 ));
// cout << ">>> " << m_minSendSeqNo+1 << endl;
- m_ccnx->sendInterest (Name (m_forwardingHint)(m_name)(m_minSendSeqNo+1),
+ m_ndnx->sendInterest (Name (m_forwardingHint)(m_name)(m_minSendSeqNo+1),
Closure (bind(&Fetcher::OnData, this, m_minSendSeqNo+1, _1, _2),
bind(&Fetcher::OnTimeout, this, m_minSendSeqNo+1, _1, _2, _3)),
Selectors().interestLifetime (m_rto)); // Alex: this lifetime should be changed to RTO
@@ -127,13 +127,13 @@
}
void
-Fetcher::OnData (uint64_t seqno, const Ccnx::Name &name, PcoPtr data)
+Fetcher::OnData (uint64_t seqno, const Ndnx::Name &name, PcoPtr data)
{
m_executor->execute (bind (&Fetcher::OnData_Execute, this, seqno, name, data));
}
void
-Fetcher::OnData_Execute (uint64_t seqno, Ccnx::Name name, Ccnx::PcoPtr data)
+Fetcher::OnData_Execute (uint64_t seqno, Ndnx::Name name, Ndnx::PcoPtr data)
{
_LOG_DEBUG (" <<< d " << name.getPartialName (0, name.size () - 1) << ", seq = " << seqno);
@@ -156,7 +156,7 @@
}
else
{
- // in this case we don't care whether "data" is verified, in fact, we expect it is unverified
+ // in this case we don't care whether "data" is verified, in fact, we expect it is unverified
try {
PcoPtr pco = make_shared<ParsedContentObject> (*data->contentPtr ());
@@ -260,14 +260,14 @@
}
void
-Fetcher::OnTimeout (uint64_t seqno, const Ccnx::Name &name, const Closure &closure, Selectors selectors)
+Fetcher::OnTimeout (uint64_t seqno, const Ndnx::Name &name, const Closure &closure, Selectors selectors)
{
_LOG_DEBUG (this << ", " << m_executor.get ());
m_executor->execute (bind (&Fetcher::OnTimeout_Execute, this, seqno, name, closure, selectors));
}
void
-Fetcher::OnTimeout_Execute (uint64_t seqno, Ccnx::Name name, Ccnx::Closure closure, Ccnx::Selectors selectors)
+Fetcher::OnTimeout_Execute (uint64_t seqno, Ndnx::Name name, Ndnx::Closure closure, Ndnx::Selectors selectors)
{
_LOG_DEBUG (" <<< :( timeout " << name.getPartialName (0, name.size () - 1) << ", seq = " << seqno);
@@ -318,11 +318,11 @@
{
m_rto = m_maxRto;
_LOG_DEBUG ("RTO is max: " << m_rto);
- }
+ }
else
{
_LOG_DEBUG ("RTO is doubled: " << m_rto);
- }
+}
}
{
@@ -333,6 +333,6 @@
m_slowStart = true;
}
- m_ccnx->sendInterest (name, closure, selectors.interestLifetime (m_rto));
+ m_ndnx->sendInterest (name, closure, selectors.interestLifetime (m_rto));
}
}
diff --git a/src/fetcher.h b/src/fetcher.h
index 1bc5d03..c62a4b4 100644
--- a/src/fetcher.h
+++ b/src/fetcher.h
@@ -22,8 +22,8 @@
#ifndef FETCHER_H
#define FETCHER_H
-#include "ccnx-wrapper.h"
-#include "ccnx-name.h"
+#include "ndnx-wrapper.h"
+#include "ndnx-name.h"
#include "executor.h"
#include <boost/intrusive/list.hpp>
@@ -37,20 +37,20 @@
class Fetcher
{
public:
- typedef boost::function<void(Ccnx::Name &deviceName, Ccnx::Name &baseName, uint64_t seq, Ccnx::PcoPtr pco)> SegmentCallback;
- typedef boost::function<void(Ccnx::Name &deviceName, Ccnx::Name &baseName)> FinishCallback;
- typedef boost::function<void (Fetcher &, const Ccnx::Name &deviceName, const Ccnx::Name &baseName)> OnFetchCompleteCallback;
+ typedef boost::function<void(Ndnx::Name &deviceName, Ndnx::Name &baseName, uint64_t seq, Ndnx::PcoPtr pco)> SegmentCallback;
+ typedef boost::function<void(Ndnx::Name &deviceName, Ndnx::Name &baseName)> FinishCallback;
+ typedef boost::function<void (Fetcher &, const Ndnx::Name &deviceName, const Ndnx::Name &baseName)> OnFetchCompleteCallback;
typedef boost::function<void (Fetcher &)> OnFetchFailedCallback;
- Fetcher (Ccnx::CcnxWrapperPtr ccnx,
+ Fetcher (Ndnx::NdnxWrapperPtr ndnx,
ExecutorPtr executor,
const SegmentCallback &segmentCallback, // callback passed by caller of FetchManager
const FinishCallback &finishCallback, // callback passed by caller of FetchManager
OnFetchCompleteCallback onFetchComplete, OnFetchFailedCallback onFetchFailed, // callbacks provided by FetchManager
- const Ccnx::Name &deviceName, const Ccnx::Name &name, int64_t minSeqNo, int64_t maxSeqNo,
+ const Ndnx::Name &deviceName, const Ndnx::Name &name, int64_t minSeqNo, int64_t maxSeqNo,
boost::posix_time::time_duration timeout = boost::posix_time::seconds (30), // this time is not precise, but sets min bound
// actual time depends on how fast Interests timeout
- const Ccnx::Name &forwardingHint = Ccnx::Name ());
+ const Ndnx::Name &forwardingHint = Ndnx::Name ());
virtual ~Fetcher ();
inline bool
@@ -63,15 +63,15 @@
RestartPipeline ();
void
- SetForwardingHint (const Ccnx::Name &forwardingHint);
+ SetForwardingHint (const Ndnx::Name &forwardingHint);
- const Ccnx::Name &
+ const Ndnx::Name &
GetForwardingHint () const { return m_forwardingHint; }
- const Ccnx::Name &
+ const Ndnx::Name &
GetName () const { return m_name; }
- const Ccnx::Name &
+ const Ndnx::Name &
GetDeviceName () const { return m_deviceName; }
double
@@ -91,22 +91,22 @@
FillPipeline ();
void
- OnData (uint64_t seqno, const Ccnx::Name &name, Ccnx::PcoPtr data);
+ OnData (uint64_t seqno, const Ndnx::Name &name, Ndnx::PcoPtr data);
void
- OnData_Execute (uint64_t seqno, Ccnx::Name name, Ccnx::PcoPtr data);
+ OnData_Execute (uint64_t seqno, Ndnx::Name name, Ndnx::PcoPtr data);
void
- OnTimeout (uint64_t seqno, const Ccnx::Name &name, const Ccnx::Closure &closure, Ccnx::Selectors selectors);
+ OnTimeout (uint64_t seqno, const Ndnx::Name &name, const Ndnx::Closure &closure, Ndnx::Selectors selectors);
void
- OnTimeout_Execute (uint64_t seqno, Ccnx::Name name, Ccnx::Closure closure, Ccnx::Selectors selectors);
+ OnTimeout_Execute (uint64_t seqno, Ndnx::Name name, Ndnx::Closure closure, Ndnx::Selectors selectors);
public:
boost::intrusive::list_member_hook<> m_managerListHook;
private:
- Ccnx::CcnxWrapperPtr m_ccnx;
+ Ndnx::NdnxWrapperPtr m_ndnx;
SegmentCallback m_segmentCallback;
OnFetchCompleteCallback m_onFetchComplete;
@@ -117,9 +117,9 @@
bool m_active;
bool m_timedwait;
- Ccnx::Name m_name;
- Ccnx::Name m_deviceName;
- Ccnx::Name m_forwardingHint;
+ Ndnx::Name m_name;
+ Ndnx::Name m_deviceName;
+ Ndnx::Name m_forwardingHint;
boost::posix_time::time_duration m_maximumNoActivityPeriod;
diff --git a/src/file-state.cc b/src/file-state.cc
index fa998de..6affed9 100644
--- a/src/file-state.cc
+++ b/src/file-state.cc
@@ -65,7 +65,7 @@
void
FileState::UpdateFile (const std::string &filename, sqlite3_int64 version,
- const Hash &hash, const Ccnx::CcnxCharbuf &device_name, sqlite3_int64 seq_no,
+ const Hash &hash, const Ndnx::NdnxCharbuf &device_name, sqlite3_int64 seq_no,
time_t atime, time_t mtime, time_t ctime, int mode, int seg_num)
{
sqlite3_stmt *stmt;
diff --git a/src/file-state.h b/src/file-state.h
index b0890a2..f5617d4 100644
--- a/src/file-state.h
+++ b/src/file-state.h
@@ -24,7 +24,7 @@
#include "db-helper.h"
-#include "ccnx-name.h"
+#include "ndnx-name.h"
#include "file-item.pb.h"
#include "hash-helper.h"
@@ -49,7 +49,7 @@
*/
void
UpdateFile (const std::string &filename, sqlite3_int64 version,
- const Hash &hash, const Ccnx::CcnxCharbuf &device_name, sqlite3_int64 seqno,
+ const Hash &hash, const Ndnx::NdnxCharbuf &device_name, sqlite3_int64 seqno,
time_t atime, time_t mtime, time_t ctime, int mode, int seg_num);
/**
diff --git a/src/hash-helper.cc b/src/hash-helper.cc
index 11b29e2..1ee08c1 100644
--- a/src/hash-helper.cc
+++ b/src/hash-helper.cc
@@ -169,7 +169,7 @@
}
HashPtr
-Hash::FromBytes (const Ccnx::Bytes &bytes)
+Hash::FromBytes (const Ndnx::Bytes &bytes)
{
HashPtr retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
@@ -178,7 +178,7 @@
EVP_DigestInit_ex (hash_context, HASH_FUNCTION (), 0);
// not sure whether it's bad to do so if bytes.size is huge
- EVP_DigestUpdate(hash_context, Ccnx::head(bytes), bytes.size());
+ EVP_DigestUpdate(hash_context, Ndnx::head(bytes), bytes.size());
retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
diff --git a/src/hash-helper.h b/src/hash-helper.h
index 9050573..a2690ce 100644
--- a/src/hash-helper.h
+++ b/src/hash-helper.h
@@ -27,7 +27,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/exception/all.hpp>
#include <boost/filesystem.hpp>
-#include "ccnx-common.h"
+#include "ndnx-common.h"
// Other options: VP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_sha256, EVP_dss, EVP_dss1, EVP_mdc2, EVP_ripemd160
#define HASH_FUNCTION EVP_sha256
@@ -74,7 +74,7 @@
FromFileContent (const boost::filesystem::path &fileName);
static HashPtr
- FromBytes (const Ccnx::Bytes &bytes);
+ FromBytes (const Ndnx::Bytes &bytes);
~Hash ()
{
diff --git a/src/object-db.cc b/src/object-db.cc
index 05aca34..276441b 100644
--- a/src/object-db.cc
+++ b/src/object-db.cc
@@ -29,7 +29,7 @@
INIT_LOGGER ("Object.Db");
using namespace std;
-using namespace Ccnx;
+using namespace Ndnx;
using namespace boost;
namespace fs = boost::filesystem;
@@ -78,7 +78,7 @@
}
bool
-ObjectDb::DoesExist (const boost::filesystem::path &folder, const Ccnx::Name &deviceName, const std::string &hash)
+ObjectDb::DoesExist (const boost::filesystem::path &folder, const Ndnx::Name &deviceName, const std::string &hash)
{
fs::path actualFolder = folder / "objects" / hash.substr (0, 2);
bool retval = false;
@@ -90,7 +90,7 @@
sqlite3_stmt *stmt;
sqlite3_prepare_v2 (db, "SELECT count(*), count(nullif(content_object,0)) FROM File WHERE device_name=?", -1, &stmt, 0);
- CcnxCharbufPtr buf = deviceName.toCcnxCharbuf ();
+ NdnxCharbufPtr buf = deviceName.toNdnxCharbuf ();
sqlite3_bind_blob (stmt, 1, buf->buf (), buf->length (), SQLITE_TRANSIENT);
int res = sqlite3_step (stmt);
@@ -128,7 +128,7 @@
}
void
-ObjectDb::saveContentObject (const Ccnx::Name &deviceName, sqlite3_int64 segment, const Ccnx::Bytes &data)
+ObjectDb::saveContentObject (const Ndnx::Name &deviceName, sqlite3_int64 segment, const Ndnx::Bytes &data)
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2 (m_db, "INSERT INTO File "
@@ -137,7 +137,7 @@
//_LOG_DEBUG ("Saving content object for [" << deviceName << ", seqno: " << segment << ", size: " << data.size () << "]");
- CcnxCharbufPtr buf = deviceName.toCcnxCharbuf ();
+ NdnxCharbufPtr buf = deviceName.toNdnxCharbuf ();
sqlite3_bind_blob (stmt, 1, buf->buf (), buf->length (), SQLITE_STATIC);
sqlite3_bind_int64 (stmt, 2, segment);
sqlite3_bind_blob (stmt, 3, &data[0], data.size (), SQLITE_STATIC);
@@ -150,13 +150,13 @@
m_lastUsed = time(NULL);
}
-Ccnx::BytesPtr
-ObjectDb::fetchSegment (const Ccnx::Name &deviceName, sqlite3_int64 segment)
+Ndnx::BytesPtr
+ObjectDb::fetchSegment (const Ndnx::Name &deviceName, sqlite3_int64 segment)
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2 (m_db, "SELECT content_object FROM File WHERE device_name=? AND segment=?", -1, &stmt, 0);
- CcnxCharbufPtr buf = deviceName.toCcnxCharbuf ();
+ NdnxCharbufPtr buf = deviceName.toNdnxCharbuf ();
sqlite3_bind_blob (stmt, 1, buf->buf (), buf->length (), SQLITE_TRANSIENT);
sqlite3_bind_int64 (stmt, 2, segment);
@@ -186,7 +186,7 @@
}
// sqlite3_int64
-// ObjectDb::getNumberOfSegments (const Ccnx::Name &deviceName)
+// ObjectDb::getNumberOfSegments (const Ndnx::Name &deviceName)
// {
// sqlite3_stmt *stmt;
// sqlite3_prepare_v2 (m_db, "SELECT count(*) FROM File WHERE device_name=?", -1, &stmt, 0);
diff --git a/src/object-db.h b/src/object-db.h
index cabc46d..7e13203 100644
--- a/src/object-db.h
+++ b/src/object-db.h
@@ -24,8 +24,8 @@
#include <string>
#include <sqlite3.h>
-#include <ccnx-common.h>
-#include <ccnx-name.h>
+#include <ndnx-common.h>
+#include <ndnx-name.h>
#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>
#include <ctime>
@@ -39,19 +39,19 @@
~ObjectDb ();
void
- saveContentObject (const Ccnx::Name &deviceName, sqlite3_int64 segment, const Ccnx::Bytes &data);
+ saveContentObject (const Ndnx::Name &deviceName, sqlite3_int64 segment, const Ndnx::Bytes &data);
- Ccnx::BytesPtr
- fetchSegment (const Ccnx::Name &deviceName, sqlite3_int64 segment);
+ Ndnx::BytesPtr
+ fetchSegment (const Ndnx::Name &deviceName, sqlite3_int64 segment);
// sqlite3_int64
- // getNumberOfSegments (const Ccnx::Name &deviceName);
+ // getNumberOfSegments (const Ndnx::Name &deviceName);
time_t
secondsSinceLastUse();
static bool
- DoesExist (const boost::filesystem::path &folder, const Ccnx::Name &deviceName, const std::string &hash);
+ DoesExist (const boost::filesystem::path &folder, const Ndnx::Name &deviceName, const std::string &hash);
private:
void
diff --git a/src/object-manager.cc b/src/object-manager.cc
index fc50488..9b87853 100644
--- a/src/object-manager.cc
+++ b/src/object-manager.cc
@@ -20,9 +20,9 @@
*/
#include "object-manager.h"
-#include "ccnx-name.h"
-#include "ccnx-common.h"
-#include "ccnx-pco.h"
+#include "ndnx-name.h"
+#include "ndnx-common.h"
+#include "ndnx-pco.h"
#include "object-db.h"
#include "logging.h"
@@ -35,15 +35,15 @@
INIT_LOGGER ("Object.Manager");
-using namespace Ccnx;
+using namespace Ndnx;
using namespace boost;
using namespace std;
namespace fs = boost::filesystem;
const int MAX_FILE_SEGMENT_SIZE = 1024;
-ObjectManager::ObjectManager (Ccnx::CcnxWrapperPtr ccnx, const fs::path &folder, const std::string &appName)
- : m_ccnx (ccnx)
+ObjectManager::ObjectManager (Ndnx::NdnxWrapperPtr ndnx, const fs::path &folder, const std::string &appName)
+ : m_ndnx (ndnx)
, m_folder (folder / ".chronoshare")
, m_appName (appName)
{
@@ -56,7 +56,7 @@
// /<devicename>/<appname>/file/<hash>/<segment>
boost::tuple<HashPtr /*object-db name*/, size_t /* number of segments*/>
-ObjectManager::localFileToObjects (const fs::path &file, const Ccnx::Name &deviceName)
+ObjectManager::localFileToObjects (const fs::path &file, const Ndnx::Name &deviceName)
{
HashPtr fileHash = Hash::FromFileContent (file);
ObjectDb fileDb (m_folder, lexical_cast<string> (*fileHash));
@@ -79,7 +79,7 @@
// cout << name << endl;
//_LOG_DEBUG ("Read " << iff.gcount () << " from " << file << " for segment " << segment);
- Bytes data = m_ccnx->createContentObject (name, buf, iff.gcount ());
+ Bytes data = m_ndnx->createContentObject (name, buf, iff.gcount ());
fileDb.saveContentObject (deviceName, segment, data);
segment ++;
@@ -87,7 +87,7 @@
if (segment == 0) // handle empty files
{
Name name = Name ("/")(m_appName)("file")(fileHash->GetHash (), fileHash->GetHashBytes ())(deviceName)(0);
- Bytes data = m_ccnx->createContentObject (name, 0, 0);
+ Bytes data = m_ndnx->createContentObject (name, 0, 0);
fileDb.saveContentObject (deviceName, 0, data);
segment ++;
@@ -97,7 +97,7 @@
}
bool
-ObjectManager::objectsToLocalFile (/*in*/const Ccnx::Name &deviceName, /*in*/const Hash &fileHash, /*out*/ const fs::path &file)
+ObjectManager::objectsToLocalFile (/*in*/const Ndnx::Name &deviceName, /*in*/const Hash &fileHash, /*out*/ const fs::path &file)
{
string hashStr = lexical_cast<string> (fileHash);
if (!ObjectDb::DoesExist (m_folder, deviceName, hashStr))
diff --git a/src/object-manager.h b/src/object-manager.h
index 2d0cdd0..9f55822 100644
--- a/src/object-manager.h
+++ b/src/object-manager.h
@@ -23,7 +23,7 @@
#define OBJECT_MANAGER_H
#include <string>
-#include <ccnx-wrapper.h>
+#include <ndnx-wrapper.h>
#include <hash-helper.h>
#include <boost/filesystem.hpp>
#include <boost/tuple/tuple.hpp>
@@ -33,7 +33,7 @@
class ObjectManager
{
public:
- ObjectManager (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &folder, const std::string &appName);
+ ObjectManager (Ndnx::NdnxWrapperPtr ndnx, const boost::filesystem::path &folder, const std::string &appName);
virtual ~ObjectManager ();
/**
@@ -42,13 +42,13 @@
* Format: /<appname>/file/<hash>/<devicename>/<segment>
*/
boost::tuple<HashPtr /*object-db name*/, size_t /* number of segments*/>
- localFileToObjects (const boost::filesystem::path &file, const Ccnx::Name &deviceName);
+ localFileToObjects (const boost::filesystem::path &file, const Ndnx::Name &deviceName);
bool
- objectsToLocalFile (/*in*/const Ccnx::Name &deviceName, /*in*/const Hash &hash, /*out*/ const boost::filesystem::path &file);
+ objectsToLocalFile (/*in*/const Ndnx::Name &deviceName, /*in*/const Hash &hash, /*out*/ const boost::filesystem::path &file);
private:
- Ccnx::CcnxWrapperPtr m_ccnx;
+ Ndnx::NdnxWrapperPtr m_ndnx;
boost::filesystem::path m_folder;
std::string m_appName;
};
diff --git a/src/state-server.cc b/src/state-server.cc
index 2d1d96a..418f8da 100644
--- a/src/state-server.cc
+++ b/src/state-server.cc
@@ -31,17 +31,17 @@
INIT_LOGGER ("StateServer");
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
-StateServer::StateServer(CcnxWrapperPtr ccnx, ActionLogPtr actionLog,
+StateServer::StateServer(NdnxWrapperPtr ndnx, ActionLogPtr actionLog,
const boost::filesystem::path &rootDir,
- const Ccnx::Name &userName, const std::string &sharedFolderName,
+ const Ndnx::Name &userName, const std::string &sharedFolderName,
const std::string &appName,
ObjectManager &objectManager,
int freshness/* = -1*/)
- : m_ccnx(ccnx)
+ : m_ndnx(ndnx)
, m_actionLog(actionLog)
, m_objectManager (objectManager)
, m_rootDir(rootDir)
@@ -78,28 +78,28 @@
// will be extended to support all planned commands later
// <PREFIX_INFO>/"actions"/"all"/<segment> get list of all actions
- m_ccnx->setInterestFilter (Name (m_PREFIX_INFO)("actions")("folder"), bind(&StateServer::info_actions_folder, this, _1));
- m_ccnx->setInterestFilter (Name (m_PREFIX_INFO)("actions")("file"), bind(&StateServer::info_actions_file, this, _1));
+ m_ndnx->setInterestFilter (Name (m_PREFIX_INFO)("actions")("folder"), bind(&StateServer::info_actions_folder, this, _1));
+ m_ndnx->setInterestFilter (Name (m_PREFIX_INFO)("actions")("file"), bind(&StateServer::info_actions_file, this, _1));
// <PREFIX_INFO>/"filestate"/"all"/<segment>
- m_ccnx->setInterestFilter (Name (m_PREFIX_INFO)("files")("folder"), bind(&StateServer::info_files_folder, this, _1));
+ m_ndnx->setInterestFilter (Name (m_PREFIX_INFO)("files")("folder"), bind(&StateServer::info_files_folder, this, _1));
// <PREFIX_CMD>/"restore"/"file"/<one-component-relative-file-name>/<version>/<file-hash>
- m_ccnx->setInterestFilter (Name (m_PREFIX_CMD)("restore")("file"), bind(&StateServer::cmd_restore_file, this, _1));
+ m_ndnx->setInterestFilter (Name (m_PREFIX_CMD)("restore")("file"), bind(&StateServer::cmd_restore_file, this, _1));
}
void
StateServer::deregisterPrefixes ()
{
- m_ccnx->clearInterestFilter (Name (m_PREFIX_INFO)("actions")("folder"));
- m_ccnx->clearInterestFilter (Name (m_PREFIX_INFO)("actions")("file"));
- m_ccnx->clearInterestFilter (Name (m_PREFIX_INFO)("files")("folder"));
- m_ccnx->clearInterestFilter (Name (m_PREFIX_CMD) ("restore")("file"));
+ m_ndnx->clearInterestFilter (Name (m_PREFIX_INFO)("actions")("folder"));
+ m_ndnx->clearInterestFilter (Name (m_PREFIX_INFO)("actions")("file"));
+ m_ndnx->clearInterestFilter (Name (m_PREFIX_INFO)("files")("folder"));
+ m_ndnx->clearInterestFilter (Name (m_PREFIX_CMD) ("restore")("file"));
}
void
StateServer::formatActionJson (json_spirit::Array &actions,
- const Ccnx::Name &name, sqlite3_int64 seq_no, const ActionItem &action)
+ const Ndnx::Name &name, sqlite3_int64 seq_no, const ActionItem &action)
{
/*
* {
@@ -161,7 +161,7 @@
if (action.has_parent_device_name ())
{
Object parentId;
- Ccnx::Name parent_device_name (action.parent_device_name ().c_str (), action.parent_device_name ().size ());
+ Ndnx::Name parent_device_name (action.parent_device_name ().c_str (), action.parent_device_name ().size ());
id.push_back (Pair ("userName", boost::lexical_cast<string> (parent_device_name)));
id.push_back (Pair ("seqNo", action.parent_seq_no ()));
@@ -201,7 +201,7 @@
void
-StateServer::info_actions_fileOrFolder_Execute (const Ccnx::Name &interest, bool isFolder/* = true*/)
+StateServer::info_actions_fileOrFolder_Execute (const Ndnx::Name &interest, bool isFolder/* = true*/)
{
// <PREFIX_INFO>/"actions"/"folder|file"/<folder|file>/<offset> get list of all actions
@@ -250,18 +250,18 @@
if (more)
{
json.push_back (Pair ("more", lexical_cast<string> (offset + 1)));
- // Ccnx::Name more = Name (interest.getPartialName (0, interest.size () - 1))(offset + 1);
+ // Ndnx::Name more = Name (interest.getPartialName (0, interest.size () - 1))(offset + 1);
// json.push_back (Pair ("more", lexical_cast<string> (more)));
}
ostringstream os;
write_stream (Value (json), os, pretty_print | raw_utf8);
- m_ccnx->publishData (interest, os.str (), 1);
+ m_ndnx->publishData (interest, os.str (), 1);
}
- catch (Ccnx::NameException &ne)
+ catch (Ndnx::NameException &ne)
{
// ignore any unexpected interests and errors
- _LOG_ERROR (*boost::get_error_info<Ccnx::error_info_str>(ne));
+ _LOG_ERROR (*boost::get_error_info<Ndnx::error_info_str>(ne));
}
}
@@ -298,7 +298,7 @@
json.push_back (Pair ("version", file.version ()));
{
Object owner;
- Ccnx::Name device_name (file.device_name ().c_str (), file.device_name ().size ());
+ Ndnx::Name device_name (file.device_name ().c_str (), file.device_name ().size ());
owner.push_back (Pair ("userName", boost::lexical_cast<string> (device_name)));
owner.push_back (Pair ("seqNo", file.seq_no ()));
@@ -323,7 +323,7 @@
}
void
-StateServer::info_files_folder (const Ccnx::Name &interest)
+StateServer::info_files_folder (const Ndnx::Name &interest)
{
if (interest.size () - m_PREFIX_INFO.size () != 3 &&
interest.size () - m_PREFIX_INFO.size () != 4)
@@ -338,7 +338,7 @@
void
-StateServer::info_files_folder_Execute (const Ccnx::Name &interest)
+StateServer::info_files_folder_Execute (const Ndnx::Name &interest)
{
// <PREFIX_INFO>/"filestate"/"folder"/<one-component-relative-folder-name>/<offset>
try
@@ -379,24 +379,24 @@
if (more)
{
json.push_back (Pair ("more", lexical_cast<string> (offset + 1)));
- // Ccnx::Name more = Name (interest.getPartialName (0, interest.size () - 1))(offset + 1);
+ // Ndnx::Name more = Name (interest.getPartialName (0, interest.size () - 1))(offset + 1);
// json.push_back (Pair ("more", lexical_cast<string> (more)));
}
ostringstream os;
write_stream (Value (json), os, pretty_print | raw_utf8);
- m_ccnx->publishData (interest, os.str (), 1);
+ m_ndnx->publishData (interest, os.str (), 1);
}
- catch (Ccnx::NameException &ne)
+ catch (Ndnx::NameException &ne)
{
// ignore any unexpected interests and errors
- _LOG_ERROR (*boost::get_error_info<Ccnx::error_info_str>(ne));
+ _LOG_ERROR (*boost::get_error_info<Ndnx::error_info_str>(ne));
}
}
void
-StateServer::cmd_restore_file (const Ccnx::Name &interest)
+StateServer::cmd_restore_file (const Ndnx::Name &interest)
{
if (interest.size () - m_PREFIX_CMD.size () != 4 &&
interest.size () - m_PREFIX_CMD.size () != 5)
@@ -410,7 +410,7 @@
}
void
-StateServer::cmd_restore_file_Execute (const Ccnx::Name &interest)
+StateServer::cmd_restore_file_Execute (const Ndnx::Name &interest)
{
// <PREFIX_CMD>/"restore"/"file"/<one-component-relative-file-name>/<version>/<file-hash>
@@ -446,7 +446,7 @@
if (!file)
{
- m_ccnx->publishData (interest, "FAIL: Requested file is not found", 1);
+ m_ndnx->publishData (interest, "FAIL: Requested file is not found", 1);
return;
}
@@ -468,14 +468,14 @@
#endif
*Hash::FromFileContent (filePath) == hash)
{
- m_ccnx->publishData (interest, "OK: File already exists", 1);
+ m_ndnx->publishData (interest, "OK: File already exists", 1);
_LOG_DEBUG ("Asking to assemble a file, but file already exists on a filesystem");
return;
}
}
catch (filesystem::filesystem_error &error)
{
- m_ccnx->publishData (interest, "FAIL: File operation failed", 1);
+ m_ndnx->publishData (interest, "FAIL: File operation failed", 1);
_LOG_ERROR ("File operations failed on [" << filePath << "] (ignoring)");
}
@@ -486,16 +486,16 @@
#if BOOST_VERSION >= 104900
permissions (filePath, static_cast<filesystem::perms> (file->mode ()));
#endif
- m_ccnx->publishData (interest, "OK", 1);
+ m_ndnx->publishData (interest, "OK", 1);
}
else
{
- m_ccnx->publishData (interest, "FAIL: Unknown error while restoring file", 1);
+ m_ndnx->publishData (interest, "FAIL: Unknown error while restoring file", 1);
}
}
- catch (Ccnx::NameException &ne)
+ catch (Ndnx::NameException &ne)
{
// ignore any unexpected interests and errors
- _LOG_ERROR(*boost::get_error_info<Ccnx::error_info_str>(ne));
+ _LOG_ERROR(*boost::get_error_info<Ndnx::error_info_str>(ne));
}
}
diff --git a/src/state-server.h b/src/state-server.h
index 8809b7f..26a6697 100644
--- a/src/state-server.h
+++ b/src/state-server.h
@@ -22,7 +22,7 @@
#ifndef STATE_SERVER_H
#define STATE_SERVER_H
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include "object-manager.h"
#include "object-db.h"
#include "action-log.h"
@@ -152,33 +152,33 @@
class StateServer
{
public:
- StateServer(Ccnx::CcnxWrapperPtr ccnx, ActionLogPtr actionLog, const boost::filesystem::path &rootDir,
- const Ccnx::Name &userName, const std::string &sharedFolderName, const std::string &appName,
+ StateServer(Ndnx::NdnxWrapperPtr ndnx, ActionLogPtr actionLog, const boost::filesystem::path &rootDir,
+ const Ndnx::Name &userName, const std::string &sharedFolderName, const std::string &appName,
ObjectManager &objectManager,
int freshness = -1);
~StateServer();
private:
void
- info_actions_folder (const Ccnx::Name &interest);
+ info_actions_folder (const Ndnx::Name &interest);
void
- info_actions_file (const Ccnx::Name &interest);
+ info_actions_file (const Ndnx::Name &interest);
void
- info_actions_fileOrFolder_Execute (const Ccnx::Name &interest, bool isFolder = true);
+ info_actions_fileOrFolder_Execute (const Ndnx::Name &interest, bool isFolder = true);
void
- info_files_folder (const Ccnx::Name &interest);
+ info_files_folder (const Ndnx::Name &interest);
void
- info_files_folder_Execute (const Ccnx::Name &interest);
+ info_files_folder_Execute (const Ndnx::Name &interest);
void
- cmd_restore_file (const Ccnx::Name &interest);
+ cmd_restore_file (const Ndnx::Name &interest);
void
- cmd_restore_file_Execute (const Ccnx::Name &interest);
+ cmd_restore_file_Execute (const Ndnx::Name &interest);
private:
void
@@ -188,25 +188,25 @@
deregisterPrefixes ();
static void
- formatActionJson (json_spirit::Array &actions, const Ccnx::Name &name, sqlite3_int64 seq_no, const ActionItem &action);
+ formatActionJson (json_spirit::Array &actions, const Ndnx::Name &name, sqlite3_int64 seq_no, const ActionItem &action);
static void
formatFilestateJson (json_spirit::Array &files, const FileItem &file);
private:
- Ccnx::CcnxWrapperPtr m_ccnx;
+ Ndnx::NdnxWrapperPtr m_ndnx;
ActionLogPtr m_actionLog;
ObjectManager &m_objectManager;
- Ccnx::Name m_PREFIX_INFO;
- Ccnx::Name m_PREFIX_CMD;
+ Ndnx::Name m_PREFIX_INFO;
+ Ndnx::Name m_PREFIX_CMD;
boost::filesystem::path m_rootDir;
int m_freshness;
Executor m_executor;
- Ccnx::Name m_userName;
+ Ndnx::Name m_userName;
std::string m_sharedFolderName;
std::string m_appName;
};
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 17cb16d..9ba28b7 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -41,11 +41,11 @@
const std::string LOCAL_STATE_CHANGE_DELAYED_TAG = "local-state-changed";
using namespace boost;
-using namespace Ccnx;
+using namespace Ndnx;
SyncCore::SyncCore(SyncLogPtr syncLog, const Name &userName, const Name &localPrefix, const Name &syncPrefix,
- const StateMsgCallback &callback, CcnxWrapperPtr ccnx, double syncInterestInterval/*= -1.0*/)
- : m_ccnx (ccnx)
+ const StateMsgCallback &callback, NdnxWrapperPtr ndnx, double syncInterestInterval/*= -1.0*/)
+ : m_ndnx (ndnx)
, m_log(syncLog)
, m_scheduler(new Scheduler ())
, m_stateMsgCallback(callback)
@@ -55,7 +55,7 @@
{
m_rootHash = m_log->RememberStateInStateLog();
- m_ccnx->setInterestFilter(m_syncPrefix, boost::bind(&SyncCore::handleInterest, this, _1));
+ m_ndnx->setInterestFilter(m_syncPrefix, boost::bind(&SyncCore::handleInterest, this, _1));
// m_log->initYP(m_yp);
m_log->UpdateLocalLocator (localPrefix);
@@ -92,7 +92,7 @@
Name syncName = Name (m_syncPrefix)(oldHash->GetHash(), oldHash->GetHashBytes());
BytesPtr syncData = serializeGZipMsg (*msg);
- m_ccnx->publishData(syncName, *syncData, FRESHNESS);
+ m_ndnx->publishData(syncName, *syncData, FRESHNESS);
_LOG_DEBUG ("[" << m_log->GetLocalName () << "] localStateChanged ");
_LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes: " << oldHash->shortHash ());
// _LOG_TRACE (msg);
@@ -147,7 +147,7 @@
SyncStateMsgPtr msg = m_log->FindStateDifferences(*(Hash::Origin), *m_rootHash);
BytesPtr syncData = serializeGZipMsg (*msg);
- m_ccnx->publishData(name, *syncData, FRESHNESS);
+ m_ndnx->publishData(name, *syncData, FRESHNESS);
_LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes " << hash.shortHash ());
// _LOG_TRACE (msg);
}
@@ -177,7 +177,7 @@
SyncStateMsgPtr msg = m_log->FindStateDifferences(*hash, *m_rootHash);
BytesPtr syncData = serializeGZipMsg (*msg);
- m_ccnx->publishData(name, *syncData, FRESHNESS);
+ m_ndnx->publishData(name, *syncData, FRESHNESS);
_LOG_TRACE (m_log->GetLocalName () << " publishes: " << hash->shortHash ());
_LOG_TRACE (msg);
}
@@ -322,7 +322,7 @@
{
selectors.interestLifetime(m_syncInterestInterval);
}
- m_ccnx->sendInterest(syncInterest,
+ m_ndnx->sendInterest(syncInterest,
Closure (boost::bind(&SyncCore::handleSyncData, this, _1, _2),
boost::bind(&SyncCore::handleSyncInterestTimeout, this, _1, _2, _3)),
selectors);
@@ -347,7 +347,7 @@
_LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> RECOVER Interests for " << hash->shortHash ());
- m_ccnx->sendInterest(recoverInterest,
+ m_ndnx->sendInterest(recoverInterest,
Closure (boost::bind(&SyncCore::handleRecoverData, this, _1, _2),
boost::bind(&SyncCore::handleRecoverInterestTimeout, this, _1, _2, _3)));
diff --git a/src/sync-core.h b/src/sync-core.h
index 7cf4368..8d97bd3 100644
--- a/src/sync-core.h
+++ b/src/sync-core.h
@@ -23,8 +23,8 @@
#define SYNC_CORE_H
#include "sync-log.h"
-#include "ccnx-wrapper.h"
-#include "ccnx-selectors.h"
+#include "ndnx-wrapper.h"
+#include "ndnx-selectors.h"
#include "scheduler.h"
#include "task.h"
@@ -42,11 +42,11 @@
public:
SyncCore(SyncLogPtr syncLog
- , const Ccnx::Name &userName
- , const Ccnx::Name &localPrefix // routable name used by the local user
- , const Ccnx::Name &syncPrefix // the prefix for the sync collection
+ , const Ndnx::Name &userName
+ , const Ndnx::Name &localPrefix // routable name used by the local user
+ , const Ndnx::Name &syncPrefix // the prefix for the sync collection
, const StateMsgCallback &callback // callback when state change is detected
- , Ccnx::CcnxWrapperPtr ccnx
+ , Ndnx::NdnxWrapperPtr ndnx
, double syncInterestInterval = -1.0);
~SyncCore();
@@ -71,26 +71,26 @@
root() const { return m_rootHash; }
sqlite3_int64
- seq (const Ccnx::Name &name);
+ seq (const Ndnx::Name &name);
private:
void
- handleInterest(const Ccnx::Name &name);
+ handleInterest(const Ndnx::Name &name);
void
- handleSyncData(const Ccnx::Name &name, Ccnx::PcoPtr content);
+ handleSyncData(const Ndnx::Name &name, Ndnx::PcoPtr content);
void
- handleRecoverData(const Ccnx::Name &name, Ccnx::PcoPtr content);
+ handleRecoverData(const Ndnx::Name &name, Ndnx::PcoPtr content);
void
- handleSyncInterestTimeout(const Ccnx::Name &name, const Ccnx::Closure &closure, Ccnx::Selectors selectors);
+ handleSyncInterestTimeout(const Ndnx::Name &name, const Ndnx::Closure &closure, Ndnx::Selectors selectors);
void
- handleRecoverInterestTimeout(const Ccnx::Name &name, const Ccnx::Closure &closure, Ccnx::Selectors selectors);
+ handleRecoverInterestTimeout(const Ndnx::Name &name, const Ndnx::Closure &closure, Ndnx::Selectors selectors);
void
- deregister(const Ccnx::Name &name);
+ deregister(const Ndnx::Name &name);
void
recover(HashPtr hash);
@@ -100,22 +100,22 @@
sendSyncInterest();
void
- handleSyncInterest(const Ccnx::Name &name);
+ handleSyncInterest(const Ndnx::Name &name);
void
- handleRecoverInterest(const Ccnx::Name &name);
+ handleRecoverInterest(const Ndnx::Name &name);
void
- handleStateData(const Ccnx::Bytes &content);
+ handleStateData(const Ndnx::Bytes &content);
private:
- Ccnx::CcnxWrapperPtr m_ccnx;
+ Ndnx::NdnxWrapperPtr m_ndnx;
SyncLogPtr m_log;
SchedulerPtr m_scheduler;
StateMsgCallback m_stateMsgCallback;
- Ccnx::Name m_syncPrefix;
+ Ndnx::Name m_syncPrefix;
HashPtr m_rootHash;
IntervalGeneratorPtr m_recoverWaitGenerator;
diff --git a/src/sync-log.cc b/src/sync-log.cc
index 5881bd9..23df286 100644
--- a/src/sync-log.cc
+++ b/src/sync-log.cc
@@ -30,7 +30,7 @@
using namespace boost;
using namespace std;
-using namespace Ccnx;
+using namespace Ndnx;
// static void xTrace (void*, const char* q)
// {
@@ -97,7 +97,7 @@
";
-SyncLog::SyncLog (const boost::filesystem::path &path, const Ccnx::Name &localName)
+SyncLog::SyncLog (const boost::filesystem::path &path, const Ndnx::Name &localName)
: DbHelper (path / ".chronoshare", "sync-log.db")
, m_localName (localName)
{
@@ -109,7 +109,7 @@
sqlite3_stmt *stmt;
int res = sqlite3_prepare_v2 (m_db, "SELECT device_id, seq_no FROM SyncNodes WHERE device_name=?", -1, &stmt, 0);
- Ccnx::CcnxCharbufPtr name = m_localName;
+ Ndnx::NdnxCharbufPtr name = m_localName;
sqlite3_bind_blob (stmt, 1, name->buf (), name->length (), SQLITE_STATIC);
if (sqlite3_step (stmt) == SQLITE_ROW)
@@ -267,14 +267,14 @@
}
void
-SyncLog::UpdateDeviceSeqNo (const Ccnx::Name &name, sqlite3_int64 seqNo)
+SyncLog::UpdateDeviceSeqNo (const Ndnx::Name &name, sqlite3_int64 seqNo)
{
sqlite3_stmt *stmt;
// update is performed using trigger
int res = sqlite3_prepare (m_db, "INSERT INTO SyncNodes (device_name, seq_no) VALUES (?,?);",
-1, &stmt, 0);
- Ccnx::CcnxCharbufPtr nameBuf = name;
+ Ndnx::NdnxCharbufPtr nameBuf = name;
res += sqlite3_bind_blob (stmt, 1, nameBuf->buf (), nameBuf->length (), SQLITE_STATIC);
res += sqlite3_bind_int64 (stmt, 2, seqNo);
sqlite3_step (stmt);
@@ -321,7 +321,7 @@
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2 (m_db, "SELECT last_known_locator FROM SyncNodes WHERE device_name=?;", -1, &stmt, 0);
- Ccnx::CcnxCharbufPtr nameBuf = deviceName;
+ Ndnx::NdnxCharbufPtr nameBuf = deviceName;
sqlite3_bind_blob (stmt, 1, nameBuf->buf(), nameBuf->length(), SQLITE_STATIC);
int res = sqlite3_step (stmt);
Name locator;
@@ -341,7 +341,7 @@
return locator;
}
-Ccnx::Name
+Ndnx::Name
SyncLog::LookupLocalLocator ()
{
return LookupLocator (m_localName);
@@ -352,8 +352,8 @@
{
sqlite3_stmt *stmt;
sqlite3_prepare_v2 (m_db, "UPDATE SyncNodes SET last_known_locator=?,last_update=datetime('now') WHERE device_name=?;", -1, &stmt, 0);
- Ccnx::CcnxCharbufPtr nameBuf = deviceName;
- Ccnx::CcnxCharbufPtr locatorBuf = locator;
+ Ndnx::NdnxCharbufPtr nameBuf = deviceName;
+ Ndnx::NdnxCharbufPtr locatorBuf = locator;
sqlite3_bind_blob (stmt, 1, locatorBuf->buf(), locatorBuf->length(), SQLITE_STATIC);
sqlite3_bind_blob (stmt, 2, nameBuf->buf(), nameBuf->length(), SQLITE_STATIC);
int res = sqlite3_step (stmt);
@@ -367,7 +367,7 @@
}
void
-SyncLog::UpdateLocalLocator (const Ccnx::Name &forwardingHint)
+SyncLog::UpdateLocalLocator (const Ndnx::Name &forwardingHint)
{
return UpdateLocator (m_localName, forwardingHint);
}
@@ -494,7 +494,7 @@
sqlite3_stmt *stmt;
sqlite3_int64 seq = -1;
sqlite3_prepare_v2 (m_db, "SELECT seq_no FROM SyncNodes WHERE device_name=?;", -1, &stmt, 0);
- Ccnx::CcnxCharbufPtr nameBuf = name;
+ Ndnx::NdnxCharbufPtr nameBuf = name;
sqlite3_bind_blob (stmt, 1, nameBuf->buf (), nameBuf->length (), SQLITE_STATIC);
if (sqlite3_step (stmt) == SQLITE_ROW)
{
diff --git a/src/sync-log.h b/src/sync-log.h
index 304afa7..1d243ad 100644
--- a/src/sync-log.h
+++ b/src/sync-log.h
@@ -24,7 +24,7 @@
#include "db-helper.h"
#include <sync-state.pb.h>
-#include <ccnx-name.h>
+#include <ndnx-name.h>
#include <map>
#include <boost/thread/shared_mutex.hpp>
@@ -33,12 +33,12 @@
class SyncLog : public DbHelper
{
public:
- SyncLog (const boost::filesystem::path &path, const Ccnx::Name &localName);
+ SyncLog (const boost::filesystem::path &path, const Ndnx::Name &localName);
/**
* @brief Get local username
*/
- inline const Ccnx::Name &
+ inline const Ndnx::Name &
GetLocalName () const;
sqlite3_int64
@@ -46,22 +46,22 @@
// done
void
- UpdateDeviceSeqNo (const Ccnx::Name &name, sqlite3_int64 seqNo);
+ UpdateDeviceSeqNo (const Ndnx::Name &name, sqlite3_int64 seqNo);
void
UpdateLocalSeqNo (sqlite3_int64 seqNo);
- Ccnx::Name
- LookupLocator (const Ccnx::Name &deviceName);
+ Ndnx::Name
+ LookupLocator (const Ndnx::Name &deviceName);
- Ccnx::Name
+ Ndnx::Name
LookupLocalLocator ();
void
- UpdateLocator (const Ccnx::Name &deviceName, const Ccnx::Name &locator);
+ UpdateLocator (const Ndnx::Name &deviceName, const Ndnx::Name &locator);
void
- UpdateLocalLocator (const Ccnx::Name &locator);
+ UpdateLocalLocator (const Ndnx::Name &locator);
// done
/**
@@ -87,7 +87,7 @@
//-------- only used in test -----------------
sqlite3_int64
- SeqNo(const Ccnx::Name &name);
+ SeqNo(const Ndnx::Name &name);
sqlite3_int64
LogSize ();
@@ -97,7 +97,7 @@
UpdateDeviceSeqNo (sqlite3_int64 deviceId, sqlite3_int64 seqNo);
protected:
- Ccnx::Name m_localName;
+ Ndnx::Name m_localName;
sqlite3_int64 m_localDeviceId;
@@ -109,7 +109,7 @@
typedef boost::shared_ptr<SyncLog> SyncLogPtr;
-const Ccnx::Name &
+const Ndnx::Name &
SyncLog::GetLocalName () const
{
return m_localName;
diff --git a/src/sync-state-helper.h b/src/sync-state-helper.h
index 435ef9a..410bb8c 100644
--- a/src/sync-state-helper.h
+++ b/src/sync-state-helper.h
@@ -40,8 +40,8 @@
string strLocator = state.locator();
sqlite3_int64 seq = state.seq();
- os << "Name: " << Ccnx::Name((const unsigned char *)strName.c_str(), strName.size())
- << ", Locator: " << Ccnx::Name((const unsigned char *)strLocator.c_str(), strLocator.size())
+ os << "Name: " << Ndnx::Name((const unsigned char *)strName.c_str(), strName.size())
+ << ", Locator: " << Ndnx::Name((const unsigned char *)strLocator.c_str(), strLocator.size())
<< ", seq: " << seq << std::endl;
index ++;
}
diff --git a/test/daemon/daemon.cc b/test/daemon/daemon.cc
index ae41418..6983965 100644
--- a/test/daemon/daemon.cc
+++ b/test/daemon/daemon.cc
@@ -23,7 +23,7 @@
#include <iostream>
#include <Ice/Service.h>
#include <Ice/Identity.h>
-#include <ccnx-wrapper.h>
+#include <ndnx-wrapper.h>
#include "notify-i.h"
#include <boost/make_shared.hpp>
@@ -31,7 +31,7 @@
using namespace std;
using namespace boost;
using namespace ChronoshareClient;
-using namespace Ccnx;
+using namespace Ndnx;
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
@@ -72,8 +72,8 @@
try
{
// DbHelper db ("./", "/ndn/ucla.edu/alex");
- CcnxWrapperPtr ccnx = make_shared<CcnxWrapper> ();
- ActionLogPtr actionLog = make_shared<ActionLog> (ccnx, "./", "/ndn/ucla.edu/alex", "shared");
+ NdnxWrapperPtr ndnx = make_shared<NdnxWrapper> ();
+ ActionLogPtr actionLog = make_shared<ActionLog> (ndnx, "./", "/ndn/ucla.edu/alex", "shared");
MyService svc (actionLog);
status = svc.main (argc, argv);
diff --git a/test/test-action-log.cc b/test/test-action-log.cc
index c4d6a9b..86eb059 100644
--- a/test/test-action-log.cc
+++ b/test/test-action-log.cc
@@ -32,7 +32,7 @@
using namespace std;
using namespace boost;
-using namespace Ccnx;
+using namespace Ndnx;
namespace fs = boost::filesystem;
BOOST_AUTO_TEST_SUITE(TestActionLog)
@@ -45,9 +45,9 @@
fs::path tmpdir = fs::unique_path (fs::temp_directory_path () / "%%%%-%%%%-%%%%-%%%%");
SyncLogPtr syncLog = make_shared<SyncLog> (tmpdir, localName);
- CcnxWrapperPtr ccnx = make_shared<CcnxWrapper> ();
+ NdnxWrapperPtr ndnx = make_shared<NdnxWrapper> ();
- ActionLogPtr actionLog = make_shared<ActionLog> (ccnx, tmpdir, syncLog, "top-secret", "test-chronoshare",
+ ActionLogPtr actionLog = make_shared<ActionLog> (ndnx, tmpdir, syncLog, "top-secret", "test-chronoshare",
ActionLog::OnFileAddedOrChangedCallback(), ActionLog::OnFileRemovedCallback ());
// const std::string &filename,
@@ -129,7 +129,7 @@
BytesPtr item_msg = serializeMsg (item);
Name actionName = Name ("/")(Name("/zhenkai/test"))("test-chronoshare")("action")("top-secret")(1);
- Bytes actionData = ccnx->createContentObject (actionName, head (*item_msg), item_msg->size ());
+ Bytes actionData = ndnx->createContentObject (actionName, head (*item_msg), item_msg->size ());
pco = make_shared<ParsedContentObject> (actionData);
BOOST_CHECK_EQUAL ((bool)actionLog->AddRemoteAction (pco), true);
diff --git a/test/test-dispatcher.cc b/test/test-dispatcher.cc
index 77a499b..b5c023b 100644
--- a/test/test-dispatcher.cc
+++ b/test/test-dispatcher.cc
@@ -19,7 +19,7 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include "logging.h"
#include "dispatcher.h"
#include <boost/test/unit_test.hpp>
@@ -28,7 +28,7 @@
#include <fstream>
#include <cassert>
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
namespace fs = boost::filesystem;
@@ -63,17 +63,17 @@
string folder = "who-is-president";
- CcnxWrapperPtr ccnx1 = make_shared<CcnxWrapper>();
+ NdnxWrapperPtr ndnx1 = make_shared<NdnxWrapper>();
usleep(100);
- CcnxWrapperPtr ccnx2 = make_shared<CcnxWrapper>();
+ NdnxWrapperPtr ndnx2 = make_shared<NdnxWrapper>();
usleep(100);
cleanDir(dir1);
cleanDir(dir2);
- Dispatcher d1(user1, folder, dir1, ccnx1, false);
+ Dispatcher d1(user1, folder, dir1, ndnx1, false);
usleep(100);
- Dispatcher d2(user2, folder, dir2, ccnx2, false);
+ Dispatcher d2(user2, folder, dir2, ndnx2, false);
usleep(14900000);
diff --git a/test/test-fetch-manager.cc b/test/test-fetch-manager.cc
index ed604f3..98c820a 100644
--- a/test/test-fetch-manager.cc
+++ b/test/test-fetch-manager.cc
@@ -21,7 +21,7 @@
#include "fetch-manager.h"
#include "fetcher.h"
-#include "ccnx-wrapper.h"
+#include "ndnx-wrapper.h"
#include <boost/test/unit_test.hpp>
#include <boost/make_shared.hpp>
#include <boost/thread/thread.hpp>
@@ -30,7 +30,7 @@
INIT_LOGGER ("Test.FetchManager");
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
@@ -54,7 +54,7 @@
}
void
- onData (const Ccnx::Name &deviceName, const Ccnx::Name &basename, uint64_t seqno, Ccnx::PcoPtr pco)
+ onData (const Ndnx::Name &deviceName, const Ndnx::Name &basename, uint64_t seqno, Ndnx::PcoPtr pco)
{
_LOG_TRACE ("onData: " << seqno);
@@ -75,7 +75,7 @@
}
void
- finish(const Ccnx::Name &deviceName, const Ccnx::Name &baseName)
+ finish(const Ndnx::Name &deviceName, const Ndnx::Name &baseName)
{
}
@@ -96,7 +96,7 @@
void run()
{
- CcnxWrapperPtr ccnx = make_shared<CcnxWrapper> ();
+ NdnxWrapperPtr ndnx = make_shared<NdnxWrapper> ();
Name baseName ("/base");
Name deviceName ("/device");
@@ -104,13 +104,13 @@
for (int i = 0; i < 10; i++)
{
usleep(100000);
- ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
+ ndnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
}
for (int i = 11; i < 50; i++)
{
usleep(100000);
- ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
+ ndnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
}
}
@@ -119,7 +119,7 @@
{
INIT_LOGGERS ();
- CcnxWrapperPtr ccnx = make_shared<CcnxWrapper> ();
+ NdnxWrapperPtr ndnx = make_shared<NdnxWrapper> ();
Name baseName ("/base");
Name deviceName ("/device");
@@ -127,22 +127,22 @@
// this will allow us to test our pipeline of 6
for (int i = 0; i < 10; i++)
{
- ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
+ ndnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
}
for (int i = 15; i < 25; i++)
{
- ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
+ ndnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
}
int oneMore = 26;
- ccnx->publishData (Name (baseName)(oneMore), reinterpret_cast<const unsigned char*> (&oneMore), sizeof(int), 30);
+ ndnx->publishData (Name (baseName)(oneMore), reinterpret_cast<const unsigned char*> (&oneMore), sizeof(int), 30);
FetcherTestData data;
ExecutorPtr executor = make_shared<Executor>(1);
executor->start ();
- Fetcher fetcher (ccnx,
+ Fetcher fetcher (ndnx,
executor,
bind (&FetcherTestData::onData, &data, _1, _2, _3, _4),
bind (&FetcherTestData::finish, &data, _1, _2),
@@ -185,7 +185,7 @@
// publishing missing pieces
for (int i = 0; i < 27; i++)
{
- ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 1);
+ ndnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 1);
}
BOOST_CHECK_EQUAL (fetcher.IsActive (), false);
fetcher.RestartPipeline ();
@@ -215,7 +215,7 @@
{
INIT_LOGGERS ();
- CcnxWrapperPtr ccnx = make_shared<CcnxWrapper> ();
+ NdnxWrapperPtr ndnx = make_shared<NdnxWrapper> ();
Name baseName ("/base");
Name deviceName ("/device");
@@ -226,7 +226,7 @@
ExecutorPtr executor = make_shared<Executor>(1);
executor->start ();
- Fetcher fetcher (ccnx,
+ Fetcher fetcher (ndnx,
executor,
bind (&FetcherTestData::onData, &data, _1, _2, _3, _4),
bind (&FetcherTestData::finish, &data, _1, _2),
@@ -247,7 +247,7 @@
-// BOOST_AUTO_TEST_CASE (CcnxWrapperSelector)
+// BOOST_AUTO_TEST_CASE (NdnxWrapperSelector)
// {
// Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1));
diff --git a/test/test-fetch-task-db.cc b/test/test-fetch-task-db.cc
index 1e647af..61bec89 100644
--- a/test/test-fetch-task-db.cc
+++ b/test/test-fetch-task-db.cc
@@ -37,7 +37,7 @@
INIT_LOGGER ("Test.FetchTaskDb");
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
namespace fs = boost::filesystem;
diff --git a/test/test-ccnx-name.cc b/test/test-ndnx-name.cc
similarity index 91%
rename from test/test-ccnx-name.cc
rename to test/test-ndnx-name.cc
index a876ba4..6022ec2 100644
--- a/test/test-ccnx-name.cc
+++ b/test/test-ndnx-name.cc
@@ -1,17 +1,17 @@
-#include "ccnx-name.h"
+#include "ndnx-name.h"
#define BOOST_TEST_MAIN 1
#include <boost/test/unit_test.hpp>
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
-BOOST_AUTO_TEST_SUITE(CcnxNameTests)
+BOOST_AUTO_TEST_SUITE(NdnxNameTests)
-BOOST_AUTO_TEST_CASE (CcnxNameTest)
+BOOST_AUTO_TEST_CASE (NdnxNameTest)
{
Name empty = Name();
Name root = Name("/");
diff --git a/test/test-ccnx-wrapper.cc b/test/test-ndnx-wrapper.cc
similarity index 91%
rename from test/test-ccnx-wrapper.cc
rename to test/test-ndnx-wrapper.cc
index 9989cdb..eaf0ef3 100644
--- a/test/test-ccnx-wrapper.cc
+++ b/test/test-ndnx-wrapper.cc
@@ -19,25 +19,25 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "ccnx-wrapper.h"
-#include "ccnx-closure.h"
-#include "ccnx-name.h"
-#include "ccnx-selectors.h"
-#include "ccnx-pco.h"
+#include "ndnx-wrapper.h"
+#include "ndnx-closure.h"
+#include "ndnx-name.h"
+#include "ndnx-selectors.h"
+#include "ndnx-pco.h"
#include <unistd.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/make_shared.hpp>
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
-BOOST_AUTO_TEST_SUITE(TestCcnxWrapper)
+BOOST_AUTO_TEST_SUITE(TestNdnxWrapper)
-CcnxWrapperPtr c1;
-CcnxWrapperPtr c2;
+NdnxWrapperPtr c1;
+NdnxWrapperPtr c2;
int g_timeout_counter = 0;
int g_dataCallback_counter = 0;
@@ -53,7 +53,7 @@
c2->publishData(name, (const unsigned char*)content.c_str(), content.size(), 5);
}
-void dataCallback(const Name &name, Ccnx::PcoPtr pco)
+void dataCallback(const Name &name, Ndnx::PcoPtr pco)
{
cout << " in data callback" << endl;
BytesPtr content = pco->contentPtr ();
@@ -62,7 +62,7 @@
BOOST_CHECK_EQUAL(name, msg);
}
-void encapCallback(const Name &name, Ccnx::PcoPtr pco)
+void encapCallback(const Name &name, Ndnx::PcoPtr pco)
{
cout << " in encap data callback" << endl;
BOOST_CHECK(!c1->verify(pco));
@@ -84,11 +84,11 @@
{
if (!c1)
{
- c1 = make_shared<CcnxWrapper> ();
+ c1 = make_shared<NdnxWrapper> ();
}
if (!c2)
{
- c2 = make_shared<CcnxWrapper> ();
+ c2 = make_shared<NdnxWrapper> ();
}
}
@@ -106,7 +106,7 @@
}
-BOOST_AUTO_TEST_CASE (BlaCcnxWrapperTest)
+BOOST_AUTO_TEST_CASE (BlaNdnxWrapperTest)
{
INIT_LOGGERS ();
@@ -132,7 +132,7 @@
teardown();
}
-BOOST_AUTO_TEST_CASE (CcnxWrapperSelector)
+BOOST_AUTO_TEST_CASE (NdnxWrapperSelector)
{
setup();
@@ -220,7 +220,7 @@
/*
- BOOST_AUTO_TEST_CASE (CcnxWrapperUnsigningTest)
+ BOOST_AUTO_TEST_CASE (NdnxWrapperUnsigningTest)
{
setup();
Bytes data;
diff --git a/test/test-object-manager.cc b/test/test-object-manager.cc
index 36c5c57..60f0c58 100644
--- a/test/test-object-manager.cc
+++ b/test/test-object-manager.cc
@@ -33,7 +33,7 @@
INIT_LOGGER ("Test.ObjectManager");
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
namespace fs = boost::filesystem;
@@ -48,8 +48,8 @@
_LOG_DEBUG ("tmpdir: " << tmpdir);
Name deviceName ("/device");
- CcnxWrapperPtr ccnx = make_shared<CcnxWrapper> ();
- ObjectManager manager (ccnx, tmpdir, "test-chronoshare");
+ NdnxWrapperPtr ndnx = make_shared<NdnxWrapper> ();
+ ObjectManager manager (ndnx, tmpdir, "test-chronoshare");
tuple<HashPtr,int> hash_semgents = manager.localFileToObjects (fs::path("test") / "test-object-manager.cc", deviceName);
diff --git a/test/test-protobuf.cc b/test/test-protobuf.cc
index fdf211b..d0a7b8e 100644
--- a/test/test-protobuf.cc
+++ b/test/test-protobuf.cc
@@ -1,4 +1,4 @@
-#include "ccnx-common.h"
+#include "ndnx-common.h"
#include "sync-core.h"
#include <boost/make_shared.hpp>
#include <boost/test/unit_test.hpp>
@@ -8,7 +8,7 @@
#include <boost/range/iterator_range.hpp>
#include <boost/make_shared.hpp>
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
diff --git a/test/test-serve-and-fetch.cc b/test/test-serve-and-fetch.cc
index a551404..8e54404 100644
--- a/test/test-serve-and-fetch.cc
+++ b/test/test-serve-and-fetch.cc
@@ -20,8 +20,8 @@
*/
#include "fetch-manager.h"
-#include "ccnx-wrapper.h"
-#include "ccnx-common.h"
+#include "ndnx-wrapper.h"
+#include "ndnx-common.h"
#include "scheduler.h"
#include "object-db.h"
#include "object-manager.h"
@@ -40,7 +40,7 @@
INIT_LOGGER("Test.ServerAndFetch");
-using namespace Ccnx;
+using namespace Ndnx;
using namespace std;
using namespace boost;
using namespace boost::filesystem;
@@ -122,9 +122,9 @@
_LOG_DEBUG ("Setting up test environment ...");
setup();
- CcnxWrapperPtr ccnx_serve = make_shared<CcnxWrapper>();
+ NdnxWrapperPtr ndnx_serve = make_shared<NdnxWrapper>();
usleep(1000);
- CcnxWrapperPtr ccnx_fetch = make_shared<CcnxWrapper>();
+ NdnxWrapperPtr ndnx_fetch = make_shared<NdnxWrapper>();
Name deviceName("/test/device");
Name localPrefix("/local");
@@ -135,17 +135,17 @@
time_t start = time(NULL);
_LOG_DEBUG ("At time " << start << ", publish local file to database, this is extremely slow ...");
// publish file to db
- ObjectManager om(ccnx_serve, root, APPNAME);
+ ObjectManager om(ndnx_serve, root, APPNAME);
tuple<HashPtr, size_t> pub = om.localFileToObjects(filePath, deviceName);
time_t end = time(NULL);
_LOG_DEBUG ("At time " << end <<", publish finally finished, used " << end - start << " seconds ...");
ActionLogPtr dummyLog;
- ContentServer server(ccnx_serve, dummyLog, root, deviceName, "pentagon's secrets", APPNAME, 5);
+ ContentServer server(ndnx_serve, dummyLog, root, deviceName, "pentagon's secrets", APPNAME, 5);
server.registerPrefix(localPrefix);
server.registerPrefix(broadcastPrefix);
- FetchManager fm(ccnx_fetch, bind(simpleMap, _1), Name("/local/broadcast"));
+ FetchManager fm(ndnx_fetch, bind(simpleMap, _1), Name("/local/broadcast"));
HashPtr hash = pub.get<0> ();
Name baseName = Name ("/")(deviceName)(APPNAME)("file")(hash->GetHash(), hash->GetHashBytes());
@@ -161,8 +161,8 @@
break;
}
}
- ccnx_fetch->shutdown ();
- ccnx_serve->shutdown ();
+ ndnx_fetch->shutdown ();
+ ndnx_serve->shutdown ();
_LOG_DEBUG ("Finish");
usleep(100000);
diff --git a/test/test-sync-core.cc b/test/test-sync-core.cc
index f38dab7..04f560a 100644
--- a/test/test-sync-core.cc
+++ b/test/test-sync-core.cc
@@ -6,7 +6,7 @@
#include <boost/make_shared.hpp>
using namespace std;
-using namespace Ccnx;
+using namespace Ndnx;
using namespace boost;
using namespace boost::filesystem;
@@ -56,8 +56,8 @@
Name user2("/darkknight");
Name loc2("/gotham2");
Name syncPrefix("/broadcast/darkknight");
- CcnxWrapperPtr c1(new CcnxWrapper());
- CcnxWrapperPtr c2(new CcnxWrapper());
+ NdnxWrapperPtr c1(new NdnxWrapper());
+ NdnxWrapperPtr c2(new NdnxWrapper());
SyncLogPtr log1(new SyncLog(dir1, user1.toString()));
SyncLogPtr log2(new SyncLog(dir2, user2.toString()));
diff --git a/test/test-sync-log.cc b/test/test-sync-log.cc
index 09443e9..8ac36b1 100644
--- a/test/test-sync-log.cc
+++ b/test/test-sync-log.cc
@@ -26,12 +26,12 @@
#include <unistd.h>
#include "action-log.h"
#include <iostream>
-#include <ccnx-name.h>
+#include <ndnx-name.h>
#include <boost/filesystem.hpp>
using namespace std;
using namespace boost;
-using namespace Ccnx;
+using namespace Ndnx;
namespace fs = boost::filesystem;
BOOST_AUTO_TEST_SUITE(TestSyncLog)
diff --git a/waf-tools/flags.py b/waf-tools/flags.py
new file mode 100644
index 0000000..416b772
--- /dev/null
+++ b/waf-tools/flags.py
@@ -0,0 +1,39 @@
+#! /usr/bin/env python
+# encoding: utf-8
+
+from waflib import Configure
+
+@Configure.conf
+def add_supported_cflags(self, cflags):
+ """
+ Check which cflags are supported by compiler and add them to env.CFLAGS variable
+ """
+ self.start_msg('Checking allowed flags for c compiler')
+
+ supportedFlags = []
+ for flag in cflags:
+ if self.check_cc (cflags=[flag], mandatory=False):
+ supportedFlags += [flag]
+
+ self.end_msg (' '.join (supportedFlags))
+ self.env.CFLAGS += supportedFlags
+
+def configure(conf):
+ conf.load ('gnu_dirs')
+
+ if conf.options.debug:
+ conf.define ('_DEBUG', 1)
+ conf.add_supported_cflags (cflags = ['-O0',
+ '-Wall',
+ '-Wno-unused-variable',
+ '-g3',
+ '-Wno-unused-private-field', # only clang supports
+ '-fcolor-diagnostics', # only clang supports
+ '-Qunused-arguments' # only clang supports
+ ])
+ else:
+ conf.add_supported_cflags (cflags = ['-O3', '-g'])
+
+def options(opt):
+ opt.load ('gnu_dirs')
+ opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
diff --git a/waf-tools/ndnx.py b/waf-tools/ndnx.py
new file mode 100644
index 0000000..fccad90
--- /dev/null
+++ b/waf-tools/ndnx.py
@@ -0,0 +1,160 @@
+#! /usr/bin/env python
+# encoding: utf-8
+
+'''
+
+When using this tool, the wscript will look like:
+
+ def options(opt):
+ opt.tool_options('ndnx')
+
+ def configure(conf):
+ conf.load('compiler_c ndnx')
+
+ def build(bld):
+ bld(source='main.cpp', target='app', use='NDNX')
+
+Options are generated, in order to specify the location of ndnx includes/libraries.
+
+
+'''
+import sys, re
+from waflib import Utils, Logs, Errors, Options, ConfigSet
+from waflib.Configure import conf
+
+NDNX_DIR=['/usr','/usr/local','/opt/local','/sw']
+NDNX_VERSION_FILE='ndn/ndn.h'
+NDNX_VERSION_CODE='''
+#include <ndn/ndn.h>
+#include <stdio.h>
+int main() { printf ("%d.%d.%d", ((NDN_API_VERSION/100000) % 100), ((NDN_API_VERSION/1000) % 100), (NDN_API_VERSION % 1000)); return 0; }
+'''
+
+@conf
+def __ndnx_get_version_file(self,dir):
+ # Logs.pprint ('CYAN', ' + %s/%s/%s' % (dir, 'include', NDNX_VERSION_FILE))
+ try:
+ return self.root.find_dir(dir).find_node('%s/%s' % ('include', NDNX_VERSION_FILE))
+ except:
+ return None
+@conf
+def ndnx_get_version(self,dir):
+ val=self.check_cc(fragment=NDNX_VERSION_CODE,includes=['%s/%s' % (dir, 'include')],execute=True,define_ret = True, mandatory=True)
+ return val
+@conf
+def ndnx_get_root(self,*k,**kw):
+ root=Options.options.ndnx_dir or (k and k[0]) or kw.get('path',None)
+
+ if root:
+ if self.__ndnx_get_version_file(root):
+ return root
+ self.fatal('NDNx not found in %s'%root)
+
+ for dir in NDNX_DIR:
+ if self.__ndnx_get_version_file(dir):
+ return dir
+ self.fatal('NDNx not found, please provide a --ndnx argument (see help)')
+
+@conf
+def check_openssl(self,*k,**kw):
+ root = k and k[0] or kw.get('path',None) or Options.options.openssl
+ mandatory = kw.get('mandatory', True)
+ var = kw.get('var', 'SSL')
+
+ CODE = """
+#include <openssl/crypto.h>
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ (void)argc;
+ printf ("%s", argv[0]);
+
+ return 0;
+}
+"""
+ if root:
+ testApp = self.check_cc (lib=['ssl', 'crypto'],
+ header_name='openssl/crypto.h',
+ define_name='HAVE_%s' % var,
+ uselib_store=var,
+ mandatory = mandatory,
+ cflags="-I%s/include" % root,
+ linkflags="-L%s/lib" % root,
+ execute = True, fragment = CODE, define_ret = True)
+ else:
+ testApp = libcrypto = self.check_cc (lib=['ssl', 'crypto'],
+ header_name='openssl/crypto.h',
+ define_name='HAVE_%s' % var,
+ uselib_store=var,
+ mandatory = mandatory,
+ execute = True, fragment = CODE, define_ret = True)
+
+ if not testApp:
+ return
+
+ self.start_msg ('Checking if selected openssl matches NDNx')
+
+ ndn_var = kw.get('ndn_var', "NDNX")
+ if Utils.unversioned_sys_platform () == "darwin":
+ def otool (binary):
+ p = Utils.subprocess.Popen (['/usr/bin/otool', '-L', binary],
+ stdout = Utils.subprocess.PIPE, )
+ for line in p.communicate()[0].split ('\n'):
+ if re.match ('.*/libcrypto\..*', line):
+ return line
+
+ selected_crypto = otool (testApp)
+ ndnd_crypto = otool ('%s/bin/ndnd' % self.env['%s_ROOT' % ndn_var])
+
+ if ndnd_crypto != selected_crypto:
+ self.fatal ("Selected openssl does not match used to compile NDNx (%s != %s)" %
+ (selected_crypto.strip (), ndnd_crypto.strip ()))
+ self.end_msg (True)
+
+ elif Utils.unversioned_sys_platform () == "linux" or Utils.unversioned_sys_platform () == "freebsd":
+ def ldd (binary):
+ p = Utils.subprocess.Popen (['/usr/bin/ldd', binary],
+ stdout = Utils.subprocess.PIPE, )
+ for line in p.communicate()[0].split ('\n'):
+ if re.match ('libcrypto\..*', line):
+ return line
+
+ selected_crypto = ldd (testApp)
+ ndnd_crypto = ldd ('%s/bin/ndnd' % self.env['%s_ROOT' % ndn_var])
+
+ if ndnd_crypto != selected_crypto:
+ self.fatal ("Selected openssl does not match used to compile NDNx (%s != %s)" %
+ (selected_crypto.strip (), ndnd_crypto.strip ()))
+ self.end_msg (True)
+ else:
+ self.end_msg ("Don't know how to check", 'YELLOW')
+
+@conf
+def check_ndnx(self,*k,**kw):
+ if not self.env['CC']:
+ self.fatal('load a c compiler first, conf.load("compiler_c")')
+
+ var=kw.get('uselib_store', 'NDNX')
+ self.start_msg('Checking for NDNx')
+ root = self.ndnx_get_root(*k,**kw);
+ self.env.NDNX_VERSION=self.ndnx_get_version(root)
+
+ self.env['INCLUDES_%s' % var]= '%s/%s' % (root, "include");
+ self.env['LIB_%s' % var] = "ndn"
+ self.env['LIBPATH_%s' % var] = '%s/%s' % (root, "lib")
+
+ self.env['%s_ROOT' % var] = root
+
+ self.end_msg("%s in %s " % (self.env.NDNX_VERSION, root))
+ if Logs.verbose:
+ Logs.pprint('CYAN',' NDNx include : %s'%self.env['INCLUDES_%s' % var])
+ Logs.pprint('CYAN',' NDNx lib : %s'%self.env['LIB_%s' % var])
+ Logs.pprint('CYAN',' NDNx libpath : %s'%self.env['LIBPATH_%s' % var])
+
+def options(opt):
+ """
+ NDNx options
+ """
+ ndnopt = opt.add_option_group("NDNx Options")
+ ndnopt.add_option('--ndnx',type='string',default=None,dest='ndnx_dir',help='''path to where NDNx is installed, e.g. /usr/local''')
+ ndnopt.add_option('--openssl',type='string',default='',dest='openssl',help='''path to openssl, should be the same NDNx is compiled against''')
diff --git a/wscript b/wscript
index 0021e41..435d075 100644
--- a/wscript
+++ b/wscript
@@ -5,7 +5,6 @@
from waflib import Build, Logs, Utils, Task, TaskGen, Configure
def options(opt):
- opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
opt.add_option('--yes',action='store_true',default=False) # for autoconf/automake/make compatibility
opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx logging support''')
@@ -13,35 +12,11 @@
if Utils.unversioned_sys_platform () == "darwin":
opt.add_option('--auto-update', action='store_true',default=False,dest='autoupdate',help='''(OSX) Download sparkle framework and enable autoupdate feature''')
- opt.load('compiler_c compiler_cxx boost ccnx protoc qt4 gnu_dirs')
- opt.load('tinyxml', tooldir=['waf-tools'])
+ opt.load('compiler_c compiler_cxx boost protoc qt4 gnu_dirs')
+ opt.load('ndnx flags tinyxml', tooldir=['waf-tools'])
def configure(conf):
- conf.load("compiler_c compiler_cxx gnu_dirs")
-
- if conf.options.debug:
- conf.define ('_DEBUG', 1)
- conf.add_supported_cxxflags (cxxflags = ['-O0',
- '-Wall',
- '-Wno-unused-variable',
- '-g3',
- '-Wno-unused-private-field', # only clang supports
- '-fcolor-diagnostics', # only clang supports
- '-Qunused-arguments' # only clang supports
- ])
- else:
- conf.add_supported_cxxflags (cxxflags = ['-O3', '-g'])
-
- # I wish I could use it, but there is some weirdness with boost tests. Give up for now
- # try:
- # conf.check(features='cxx cxxprogram', cxxflags="-std=c++11")
- # conf.env.append_value ('CXXFLAGS', ["-std=c++11"])
- # except:
- # try:
- # conf.check(features='cxx cxxprogram', cxxflags="-std=c++0x")
- # conf.env.append_value ('CXXFLAGS', ["-std=c++0x"])
- # except:
- # conf.fatal ("You compiler doesn't support C++11. You can try GCC >= 4.4 or recent version of Clang.")
+ conf.load("compiler_c compiler_cxx gnu_dirs flags")
conf.define ("CHRONOSHARE_VERSION", VERSION)
@@ -105,21 +80,11 @@
if conf.is_defined('HAVE_SPARKLE'):
conf.env.HAVE_SPARKLE = 1 # small cheat for wscript
- if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
- libcrypto = conf.check_cc(lib='crypto',
- header_name='openssl/crypto.h',
- define_name='HAVE_SSL',
- uselib_store='SSL')
- else:
- conf.define ("HAVE_SSL", 1)
- if not conf.get_define ("HAVE_SSL"):
- conf.fatal ("Cannot find SSL libraries")
-
if conf.options.log4cxx:
conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
conf.define ("HAVE_LOG4CXX", 1)
- conf.load ('ccnx')
+ conf.load ('ndnx')
conf.load('protoc')
@@ -134,8 +99,9 @@
Logs.error ("Minumum required boost version is 1.46")
return
- conf.check_ccnx (path=conf.options.ccnx_dir)
- conf.define ('CCNX_PATH', conf.env.CCNX_ROOT)
+ conf.check_ndnx ()
+ conf.check_openssl ()
+ conf.define ('NDNX_PATH', conf.env.NDNX_ROOT)
if conf.options._test:
conf.define ('_TESTS', 1)
@@ -160,18 +126,18 @@
includes = "scheduler executor src",
)
- libccnx = bld (
- target="ccnx",
+ libndnx = bld (
+ target="ndnx",
features=['cxx'],
- source = bld.path.ant_glob(['ccnx/**/*.cc', 'ccnx/**/*.cpp']),
- use = 'TINYXML BOOST BOOST_THREAD SSL CCNX LOG4CXX scheduler executor',
- includes = "ccnx src scheduler executor",
+ source = bld.path.ant_glob(['ndnx/**/*.cc', 'ndnx/**/*.cpp']),
+ use = 'TINYXML BOOST BOOST_THREAD SSL NDNX LOG4CXX scheduler executor',
+ includes = "ndnx src scheduler executor",
)
adhoc = bld (
target = "adhoc",
features=['cxx'],
- includes = "ccnx src",
+ includes = "ndnx src",
)
if Utils.unversioned_sys_platform () == "darwin":
adhoc.mac_app = True
@@ -182,8 +148,8 @@
target="chronoshare",
features=['cxx'],
source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']),
- use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 LOG4CXX scheduler ccnx",
- includes = "ccnx scheduler src executor",
+ use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 LOG4CXX scheduler ndnx",
+ includes = "ndnx scheduler src executor",
)
fs_watcher = bld (
@@ -192,7 +158,7 @@
defines = "WAF",
source = bld.path.ant_glob(['fs-watcher/*.cc']),
use = "SQLITE3 LOG4CXX scheduler executor QTCORE",
- includes = "fs-watcher scheduler executor src ccnx",
+ includes = "ndnx fs-watcher scheduler executor src",
)
# Unit tests
@@ -202,8 +168,8 @@
features = "qt4 cxx cxxprogram",
defines = "WAF",
source = bld.path.ant_glob(['test/*.cc']),
- use = 'BOOST_TEST BOOST_FILESYSTEM BOOST_DATE_TIME LOG4CXX SQLITE3 QTCORE QTGUI ccnx database fs_watcher chronoshare',
- includes = "ccnx scheduler src executor gui fs-watcher",
+ use = 'BOOST_TEST BOOST_FILESYSTEM BOOST_DATE_TIME LOG4CXX SQLITE3 QTCORE QTGUI ndnx database fs_watcher chronoshare',
+ includes = "ndnx scheduler src executor gui fs-watcher",
install_prefix = None,
)
@@ -220,8 +186,8 @@
features = "qt4 cxx cxxprogram html_resources",
defines = "WAF",
source = bld.path.ant_glob(['gui/*.cpp', 'gui/*.cc', 'gui/images.qrc']),
- includes = "ccnx scheduler executor fs-watcher gui src adhoc server . ",
- use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare http_server",
+ includes = "ndnx scheduler executor fs-watcher gui src adhoc server . ",
+ use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ndnx database chronoshare http_server",
html_resources = bld.path.find_dir ("gui/html").ant_glob([
'**/*.js', '**/*.png', '**/*.css',
@@ -283,16 +249,16 @@
features = "qt4 cxx cxxprogram",
defines = "WAF",
source = "cmd/csd.cc",
- includes = "ccnx scheduler executor gui fs-watcher src . ",
- use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare"
+ includes = "ndnx scheduler executor gui fs-watcher src . ",
+ use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ndnx database chronoshare"
)
dump_db = bld (
target = "dump-db",
features = "cxx cxxprogram",
source = "cmd/dump-db.cc",
- includes = "ccnx scheduler executor gui fs-watcher src . ",
- use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE LOG4CXX fs_watcher ccnx database chronoshare"
+ includes = "ndnx scheduler executor gui fs-watcher src . ",
+ use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE LOG4CXX fs_watcher ndnx database chronoshare"
)
from waflib import TaskGen
@@ -342,18 +308,3 @@
src_out.write (bld_out.read(), 'w')
return 0
-
-@Configure.conf
-def add_supported_cxxflags(self, cxxflags):
- """
- Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
- """
- self.start_msg('Checking allowed flags for c++ compiler')
-
- supportedFlags = []
- for flag in cxxflags:
- if self.check_cxx (cxxflags=[flag], mandatory=False):
- supportedFlags += [flag]
-
- self.end_msg (' '.join (supportedFlags))
- self.env.CXXFLAGS += supportedFlags