26 #ifndef NFD_DAEMON_MGMT_MANAGER_BASE_HPP
27 #define NFD_DAEMON_MGMT_MANAGER_BASE_HPP
31 #include <ndn-cxx/mgmt/dispatcher.hpp>
32 #include <ndn-cxx/mgmt/nfd/control-command.hpp>
33 #include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
34 #include <ndn-cxx/mgmt/nfd/control-response.hpp>
40 using ndn::mgmt::Dispatcher;
41 using ndn::mgmt::CommandContinuation;
42 using ndn::nfd::ControlParameters;
43 using ndn::nfd::ControlResponse;
52 class Error :
public std::runtime_error
55 using std::runtime_error::runtime_error;
68 ManagerBase(std::string_view module, Dispatcher& dispatcher);
70 ManagerBase(std::string_view module, Dispatcher& dispatcher,
79 template<
typename Command>
81 const typename Command::RequestParameters& parameters,
82 const CommandContinuation& done)>;
84 template<
typename Command>
88 auto handle = [h = std::move(handler)] (
const auto& prefix,
const auto& interest,
89 const auto& params,
const auto& done) {
90 const auto& reqParams =
static_cast<const typename Command::RequestParameters&
>(params);
91 h(prefix, interest, reqParams, done);
93 m_dispatcher.addControlCommand<Command>(makeAuthorization(Command::verb.toUri()),
99 const ndn::mgmt::StatusDatasetHandler& handler);
101 ndn::mgmt::PostNotification
118 virtual ndn::mgmt::Authorization
119 makeAuthorization(
const std::string& verb);
128 makeRelPrefix(
const std::string& verb)
const
130 return PartialName(m_module).append(verb);
134 std::string m_module;
135 Dispatcher& m_dispatcher;
136 CommandAuthenticator* m_authenticator =
nullptr;
Provides ControlCommand authorization according to NFD's configuration file.
A collection of common functions shared by all NFD managers, such as communicating with the dispatche...
void registerCommandHandler(ControlCommandHandler< Command > handler)
const std::string & getModule() const
ndn::mgmt::PostNotification registerNotificationStream(const std::string &verb)
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
static std::string extractSigner(const Interest &interest)
Extracts the name from the KeyLocator of a ControlCommand request.
std::function< void(const Name &prefix, const Interest &interest, const typename Command::RequestParameters ¶meters, const CommandContinuation &done)> ControlCommandHandler
ManagerBase(std::string_view module, Dispatcher &dispatcher)
#define NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE