Do not compile ChronoSync support by default
ChronoSync dependency is now made optional
and is kept for testing purposes only.
Also change sig-type to ecdsa-sha256 in nlsr.conf
as ndn-cxx now has strict checking for it.
refs: #5147
Change-Id: I95c9fb844681ebf2c4e7bbb03cc7796a0795de83
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 99bdeac..4f8eba2 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
+/*
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -26,6 +26,8 @@
#include "logger.hpp"
#include "utility/name-helper.hpp"
+#include <boost/lexical_cast.hpp>
+
namespace nlsr {
INIT_LOGGER(SyncLogicHandler);
diff --git a/src/communication/sync-protocol-adapter.cpp b/src/communication/sync-protocol-adapter.cpp
index af263c8..ae08e3a 100644
--- a/src/communication/sync-protocol-adapter.cpp
+++ b/src/communication/sync-protocol-adapter.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018, The University of Memphis,
+/*
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
#include "sync-protocol-adapter.hpp"
#include "logger.hpp"
@@ -29,7 +29,7 @@
const auto FIXED_SESSION = ndn::name::Component::fromNumber(0);
SyncProtocolAdapter::SyncProtocolAdapter(ndn::Face& face,
- int32_t syncProtocol,
+ SyncProtocol syncProtocol,
const ndn::Name& syncPrefix,
const ndn::Name& userPrefix,
ndn::time::milliseconds syncInterestLifetime,
@@ -37,6 +37,9 @@
: m_syncProtocol(syncProtocol)
, m_syncUpdateCallback(syncUpdateCallback)
{
+ NLSR_LOG_TRACE("SyncProtocol value: " << m_syncProtocol);
+
+#ifdef HAVE_CHRONOSYNC
if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) {
NDN_LOG_DEBUG("Using ChronoSync");
m_chronoSyncLogic = std::make_shared<chronosync::Logic>(face,
@@ -52,40 +55,45 @@
chronosync::Logic::DEFAULT_SYNC_REPLY_FRESHNESS,
chronosync::Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME,
FIXED_SESSION);
+ return;
}
- else {
- NDN_LOG_DEBUG("Using PSync");
- m_psyncLogic = std::make_shared<psync::FullProducer>(80,
- face,
- syncPrefix,
- userPrefix,
- std::bind(&SyncProtocolAdapter::onPSyncUpdate, this, _1),
- syncInterestLifetime);
- }
+#endif
+
+ NDN_LOG_DEBUG("Using PSync");
+ m_psyncLogic = std::make_shared<psync::FullProducer>(80,
+ face,
+ syncPrefix,
+ userPrefix,
+ std::bind(&SyncProtocolAdapter::onPSyncUpdate, this, _1),
+ syncInterestLifetime);
}
void
SyncProtocolAdapter::addUserNode(const ndn::Name& userPrefix)
{
+#ifdef HAVE_CHRONOSYNC
if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) {
m_chronoSyncLogic->addUserNode(userPrefix, chronosync::Logic::DEFAULT_NAME, FIXED_SESSION);
+ return;
}
- else {
- m_psyncLogic->addUserNode(userPrefix);
- }
+#endif
+
+ m_psyncLogic->addUserNode(userPrefix);
}
void
SyncProtocolAdapter::publishUpdate(const ndn::Name& userPrefix, uint64_t seq)
{
+#ifdef HAVE_CHRONOSYNC
if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) {
m_chronoSyncLogic->updateSeqNo(seq, userPrefix);
+ return;
}
- else {
- m_psyncLogic->publishName(userPrefix, seq);
- }
+#endif
+ m_psyncLogic->publishName(userPrefix, seq);
}
+#ifdef HAVE_CHRONOSYNC
void
SyncProtocolAdapter::onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& updates)
{
@@ -96,6 +104,7 @@
m_syncUpdateCallback(update.session.getPrefix(-1), update.high);
}
}
+#endif
void
SyncProtocolAdapter::onPSyncUpdate(const std::vector<psync::MissingDataInfo>& updates)
diff --git a/src/communication/sync-protocol-adapter.hpp b/src/communication/sync-protocol-adapter.hpp
index 363f02d..1d56b25 100644
--- a/src/communication/sync-protocol-adapter.hpp
+++ b/src/communication/sync-protocol-adapter.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018, The University of Memphis,
+/*
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
#ifndef NLSR_SYNC_PROTOCOL_ADAPTER_HPP
#define NLSR_SYNC_PROTOCOL_ADAPTER_HPP
@@ -25,7 +25,9 @@
#include "conf-parameter.hpp"
#include <ndn-cxx/face.hpp>
+#ifdef HAVE_CHRONOSYNC
#include <ChronoSync/logic.hpp>
+#endif
#include <PSync/full-producer.hpp>
namespace nlsr {
@@ -37,7 +39,7 @@
{
public:
SyncProtocolAdapter(ndn::Face& facePtr,
- int32_t syncProtocol,
+ SyncProtocol syncProtocol,
const ndn::Name& syncPrefix,
const ndn::Name& userPrefix,
ndn::time::milliseconds syncInterestLifetime,
@@ -62,6 +64,7 @@
publishUpdate(const ndn::Name& userPrefix, uint64_t seq);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
+#ifdef HAVE_CHRONOSYNC
/*! \brief Hook function to call whenever ChronoSync detects new data.
*
* This function packages the sync information into discrete updates
@@ -72,6 +75,7 @@
*/
void
onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& updates);
+#endif
/*! \brief Hook function to call whenever PSync detects new data.
*
@@ -85,9 +89,11 @@
onPSyncUpdate(const std::vector<psync::MissingDataInfo>& updates);
private:
- int32_t m_syncProtocol;
+ SyncProtocol m_syncProtocol;
SyncUpdateCallback m_syncUpdateCallback;
+#ifdef HAVE_CHRONOSYNC
std::shared_ptr<chronosync::Logic> m_chronoSyncLogic;
+#endif
std::shared_ptr<psync::FullProducer> m_psyncLogic;
};