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;
};
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index d3e1625..1d3b781 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -293,9 +293,15 @@
}
// sync-protocol
- std::string syncProtocol = section.get<std::string>("sync-protocol", "chronosync");
+ std::string syncProtocol = section.get<std::string>("sync-protocol", "psync");
if (syncProtocol == "chronosync") {
+#ifdef HAVE_CHRONOSYNC
m_confParam.setSyncProtocol(SYNC_PROTOCOL_CHRONOSYNC);
+#else
+ std::cerr << "NLSR was compiled without Chronosync support!" << std::endl;
+ std::cerr << "Only PSync support is currently available ('sync-protocol psync')" << std::endl;
+ return false;
+#endif
}
else if (syncProtocol == "psync") {
m_confParam.setSyncProtocol(SYNC_PROTOCOL_PSYNC);
diff --git a/src/conf-parameter.cpp b/src/conf-parameter.cpp
index 47a33e8..fb92aa2 100644
--- a/src/conf-parameter.cpp
+++ b/src/conf-parameter.cpp
@@ -26,7 +26,7 @@
INIT_LOGGER(ConfParameter);
// To be changed when breaking changes are made to sync
-const uint64_t ConfParameter::SYNC_VERSION = 9;
+const uint64_t ConfParameter::SYNC_VERSION = 10;
static std::unique_ptr<ndn::security::CertificateFetcherDirectFetch>
makeCertificateFetcher(ndn::Face& face)
@@ -52,7 +52,7 @@
, m_corR(0)
, m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
, m_syncInterestLifetime(ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT))
- , m_syncProtocol(SYNC_PROTOCOL_CHRONOSYNC)
+ , m_syncProtocol(SYNC_PROTOCOL_PSYNC)
, m_adjl()
, m_npl()
, m_validator(makeCertificateFetcher(face))
diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp
index c000c4b..57dd2c2 100644
--- a/src/conf-parameter.hpp
+++ b/src/conf-parameter.hpp
@@ -40,9 +40,11 @@
LSA_REFRESH_TIME_MAX = 7200
};
-enum {
- SYNC_PROTOCOL_CHRONOSYNC = 0,
- SYNC_PROTOCOL_PSYNC = 1
+enum SyncProtocol {
+#ifdef HAVE_CHRONOSYNC
+ SYNC_PROTOCOL_CHRONOSYNC,
+#endif
+ SYNC_PROTOCOL_PSYNC
};
enum {
@@ -211,18 +213,16 @@
m_lsaRefreshTime = lrt;
}
- uint32_t
+ SyncProtocol
getSyncProtocol() const
{
return m_syncProtocol;
}
void
- setSyncProtocol(int32_t syncProtocol)
+ setSyncProtocol(SyncProtocol syncProtocol)
{
- if (syncProtocol == SYNC_PROTOCOL_CHRONOSYNC || syncProtocol == SYNC_PROTOCOL_PSYNC) {
- m_syncProtocol = syncProtocol;
- }
+ m_syncProtocol = syncProtocol;
}
uint32_t
@@ -527,7 +527,7 @@
ndn::time::milliseconds m_syncInterestLifetime;
- int32_t m_syncProtocol;
+ SyncProtocol m_syncProtocol;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
static const uint64_t SYNC_VERSION;