Kea: isc::d2::D2CfgMgr Class Reference

| Kea 2.2.0

Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
isc::d2::D2CfgMgr Class Reference

DHCP-DDNS Configuration Manager. More...

`#include <d2_cfg_mgr.h>`

Inheritance diagram for isc::d2::D2CfgMgr:
[legend]

## Public Member Functions
| D2CfgMgr ()
| Constructor. More...
virtual | ~D2CfgMgr ()
| Destructor. More...
bool | forwardUpdatesEnabled ()
| Returns whether or not forward updates are enabled. More...
virtual std::string | getConfigSummary (const uint32_t selection) override
| Returns configuration summary in the textual format. More...
const isc::data::ConstElementPtr | getControlSocketInfo ()
| Convenience method fetches information about control socket from context. More...
D2CfgContextPtr | getD2CfgContext ()
| Convenience method that returns the D2 configuration context. More...
const D2ParamsPtr & | getD2Params ()
| Convenience method fetches the D2Params from context. More...
std::list< std::list< std::string > > | jsonPathsToRedact () const final override
| Return a list of all paths that contain passwords or secrets. More...
bool | matchForward (const std::string &fqdn, DdnsDomainPtr &domain)
| Matches a given FQDN to a forward domain. More...
bool | matchReverse (const std::string &ip_address, DdnsDomainPtr &domain)
| Matches a given IP address to a reverse domain. More...
bool | reverseUpdatesEnabled ()
| Returns whether or not reverse updates are enabled. More...
Public Member Functions inherited from isc::process::DCfgMgrBase
| DCfgMgrBase (ConfigPtr context)
| Constructor. More...
virtual | ~DCfgMgrBase ()
| Destructor. More...
virtual std::string | getConfigSummary (const uint32_t selection)=0
| Returns configuration summary in the textual format. More...
ConfigPtr & | getContext ()
| Fetches the configuration context. More...
isc::data::ConstElementPtr | redactConfig (isc::data::ConstElementPtr const &config) const
| Redact the configuration. More...
isc::data::ConstElementPtr | simpleParseConfig (isc::data::ConstElementPtr config, bool check_only=false, const std::function< void()> &post_config_cb=nullptr)
| Acts as the receiver of new configurations. More...

## Static Public Member Functions
static std::string | reverseIpAddress (const std::string &address)
| Generate a reverse order string for the given IP address. More...
static std::string | reverseV4Address (const isc::asiolink::IOAddress &ioaddr)
| Generate a reverse order string for the given IP address. More...
static std::string | reverseV6Address (const isc::asiolink::IOAddress &ioaddr)
| Generate a reverse order string for the given IP address. More...

## Static Public Attributes
static const char * | IPV4_REV_ZONE_SUFFIX = "in-addr.arpa."
| Reverse zone suffix added to IPv4 addresses for reverse lookups. More...
static const char * | IPV6_REV_ZONE_SUFFIX = "ip6.arpa."
| Reverse zone suffix added to IPv6 addresses for reverse lookups. More...

## Protected Member Functions
virtual process::ConfigPtr | createNewContext () override
| Creates an new, blank D2CfgContext context. More...
virtual isc::data::ConstElementPtr | parse (isc::data::ConstElementPtr config, bool check_only) override
| Parses configuration of the D2. More...
virtual void | setCfgDefaults (isc::data::ElementPtr mutable_config) override
| Adds default values to the given config. More...
Protected Member Functions inherited from isc::process::DCfgMgrBase
virtual ConfigPtr | createNewContext ()=0
| Abstract factory which creates a context instance. More...
virtual std::list< std::list< std::string > > | jsonPathsToRedact () const
| Return a list of all paths that contain passwords or secrets. More...
virtual isc::data::ConstElementPtr | parse (isc::data::ConstElementPtr config, bool check_only)
| Parses actual configuration. More...
void | resetContext ()
| Replaces existing context with a new, empty context. More...
virtual void | setCfgDefaults (isc::data::ElementPtr mutable_config)
| Adds default values to the given config. More...
void | setContext (ConfigPtr &context)
| Update the current context. More...

## Detailed Description

DHCP-DDNS Configuration Manager.

Provides the mechanisms for managing the DHCP-DDNS application's configuration. This includes services for parsing sets of configuration values, storing the parsed information in its converted form, and retrieving the information on demand.

Definition at line 161 of file d2_cfg_mgr.h.

## Constructor & Destructor Documentation

## ◆ D2CfgMgr()

isc::d2::D2CfgMgr::D2CfgMgr | ( |  | ) |

Constructor.

Definition at line 121 of file d2_cfg_mgr.cc.

## ◆ ~D2CfgMgr()

isc::d2::D2CfgMgr::~D2CfgMgr | ( |  | ) |
| virtual

Destructor.

Definition at line 124 of file d2_cfg_mgr.cc.

## Member Function Documentation

## ◆ createNewContext()

ConfigPtr isc::d2::D2CfgMgr::createNewContext | ( |  | ) |
| overrideprotectedvirtual

Creates an new, blank D2CfgContext context.

This method is used at the beginning of configuration process to create a fresh, empty copy of a D2CfgContext. This new context will be populated during the configuration process and will replace the existing context provided the configuration process completes without error.

Returns
  Returns a ConfigPtr to the new context instance.

Implements isc::process::DCfgMgrBase.

Definition at line 128 of file d2_cfg_mgr.cc.

## ◆ forwardUpdatesEnabled()

bool isc::d2::D2CfgMgr::forwardUpdatesEnabled | ( |  | ) |

Returns whether or not forward updates are enabled.

This method currently uses the presence or absence of Forward DDNS Domains to determine if forward updates are enabled or disabled.

Todo:
  This could be expanded to include the check of a configurable boolean value.

Returns
  true if forward updates are enabled, false otherwise.

Definition at line 133 of file d2_cfg_mgr.cc.

References getD2CfgContext().

Here is the call graph for this function:

## ◆ getConfigSummary()

std::string isc::d2::D2CfgMgr::getConfigSummary | ( | const uint32_t | selection | ) |
| overridevirtual

Returns configuration summary in the textual format.

Parameters

  selection | Bitfield which describes the parts of the configuration to be returned. This parameter is ignored for the D2.

Returns
  Summary of the configuration in the textual format.

Implements isc::process::DCfgMgrBase.

Definition at line 258 of file d2_cfg_mgr.cc.

References getConfigSummary(), and getD2Params().

Referenced by getConfigSummary().

Here is the call graph for this function:

## ◆ getControlSocketInfo()

const isc::data::ConstElementPtr isc::d2::D2CfgMgr::getControlSocketInfo | ( |  | ) |

Convenience method fetches information about control socket from context.

Returns
  pointer to the Element that holds control-socket map

Definition at line 253 of file d2_cfg_mgr.cc.

References getControlSocketInfo(), and getD2CfgContext().

Referenced by getControlSocketInfo().

Here is the call graph for this function:

## ◆ getD2CfgContext()

D2CfgContextPtr isc::d2::D2CfgMgr::getD2CfgContext | ( |  | ) |
| inline

Convenience method that returns the D2 configuration context.

Returns
  returns a pointer to the configuration context.

Definition at line 180 of file d2_cfg_mgr.h.

References isc::process::DCfgMgrBase::getContext().

Referenced by forwardUpdatesEnabled(), getControlSocketInfo(), getD2Params(), matchForward(), matchReverse(), parse(), and reverseUpdatesEnabled().

Here is the call graph for this function:

## ◆ getD2Params()

const D2ParamsPtr & isc::d2::D2CfgMgr::getD2Params | ( |  | ) |

Convenience method fetches the D2Params from context.

Returns
  reference to const D2ParamsPtr

Definition at line 248 of file d2_cfg_mgr.cc.

References getD2CfgContext(), and getD2Params().

Referenced by getConfigSummary(), and getD2Params().

Here is the call graph for this function:

## ◆ jsonPathsToRedact()

std::list< std::list< std::string > > isc::d2::D2CfgMgr::jsonPathsToRedact | ( |  | ) | const
| finaloverridevirtual

Return a list of all paths that contain passwords or secrets.

Used in isc::process::Daemon::redactConfig to only make copies and only redact configuration subtrees that contain passwords or secrets.

This method needs to be overridden in each process that has a distinct configuration structure.

Returns
  the list of lists of sequential JSON map keys needed to reach the passwords and secrets.

Reimplemented from isc::process::DCfgMgrBase.

Definition at line 317 of file d2_cfg_mgr.cc.

## ◆ matchForward()

bool isc::d2::D2CfgMgr::matchForward | ( | const std::string & | fqdn,
|  | DdnsDomainPtr & | domain
| ) |  |

Matches a given FQDN to a forward domain.

This calls the matchDomain method of the forward domain manager to match the given FQDN to a forward domain.

Parameters

  fqdn | is the name for which to look.
  domain | receives the matching domain. Note that it will be reset upon entry and only set if a match is subsequently found.

Returns
  returns true if a match is found, false otherwise.

Exceptions

  throws | D2CfgError if given an invalid fqdn.

Definition at line 145 of file d2_cfg_mgr.cc.

References getD2CfgContext(), and isc_throw.

Here is the call graph for this function:

## ◆ matchReverse()

bool isc::d2::D2CfgMgr::matchReverse | ( | const std::string & | ip_address,
|  | DdnsDomainPtr & | domain
| ) |  |

Matches a given IP address to a reverse domain.

This calls the matchDomain method of the reverse domain manager to match the given IPv4 or IPv6 address to a reverse domain.

Parameters

  ip_address | is the name for which to look.
  domain | receives the matching domain. Note that it will be reset upon entry and only set if a match is subsequently found.

Returns
  returns true if a match is found, false otherwise.

Exceptions

  throws | D2CfgError if given an invalid fqdn.

Definition at line 159 of file d2_cfg_mgr.cc.

References getD2CfgContext(), and reverseIpAddress().

Here is the call graph for this function:

## ◆ parse()

isc::data::ConstElementPtr isc::d2::D2CfgMgr::parse | ( | isc::data::ConstElementPtr | config,
|  | bool | check_only
| ) |  |
| overrideprotectedvirtual

Parses configuration of the D2.

Parameters

  config | Pointer to a configuration specified for D2.
  check_only | Boolean flag indicating if this method should only verify correctness of the provided configuration.

Returns
  Pointer to a result of configuration parsing.

Reimplemented from isc::process::DCfgMgrBase.

Definition at line 268 of file d2_cfg_mgr.cc.

References isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::d2::d2_logger, isc::d2::DHCP_DDNS_CONFIG_CHECK_FAIL, isc::d2::DHCP_DDNS_CONFIG_FAIL, getD2CfgContext(), isc_throw, LOG_ERROR, isc::d2::D2SimpleParser::parse(), isc::d2::D2SimpleParser::setAllDefaults(), and isc::Exception::what().

Here is the call graph for this function:

## ◆ reverseIpAddress()

std::string isc::d2::D2CfgMgr::reverseIpAddress | ( | const std::string & | address | ) |
| static

Generate a reverse order string for the given IP address.

This method creates a string containing the given IP address contents in reverse order. This format is used for matching against reverse DDNS domains in DHCP_DDNS configuration. After reversing the syllables of the address, it appends the appropriate suffix.

Parameters

  address | string containing a valid IPv4 or IPv6 address.

Returns
  a std::string containing the reverse order address.

Exceptions

  D2CfgError | if given an invalid address.

Definition at line 170 of file d2_cfg_mgr.cc.

References isc_throw, isc::asiolink::IOAddress::isV4(), reverseV4Address(), reverseV6Address(), and isc::Exception::what().

Referenced by isc::d2::NameRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::SimpleRemoveTransaction::buildRemoveRevPtrsRequest(), isc::d2::NameAddTransaction::buildReplaceRevPtrsRequest(), isc::d2::SimpleAddTransaction::buildReplaceRevPtrsRequest(), and matchReverse().

Here is the call graph for this function:

## ◆ reverseUpdatesEnabled()

bool isc::d2::D2CfgMgr::reverseUpdatesEnabled | ( |  | ) |

Returns whether or not reverse updates are enabled.

This method currently uses the presence or absence of Reverse DDNS Domains to determine if reverse updates are enabled or disabled.

Todo:
  This could be expanded to include the check of a configurable boolean value.

Returns
  true if reverse updates are enabled, false otherwise.

Definition at line 139 of file d2_cfg_mgr.cc.

References getD2CfgContext().

Here is the call graph for this function:

## ◆ reverseV4Address()

std::string isc::d2::D2CfgMgr::reverseV4Address | ( | const isc::asiolink::IOAddress & | ioaddr | ) |
| static

Generate a reverse order string for the given IP address.

This method creates a string containing the given IP address contents in reverse order. This format is used for matching against reverse DDNS domains in DHCP_DDNS configuration. After reversing the syllables of the address, it appends the appropriate suffix.

Example: input: 192.168.1.15 output: 15.1.168.192.in-addr.arpa.

Parameters

  ioaddr | is the IPv4 IOaddress to convert

Returns
  a std::string containing the reverse order address.

Exceptions

  D2CfgError | if not given an IPv4 address.

Definition at line 188 of file d2_cfg_mgr.cc.

References IPV4_REV_ZONE_SUFFIX, isc_throw, isc::asiolink::IOAddress::isV4(), and isc::asiolink::IOAddress::toBytes().

Referenced by reverseIpAddress().

Here is the call graph for this function:

## ◆ reverseV6Address()

std::string isc::d2::D2CfgMgr::reverseV6Address | ( | const isc::asiolink::IOAddress & | ioaddr | ) |
| static

Generate a reverse order string for the given IP address.

This method creates a string containing the given IPv6 address contents in reverse order. This format is used for matching against reverse DDNS domains in DHCP_DDNS configuration. After reversing the syllables of the address, it appends the appropriate suffix.

IPv6 example: input: 2001:db8:302:99:: output: 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.9.9.0.0.2.0.3.0.8.B.D.0.1.0.0.2.ip6.arpa.

Parameters

  ioaddr | string containing a valid IPv6 address.

Returns
  a std::string containing the reverse order address.

Exceptions

  D2CfgError | if not given an IPv6 address.

Definition at line 218 of file d2_cfg_mgr.cc.

References isc::util::encode::encodeHex(), IPV6_REV_ZONE_SUFFIX, isc_throw, isc::asiolink::IOAddress::isV6(), and isc::asiolink::IOAddress::toBytes().

Referenced by reverseIpAddress().

Here is the call graph for this function:

## ◆ setCfgDefaults()

void isc::d2::D2CfgMgr::setCfgDefaults | ( | isc::data::ElementPtr | mutable_config | ) |
| overrideprotectedvirtual

Adds default values to the given config.

Adds the D2 default values to the configuration Element map. This method is invoked by `DCfgMgrBase::parseConfig()`.

Parameters

  mutable_config | - configuration to which defaults should be added

Reimplemented from isc::process::DCfgMgrBase.

Definition at line 263 of file d2_cfg_mgr.cc.

References isc::d2::D2SimpleParser::setAllDefaults().

Here is the call graph for this function:

## Member Data Documentation

## ◆ IPV4_REV_ZONE_SUFFIX

const char * isc::d2::D2CfgMgr::IPV4_REV_ZONE_SUFFIX = "in-addr.arpa."
| static

Reverse zone suffix added to IPv4 addresses for reverse lookups.

Todo:
  This should be configurable.

Definition at line 165 of file d2_cfg_mgr.h.

Referenced by reverseV4Address().

## ◆ IPV6_REV_ZONE_SUFFIX

const char * isc::d2::D2CfgMgr::IPV6_REV_ZONE_SUFFIX = "ip6.arpa."
| static

Reverse zone suffix added to IPv6 addresses for reverse lookups.

Todo:
  This should be configurable.

Definition at line 169 of file d2_cfg_mgr.h.

Referenced by reverseV6Address().

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

- d2_cfg_mgr.h
- d2_cfg_mgr.cc