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

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. More...
 
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. More...
 

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. More...
 
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. More...
 
- Protected Types inherited from isc::config::BaseCommandMgr
typedef std::map< std::string, HandlersPairHandlerContainer
 Type of the container for command handlers. More...
 
- Protected Attributes inherited from isc::config::BaseCommandMgr
HandlerContainer handlers_
 Container for command handlers. More...
 

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::config::createCommand().

Referenced by 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::config::createAnswer(), delegateCommandToHookLibrary(), and isc::config::BaseCommandMgr::handleCommand().

+ Here is the call graph for this function:

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