diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp index 3e29067..cd9e17a 100644 --- a/src/communication/sync-logic-handler.cpp +++ b/src/communication/sync-logic-handler.cpp @@ -20,9 +20,7 @@ */ #include "sync-logic-handler.hpp" -#include "common.hpp" -#include "conf-parameter.hpp" -#include "lsa/lsa.hpp" +#include "hello-protocol.hpp" #include "logger.hpp" #include "utility/name-helper.hpp" @@ -32,14 +30,14 @@ namespace nlsr { INIT_LOGGER(SyncLogicHandler); -SyncLogicHandler::SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, - const ConfParameter& conf) - : onNewLsa(std::make_unique()) - , m_syncFace(face) - , m_isLsaNew(isLsaNew) +const std::string LSA_COMPONENT{"LSA"}; + +SyncLogicHandler::SyncLogicHandler(ndn::Face& face, ndn::KeyChain& keyChain, + IsLsaNew isLsaNew, const ConfParameter& conf) + : m_isLsaNew(std::move(isLsaNew)) , m_confParam(conf) , m_nameLsaUserPrefix(ndn::Name(m_confParam.getSyncUserPrefix()).append(boost::lexical_cast(Lsa::Type::NAME))) - , m_syncLogic(m_syncFace, m_confParam.getSyncProtocol(), m_confParam.getSyncPrefix(), + , m_syncLogic(face, keyChain, m_confParam.getSyncProtocol(), m_confParam.getSyncPrefix(), m_nameLsaUserPrefix, m_confParam.getSyncInterestLifetime(), std::bind(&SyncLogicHandler::processUpdate, this, _1, _2, _3)) { @@ -62,7 +60,7 @@ SyncLogicHandler::processUpdate(const ndn::Name& updateName, uint64_t highSeq, u { NLSR_LOG_DEBUG("Update Name: " << updateName << " Seq no: " << highSeq); - int32_t nlsrPosition = util::getNameComponentPosition(updateName, NLSR_COMPONENT); + int32_t nlsrPosition = util::getNameComponentPosition(updateName, HelloProtocol::NLSR_COMPONENT); int32_t lsaPosition = util::getNameComponentPosition(updateName, LSA_COMPONENT); if (nlsrPosition < 0 || lsaPosition < 0) { @@ -70,9 +68,8 @@ SyncLogicHandler::processUpdate(const ndn::Name& updateName, uint64_t highSeq, u return; } - ndn::Name networkName = updateName.getSubName(1, nlsrPosition-1); + ndn::Name networkName = updateName.getSubName(1, nlsrPosition - 1); ndn::Name routerName = updateName.getSubName(lsaPosition + 1).getPrefix(-1); - ndn::Name originRouter = networkName; originRouter.append(routerName); @@ -109,7 +106,8 @@ SyncLogicHandler::processUpdateFromSync(const ndn::Name& originRouter, "is enabled. Not going to fetch."); return; } - (*onNewLsa)(updateName, seqNo, originRouter, incomingFaceId); + + onNewLsa(updateName, seqNo, originRouter, incomingFaceId); } } } diff --git a/src/communication/sync-logic-handler.hpp b/src/communication/sync-logic-handler.hpp index 9f3e5de..6eee213 100644 --- a/src/communication/sync-logic-handler.hpp +++ b/src/communication/sync-logic-handler.hpp @@ -23,25 +23,19 @@ #define NLSR_SYNC_LOGIC_HANDLER_HPP #include "conf-parameter.hpp" -#include "test-access-control.hpp" -#include "signals.hpp" #include "lsa/lsa.hpp" +#include "signals.hpp" #include "sync-protocol-adapter.hpp" - -#include -#include +#include "test-access-control.hpp" namespace nlsr { -class ConfParameter; - /*! \brief NLSR-to-ChronoSync interaction point * * This class serves as the abstraction for the syncing portion of * NLSR and its components. NLSR has no particular reliance on * ChronoSync, except that the NLSR source would need to be modified * for use with other sync protocols. - * */ class SyncLogicHandler { @@ -55,7 +49,8 @@ public: using IsLsaNew = std::function; - SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, const ConfParameter& conf); + SyncLogicHandler(ndn::Face& face, ndn::KeyChain& keyChain, + IsLsaNew isLsaNew, const ConfParameter& conf); /*! \brief Instruct ChronoSync to publish an update. * @@ -92,10 +87,9 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: const ndn::Name& updateName, uint64_t seqNo, uint64_t incomingFaceId); public: - std::unique_ptr onNewLsa; + OnNewLsa onNewLsa; private: - ndn::Face& m_syncFace; IsLsaNew m_isLsaNew; const ConfParameter& m_confParam; @@ -105,10 +99,6 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: ndn::Name m_coorLsaUserPrefix; SyncProtocolAdapter m_syncLogic; - -private: - const std::string NLSR_COMPONENT = "nlsr"; - const std::string LSA_COMPONENT = "LSA"; }; } // namespace nlsr diff --git a/src/communication/sync-protocol-adapter.cpp b/src/communication/sync-protocol-adapter.cpp index 81ec6f3..2e09d2b 100644 --- a/src/communication/sync-protocol-adapter.cpp +++ b/src/communication/sync-protocol-adapter.cpp @@ -22,30 +22,32 @@ #include "sync-protocol-adapter.hpp" #include "logger.hpp" -INIT_LOGGER(SyncProtocolAdapter); - namespace nlsr { +INIT_LOGGER(SyncProtocolAdapter); + +#ifdef HAVE_CHRONOSYNC const auto FIXED_SESSION = ndn::name::Component::fromNumber(0); +#endif SyncProtocolAdapter::SyncProtocolAdapter(ndn::Face& face, + ndn::KeyChain& keyChain, SyncProtocol syncProtocol, const ndn::Name& syncPrefix, const ndn::Name& userPrefix, ndn::time::milliseconds syncInterestLifetime, - const SyncUpdateCallback& syncUpdateCallback) - : m_syncProtocol(syncProtocol) - , m_syncUpdateCallback(syncUpdateCallback) + SyncUpdateCallback syncUpdateCallback) + : m_syncProtocol(syncProtocol) + , m_syncUpdateCallback(std::move(syncUpdateCallback)) { - NLSR_LOG_TRACE("SyncProtocol value: " << m_syncProtocol); - + switch (m_syncProtocol) { #ifdef HAVE_CHRONOSYNC - if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) { + case SyncProtocol::CHRONOSYNC: NDN_LOG_DEBUG("Using ChronoSync"); m_chronoSyncLogic = std::make_shared(face, syncPrefix, userPrefix, - std::bind(&SyncProtocolAdapter::onChronoSyncUpdate, this, _1), + [this] (auto&&... args) { onChronoSyncUpdate(std::forward(args)...); }, chronosync::Logic::DEFAULT_NAME, chronosync::Logic::DEFAULT_VALIDATOR, chronosync::Logic::DEFAULT_RESET_TIMER, @@ -55,42 +57,55 @@ SyncProtocolAdapter::SyncProtocolAdapter(ndn::Face& face, chronosync::Logic::DEFAULT_SYNC_REPLY_FRESHNESS, chronosync::Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME, FIXED_SESSION); - return; - } + break; #endif - - NDN_LOG_DEBUG("Using PSync"); - m_psyncLogic = std::make_shared(80, - face, - syncPrefix, - userPrefix, - std::bind(&SyncProtocolAdapter::onPSyncUpdate, this, _1), - syncInterestLifetime); + case SyncProtocol::PSYNC: + NDN_LOG_DEBUG("Using PSync"); + m_psyncLogic = std::make_shared(face, + keyChain, + 80, + syncPrefix, + userPrefix, + [this] (auto&&... args) { onPSyncUpdate(std::forward(args)...); }, + syncInterestLifetime); + break; + default: + NDN_CXX_UNREACHABLE; + } } void SyncProtocolAdapter::addUserNode(const ndn::Name& userPrefix) { + switch (m_syncProtocol) { #ifdef HAVE_CHRONOSYNC - if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) { + case SyncProtocol::CHRONOSYNC: m_chronoSyncLogic->addUserNode(userPrefix, chronosync::Logic::DEFAULT_NAME, FIXED_SESSION); - return; - } + break; #endif - - m_psyncLogic->addUserNode(userPrefix); + case SyncProtocol::PSYNC: + m_psyncLogic->addUserNode(userPrefix); + break; + default: + NDN_CXX_UNREACHABLE; + } } void SyncProtocolAdapter::publishUpdate(const ndn::Name& userPrefix, uint64_t seq) { + switch (m_syncProtocol) { #ifdef HAVE_CHRONOSYNC - if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) { + case SyncProtocol::CHRONOSYNC: m_chronoSyncLogic->updateSeqNo(seq, userPrefix); - return; - } + break; #endif - m_psyncLogic->publishName(userPrefix, seq); + case SyncProtocol::PSYNC: + m_psyncLogic->publishName(userPrefix, seq); + break; + default: + NDN_CXX_UNREACHABLE; + } } #ifdef HAVE_CHRONOSYNC diff --git a/src/communication/sync-protocol-adapter.hpp b/src/communication/sync-protocol-adapter.hpp index db67fb1..fb5cdbe 100644 --- a/src/communication/sync-protocol-adapter.hpp +++ b/src/communication/sync-protocol-adapter.hpp @@ -25,6 +25,8 @@ #include "conf-parameter.hpp" #include +#include + #ifdef HAVE_CHRONOSYNC #include #endif @@ -32,18 +34,19 @@ namespace nlsr { -typedef std::function SyncUpdateCallback; +using SyncUpdateCallback = std::function; class SyncProtocolAdapter { public: - SyncProtocolAdapter(ndn::Face& facePtr, + SyncProtocolAdapter(ndn::Face& face, + ndn::KeyChain& keyChain, SyncProtocol syncProtocol, const ndn::Name& syncPrefix, const ndn::Name& userPrefix, ndn::time::milliseconds syncInterestLifetime, - const SyncUpdateCallback& syncUpdateCallback); + SyncUpdateCallback syncUpdateCallback); /*! \brief Add user node to ChronoSync or PSync * @@ -91,6 +94,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: private: SyncProtocol m_syncProtocol; SyncUpdateCallback m_syncUpdateCallback; + #ifdef HAVE_CHRONOSYNC std::shared_ptr m_chronoSyncLogic; #endif diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp index 4140e0d..bd7dceb 100644 --- a/src/conf-file-processor.cpp +++ b/src/conf-file-processor.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2021, The University of Memphis, + * Copyright (c) 2014-2022, The University of Memphis, * Regents of the University of California, * Arizona Board of Regents. * @@ -287,19 +287,19 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section) std::string syncProtocol = section.get("sync-protocol", "psync"); if (syncProtocol == "chronosync") { #ifdef HAVE_CHRONOSYNC - m_confParam.setSyncProtocol(SYNC_PROTOCOL_CHRONOSYNC); + m_confParam.setSyncProtocol(SyncProtocol::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; + std::cerr << "NLSR was compiled without ChronoSync support!\n" + << "Only PSync support is currently available ('sync-protocol psync')\n"; return false; #endif } else if (syncProtocol == "psync") { - m_confParam.setSyncProtocol(SYNC_PROTOCOL_PSYNC); + m_confParam.setSyncProtocol(SyncProtocol::PSYNC); } else { std::cerr << "Sync protocol '" << syncProtocol << "' is not supported!\n" - << "Use chronosync or psync" << std::endl; + << "Use either 'chronosync' or 'psync'\n"; return false; } diff --git a/src/conf-parameter.cpp b/src/conf-parameter.cpp index 8a7a56f..d1c6412 100644 --- a/src/conf-parameter.cpp +++ b/src/conf-parameter.cpp @@ -51,7 +51,6 @@ 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_PSYNC) , m_adjl() , m_npl() , m_validator(makeCertificateFetcher(face)) diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp index aedffac..32b343c 100644 --- a/src/conf-parameter.hpp +++ b/src/conf-parameter.hpp @@ -35,19 +35,17 @@ namespace nlsr { +enum class SyncProtocol { + CHRONOSYNC, + PSYNC, +}; + enum { LSA_REFRESH_TIME_MIN = 240, LSA_REFRESH_TIME_DEFAULT = 1800, LSA_REFRESH_TIME_MAX = 7200 }; -enum SyncProtocol { -#ifdef HAVE_CHRONOSYNC - SYNC_PROTOCOL_CHRONOSYNC, -#endif - SYNC_PROTOCOL_PSYNC -}; - enum { LSA_INTEREST_LIFETIME_MIN = 1, LSA_INTEREST_LIFETIME_DEFAULT = 4, @@ -528,7 +526,7 @@ private: ndn::time::milliseconds m_syncInterestLifetime; - SyncProtocol m_syncProtocol; + SyncProtocol m_syncProtocol = SyncProtocol::PSYNC; PUBLIC_WITH_TESTS_ELSE_PRIVATE: // must be incremented when breaking changes are made to sync diff --git a/src/hello-protocol.hpp b/src/hello-protocol.hpp index 3ae3629..c1664bd 100644 --- a/src/hello-protocol.hpp +++ b/src/hello-protocol.hpp @@ -123,6 +123,9 @@ private: const ndn::security::ValidationError& ve); public: + static inline const std::string INFO_COMPONENT{"INFO"}; + static inline const std::string NLSR_COMPONENT{"nlsr"}; + ndn::util::Signal onInitialHelloDataValidated; private: @@ -134,10 +137,6 @@ private: RoutingTable& m_routingTable; Lsdb& m_lsdb; AdjacencyList& m_adjacencyList; - -PUBLIC_WITH_TESTS_ELSE_PRIVATE: - static inline const std::string INFO_COMPONENT{"INFO"}; - static inline const std::string NLSR_COMPONENT{"nlsr"}; }; } // namespace nlsr diff --git a/src/lsdb.cpp b/src/lsdb.cpp index bca46a6..9922fa0 100644 --- a/src/lsdb.cpp +++ b/src/lsdb.cpp @@ -35,7 +35,7 @@ Lsdb::Lsdb(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam) : m_face(face) , m_scheduler(face.getIoService()) , m_confParam(confParam) - , m_sync(m_face, + , m_sync(m_face, keyChain, [this] (const auto& routerName, const Lsa::Type& lsaType, uint64_t sequenceNumber, uint64_t incomingFaceId) { return isLsaNew(routerName, lsaType, sequenceNumber); @@ -44,7 +44,7 @@ Lsdb::Lsdb(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam) , m_adjLsaBuildInterval(m_confParam.getAdjLsaBuildInterval()) , m_thisRouterPrefix(m_confParam.getRouterPrefix()) , m_sequencingManager(m_confParam.getStateFileDir(), m_confParam.getHyperbolicState()) - , m_onNewLsaConnection(m_sync.onNewLsa->connect( + , m_onNewLsaConnection(m_sync.onNewLsa.connect( [this] (const ndn::Name& updateName, uint64_t sequenceNumber, const ndn::Name& originRouter, uint64_t incomingFaceId) { ndn::Name lsaInterest{updateName}; diff --git a/src/lsdb.hpp b/src/lsdb.hpp index 915c7b6..0578edd 100644 --- a/src/lsdb.hpp +++ b/src/lsdb.hpp @@ -178,7 +178,8 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: } void - incrementDataSentStats(Lsa::Type lsaType) { + incrementDataSentStats(Lsa::Type lsaType) + { if (lsaType == Lsa::Type::NAME) { lsaIncrementSignal(Statistics::PacketType::SENT_NAME_LSA_DATA); } @@ -191,7 +192,8 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: } void - incrementInterestRcvdStats(Lsa::Type lsaType) { + incrementInterestRcvdStats(Lsa::Type lsaType) + { if (lsaType == Lsa::Type::NAME) { lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_INTEREST); } @@ -204,7 +206,8 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: } void - incrementInterestSentStats(Lsa::Type lsaType) { + incrementInterestSentStats(Lsa::Type lsaType) + { if (lsaType == Lsa::Type::NAME) { lsaIncrementSignal(Statistics::PacketType::SENT_NAME_LSA_INTEREST); } @@ -222,7 +225,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE: \param seqNo The sequence number to check. */ bool - isLsaNew(const ndn::Name& originRouter, const Lsa::Type& lsaType, uint64_t lsSeqNo) + isLsaNew(const ndn::Name& originRouter, const Lsa::Type& lsaType, uint64_t lsSeqNo) const { // Is the name in the LSDB and the supplied seq no is the highest so far auto lsaPtr = findLsa(originRouter, lsaType); diff --git a/src/nlsr.cpp b/src/nlsr.cpp index c43ad47..533d920 100644 --- a/src/nlsr.cpp +++ b/src/nlsr.cpp @@ -45,7 +45,7 @@ Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam) , m_namePrefixTable(confParam.getRouterPrefix(), m_fib, m_routingTable, m_routingTable.afterRoutingChange, m_lsdb.onLsdbModified) , m_helloProtocol(m_face, keyChain, confParam, m_routingTable, m_lsdb) - , m_onNewLsaConnection(m_lsdb.getSync().onNewLsa->connect( + , m_onNewLsaConnection(m_lsdb.getSync().onNewLsa.connect( [this] (const ndn::Name& updateName, uint64_t sequenceNumber, const ndn::Name& originRouter, uint64_t incomingFaceId) { registerStrategyForCerts(originRouter); diff --git a/tests/communication/test-sync-logic-handler.cpp b/tests/communication/test-sync-logic-handler.cpp index b7836c2..8c0cc3d 100644 --- a/tests/communication/test-sync-logic-handler.cpp +++ b/tests/communication/test-sync-logic-handler.cpp @@ -37,7 +37,6 @@ class SyncLogicFixture : public IoKeyChainFixture public: SyncLogicFixture() : testIsLsaNew([] (auto&&...) { return true; }) - , sync(face, testIsLsaNew, conf) , updateNamePrefix(this->conf.getLsaPrefix().toUri() + this->conf.getSiteName().toUri() + "/%C1.Router/other-router/") @@ -61,9 +60,9 @@ public: public: ndn::util::DummyClientFace face{m_io, m_keyChain}; ConfParameter conf{face, m_keyChain}; - DummyConfFileProcessor confProcessor{conf, SYNC_PROTOCOL_PSYNC}; + DummyConfFileProcessor confProcessor{conf, SyncProtocol::PSYNC}; SyncLogicHandler::IsLsaNew testIsLsaNew; - SyncLogicHandler sync; + SyncLogicHandler sync{face, m_keyChain, testIsLsaNew, conf}; const std::string updateNamePrefix; const std::vector lsaTypes{Lsa::Type::NAME, @@ -85,7 +84,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherLS) for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::ADJACENCY}) { std::string updateName = this->updateNamePrefix + boost::lexical_cast(lsaType); - ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect( + ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect( [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) { BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName); BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo); @@ -112,7 +111,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHR) for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::COORDINATE}) { std::string updateName = this->updateNamePrefix + boost::lexical_cast(lsaType); - ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect( + ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect( [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) { BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName); BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo); @@ -139,7 +138,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry) for (auto lsaType : this->lsaTypes) { std::string updateName = this->updateNamePrefix + boost::lexical_cast(lsaType); - ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect( + ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect( [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) { BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName); BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo); @@ -168,7 +167,7 @@ BOOST_AUTO_TEST_CASE(NoUpdateForSelf) .append(this->conf.getRouterName()) .append(boost::lexical_cast(lsaType)); - ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect( + ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect( [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) { BOOST_FAIL("Updates for self should not be emitted!"); }); @@ -192,7 +191,7 @@ BOOST_AUTO_TEST_CASE(MalformedUpdate) ndn::Name updateName{this->conf.getSiteName()}; updateName.append(this->conf.getRouterName()).append(boost::lexical_cast(lsaType)); - ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect( + ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect( [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) { BOOST_FAIL("Malformed updates should not be emitted!"); }); @@ -216,11 +215,11 @@ BOOST_AUTO_TEST_CASE(LsaNotNew) }; const uint64_t sequenceNumber = 1; - SyncLogicHandler sync{this->face, testLsaAlwaysFalse, this->conf}; - ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect( - [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) { - BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!"); - }); + SyncLogicHandler sync{this->face, this->m_keyChain, testLsaAlwaysFalse, this->conf}; + ndn::util::signal::ScopedConnection connection = sync.onNewLsa.connect( + [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) { + BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!"); + }); std::string updateName = this->updateNamePrefix + boost::lexical_cast(Lsa::Type::NAME); this->receiveUpdate(updateName, sequenceNumber); diff --git a/tests/communication/test-sync-protocol-adapter.cpp b/tests/communication/test-sync-protocol-adapter.cpp index 919f5e8..721b2f7 100644 --- a/tests/communication/test-sync-protocol-adapter.cpp +++ b/tests/communication/test-sync-protocol-adapter.cpp @@ -49,11 +49,11 @@ public: faces[i] = std::make_shared(m_io, util::DummyClientFace::Options{true, true}); userPrefixes[i] = Name(nameLsaUserPrefix).appendNumber(i); - nodes[i] = std::make_shared(*faces[i], SYNC_PROTOCOL_PSYNC, syncPrefix, - userPrefixes[i], + nodes[i] = std::make_shared(*faces[i], m_keyChain, SyncProtocol::PSYNC, + syncPrefix, userPrefixes[i], syncInterestLifetime, [i, this] (const ndn::Name& updateName, - uint64_t highSeq, uint64_t incomingFaceId) { + uint64_t highSeq, uint64_t incomingFaceId) { prefixToSeq[i].emplace(updateName, highSeq); }); } diff --git a/tests/security/test-certificate-store.cpp b/tests/security/test-certificate-store.cpp index 6c8a4f6..b0580c9 100644 --- a/tests/security/test-certificate-store.cpp +++ b/tests/security/test-certificate-store.cpp @@ -42,7 +42,7 @@ public: CertificateStoreFixture() : face(m_io, m_keyChain, {true, true}) , conf(face, m_keyChain, "unit-test-nlsr.conf") - , confProcessor(conf, SYNC_PROTOCOL_PSYNC, HYPERBOLIC_STATE_OFF, + , confProcessor(conf, SyncProtocol::PSYNC, HYPERBOLIC_STATE_OFF, "/ndn/", "/site", "/%C1.Router/router1") , rootIdName(conf.getNetwork()) , siteIdentityName(ndn::Name(conf.getNetwork()).append(conf.getSiteName())) diff --git a/tests/test-common.hpp b/tests/test-common.hpp index 1c8c0e2..3498f81 100644 --- a/tests/test-common.hpp +++ b/tests/test-common.hpp @@ -62,7 +62,7 @@ class DummyConfFileProcessor { public: DummyConfFileProcessor(ConfParameter& conf, - SyncProtocol protocol = SYNC_PROTOCOL_PSYNC, + SyncProtocol protocol = SyncProtocol::PSYNC, HyperbolicState hyperbolicState = HYPERBOLIC_STATE_OFF, const ndn::Name& networkName = "/ndn", const ndn::Name& siteName = "/site", diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp index 05e1a94..06c041c 100644 --- a/tests/test-conf-file-processor.cpp +++ b/tests/test-conf-file-processor.cpp @@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(LinkState) BOOST_CHECK_EQUAL(conf.getSyncPrefix(), ndn::Name("/localhop/ndn/nlsr/sync").appendVersion(ConfParameter::SYNC_VERSION)); BOOST_CHECK_EQUAL(conf.getLsaPrefix(), "/localhop/ndn/nlsr/LSA"); BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), 1800); - BOOST_CHECK_EQUAL(conf.getSyncProtocol(), SYNC_PROTOCOL_PSYNC); + BOOST_CHECK(conf.getSyncProtocol() == SyncProtocol::PSYNC); BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(), ndn::time::seconds(3)); BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), 86400); BOOST_CHECK_EQUAL(conf.getSyncInterestLifetime(), ndn::time::milliseconds(10000)); diff --git a/tests/test-conf-parameter.cpp b/tests/test-conf-parameter.cpp index e45a605..4d16ba5 100644 --- a/tests/test-conf-parameter.cpp +++ b/tests/test-conf-parameter.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-2022, The University of Memphis, * Regents of the University of California * * This file is part of NLSR (Named-data Link State Routing). @@ -18,7 +18,7 @@ * NLSR, e.g., in COPYING.md file. If not, see . * * \author Ashlesh Gawande - **/ + */ #include "conf-parameter.hpp" #include "tests/boost-test.hpp" @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(ConfParameterSettersAndGetters) cp1.setLsaInterestLifetime(ndn::time::seconds(1)); - cp1.setSyncProtocol(SYNC_PROTOCOL_PSYNC); + cp1.setSyncProtocol(SyncProtocol::PSYNC); cp1.setRouterDeadInterval(10); @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(ConfParameterSettersAndGetters) BOOST_CHECK_EQUAL(cp1.getLsaInterestLifetime(), ndn::time::seconds(1)); - BOOST_CHECK_EQUAL(cp1.getSyncProtocol(), SYNC_PROTOCOL_PSYNC); + BOOST_CHECK(cp1.getSyncProtocol() == SyncProtocol::PSYNC); BOOST_CHECK_EQUAL(cp1.getRouterDeadInterval(), 10); diff --git a/tests/test-lsa-rule.cpp b/tests/test-lsa-rule.cpp index a2d0481..e5e6823 100644 --- a/tests/test-lsa-rule.cpp +++ b/tests/test-lsa-rule.cpp @@ -46,7 +46,7 @@ public: , opIdentityName("/ndn/edu/test-site/%C1.Operator/op1") , routerIdName("/ndn/edu/test-site/%C1.Router/router1") , confParam(face, m_keyChain) - , confProcessor(confParam, SYNC_PROTOCOL_PSYNC, HYPERBOLIC_STATE_OFF, + , confProcessor(confParam, SyncProtocol::PSYNC, HYPERBOLIC_STATE_OFF, "/ndn/", "/edu/test-site", "/%C1.Router/router1") , lsdb(face, m_keyChain, confParam) , ROOT_CERT_PATH(boost::filesystem::current_path() / std::string("root.cert"))