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>
38 using ndn::mgmt::Dispatcher;
39 using ndn::nfd::ControlCommand;
40 using ndn::nfd::ControlParameters;
41 using ndn::nfd::ControlResponse;
50 class Error :
public std::runtime_error
53 using std::runtime_error::runtime_error;
69 ManagerBase(
const std::string& module, Dispatcher& dispatcher);
71 ManagerBase(
const std::string& module, Dispatcher& dispatcher,
77 const Name& prefix,
const Interest& interest,
78 const ControlParameters& parameters,
79 const ndn::mgmt::CommandContinuation done)>;
81 template<
typename Command>
88 const ndn::mgmt::StatusDatasetHandler& handler);
90 ndn::mgmt::PostNotification
107 virtual ndn::mgmt::Authorization
108 makeAuthorization(
const std::string& verb);
116 [[nodiscard]]
static bool
117 validateParameters(
const ControlCommand& command,
118 const ndn::mgmt::ControlParameters& parameters);
124 handleCommand(shared_ptr<ControlCommand> command,
126 const Name& prefix,
const Interest& interest,
127 const ndn::mgmt::ControlParameters& params,
128 const ndn::mgmt::CommandContinuation& done);
137 makeRelPrefix(
const std::string& verb)
139 return PartialName(m_module).append(verb);
143 std::string m_module;
144 Dispatcher& m_dispatcher;
148 template<
typename Command>
153 auto command = make_shared<Command>();
155 m_dispatcher.addControlCommand<ControlParameters>(
157 makeAuthorization(verb),
158 [=] (
const auto& params) {
return validateParameters(*command, params); },
159 [=] (
auto&&... args) { handleCommand(command, handler, std::forward<decltype(args)>(args)...); });
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...
const std::string & getModule() const
ndn::mgmt::PostNotification registerNotificationStream(const std::string &verb)
std::function< void(const ControlCommand &command, const Name &prefix, const Interest &interest, const ControlParameters ¶meters, const ndn::mgmt::CommandContinuation done)> ControlCommandHandler
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
void registerCommandHandler(const std::string &verb, const ControlCommandHandler &handler)
ManagerBase(const std::string &module, Dispatcher &dispatcher)
static std::string extractSigner(const Interest &interest)
Extracts the name from the KeyLocator of a ControlCommand request.
#define NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE