Kea 2.7.6
isc::config::HookedCommandMgr Class Reference

Command Manager which can delegate commands to a hook library. More...

#include <hooked_command_mgr.h>

+ Inheritance diagram for isc::config::HookedCommandMgr:

Public Member Functions

 HookedCommandMgr ()
 Constructor.
 
- Public Member Functions inherited from isc::config::BaseCommandMgr
 BaseCommandMgr ()
 Constructor.
 
virtual ~BaseCommandMgr ()
 Destructor.
 
void deregisterAll ()
 Auxiliary method that removes all installed commands.
 
void deregisterCommand (const std::string &cmd)
 Deregisters specified command handler.
 
virtual isc::data::ConstElementPtr processCommand (const isc::data::ConstElementPtr &cmd)
 Triggers command processing.
 
void registerCommand (const std::string &cmd, CommandHandler handler)
 Registers specified command handler for a given command.
 
void registerExtendedCommand (const std::string &cmd, ExtendedCommandHandler handler)
 Registers specified command handler for a given command.
 

Protected Member Functions

bool delegateCommandToHookLibrary (const std::string &cmd_name, const isc::data::ConstElementPtr &params, const isc::data::ConstElementPtr &original_cmd, isc::data::ElementPtr &answer)
 Handles the command within the hooks libraries.
 
virtual isc::data::ConstElementPtr handleCommand (const std::string &cmd_name, const isc::data::ConstElementPtr &params, const isc::data::ConstElementPtr &original_cmd)
 Handles the command having a given name and arguments.
 
- Protected Member Functions inherited from isc::config::BaseCommandMgr

Additional Inherited Members

- Public Types inherited from isc::config::BaseCommandMgr
typedef std::function< isc::data::ConstElementPtr(const std::string &name, const isc::data::ConstElementPtr &params)> CommandHandler
 Defines command handler type.
 
typedef std::function< isc::data::ConstElementPtr(const std::string &name, const isc::data::ConstElementPtr &params, const isc::data::ConstElementPtr &original)> ExtendedCommandHandler
 Defines extended command handler type.
 
- Static Public Member Functions inherited from isc::config::BaseCommandMgr
static std::string getHash (const isc::data::ConstElementPtr &config)
 returns a hash of a given Element structure
 
- Protected Types inherited from isc::config::BaseCommandMgr
typedef std::map< std::string, HandlersPairHandlerContainer
 Type of the container for command handlers.
 
- Protected Attributes inherited from isc::config::BaseCommandMgr
HandlerContainer handlers_
 Container for command handlers.
 

Detailed Description

Command Manager which can delegate commands to a hook library.

This class extends BaseCommandMgr with the logic to delegate the commands to a hook library if the hook library is installed and provides command handlers for the control API.

The command handlers are registered by a hook library by calling isc::hooks::LibraryHandle::registerCommandCallout. This call creates a hook point for this command (if one doesn't exist) and then registers the specified handler(s). When the HookedCommandMgr receives a command for processing it calls the isc::hooks::HooksManager::commandHandlersPresent to check if there are handlers present for this command. If so, the HookedCommandMgr calls isc::hooks::HooksManager::callCommandHandlers to process the command in the hooks libraries. If command handlers are not installed for this command, the HookedCommandMgr will try to process the command on its own.

The isc::hooks::CalloutHandle::CalloutNextStep flag setting by the command handlers does NOT have any influence on the operation of the HookedCommandMgr, i.e. it will always skip processing command on its own if the command handlers are present for the given command, even if the handlers return an error code.

Definition at line 39 of file hooked_command_mgr.h.

Constructor & Destructor Documentation

◆ HookedCommandMgr()

isc::config::HookedCommandMgr::HookedCommandMgr ( )

Constructor.

Initializes callout handle used by the Command Manager.

Definition at line 24 of file hooked_command_mgr.cc.

Member Function Documentation

◆ delegateCommandToHookLibrary()

bool isc::config::HookedCommandMgr::delegateCommandToHookLibrary ( const std::string & cmd_name,
const isc::data::ConstElementPtr & params,
const isc::data::ConstElementPtr & original_cmd,
isc::data::ElementPtr & answer )
protected

Handles the command within the hooks libraries.

This method checks if the hooks libraries are installed which implement command handlers for the specified command to be processed. If the command handlers are present, this method calls them to create a response and then passes the response back within the answer argument.

Values of all arguments can be modified by the hook library.

Parameters
cmd_nameCommand name.
paramsCommand arguments.
original_cmdOriginal command received.
[out]answerCommand processing result returned by the hook.
Returns
Boolean value indicating if any callouts have been executed.

Definition at line 29 of file hooked_command_mgr.cc.

References isc::hooks::HooksManager::callCommandHandlers(), isc::hooks::HooksManager::commandHandlersPresent(), isc::hooks::HooksManager::createCalloutHandle(), isc::config::createCommand(), and isc::hooks::CalloutHandle::NEXT_STEP_CONTINUE.

Referenced by isc::agent::CtrlAgentCommandMgr::handleCommand(), and handleCommand().

+ Here is the call graph for this function:

◆ handleCommand()

ConstElementPtr isc::config::HookedCommandMgr::handleCommand ( const std::string & cmd_name,
const isc::data::ConstElementPtr & params,
const isc::data::ConstElementPtr & original_cmd )
protectedvirtual

Handles the command having a given name and arguments.

This method calls HookedCommandMgr::delegateCommandToHookLibrary to try to process the command with the hook libraries, if they are installed.

Parameters
cmd_nameCommand name.
paramsCommand arguments.
original_cmdOriginal command received.
Returns
Pointer to the const data element representing response to a command.

Reimplemented from isc::config::BaseCommandMgr.

Reimplemented in isc::agent::CtrlAgentCommandMgr.

Definition at line 66 of file hooked_command_mgr.cc.

References isc::config::combineCommandsLists(), isc::hooks::HooksManager::commandHandlersPresent(), isc::config::CONTROL_RESULT_SUCCESS, isc::data::Element::create(), isc::config::createAnswer(), isc::data::Element::createList(), delegateCommandToHookLibrary(), isc::hooks::ServerHooks::getServerHooksPtr(), isc::config::BaseCommandMgr::handleCommand(), and isc::hooks::ServerHooks::hookToCommandName().

Referenced by isc::agent::CtrlAgentCommandMgr::handleCommand().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: