Kea 2.7.5
isc::hooks::HooksConfig Class Reference

Wrapper class that holds hooks libraries configuration. More...

#include <hooks_config.h>

+ Inheritance diagram for isc::hooks::HooksConfig:

Public Member Functions

 HooksConfig ()
 Default constructor.
 
void add (std::string libname, isc::data::ConstElementPtr parameters)
 Adds additional hooks libraries.
 
void clear ()
 Removes all configured hooks libraries.
 
bool equal (const HooksConfig &other) const
 Compares two Hooks Config classes for equality.
 
const isc::hooks::HookLibsCollectionget () const
 Provides access to the configured hooks libraries.
 
void loadLibraries (bool multi_threading_enabled) const
 Commits hooks libraries configuration.
 
isc::data::ElementPtr toElement () const
 Unparse a configuration object.
 
void verifyLibraries (const isc::data::Element::Position &position, bool multi_threading_enabled) const
 Verifies that libraries stored in libraries_ are valid.
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor.
 

Detailed Description

Wrapper class that holds hooks libraries configuration.

This was moved from HooksLibrariesParser

However, this class does more than just check the list of library names. It does two other things:

validate libraries

load libraries

and it provides a toElement() method to unparse a configuration.

Todo
add toElement() unit tests

Definition at line 36 of file hooks_config.h.

Constructor & Destructor Documentation

◆ HooksConfig()

isc::hooks::HooksConfig::HooksConfig ( )
inline

Default constructor.

Definition at line 40 of file hooks_config.h.

Member Function Documentation

◆ add()

void isc::hooks::HooksConfig::add ( std::string libname,
isc::data::ConstElementPtr parameters )
inline

Adds additional hooks libraries.

Parameters
libnamefull filename with path to the library.
parametersmap of parameters that configure the library.

Definition at line 46 of file hooks_config.h.

◆ clear()

void isc::hooks::HooksConfig::clear ( )
inline

Removes all configured hooks libraries.

Definition at line 59 of file hooks_config.h.

◆ equal()

bool isc::hooks::HooksConfig::equal ( const HooksConfig & other) const

Compares two Hooks Config classes for equality.

Parameters
otherother hooksconfig to compare with
Todo
: This comparision assumes that the library order is not relevant, so [ lib1, lib2 ] is equal to [ lib2, lib1 ]. However, this is not strictly true, because callouts execution is called in other they're loaded. Therefore changing the libraries order may change the server behavior.

We don't have any libraries that are interacting (or would change their behavior depending on the order in which their callouts are executed), so the code is ok for now.

Definition at line 66 of file hooks_config.cc.

References isc::data::isNull().

Referenced by isc::dhcp::SrvConfig::equals().

+ Here is the call graph for this function:

◆ get()

const isc::hooks::HookLibsCollection & isc::hooks::HooksConfig::get ( ) const
inline

Provides access to the configured hooks libraries.

Note
The const reference returned is only valid as long as the object that returned it.

Definition at line 54 of file hooks_config.h.

Referenced by isc::dhcp::SrvConfig::copy(), isc::dhcp::SrvConfig::equals(), isc::agent::AgentSimpleParser::parse(), isc::d2::D2SimpleParser::parse(), and isc::netconf::NetconfSimpleParser::parse().

◆ loadLibraries()

void isc::hooks::HooksConfig::loadLibraries ( bool multi_threading_enabled) const

Commits hooks libraries configuration.

This method calls necessary methods in HooksManager that will unload any libraries that may be currently loaded and will load the actual libraries. Providing that the specified libraries are valid and are different to those already loaded, this method loads the new set of libraries (and unloads the existing set).

Parameters
multi_threading_enabledThe flag which indicates if MT is enabled (used to check hook libraries compatibility with MT).
Exceptions
InvalidHooksLibrariesif the call to HooksManager fails.

Commits the list of libraries to the configuration manager storage if the list of libraries has changed.

Todo
: Delete any stored CalloutHandles before reloading the libraries

Definition at line 54 of file hooks_config.cc.

References isc_throw, and isc::hooks::HooksManager::loadLibraries().

+ Here is the call graph for this function:

◆ toElement()

ElementPtr isc::hooks::HooksConfig::toElement ( ) const
virtual

Unparse a configuration object.

Returns an element which must parse into the same object, i.e.

for all valid config C parse(parse(C)->toElement()) == parse(C)
isc::data::ElementPtr toElement() const
Unparse a configuration object.
Returns
a pointer to a configuration which can be parsed into the initial configuration object

Implements isc::data::CfgToElement.

Definition at line 103 of file hooks_config.cc.

References isc::data::Element::create(), isc::data::Element::createList(), isc::data::Element::createMap(), and isc::data::isNull().

Referenced by isc::agent::CtrlAgentCfgContext::toElement(), isc::d2::D2CfgContext::toElement(), isc::dhcp::SrvConfig::toElement(), and isc::netconf::NetconfConfig::toElement().

+ Here is the call graph for this function:

◆ verifyLibraries()

void isc::hooks::HooksConfig::verifyLibraries ( const isc::data::Element::Position & position,
bool multi_threading_enabled ) const

Verifies that libraries stored in libraries_ are valid.

This method is a smart wrapper around isc::hooks::HooksManager::validateLibraries(). It tries to validate all the libraries stored in libraries_.

Parameters
positionposition of the hooks-library map for error reporting
multi_threading_enabledThe flag which indicates if MT is enabled (used to check hook libraries compatibility with MT).
Exceptions
InvalidHooksLibrariesif any issue is discovered.

Definition at line 20 of file hooks_config.cc.

References isc::hooks::extractNames(), isc::hooks::HooksManager::getLibraryNames(), isc_throw, and isc::hooks::HooksManager::validateLibraries().

Referenced by isc::dhcp::processDhcp4Config(), and isc::dhcp::processDhcp6Config().

+ Here is the call graph for this function:

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