Kea  1.9.9-git
isc::yang::AdaptorConfig Class Reference

JSON adaptor for Kea server configurations. More...

#include <adaptor_config.h>

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

Public Member Functions

 AdaptorConfig ()
 Constructor. More...
 
virtual ~AdaptorConfig ()
 Destructor. More...
 
- Public Member Functions inherited from isc::yang::AdaptorHost
 AdaptorHost ()
 Constructor. More...
 
virtual ~AdaptorHost ()
 Destructor. More...
 
- Public Member Functions inherited from isc::yang::AdaptorOption
 AdaptorOption ()
 Constructor. More...
 
virtual ~AdaptorOption ()
 Destructor. More...
 
- Public Member Functions inherited from isc::yang::AdaptorSubnet
 AdaptorSubnet ()
 Constructor. More...
 
virtual ~AdaptorSubnet ()
 Destructor. More...
 

Static Public Member Functions

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

Static Protected Member Functions

static void preProcess (isc::data::ElementPtr dhcp, const std::string &subsel, const std::string &space)
 Pre process a configuration. More...
 
static void requireClassesSharedNetworks (isc::data::ConstElementPtr networks, const std::string &subsel)
 Process require client classes in a shared network list. More...
 
static void sanitizeDatabase (isc::data::ConstElementPtr dhcp)
 Update (hosts) database. More...
 
static void sanitizeHostList (isc::data::ConstElementPtr hosts)
 Process host reservation list. More...
 
static void SanitizeHostsInSharedNetworks (isc::data::ConstElementPtr networks, const std::string &space)
 Process host reservations in a shared network list. More...
 
static void sanitizeHostSubnets (isc::data::ConstElementPtr subnets)
 Process host reservations in a subnet list. More...
 
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. More...
 
static void sanitizeOptionDataList (isc::data::ConstElementPtr options, const std::string &space, const OptionCodes &codes)
 Set missing option codes to an option data list. More...
 
static void sanitizeOptionDefList (isc::data::ConstElementPtr defs, const std::string &space, OptionCodes &codes)
 Collect option definitions from an option definition list. More...
 
static void sanitizeOptionHosts (isc::data::ConstElementPtr hosts, const std::string &space, const OptionCodes &codes)
 Set missing option codes to a host reservation list. More...
 
static void sanitizeOptionPools (isc::data::ConstElementPtr pools, const std::string &space, const OptionCodes &codes)
 Set missing option codes to a pool list. More...
 
static void sanitizeOptionSharedNetworks (isc::data::ConstElementPtr networks, const std::string &space, const OptionCodes &codes)
 Set missing option codes to a shared network list. More...
 
static void sanitizeOptionSubnets (isc::data::ConstElementPtr subnets, const std::string &space, const OptionCodes &codes)
 Set missing option codes to a subnet list. More...
 
static void sanitizePools (isc::data::ConstElementPtr pools)
 Sanitizes all pools in a pools list. More...
 
static void sanitizePoolsInSharedNetworks (isc::data::ConstElementPtr networks, const std::string &subsel)
 Sanitizes all pools in all subnets in a shared network list. More...
 
static void sanitizePoolsInSubnets (isc::data::ConstElementPtr subnets)
 Sanitizes all pools in a subnets list. More...
 
static void sanitizeRelayInSharedNetworks (isc::data::ConstElementPtr networks, const std::string &subsel)
 Sanitizes relay information in a shared network list. More...
 
static void sanitizeRelaySubnets (isc::data::ConstElementPtr subnets)
 Sanitizes relay information in subnets in a subnet list. More...
 
static void sanitizeRelaySuppliedOptions (isc::data::ConstElementPtr dhcp)
 Update relay supplied options. More...
 
static void sanitizeRequireClassesPools (isc::data::ConstElementPtr pools)
 Process require client classes in a pool list. More...
 
static void sanitizeRequireClassesSubnets (isc::data::ConstElementPtr subnets)
 Process require client classes in a subnet list. More...
 
static void sharedNetworksAssignID (isc::data::ConstElementPtr networks, SubnetIDSet &set, isc::dhcp::SubnetID &next, const std::string &subsel)
 Assigns subnet-id to every subnet in a shared network list. More...
 
static bool sharedNetworksCollectID (isc::data::ConstElementPtr networks, SubnetIDSet &set, const std::string &subsel)
 Collects subnet-ids in all subnets in all shared network list. More...
 
static void subnetsAssignID (isc::data::ConstElementPtr subnets, SubnetIDSet &set, isc::dhcp::SubnetID &next)
 Assigns subnet-id to every subnet in a subnet list. More...
 
static bool subnetsCollectID (isc::data::ConstElementPtr subnets, SubnetIDSet &set)
 Collects subnet-ids on all subnets. More...
 
- 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. More...
 

Additional Inherited Members

- 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, -, ., @, _). More...
 

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.

Constructor & Destructor Documentation

isc::yang::AdaptorConfig::AdaptorConfig ( )

Constructor.

Definition at line 23 of file adaptor_config.cc.

isc::yang::AdaptorConfig::~AdaptorConfig ( )
virtual

Destructor.

Definition at line 26 of file adaptor_config.cc.

Member Function Documentation

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

Pre process a configuration.

Assign subnet IDs, check and set default in options, etc.

Parameters
dhcpThe server configuration.
subselThe subnet list name.
spaceThe default option space name.
Exceptions
MissingKeywhen a required key is missing.

Definition at line 528 of file adaptor_config.cc.

References isc_throw.

void isc::yang::AdaptorConfig::preProcess4 ( isc::data::ConstElementPtr  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 620 of file adaptor_config.cc.

References isc_throw.

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

void isc::yang::AdaptorConfig::preProcess6 ( isc::data::ConstElementPtr  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 639 of file adaptor_config.cc.

References isc_throw.

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

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 412 of file adaptor_config.cc.

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

Update (hosts) database.

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

Parameters
dhcpThe DHCP server.

Definition at line 502 of file adaptor_config.cc.

References isc::data::Element::remove().

+ Here is the call graph for this function:

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 430 of file adaptor_config.cc.

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 457 of file adaptor_config.cc.

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 444 of file adaptor_config.cc.

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 199 of file adaptor_config.cc.

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 181 of file adaptor_config.cc.

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 161 of file adaptor_config.cc.

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 260 of file adaptor_config.cc.

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 239 of file adaptor_config.cc.

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 337 of file adaptor_config.cc.

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 281 of file adaptor_config.cc.

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 121 of file adaptor_config.cc.

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 148 of file adaptor_config.cc.

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

Sanitizes all pools in a subnets list.

Parameters
subnetsThe subnet list.

Definition at line 136 of file adaptor_config.cc.

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 487 of file adaptor_config.cc.

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 474 of file adaptor_config.cc.

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

Update relay supplied options.

Remove empty relay supplied option list.

Parameters
dhcpThe DHCPv6 server.

Definition at line 517 of file adaptor_config.cc.

References isc::data::Element::remove().

+ Here is the call graph for this function:

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 378 of file adaptor_config.cc.

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 394 of file adaptor_config.cc.

void isc::yang::AdaptorConfig::sharedNetworksAssignID ( isc::data::ConstElementPtr  networks,
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.
Returns
True if all subnets have an ID, false otherwise.

Definition at line 99 of file adaptor_config.cc.

bool isc::yang::AdaptorConfig::sharedNetworksCollectID ( isc::data::ConstElementPtr  networks,
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 52 of file adaptor_config.cc.

void isc::yang::AdaptorConfig::subnetsAssignID ( isc::data::ConstElementPtr  subnets,
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.
Returns
True if all subnets have an ID, false otherwise.

Definition at line 85 of file adaptor_config.cc.

bool isc::yang::AdaptorConfig::subnetsCollectID ( isc::data::ConstElementPtr  subnets,
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 30 of file adaptor_config.cc.


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