From 20e60a22bf0c1343b0d97e54747e9b984b0a7d86 Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Tue, 7 Jan 2025 01:50:10 -0500 Subject: [PATCH] update: merge ManagerBase and CommandManagerBase Change-Id: Ib939d8d032ff9e6e27f51d9053d08da558fd5027 --- src/nlsr.cpp | 1 + src/nlsr.hpp | 6 +-- ...manager-base.cpp => command-processor.cpp} | 36 +++++++-------- ...manager-base.hpp => command-processor.hpp} | 44 +++++-------------- src/update/nfd-rib-command-processor.cpp | 6 ++- src/update/nfd-rib-command-processor.hpp | 4 +- src/update/prefix-update-processor.cpp | 7 ++- src/update/prefix-update-processor.hpp | 4 +- 8 files changed, 40 insertions(+), 68 deletions(-) rename src/update/{manager-base.cpp => command-processor.cpp} (81%) rename src/update/{manager-base.hpp => command-processor.hpp} (76%) diff --git a/src/nlsr.cpp b/src/nlsr.cpp index 3902959..144f1d3 100644 --- a/src/nlsr.cpp +++ b/src/nlsr.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include diff --git a/src/nlsr.hpp b/src/nlsr.hpp index f562bc9..f375eca 100644 --- a/src/nlsr.hpp +++ b/src/nlsr.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2023, The University of Memphis, + * Copyright (c) 2014-2025, The University of Memphis, * Regents of the University of California, * Arizona Board of Regents. * @@ -185,10 +185,6 @@ class Nlsr DatasetInterestHandler m_datasetHandler; private: - /*! \brief Where NLSR stores certificates it claims to be - * authoritative for. Usually the router certificate. - */ - ndn::nfd::Controller m_controller; ndn::nfd::Controller m_faceDatasetController; diff --git a/src/update/manager-base.cpp b/src/update/command-processor.cpp similarity index 81% rename from src/update/manager-base.cpp rename to src/update/command-processor.cpp index e066bfc..d13d9b6 100644 --- a/src/update/manager-base.cpp +++ b/src/update/command-processor.cpp @@ -19,34 +19,29 @@ * NLSR, e.g., in COPYING.md file. If not, see . */ -#include "manager-base.hpp" +#include "command-processor.hpp" #include "logger.hpp" -namespace nlsr { -namespace update { +#include -INIT_LOGGER(update.PrefixCommandProcessor); +namespace nlsr::update { -ManagerBase::ManagerBase(ndn::mgmt::Dispatcher& dispatcher, - const std::string& module) - : m_dispatcher(dispatcher) - , m_module(module) -{ -} +INIT_LOGGER(update.CommandProcessor); -CommandManagerBase::CommandManagerBase(ndn::mgmt::Dispatcher& dispatcher, - NamePrefixList& namePrefixList, - Lsdb& lsdb, - const std::string& module) - : ManagerBase(dispatcher, module) +CommandProcessor::CommandProcessor(ndn::mgmt::Dispatcher& dispatcher, + NamePrefixList& namePrefixList, + Lsdb& lsdb) + : m_dispatcher(dispatcher) , m_namePrefixList(namePrefixList) , m_lsdb(lsdb) { } +CommandProcessor::~CommandProcessor() = default; + void -CommandManagerBase::advertiseAndInsertPrefix(const ndn::mgmt::ControlParametersBase& parameters, - const ndn::mgmt::CommandContinuation& done) +CommandProcessor::advertiseAndInsertPrefix(const ndn::mgmt::ControlParametersBase& parameters, + const ndn::mgmt::CommandContinuation& done) { const auto& castParams = static_cast(parameters); @@ -84,8 +79,8 @@ CommandManagerBase::advertiseAndInsertPrefix(const ndn::mgmt::ControlParametersB } void -CommandManagerBase::withdrawAndRemovePrefix(const ndn::mgmt::ControlParametersBase& parameters, - const ndn::mgmt::CommandContinuation& done) +CommandProcessor::withdrawAndRemovePrefix(const ndn::mgmt::ControlParametersBase& parameters, + const ndn::mgmt::CommandContinuation& done) { const auto& castParams = static_cast(parameters); @@ -121,5 +116,4 @@ CommandManagerBase::withdrawAndRemovePrefix(const ndn::mgmt::ControlParametersBa } } -} // namespace update -} // namespace nlsr +} // namespace nlsr::update diff --git a/src/update/manager-base.hpp b/src/update/command-processor.hpp similarity index 76% rename from src/update/manager-base.hpp rename to src/update/command-processor.hpp index 7616ef6..d0245fd 100644 --- a/src/update/manager-base.hpp +++ b/src/update/command-processor.hpp @@ -19,31 +19,23 @@ * NLSR, e.g., in COPYING.md file. If not, see . */ -#ifndef NLSR_MANAGER_BASE_HPP -#define NLSR_MANAGER_BASE_HPP +#ifndef NLSR_UPDATE_COMMAND_PROCESSOR_HPP +#define NLSR_UPDATE_COMMAND_PROCESSOR_HPP #include "lsdb.hpp" #include "name-prefix-list.hpp" -#include -#include #include -#include #include -#include #include #include -namespace nlsr { - -class Lsdb; - -namespace update { +namespace nlsr::update { enum { PREFIX_FLAG = 1 }; -class ManagerBase : boost::noncopyable +class CommandProcessor : boost::noncopyable { public: class Error : public std::runtime_error @@ -52,26 +44,12 @@ class ManagerBase : boost::noncopyable using std::runtime_error::runtime_error; }; -protected: - ManagerBase(ndn::mgmt::Dispatcher& m_dispatcher, const std::string& module); - -protected: - ndn::mgmt::Dispatcher& m_dispatcher; - -private: - std::string m_module; -}; - -class CommandManagerBase : public ManagerBase -{ -public: - CommandManagerBase(ndn::mgmt::Dispatcher& m_dispatcher, - NamePrefixList& m_namePrefixList, - Lsdb& lsdb, - const std::string& module); + CommandProcessor(ndn::mgmt::Dispatcher& m_dispatcher, + NamePrefixList& m_namePrefixList, + Lsdb& lsdb); virtual - ~CommandManagerBase() = default; + ~CommandProcessor() = 0; /*! \brief Add desired name prefix to the advertised name prefix list * or insert a prefix into the FIB if parameters is valid. @@ -106,11 +84,11 @@ class CommandManagerBase : public ManagerBase } protected: + ndn::mgmt::Dispatcher& m_dispatcher; NamePrefixList& m_namePrefixList; Lsdb& m_lsdb; }; -} // namespace update -} // namespace nlsr +} // namespace nlsr::update -#endif // NLSR_MANAGER_BASE_HPP +#endif // NLSR_UPDATE_COMMAND_PROCESSOR_HPP diff --git a/src/update/nfd-rib-command-processor.cpp b/src/update/nfd-rib-command-processor.cpp index 6892415..21f9a7b 100644 --- a/src/update/nfd-rib-command-processor.cpp +++ b/src/update/nfd-rib-command-processor.cpp @@ -21,19 +21,23 @@ #include "nfd-rib-command-processor.hpp" +#include + namespace nlsr::update { NfdRibCommandProcessor::NfdRibCommandProcessor(ndn::mgmt::Dispatcher& dispatcher, NamePrefixList& namePrefixList, Lsdb& lsdb) - : CommandManagerBase(dispatcher, namePrefixList, lsdb, "rib") + : CommandProcessor(dispatcher, namePrefixList, lsdb) { m_dispatcher.addControlCommand( ndn::mgmt::makeAcceptAllAuthorization(), + // the first and second arguments are ignored since the handler does not need them std::bind(&NfdRibCommandProcessor::advertiseAndInsertPrefix, this, _3, _4)); m_dispatcher.addControlCommand( ndn::mgmt::makeAcceptAllAuthorization(), + // the first and second arguments are ignored since the handler does not need them std::bind(&NfdRibCommandProcessor::withdrawAndRemovePrefix, this, _3, _4)); } diff --git a/src/update/nfd-rib-command-processor.hpp b/src/update/nfd-rib-command-processor.hpp index 351e375..4188504 100644 --- a/src/update/nfd-rib-command-processor.hpp +++ b/src/update/nfd-rib-command-processor.hpp @@ -22,11 +22,11 @@ #ifndef NLSR_UPDATE_NFD_RIB_COMMAND_PROCESSOR_HPP #define NLSR_UPDATE_NFD_RIB_COMMAND_PROCESSOR_HPP -#include "manager-base.hpp" +#include "command-processor.hpp" namespace nlsr::update { -class NfdRibCommandProcessor : public CommandManagerBase +class NfdRibCommandProcessor : public CommandProcessor { public: NfdRibCommandProcessor(ndn::mgmt::Dispatcher& dispatcher, diff --git a/src/update/prefix-update-processor.cpp b/src/update/prefix-update-processor.cpp index 83bfcc4..f07f0d0 100644 --- a/src/update/prefix-update-processor.cpp +++ b/src/update/prefix-update-processor.cpp @@ -21,11 +21,8 @@ #include "prefix-update-processor.hpp" #include "logger.hpp" -#include "lsdb.hpp" #include "prefix-update-commands.hpp" -#include - #include #include @@ -55,16 +52,18 @@ PrefixUpdateProcessor::PrefixUpdateProcessor(ndn::mgmt::Dispatcher& dispatcher, ndn::security::ValidatorConfig& validator, NamePrefixList& namePrefixList, Lsdb& lsdb, const std::string& configFileName) - : CommandManagerBase(dispatcher, namePrefixList, lsdb, "prefix-update") + : CommandProcessor(dispatcher, namePrefixList, lsdb) , m_validator(validator) , m_confFileNameDynamic(configFileName) { m_dispatcher.addControlCommand( makeAuthorization(), + // the first and second arguments are ignored since the handler does not need them std::bind(&PrefixUpdateProcessor::advertiseAndInsertPrefix, this, _3, _4)); m_dispatcher.addControlCommand( makeAuthorization(), + // the first and second arguments are ignored since the handler does not need them std::bind(&PrefixUpdateProcessor::withdrawAndRemovePrefix, this, _3, _4)); } diff --git a/src/update/prefix-update-processor.hpp b/src/update/prefix-update-processor.hpp index 9230f0b..bc59937 100644 --- a/src/update/prefix-update-processor.hpp +++ b/src/update/prefix-update-processor.hpp @@ -22,7 +22,7 @@ #ifndef NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP #define NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP -#include "manager-base.hpp" +#include "command-processor.hpp" #include @@ -32,7 +32,7 @@ namespace nlsr::update { using ConfigSection = boost::property_tree::ptree; -class PrefixUpdateProcessor : public CommandManagerBase +class PrefixUpdateProcessor : public CommandProcessor { public: PrefixUpdateProcessor(ndn::mgmt::Dispatcher& dispatcher,