From 30d96e48750cac510d950191c71dba91a49be7cf Mon Sep 17 00:00:00 2001 From: Ashlesh Gawande Date: Sun, 21 Mar 2021 19:15:33 -0700 Subject: [PATCH] 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 --- .jenkins.d/10-build.sh | 2 +- docs/INSTALL.rst | 15 ++-- docs/beginners-guide.rst | 73 +++++++++++-------- nlsr.conf | 14 ++-- src/communication/sync-logic-handler.cpp | 6 +- src/communication/sync-protocol-adapter.cpp | 47 +++++++----- src/communication/sync-protocol-adapter.hpp | 16 ++-- src/conf-file-processor.cpp | 8 +- src/conf-parameter.cpp | 4 +- src/conf-parameter.hpp | 18 ++--- .../communication/test-sync-logic-handler.cpp | 43 ++++------- .../test-sync-protocol-adapter.cpp | 21 ++---- tests/security/test-certificate-store.cpp | 3 +- tests/test-common.hpp | 2 +- tests/test-lsa-rule.cpp | 5 +- tests/test-statistics.cpp | 1 + .../update/test-nfd-rib-command-processor.cpp | 2 + tests/update/test-prefix-update-processor.cpp | 3 +- tests/update/test-save-delete-prefix.cpp | 2 +- tools/nlsrc.cpp | 11 +-- wscript | 11 ++- 21 files changed, 169 insertions(+), 138 deletions(-) diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh index 2a60f0d..b09f968 100755 --- a/.jenkins.d/10-build.sh +++ b/.jenkins.d/10-build.sh @@ -28,7 +28,7 @@ if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then fi # Build in debug mode with tests -./waf --color=yes configure --debug --with-tests $ASAN $COVERAGE +./waf --color=yes configure --with-chronosync --debug --with-tests $ASAN $COVERAGE ./waf --color=yes build -j$WAF_JOBS # (tests will be run against the debug version) diff --git a/docs/INSTALL.rst b/docs/INSTALL.rst index f496919..d66d59f 100644 --- a/docs/INSTALL.rst +++ b/docs/INSTALL.rst @@ -12,16 +12,17 @@ Prerequisites Refer to `Getting started with NFD `_ for detailed installation and running instruction. -- ChronoSync library - -Download the ChronoSync library and build it according to the instructions available at -https://github.com/named-data/ChronoSync#build - - PSync library Download the PSync library and build it according to the instructions available at https://github.com/named-data/PSync#build +- [Optional] ChronoSync library + +For testing purposes, NLSR can be optionally built with Chronosync support. +Download the ChronoSync library and build it according to the instructions available at +https://github.com/named-data/ChronoSync#build + Build ----- @@ -40,3 +41,7 @@ configure``:: export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig # or export PKG_CONFIG_PATH=/path/to/pkgconfig/on/your/machine + +If ChronoSync support is desired, NLSR needs to be configured with the following option: + + ./waf configure --with-chronosync diff --git a/docs/beginners-guide.rst b/docs/beginners-guide.rst index 9807191..8cc7e99 100644 --- a/docs/beginners-guide.rst +++ b/docs/beginners-guide.rst @@ -18,7 +18,7 @@ A beginners guide to installing and testing NLSR on Fedora The following instructions are based on the information provided at the Named Data Networking project web page [NDNmain]_. Before installing NLSR it is necessary to install different libraries -and programs: ndn-cxx, NFD, ChronoSync, and PSync. This document describes the +and programs: ndn-cxx, NFD, ChronoSync [optional], and PSync. This document describes the necessary steps to correctly install these programs (§ `2 <#ndncxx>`__, `3 <#nfd>`__ and `4 <#nlsr>`__) and a brief guide on how to configure and test NLSR using a simple two-node network (§ `5 <#test>`__). @@ -361,8 +361,40 @@ commands: 4. Installing NLSR ================== -4.1 Installing ChronoSync -------------------------- +4.1 Installing PSync +-------------------- + +Before installing NLSR, it is also necessary to download and install +PSync. PSync is a synchronization library which allows NLSR to synchronize LSAs +similar to ChronoSync. More information about PSync may be found at [PSync]_. +This library may be installed by running the following commands as a regular +user and at the directory defined at § `1 <#intro>`__: + +:: + + $ git clone --depth 1 https://github.com/named-data/PSync.git + $ cd PSync + $ ./waf configure + $ ./waf + $ sudo ./waf install + +The following command needs to be used again to configure the libraries: + +:: + + $ sudo ldconfig -v | grep -i psync + +This command should display a line similar to the following: + +:: + + libPSync.so.0.1.0 -> libPSync.so.0.1.0 + +4.2 [Optional] Installing ChronoSync +------------------------------------ + +By default NLSR no longer builds with ChronoSync support. +Since ChronoSync is deprecated, only install it for testing purposes. Before installing NLSR, it is necessary to first download and install ChronoSync, which is a synchronization library which allows NLSR routers @@ -391,35 +423,6 @@ This command should display a line similar to the following: libChronoSync.so.0.5.0 -> libChronoSync.so.0.5.0 -4.2 Installing PSync -------------------------- - -Before installing NLSR, it is also necessary to download and install -PSync. PSync is a synchronization library which allows NLSR to synchronize LSAs -similar to ChronoSync. More information about PSync may be found at [PSync]_. -This library may be installed by running the following commands as a regular -user and at the directory defined at § `1 <#intro>`__: - -:: - - $ git clone --depth 1 https://github.com/named-data/PSync.git - $ cd PSync - $ ./waf configure - $ ./waf - $ sudo ./waf install - -The following command needs to be used again to configure the libraries: - -:: - - $ sudo ldconfig -v | grep -i psync - -This command should display a line similar to the following: - -:: - - libPSync.so.0.1.0 -> libPSync.so.0.1.0 - 4.3 Downloading and installing NLSR ----------------------------------- @@ -435,6 +438,12 @@ commands need to be run as a regular user: $ ./waf $ sudo ./waf install +If ChronoSync support is needed for testing, please configure NLSR with: + +:: + + $ ./waf configure --with-chronosync + 4.4 Configuring NLSR -------------------- diff --git a/nlsr.conf b/nlsr.conf index 0adf02c..752dc44 100644 --- a/nlsr.conf +++ b/nlsr.conf @@ -28,7 +28,7 @@ general state-dir /var/lib/nlsr ; path for intermediate state files including sequence directory (Absolute path) } -; the neighbor's section contains the configuration for router's neighbors and hellos behavior +; the neighbors section contains the configuration for router's neighbors and hello protocol behavior neighbors { @@ -144,7 +144,7 @@ security checker { type customized - sig-type rsa-sha256 + sig-type ecdsa-sha256 key-locator { type name @@ -172,7 +172,7 @@ security checker { type customized - sig-type rsa-sha256 + sig-type ecdsa-sha256 key-locator { type name @@ -201,7 +201,7 @@ security checker { type customized - sig-type rsa-sha256 + sig-type ecdsa-sha256 key-locator { type name @@ -229,7 +229,7 @@ security checker { type hierarchical - sig-type rsa-sha256 + sig-type ecdsa-sha256 } } @@ -256,7 +256,7 @@ security checker { type customized - sig-type rsa-sha256 + sig-type ecdsa-sha256 key-locator { type name @@ -277,7 +277,7 @@ security checker { type hierarchical - sig-type rsa-sha256 + sig-type ecdsa-sha256 } } 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 + 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 . - **/ + */ #include "sync-protocol-adapter.hpp" #include "logger.hpp" @@ -29,7 +29,7 @@ namespace nlsr { 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 @@ SyncProtocolAdapter::SyncProtocolAdapter(ndn::Face& face, : 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(face, @@ -52,40 +55,45 @@ SyncProtocolAdapter::SyncProtocolAdapter(ndn::Face& face, 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(80, - face, - syncPrefix, - userPrefix, - std::bind(&SyncProtocolAdapter::onPSyncUpdate, this, _1), - syncInterestLifetime); - } +#endif + + NDN_LOG_DEBUG("Using PSync"); + m_psyncLogic = std::make_shared(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& updates) { @@ -96,6 +104,7 @@ SyncProtocolAdapter::onChronoSyncUpdate(const std::vector& 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 . - **/ + */ #ifndef NLSR_SYNC_PROTOCOL_ADAPTER_HPP #define NLSR_SYNC_PROTOCOL_ADAPTER_HPP @@ -25,7 +25,9 @@ #include "conf-parameter.hpp" #include +#ifdef HAVE_CHRONOSYNC #include +#endif #include namespace nlsr { @@ -37,7 +39,7 @@ class SyncProtocolAdapter { 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 @@ public: 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 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: */ void onChronoSyncUpdate(const std::vector& updates); +#endif /*! \brief Hook function to call whenever PSync detects new data. * @@ -85,9 +89,11 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: onPSyncUpdate(const std::vector& updates); private: - int32_t m_syncProtocol; + SyncProtocol m_syncProtocol; SyncUpdateCallback m_syncUpdateCallback; +#ifdef HAVE_CHRONOSYNC std::shared_ptr m_chronoSyncLogic; +#endif std::shared_ptr 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 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section) } // sync-protocol - std::string syncProtocol = section.get("sync-protocol", "chronosync"); + std::string syncProtocol = section.get("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 @@ namespace nlsr { 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 makeCertificateFetcher(ndn::Face& face) @@ -52,7 +52,7 @@ ConfParameter::ConfParameter(ndn::Face& face, ndn::KeyChain& keyChain, , 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 @@ enum { 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 @@ public: 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 @@ private: ndn::time::milliseconds m_syncInterestLifetime; - int32_t m_syncProtocol; + SyncProtocol m_syncProtocol; PUBLIC_WITH_TESTS_ELSE_PRIVATE: static const uint64_t SYNC_VERSION; diff --git a/tests/communication/test-sync-logic-handler.cpp b/tests/communication/test-sync-logic-handler.cpp index bdd8a3e..55007b8 100644 --- a/tests/communication/test-sync-logic-handler.cpp +++ b/tests/communication/test-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. * @@ -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 . - **/ + */ #include "communication/sync-logic-handler.hpp" #include "tests/test-common.hpp" @@ -25,20 +25,20 @@ #include "nlsr.hpp" #include +#include namespace nlsr { namespace test { using std::shared_ptr; -template class SyncLogicFixture : public UnitTestTimeFixture { public: SyncLogicFixture() : face(m_ioService, m_keyChain) , conf(face, m_keyChain) - , confProcessor(conf, Protocol) + , confProcessor(conf, SYNC_PROTOCOL_PSYNC) , testIsLsaNew([] (const ndn::Name& name, const Lsa::Type& lsaType, const uint64_t sequenceNumber) { return true; @@ -57,16 +57,9 @@ public: this->advanceClocks(ndn::time::milliseconds(1), 10); face.sentInterests.clear(); - if (Protocol == SYNC_PROTOCOL_CHRONOSYNC) { - std::vector updates; - updates.push_back({ndn::Name(prefix).appendNumber(1), 0, seqNo}); - sync.m_syncLogic.onChronoSyncUpdate(updates); - } - else { - std::vector updates; - updates.push_back({ndn::Name(prefix), 0, seqNo}); - sync.m_syncLogic.onPSyncUpdate(updates); - } + std::vector updates; + updates.push_back({ndn::Name(prefix), 0, seqNo}); + sync.m_syncLogic.onPSyncUpdate(updates); this->advanceClocks(ndn::time::milliseconds(1), 10); } @@ -83,17 +76,13 @@ public: Lsa::Type::COORDINATE}; }; -using mpl_::int_; -using Protocols = boost::mpl::vector, - int_>; - BOOST_AUTO_TEST_SUITE(TestSyncLogicHandler) /* Tests that when SyncLogicHandler receives an LSA of either Name or Adjacency type that appears to be newer, it will emit to its signal with those LSA details. */ -BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherLS, T, Protocols, SyncLogicFixture) +BOOST_FIXTURE_TEST_CASE(UpdateForOtherLS, SyncLogicFixture) { std::vector lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY}; @@ -118,7 +107,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherLS, T, Protocols, SyncLogicFixtur either Coordinate or Name type that appears to be newer, it will emit to its signal with those LSA details. */ -BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherHR, T, Protocols, SyncLogicFixture) +BOOST_FIXTURE_TEST_CASE(UpdateForOtherHR, SyncLogicFixture) { this->conf.setHyperbolicState(HYPERBOLIC_STATE_ON); @@ -143,7 +132,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherHR, T, Protocols, SyncLogicFixtur any type that appears to be newer, it will emit to its signal with those LSA details. */ -BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherHRDry, T, Protocols, SyncLogicFixture) +BOOST_FIXTURE_TEST_CASE(UpdateForOtherHRDry, SyncLogicFixture) { this->conf.setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN); @@ -167,7 +156,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherHRDry, T, Protocols, SyncLogicFix details matching this router's details, it will *not* emit to its signal those LSA details. */ -BOOST_FIXTURE_TEST_CASE_TEMPLATE(NoUpdateForSelf, T, Protocols, SyncLogicFixture) +BOOST_FIXTURE_TEST_CASE(NoUpdateForSelf, SyncLogicFixture) { const uint64_t sequenceNumber = 1; @@ -193,7 +182,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(NoUpdateForSelf, T, Protocols, SyncLogicFixture details that do not match the expected format, it will *not* emit to its signal those LSA details. */ -BOOST_FIXTURE_TEST_CASE_TEMPLATE(MalformedUpdate, T, Protocols, SyncLogicFixture) +BOOST_FIXTURE_TEST_CASE(MalformedUpdate, SyncLogicFixture) { const uint64_t sequenceNumber = 1; @@ -215,7 +204,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(MalformedUpdate, T, Protocols, SyncLogicFixture details that do not appear to be new, it will *not* emit to its signal those LSA details. */ -BOOST_FIXTURE_TEST_CASE_TEMPLATE(LsaNotNew, T, Protocols, SyncLogicFixture) +BOOST_FIXTURE_TEST_CASE(LsaNotNew, SyncLogicFixture) { auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const Lsa::Type& lsaType, const uint64_t& sequenceNumber) { @@ -237,9 +226,9 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LsaNotNew, T, Protocols, SyncLogicFixture) +BOOST_FIXTURE_TEST_CASE(UpdatePrefix, SyncLogicFixture) { ndn::Name expectedPrefix = this->conf.getLsaPrefix(); expectedPrefix.append(this->conf.getSiteName()); diff --git a/tests/communication/test-sync-protocol-adapter.cpp b/tests/communication/test-sync-protocol-adapter.cpp index 5998caf..0266981 100644 --- a/tests/communication/test-sync-protocol-adapter.cpp +++ b/tests/communication/test-sync-protocol-adapter.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2019, The University of Memphis, +/* + * Copyright (c) 2014-2021, The University of Memphis, * Regents of the University of California, * Arizona Board of Regents. * @@ -17,15 +17,14 @@ * * You should have received a copy of the GNU General Public License along with * NLSR, e.g., in COPYING.md file. If not, see . - **/ + */ #include "communication/sync-protocol-adapter.hpp" #include "tests/test-common.hpp" #include -#include -#include +#include namespace nlsr { namespace test { @@ -43,7 +42,6 @@ public: syncPrefix.appendVersion(4); } - template void addNodes() { @@ -51,7 +49,7 @@ public: faces[i] = std::make_shared(m_ioService, util::DummyClientFace::Options{true, true}); userPrefixes[i] = Name(nameLsaUserPrefix).appendNumber(i); - nodes[i] = std::make_shared(*faces[i], T, syncPrefix, + nodes[i] = std::make_shared(*faces[i], SYNC_PROTOCOL_PSYNC, syncPrefix, userPrefixes[i], syncInterestLifetime, [i, this] (const ndn::Name& updateName, @@ -73,14 +71,11 @@ public: std::map prefixToSeq[2]; }; -using boost::mpl::int_; -using Protocols = boost::mpl::vector, int_>; +BOOST_AUTO_TEST_SUITE(TestSyncProtocolAdapter) -BOOST_FIXTURE_TEST_SUITE(TestSyncProtocolAdapter, SyncProtocolAdapterFixture) - -BOOST_AUTO_TEST_CASE_TEMPLATE(Sync, SyncProtocol, Protocols) +BOOST_FIXTURE_TEST_CASE(Basic, SyncProtocolAdapterFixture) { - addNodes(); + addNodes(); nodes[0]->publishUpdate(userPrefixes[0], 10); advanceClocks(ndn::time::milliseconds(1000), 100); diff --git a/tests/security/test-certificate-store.cpp b/tests/security/test-certificate-store.cpp index 00d5d62..df74c28 100644 --- a/tests/security/test-certificate-store.cpp +++ b/tests/security/test-certificate-store.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,7 @@ #include "lsdb.hpp" #include +#include namespace nlsr { namespace test { diff --git a/tests/test-common.hpp b/tests/test-common.hpp index 495f0ba..0f18dd7 100644 --- a/tests/test-common.hpp +++ b/tests/test-common.hpp @@ -177,7 +177,7 @@ class DummyConfFileProcessor public: DummyConfFileProcessor(ConfParameter& conf, - int32_t protocol = SYNC_PROTOCOL_PSYNC, + SyncProtocol protocol = SYNC_PROTOCOL_PSYNC, int32_t hyperbolicState = HYPERBOLIC_STATE_OFF, ndn::Name networkName = "/ndn", ndn::Name siteName = "/site", ndn::Name routerName = "/%C1.Router/this-router") diff --git a/tests/test-lsa-rule.cpp b/tests/test-lsa-rule.cpp index e6d4458..4e7b3b3 100644 --- a/tests/test-lsa-rule.cpp +++ b/tests/test-lsa-rule.cpp @@ -25,13 +25,14 @@ #include #include -#include #include #include +#include #include -#include +#include #include +#include using namespace ndn; diff --git a/tests/test-statistics.cpp b/tests/test-statistics.cpp index 0000fb0..2c02bb7 100644 --- a/tests/test-statistics.cpp +++ b/tests/test-statistics.cpp @@ -26,6 +26,7 @@ #include "nlsr.hpp" #include +#include namespace nlsr { namespace test { diff --git a/tests/update/test-nfd-rib-command-processor.cpp b/tests/update/test-nfd-rib-command-processor.cpp index d5fa0c8..ef8c1b6 100644 --- a/tests/update/test-nfd-rib-command-processor.cpp +++ b/tests/update/test-nfd-rib-command-processor.cpp @@ -27,6 +27,8 @@ #include "../test-common.hpp" #include "../control-commands.hpp" +#include + namespace nlsr { namespace test { diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp index e5a5890..70fd491 100644 --- a/tests/update/test-prefix-update-processor.cpp +++ b/tests/update/test-prefix-update-processor.cpp @@ -31,8 +31,9 @@ #include #include -#include +#include #include +#include using namespace ndn; diff --git a/tests/update/test-save-delete-prefix.cpp b/tests/update/test-save-delete-prefix.cpp index 336ec8a..26644f8 100644 --- a/tests/update/test-save-delete-prefix.cpp +++ b/tests/update/test-save-delete-prefix.cpp @@ -53,7 +53,7 @@ public: , SITE_CERT_PATH(boost::filesystem::current_path() / std::string("site.cert")) , counter(0) { - std::ifstream source("/usr/local/etc/ndn/nlsr.conf.sample", std::ios::binary); + std::ifstream source("nlsr.conf", std::ios::binary); std::ofstream destination(testConfFile, std::ios::binary); destination << source.rdbuf(); source.close(); diff --git a/tools/nlsrc.cpp b/tools/nlsrc.cpp index adeaeee..6c1f064 100644 --- a/tools/nlsrc.cpp +++ b/tools/nlsrc.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. * @@ -24,15 +24,16 @@ #include "version.hpp" #include "src/publisher/dataset-interest-handler.hpp" -#include #include -#include #include +#include +#include #include #include -#include -#include #include +#include +#include +#include #include diff --git a/wscript b/wscript index 087ed61..1c24944 100644 --- a/wscript +++ b/wscript @@ -1,6 +1,6 @@ # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- """ -Copyright (c) 2014-2019, The University of Memphis, +Copyright (c) 2014-2021, The University of Memphis, Regents of the University of California, Arizona Board of Regents. @@ -37,6 +37,8 @@ def options(opt): optgrp = opt.add_option_group('NLSR Options') optgrp.add_option('--with-tests', action='store_true', default=False, help='Build unit tests') + optgrp.add_option('--with-chronosync', action='store_true', default=False, + help='Build with Chronosync support') def configure(conf): conf.load(['compiler_cxx', 'gnu_dirs', @@ -59,8 +61,9 @@ def configure(conf): 'Please upgrade your distribution or manually install a newer version of Boost' ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)') - conf.check_cfg(package='ChronoSync', args=['--cflags', '--libs'], uselib_store='SYNC', - pkg_config_path=pkg_config_path) + if conf.options.with_chronosync: + conf.check_cfg(package='ChronoSync', args=['--cflags', '--libs'], + uselib_store='CHRONOSYNC', pkg_config_path=pkg_config_path) conf.check_cfg(package='PSync', args=['--cflags', '--libs'], uselib_store='PSYNC', pkg_config_path=pkg_config_path) @@ -98,7 +101,7 @@ def build(bld): target='nlsr-objects', source=bld.path.ant_glob('src/**/*.cpp', excl=['src/main.cpp']), - use='NDN_CXX BOOST SYNC PSYNC', + use='NDN_CXX BOOST CHRONOSYNC PSYNC', includes='. src', export_includes='. src')