Kea: isc::hooks::HooksConfig Class Reference

| Kea 3.2.0-git

isc::hooks::HooksConfig Class Reference

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

`#include <hooks_config.h>`

Inheritance diagram for isc::hooks::HooksConfig:
[legend]

## Public Member Functions
| HooksConfig ()
| Default constructor.
void | add (const std::string &libname, isc::data::ConstElementPtr parameters, const std::string &cfgname="")
| 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::HookLibsCollection & | get () 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.

Referenced by equal().

## Member Function Documentation

## ◆ add()

void isc::hooks::HooksConfig::add | ( | const std::string & | libname,
|  | isc::data::ConstElementPtr | parameters,
|  | const std::string & | cfgname = "" )

Adds additional hooks libraries.

Parameters

  libname | full filename with path to the library.
  parameters | map of parameters that configure the library.
  cfgname | original value of library parameter from this library's configuration.

Definition at line 20 of file hooks_config.cc.

Referenced by isc::dhcp::SrvConfig::copy(), and isc::hooks::HooksLibrariesParser::parse().

## ◆ clear()

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

Removes all configured hooks libraries.

Definition at line 61 of file hooks_config.h.

Referenced by isc::dhcp::SrvConfig::copy(), and isc::hooks::HooksLibrariesParser::parse().

## ◆ equal()

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

Compares two Hooks Config classes for equality.

Parameters

  other | other 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 74 of file hooks_config.cc.

References HooksConfig().

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 56 of file hooks_config.h.

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

## ◆ 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_enabled | The flag which indicates if MT is enabled (used to check hook libraries compatibility with MT).

Exceptions

  InvalidHooksLibraries | if 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 62 of file hooks_config.cc.

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

Referenced by isc::dhcp::configureDhcp4Server(), isc::dhcp::configureDhcp6Server(), isc::d2::D2SimpleParser::parse(), and isc::netconf::NetconfSimpleParser::parse().

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::hooks::HooksConfig::toElement
isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition hooks_config.cc:103
isc::config
Definition command_interpreter.cc:23

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 Element::create(), Element::createList(), Element::createMap(), and isc::data::isNull().

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

  position | position of the hooks-library map for error reporting
  multi_threading_enabled | The flag which indicates if MT is enabled (used to check hook libraries compatibility with MT).

Exceptions

  InvalidHooksLibraries | if any issue is discovered.

Definition at line 28 of file hooks_config.cc.

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

Referenced by isc::d2::D2SimpleParser::parse(), isc::netconf::NetconfSimpleParser::parse(), 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:

- hooks_config.h
- hooks_config.cc