communication: adapt to API changes in PSync
Pass the KeyChain instance to psync::FullProducer Change-Id: Ia97356dc364c7bdaf6dc80ad57fa351eeabe997d
This commit is contained in:
1 parent
d1cb063482
commit
1954a0c5ce
18 files changed
+116
-111
No files matched your search
@@ -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<OnNewLsa>())
|
||||
, 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<std::string>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/util/signal.hpp>
|
||||
#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<bool(const ndn::Name&, const Lsa::Type& lsaType, const uint64_t&, uint64_t/*inFace*/)>;
|
||||
|
||||
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 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
|
||||
|
||||
@@ -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<chronosync::Logic>(face,
|
||||
syncPrefix,
|
||||
userPrefix,
|
||||
std::bind(&SyncProtocolAdapter::onChronoSyncUpdate, this, _1),
|
||||
[this] (auto&&... args) { onChronoSyncUpdate(std::forward<decltype(args)>(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<psync::FullProducer>(80,
|
||||
face,
|
||||
syncPrefix,
|
||||
userPrefix,
|
||||
std::bind(&SyncProtocolAdapter::onPSyncUpdate, this, _1),
|
||||
syncInterestLifetime);
|
||||
case SyncProtocol::PSYNC:
|
||||
NDN_LOG_DEBUG("Using PSync");
|
||||
m_psyncLogic = std::make_shared<psync::FullProducer>(face,
|
||||
keyChain,
|
||||
80,
|
||||
syncPrefix,
|
||||
userPrefix,
|
||||
[this] (auto&&... args) { onPSyncUpdate(std::forward<decltype(args)>(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
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
|
||||
#ifdef HAVE_CHRONOSYNC
|
||||
#include <ChronoSync/logic.hpp>
|
||||
#endif
|
||||
@@ -32,18 +34,19 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
typedef std::function<void(const ndn::Name& updateName,
|
||||
uint64_t seqNo, uint64_t incomingFaceId)> SyncUpdateCallback;
|
||||
using SyncUpdateCallback = std::function<void(const ndn::Name& updateName,
|
||||
uint64_t seqNo, uint64_t incomingFaceId)>;
|
||||
|
||||
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<chronosync::Logic> m_chronoSyncLogic;
|
||||
#endif
|
||||
|
||||
@@ -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<std::string>("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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<HelloProtocol, const ndn::Name&> 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
|
||||
|
||||
+2
-2
@@ -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};
|
||||
|
||||
+7
-4
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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<Lsa::Type> 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<std::string>(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<std::string>(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<std::string>(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<std::string>(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<std::string>(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<std::string>(Lsa::Type::NAME);
|
||||
this->receiveUpdate(updateName, sequenceNumber);
|
||||
|
||||
@@ -49,11 +49,11 @@ public:
|
||||
faces[i] = std::make_shared<util::DummyClientFace>(m_io,
|
||||
util::DummyClientFace::Options{true, true});
|
||||
userPrefixes[i] = Name(nameLsaUserPrefix).appendNumber(i);
|
||||
nodes[i] = std::make_shared<SyncProtocolAdapter>(*faces[i], SYNC_PROTOCOL_PSYNC, syncPrefix,
|
||||
userPrefixes[i],
|
||||
nodes[i] = std::make_shared<SyncProtocolAdapter>(*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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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()))
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author Ashlesh Gawande <agawande@memphis.edu>
|
||||
**/
|
||||
*/
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in new issue
Block a user