15 #include <boost/pointer_cast.hpp>
24 HookedCommandMgr::HookedCommandMgr()
35 if (HooksManager::commandHandlersPresent(cmd_name)) {
40 callout_handle->setStatus(CalloutHandle::NEXT_STEP_CONTINUE);
43 callout_handle->deleteAllArguments();
49 callout_handle->setArgument(
"command", command);
50 callout_handle->setArgument(
"response", hook_response);
52 HooksManager::callCommandHandlers(cmd_name, *callout_handle);
55 callout_handle->getArgument(
"response", hook_response);
57 answer = boost::const_pointer_cast<
Element>(hook_response);
74 if ((cmd_name !=
"list-commands")) {
81 return (hook_response);
94 if (cmd_name ==
"list-commands") {
96 const std::vector<std::string>& hooks =
97 ServerHooks::getServerHooksPtr()->getHookNames();
100 if (!hooks.empty()) {
101 ElementPtr hooks_commands = Element::createList();
102 for (
auto h = hooks.cbegin(); h != hooks.end(); ++h) {
108 std::string command_name = ServerHooks::hookToCommandName(*h);
109 if (!command_name.empty()) {
113 if (HooksManager::commandHandlersPresent(command_name)) {
114 hooks_commands->add(Element::create(command_name));
122 if (!hooks_commands->empty()) {
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
virtual isc::data::ConstElementPtr handleCommand(const std::string &cmd_name, const isc::data::ConstElementPtr ¶ms, const isc::data::ConstElementPtr &original_cmd)
Handles the command having a given name and arguments.
boost::shared_ptr< Element > ElementPtr
ConstElementPtr createCommand(const std::string &command)
Creates a standard command message with no argument (of the form { "command": "my_command" }) ...
boost::shared_ptr< const Element > ConstElementPtr
Commands Manager, responsible for processing external commands.
bool delegateCommandToHookLibrary(const std::string &cmd_name, const isc::data::ConstElementPtr ¶ms, const isc::data::ConstElementPtr &original_cmd, isc::data::ElementPtr &answer)
Handles the command within the hooks libraries.
Defines the logger used by the top-level component of kea-dhcp-ddns.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
This file contains several functions and constants that are used for handling commands and responses ...
virtual isc::data::ConstElementPtr handleCommand(const std::string &cmd_name, const isc::data::ConstElementPtr ¶ms, const isc::data::ConstElementPtr &original_cmd)
Handles the command having a given name and arguments.
ConstElementPtr combineCommandsLists(const ConstElementPtr &response1, const ConstElementPtr &response2)
The Element class represents a piece of data, used by the command channel and configuration parts...