Kea 2.5.7
isc::yang::AdaptorConfig Class Reference

JSON adaptor for Kea server configurations. More...

#include <adaptor_config.h>

+ Inheritance diagram for isc::yang::AdaptorConfig:

Static Public Member Functions

static void preProcess4 (isc::data::ElementPtr config)
 Pre process a DHCPv4 configuration.
 
static void preProcess6 (isc::data::ElementPtr config)
 Pre process a DHCPv6 configuration.
 
- Static Public Member Functions inherited from isc::yang::AdaptorHost
static void quoteIdentifier (isc::data::ElementPtr host)
 Quote when needed a host identifier.
 
- Static Public Member Functions inherited from isc::yang::AdaptorOption
static void checkCode (isc::data::ConstElementPtr option)
 Check if code is specified in option defintion.
 
static void checkType (isc::data::ConstElementPtr option)
 Checks if type is specified in option definition.
 
static void collect (isc::data::ConstElementPtr option, OptionCodes &codes)
 Collect definition.
 
static void initCodes (OptionCodes &codes, const std::string &space)
 Initialize code map.
 
static void setCode (isc::data::ElementPtr option, const OptionCodes &codes)
 Set code from name and definitions.
 
static void setSpace (isc::data::ElementPtr option, const std::string &space)
 Set space.
 
- Static Public Member Functions inherited from isc::yang::AdaptorSubnet
static void assignID (isc::data::ElementPtr subnet, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next)
 Assign subnet ID.
 
static bool collectID (isc::data::ConstElementPtr subnet, isc::dhcp::SubnetIDSet &set)
 Collect a subnet ID.
 
static void updateRelay (isc::data::ElementPtr subnet)
 Update relay.
 

Static Protected Member Functions

static void preProcess (isc::data::ElementPtr dhcp, const std::string &subsel, const std::string &space)
 Pre process a configuration.
 
static void requireClassesSharedNetworks (isc::data::ConstElementPtr networks, const std::string &subsel)
 Process require client classes in a shared network list.
 
static void sanitizeDatabase (isc::data::ElementPtr dhcp)
 Update (hosts) database.
 
static void sanitizeHostList (isc::data::ConstElementPtr hosts)
 Process host reservation list.
 
static void SanitizeHostsInSharedNetworks (isc::data::ConstElementPtr networks, const std::string &space)
 Process host reservations in a shared network list.
 
static void sanitizeHostSubnets (isc::data::ConstElementPtr subnets)
 Process host reservations in a subnet list.
 
static void sanitizeOptionClasses (isc::data::ConstElementPtr classes, const std::string &space, OptionCodes &codes)
 Collect option definitions from a client class list and set missing option codes.
 
static void sanitizeOptionDataList (isc::data::ConstElementPtr options, const std::string &space, const OptionCodes &codes)
 Set missing option codes to an option data list.
 
static void sanitizeOptionDefList (isc::data::ConstElementPtr defs, const std::string &space, OptionCodes &codes)
 Collect option definitions from an option definition list.
 
static void sanitizeOptionHosts (isc::data::ConstElementPtr hosts, const std::string &space, const OptionCodes &codes)
 Set missing option codes to a host reservation list.
 
static void sanitizeOptionPools (isc::data::ConstElementPtr pools, const std::string &space, const OptionCodes &codes)
 Set missing option codes to a pool list.
 
static void sanitizeOptionSharedNetworks (isc::data::ConstElementPtr networks, const std::string &space, const OptionCodes &codes)
 Set missing option codes to a shared network list.
 
static void sanitizeOptionSubnets (isc::data::ConstElementPtr subnets, const std::string &space, const OptionCodes &codes)
 Set missing option codes to a subnet list.
 
static void sanitizePools (isc::data::ConstElementPtr pools)
 Sanitizes all pools in a pools list.
 
static void sanitizePoolsInSharedNetworks (isc::data::ConstElementPtr networks, const std::string &subsel)
 Sanitizes all pools in all subnets in a shared network list.
 
static void sanitizePoolsInSubnets (isc::data::ConstElementPtr subnets)
 Sanitizes all pools in a subnets list.
 
static void sanitizeRelayInSharedNetworks (isc::data::ConstElementPtr networks, const std::string &subsel)
 Sanitizes relay information in a shared network list.
 
static void sanitizeRelaySubnets (isc::data::ConstElementPtr subnets)
 Sanitizes relay information in subnets in a subnet list.
 
static void sanitizeRelaySuppliedOptions (isc::data::ElementPtr dhcp)
 Update relay supplied options.
 
static void sanitizeRequireClassesPools (isc::data::ConstElementPtr pools)
 Process require client classes in a pool list.
 
static void sanitizeRequireClassesSubnets (isc::data::ConstElementPtr subnets)
 Process require client classes in a subnet list.
 
static void sharedNetworksAssignID (isc::data::ConstElementPtr networks, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next, const std::string &subsel)
 Assigns subnet-id to every subnet in a shared network list.
 
static bool sharedNetworksCollectID (isc::data::ConstElementPtr networks, isc::dhcp::SubnetIDSet &set, const std::string &subsel)
 Collects subnet-ids in all subnets in all shared network list.
 
static void subnetsAssignID (isc::data::ConstElementPtr subnets, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next)
 Assigns subnet-id to every subnet in a subnet list.
 
static bool subnetsCollectID (isc::data::ConstElementPtr subnets, isc::dhcp::SubnetIDSet &set)
 Collects subnet-ids on all subnets.
 
- Static Protected Member Functions inherited from isc::yang::AdaptorOption
static void initCodesInternal (OptionCodes &codes, const std::string &space, const isc::dhcp::OptionDefParams *params, size_t params_size)
 Initialize code map from option definition parameters.
 

Additional Inherited Members

- Public Member Functions inherited from isc::yang::AdaptorHost
virtual ~AdaptorHost ()=default
 Destructor.
 
- Public Member Functions inherited from isc::yang::AdaptorOption
virtual ~AdaptorOption ()=default
 Destructor.
 
- Public Member Functions inherited from isc::yang::AdaptorSubnet
virtual ~AdaptorSubnet ()=default
 Destructor.
 
- Static Public Attributes inherited from isc::yang::AdaptorHost
static const std::string STD_CHARACTERS
 The string of standard (vs special or not printable) characters (digit, letters, -, ., @, _).
 

Detailed Description

JSON adaptor for Kea server configurations.

Currently only from JSON to YANG for DHCPv4 and DHCPv6 available as preProcess4 and preProcess6 class methods, filling some required (by YANG) fields (e.g. subnet IDs, or option code and space), or transforming a hand-written JSON configuration into a canonical form.

Definition at line 25 of file adaptor_config.h.

Member Function Documentation

◆ preProcess()

void isc::yang::AdaptorConfig::preProcess ( isc::data::ElementPtr  dhcp,
const std::string &  subsel,
const std::string &  space 
)
staticprotected

◆ preProcess4()

void isc::yang::AdaptorConfig::preProcess4 ( isc::data::ElementPtr  config)
static

Pre process a DHCPv4 configuration.

Assign subnet IDs, check and set defaults in options, etc. Note even though the parameter is a ConstElementPtr and is not modified, sub-structures can modify it, so if you need a copy do a deep one.

Parameters
configThe configuration.
Exceptions
MissingKeywhen a required key is missing.
BadValuewhen null or not a map or deprecated Logging present.
Note
Does nothing if "Dhcp4" is not present in the map.

Definition at line 613 of file adaptor_config.cc.

References isc::data::copy(), isc_throw, isc::data::Element::map, and preProcess().

Referenced by isc::yang::TranslatorConfig::setConfig().

+ Here is the call graph for this function:

◆ preProcess6()

void isc::yang::AdaptorConfig::preProcess6 ( isc::data::ElementPtr  config)
static

Pre process a DHCPv6 configuration.

Assign subnet IDs, check and set default in options, etc. Note even though the parameter is a ConstElementPtr and is not modified, sub-structures can modify it, so if you need a copy do a deep one.

Parameters
configThe configuration.
Exceptions
MissingKeywhen a required key is missing.
BadValuewhen null or not a map or deprecated Logging present.
Note
Does nothing if "Dhcp6" is not present in the map.

Definition at line 633 of file adaptor_config.cc.

References isc::data::copy(), isc_throw, isc::data::Element::map, and preProcess().

Referenced by isc::yang::TranslatorConfig::setConfig().

+ Here is the call graph for this function:

◆ requireClassesSharedNetworks()

void isc::yang::AdaptorConfig::requireClassesSharedNetworks ( isc::data::ConstElementPtr  networks,
const std::string &  subsel 
)
staticprotected

Process require client classes in a shared network list.

Remove empty require client class lists.

Parameters
networksThe shared network list.
subselThe subnet list name.

Definition at line 407 of file adaptor_config.cc.

References sanitizeRequireClassesSubnets().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ sanitizeDatabase()

void isc::yang::AdaptorConfig::sanitizeDatabase ( isc::data::ElementPtr  dhcp)
staticprotected

Update (hosts) database.

Force the use of hosts-databases vs. hosts-database.

Parameters
dhcpThe DHCP server.

Definition at line 497 of file adaptor_config.cc.

References isc::data::copy(), and isc::data::Element::createList().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ sanitizeHostList()

void isc::yang::AdaptorConfig::sanitizeHostList ( isc::data::ConstElementPtr  hosts)
staticprotected

Process host reservation list.

Quote when needed flex-id identifiers.

Parameters
hostsThe host reservation list.

Definition at line 425 of file adaptor_config.cc.

References isc::yang::AdaptorHost::quoteIdentifier().

Referenced by preProcess(), and sanitizeHostSubnets().

+ Here is the call graph for this function:

◆ SanitizeHostsInSharedNetworks()

void isc::yang::AdaptorConfig::SanitizeHostsInSharedNetworks ( isc::data::ConstElementPtr  networks,
const std::string &  space 
)
staticprotected

Process host reservations in a shared network list.

Quote when needed flex-id identifiers.

Parameters
networksThe shared network list.
spaceThe default space name.

Definition at line 452 of file adaptor_config.cc.

References sanitizeHostSubnets().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ sanitizeHostSubnets()

void isc::yang::AdaptorConfig::sanitizeHostSubnets ( isc::data::ConstElementPtr  subnets)
staticprotected

Process host reservations in a subnet list.

Quote when needed flex-id identifiers.

Parameters
subnetsThe subnet list.

Definition at line 439 of file adaptor_config.cc.

References sanitizeHostList().

Referenced by preProcess(), and SanitizeHostsInSharedNetworks().

+ Here is the call graph for this function:

◆ sanitizeOptionClasses()

void isc::yang::AdaptorConfig::sanitizeOptionClasses ( isc::data::ConstElementPtr  classes,
const std::string &  space,
OptionCodes codes 
)
staticprotected

Collect option definitions from a client class list and set missing option codes.

Parameters
classesThe client class list.
spaceThe default space name.
codesOption definitions.

Definition at line 194 of file adaptor_config.cc.

References sanitizeOptionDataList(), and sanitizeOptionDefList().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ sanitizeOptionDataList()

void isc::yang::AdaptorConfig::sanitizeOptionDataList ( isc::data::ConstElementPtr  options,
const std::string &  space,
const OptionCodes codes 
)
staticprotected

Set missing option codes to an option data list.

Parameters
optionsThe option data list.
spaceThe default space name.
codesOption definitions.

Definition at line 176 of file adaptor_config.cc.

References isc::yang::AdaptorOption::setCode(), and isc::yang::AdaptorOption::setSpace().

Referenced by preProcess(), sanitizeOptionClasses(), sanitizeOptionHosts(), sanitizeOptionPools(), sanitizeOptionSharedNetworks(), and sanitizeOptionSubnets().

+ Here is the call graph for this function:

◆ sanitizeOptionDefList()

void isc::yang::AdaptorConfig::sanitizeOptionDefList ( isc::data::ConstElementPtr  defs,
const std::string &  space,
OptionCodes codes 
)
staticprotected

Collect option definitions from an option definition list.

Collects options definitions, but also sets missing option space with default.

Parameters
defsThe option definition list.
spaceThe default space name (missing will be filled with this)
codesOption definitions.

Definition at line 156 of file adaptor_config.cc.

References isc::yang::AdaptorOption::checkCode(), isc::yang::AdaptorOption::checkType(), isc::yang::AdaptorOption::collect(), and isc::yang::AdaptorOption::setSpace().

Referenced by preProcess(), and sanitizeOptionClasses().

+ Here is the call graph for this function:

◆ sanitizeOptionHosts()

void isc::yang::AdaptorConfig::sanitizeOptionHosts ( isc::data::ConstElementPtr  hosts,
const std::string &  space,
const OptionCodes codes 
)
staticprotected

Set missing option codes to a host reservation list.

Parameters
hostsThe host reservation list.
spaceThe default space name.
codesOption definitions.

Definition at line 255 of file adaptor_config.cc.

References sanitizeOptionDataList().

Referenced by preProcess(), and sanitizeOptionSubnets().

+ Here is the call graph for this function:

◆ sanitizeOptionPools()

void isc::yang::AdaptorConfig::sanitizeOptionPools ( isc::data::ConstElementPtr  pools,
const std::string &  space,
const OptionCodes codes 
)
staticprotected

Set missing option codes to a pool list.

Parameters
poolsThe pool list.
spaceThe default space name.
codesOption definitions.

Definition at line 234 of file adaptor_config.cc.

References sanitizeOptionDataList().

Referenced by sanitizeOptionSubnets().

+ Here is the call graph for this function:

◆ sanitizeOptionSharedNetworks()

void isc::yang::AdaptorConfig::sanitizeOptionSharedNetworks ( isc::data::ConstElementPtr  networks,
const std::string &  space,
const OptionCodes codes 
)
staticprotected

Set missing option codes to a shared network list.

Parameters
networksThe shared network list.
spaceThe default space name.
codesOption definitions.

Definition at line 332 of file adaptor_config.cc.

References sanitizeOptionDataList(), and sanitizeOptionSubnets().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ sanitizeOptionSubnets()

void isc::yang::AdaptorConfig::sanitizeOptionSubnets ( isc::data::ConstElementPtr  subnets,
const std::string &  space,
const OptionCodes codes 
)
staticprotected

Set missing option codes to a subnet list.

Parameters
subnetsThe subnet list.
spaceThe default space name.
codesOption definitions.

Definition at line 276 of file adaptor_config.cc.

References sanitizeOptionDataList(), sanitizeOptionHosts(), and sanitizeOptionPools().

Referenced by preProcess(), and sanitizeOptionSharedNetworks().

+ Here is the call graph for this function:

◆ sanitizePools()

void isc::yang::AdaptorConfig::sanitizePools ( isc::data::ConstElementPtr  pools)
staticprotected

Sanitizes all pools in a pools list.

Goes over each pool and cleans up its definition (removes extra spaces, adds one space before and after - ).

Parameters
poolsThe pool list.

Definition at line 116 of file adaptor_config.cc.

References isc::yang::AdaptorPool::canonizePool().

Referenced by sanitizePoolsInSubnets().

+ Here is the call graph for this function:

◆ sanitizePoolsInSharedNetworks()

void isc::yang::AdaptorConfig::sanitizePoolsInSharedNetworks ( isc::data::ConstElementPtr  networks,
const std::string &  subsel 
)
staticprotected

Sanitizes all pools in all subnets in a shared network list.

Parameters
networksThe shared network list.
subselThe subnet list name.

Definition at line 143 of file adaptor_config.cc.

References sanitizePoolsInSubnets().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ sanitizePoolsInSubnets()

void isc::yang::AdaptorConfig::sanitizePoolsInSubnets ( isc::data::ConstElementPtr  subnets)
staticprotected

Sanitizes all pools in a subnets list.

Parameters
subnetsThe subnet list.

Definition at line 131 of file adaptor_config.cc.

References sanitizePools().

Referenced by preProcess(), and sanitizePoolsInSharedNetworks().

+ Here is the call graph for this function:

◆ sanitizeRelayInSharedNetworks()

void isc::yang::AdaptorConfig::sanitizeRelayInSharedNetworks ( isc::data::ConstElementPtr  networks,
const std::string &  subsel 
)
staticprotected

Sanitizes relay information in a shared network list.

Force the use of ip-addresses when it finds an ip-address entry.

Parameters
networksThe shared network list.
subselThe subnet list name.

Definition at line 482 of file adaptor_config.cc.

References sanitizeRelaySubnets(), and isc::yang::AdaptorSubnet::updateRelay().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ sanitizeRelaySubnets()

void isc::yang::AdaptorConfig::sanitizeRelaySubnets ( isc::data::ConstElementPtr  subnets)
staticprotected

Sanitizes relay information in subnets in a subnet list.

Force the use of ip-addresses when it finds an ip-address entry.

Parameters
subnetsThe subnet list.

Definition at line 469 of file adaptor_config.cc.

References isc::yang::AdaptorSubnet::updateRelay().

Referenced by preProcess(), and sanitizeRelayInSharedNetworks().

+ Here is the call graph for this function:

◆ sanitizeRelaySuppliedOptions()

void isc::yang::AdaptorConfig::sanitizeRelaySuppliedOptions ( isc::data::ElementPtr  dhcp)
staticprotected

Update relay supplied options.

Remove empty relay supplied option list.

Parameters
dhcpThe DHCPv6 server.

Definition at line 511 of file adaptor_config.cc.

Referenced by preProcess().

◆ sanitizeRequireClassesPools()

void isc::yang::AdaptorConfig::sanitizeRequireClassesPools ( isc::data::ConstElementPtr  pools)
staticprotected

Process require client classes in a pool list.

Remove empty require client class list.

Parameters
poolsThe pool list.

Definition at line 373 of file adaptor_config.cc.

Referenced by sanitizeRequireClassesSubnets().

◆ sanitizeRequireClassesSubnets()

void isc::yang::AdaptorConfig::sanitizeRequireClassesSubnets ( isc::data::ConstElementPtr  subnets)
staticprotected

Process require client classes in a subnet list.

Remove empty require client class lists.

Parameters
subnetsThe subnet list.

Definition at line 389 of file adaptor_config.cc.

References sanitizeRequireClassesPools().

Referenced by preProcess(), and requireClassesSharedNetworks().

+ Here is the call graph for this function:

◆ sharedNetworksAssignID()

void isc::yang::AdaptorConfig::sharedNetworksAssignID ( isc::data::ConstElementPtr  networks,
isc::dhcp::SubnetIDSet set,
isc::dhcp::SubnetID next,
const std::string &  subsel 
)
staticprotected

Assigns subnet-id to every subnet in a shared network list.

Only those subnets that don't have one subnet-id assigned yet, will get a new subnet-id value.

Parameters
networksThe shared network list.
setThe reference to the set of assigned IDs.
nextThe next ID.
subselThe subnet list name.

Definition at line 94 of file adaptor_config.cc.

References isc::yang::AdaptorSubnet::assignID().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ sharedNetworksCollectID()

bool isc::yang::AdaptorConfig::sharedNetworksCollectID ( isc::data::ConstElementPtr  networks,
isc::dhcp::SubnetIDSet set,
const std::string &  subsel 
)
staticprotected

Collects subnet-ids in all subnets in all shared network list.

It will go over all subnets in all shared networks specified to collect their subnet-ids. It will then return true if all subnets have ids. If the subnets list is empty, it will also return true. False will be returned if there is at least one subnet that doesn't have subnet-id.

Parameters
networksThe shared network list.
setThe reference to the set of assigned IDs.
subselThe subnet list name.
Returns
True if all subnets have an ID, false otherwise.

Definition at line 47 of file adaptor_config.cc.

References subnetsCollectID().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ subnetsAssignID()

void isc::yang::AdaptorConfig::subnetsAssignID ( isc::data::ConstElementPtr  subnets,
isc::dhcp::SubnetIDSet set,
isc::dhcp::SubnetID next 
)
staticprotected

Assigns subnet-id to every subnet in a subnet list.

Only those subnets that don't have one subnet-id assigned yet, will get a new subnet-id value.

Parameters
subnetsThe subnet list.
setThe reference to the set of assigned IDs.
nextThe next ID.

Definition at line 80 of file adaptor_config.cc.

References isc::yang::AdaptorSubnet::assignID().

Referenced by preProcess().

+ Here is the call graph for this function:

◆ subnetsCollectID()

bool isc::yang::AdaptorConfig::subnetsCollectID ( isc::data::ConstElementPtr  subnets,
isc::dhcp::SubnetIDSet set 
)
staticprotected

Collects subnet-ids on all subnets.

It will go over all subnets and collect their ids. It will then return true if all subnets have ids. If the subnets list is empty, it will also return true. False will be returned if there is at least one subnet that doesn't have subnet-id.

Parameters
subnetsThe subnet list.
setThe reference to the set of assigned IDs.
Returns
True if all subnets have an ID, false otherwise.

Definition at line 25 of file adaptor_config.cc.

References isc::yang::AdaptorSubnet::collectID().

Referenced by preProcess(), and sharedNetworksCollectID().

+ Here is the call graph for this function:

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