Kea: isc::dhcp::CfgOptionDef Class Reference

| Kea 2.2.0

Public Member Functions | List of all members
isc::dhcp::CfgOptionDef Class Reference

Represents option definitions used by the DHCP server. More...

`#include <cfg_option_def.h>`

Inheritance diagram for isc::dhcp::CfgOptionDef:
[legend]

## Public Member Functions
void | copyTo (CfgOptionDef &new_config) const
| Copies this configuration to a new configuration. More...
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor. More...
virtual isc::data::ElementPtr | toElement () const =0
| Unparse a configuration object. More...

## Methods and operators used for comparing objects.
bool | equals (const CfgOptionDef &other) const
| Check if configuration is equal to other configuration. More...
bool | operator== (const CfgOptionDef &other) const
| Equality operator. More...
bool | operator!= (const CfgOptionDef &other) const
| Inequality operator. More...
void | add (const OptionDefinitionPtr &def)
| Add new option definition. More...
OptionDefContainerPtr | getAll (const std::string &option_space) const
| Return option definitions for particular option space. More...
OptionDefinitionPtr | get (const std::string &option_space, const uint16_t option_code) const
| Return option definition for a particular option space and code. More...
OptionDefinitionPtr | get (const std::string &option_space, const std::string &option_name) const
| Return option definition for the particular option space and name. More...
uint64_t | del (const uint64_t id)
| Deletes all option definitions having a given database id. More...
const OptionDefSpaceContainer & | getContainer () const
| Returns reference to container holding option definitions. More...
virtual isc::data::ElementPtr | toElement () const
| Unparse a configuration object. More...
isc::data::ElementPtr | toElementWithMetadata (const bool include_metadata) const
| Unparse a configuration object with optionally including the metadata. More...
void | merge (CfgOptionDef &other)
| Merges specified option definitions from a configuration into this configuration. More...

## Detailed Description

Represents option definitions used by the DHCP server.

This class provides methods to add and retrieve option definitions specified by the administrator for the DHCP server. Option definitions specify formats of the options. This class doesn't hold information about the data being carried by the options.

Option definitions are grouped by option spaces. The option space is identified by the unique name which is specified as a string. The following names: "dhcp4" and "dhcp6" are reserved, though. They are names of option spaces used for standard top-level DHCPv4 and DHCPv6 options respectively.

Definition at line 30 of file cfg_option_def.h.

## Member Function Documentation

## ◆ add()

void isc::dhcp::CfgOptionDef::add | ( | const OptionDefinitionPtr & | def | ) |

Add new option definition.

Parameters

  def | option definition to be added.

Exceptions

  isc::dhcp::DuplicateOptionDefinition | when the particular option definition already exists.
  isc::dhcp::MalformedOptionDefinition | when the pointer to an option definition is NULL.
  isc::BadValue | when the option space name is empty or when trying to override the standard option (in dhcp4 or dhcp6 option space).

Definition at line 79 of file cfg_option_def.cc.

References isc::dhcp::OptionDefSpaceContainer::addItem(), get(), isc::dhcp::LibDHCP::getOptionDef(), and isc_throw.

Referenced by copyTo(), and merge().

Here is the call graph for this function:

## ◆ copyTo()

void isc::dhcp::CfgOptionDef::copyTo | ( | CfgOptionDef & | new_config | ) | const

Copies this configuration to a new configuration.

This method copies the option definitions stores in the configuration to an object passed as parameter. There are no shared objects or pointers between the original object and a copy.

Parameters

  [out] | new_config | An object to which the configuration will be copied.

Definition at line 21 of file cfg_option_def.cc.

References add(), isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::clearItems(), getAll(), and isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::getOptionSpaceNames().

Referenced by merge().

Here is the call graph for this function:

## ◆ del()

uint64_t isc::dhcp::CfgOptionDef::del | ( | const uint64_t | id | ) |

Deletes all option definitions having a given database id.

Note that there are cases when there will be multiple option definitions having the same id (typically id of 0). When configuration backend is in use it sets the unique ids from the database. In cases when the configuration backend is not used, the ids default to 0. Passing the id of 0 would result in deleting all option definitions that were not added via the database.

Parameters

  id | Identifier of the option definitions to be deleted.

Returns
  Number of deleted option definitions.

Definition at line 162 of file cfg_option_def.cc.

References isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::deleteItems().

Here is the call graph for this function:

## ◆ equals()

bool isc::dhcp::CfgOptionDef::equals | ( | const CfgOptionDef & | other | ) | const

Check if configuration is equal to other configuration.

Parameters

  other | An object holding configuration to compare to.

Returns
  true if configurations are equal, false otherwise.

Definition at line 39 of file cfg_option_def.cc.

References get(), getAll(), and isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::getOptionSpaceNames().

Referenced by operator!=(), and operator==().

Here is the call graph for this function:

## ◆ get() [1/2]

OptionDefinitionPtr isc::dhcp::CfgOptionDef::get | ( | const std::string & | option_space,
|  | const std::string & | option_name
| ) |  | const

Return option definition for the particular option space and name.

Parameters

  option_space | option space.
  option_name | option name.

Returns
  An option definition or NULL pointer if option definition has not been found.

Definition at line 140 of file cfg_option_def.cc.

References getAll().

Here is the call graph for this function:

## ◆ get() [2/2]

OptionDefinitionPtr isc::dhcp::CfgOptionDef::get | ( | const std::string & | option_space,
|  | const uint16_t | option_code
| ) |  | const

Return option definition for a particular option space and code.

Parameters

  option_space | option space.
  option_code | option code.

Returns
  An option definition or NULL pointer if option definition has not been found.

Definition at line 118 of file cfg_option_def.cc.

References getAll().

Referenced by add(), equals(), and merge().

Here is the call graph for this function:

## ◆ getAll()

OptionDefContainerPtr isc::dhcp::CfgOptionDef::getAll | ( | const std::string & | option_space | ) | const

Return option definitions for particular option space.

Parameters

  option_space | option space.

Returns
  Pointer to the collection of option definitions for the particular option space. The option collection is empty if no option exists for the option space specified.

Todo:
  Does option space require any validation here?

Definition at line 112 of file cfg_option_def.cc.

References isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::getItems().

Referenced by copyTo(), equals(), get(), merge(), and toElementWithMetadata().

Here is the call graph for this function:

## ◆ getContainer()

const OptionDefSpaceContainer & isc::dhcp::CfgOptionDef::getContainer | ( |  | ) | const
| inline

Returns reference to container holding option definitions.

Definition at line 131 of file cfg_option_def.h.

Referenced by merge().

## ◆ merge()

void isc::dhcp::CfgOptionDef::merge | ( | CfgOptionDef & | other | ) |

Merges specified option definitions from a configuration into this configuration.

This method merges the option definitions from the `other` configuration into this configuration. The merged set of definitions is created as follows:

Iterator over the definitions in each name space in this configuration: If either the definition's name or code are defined in `other` then skip over the definition otherwise add it to `other`.

Replace this configuration's definitions with the definitions in `other` using `copyTo()`.

Parameters

  other | option definitions to merge in.

Warning
  The merge operation affects `other`. Therefore, the caller must not rely on the data held in the `other` object after the call to `merge`. Also, the data held in `other` must not be modified after the call to `merge` because it may affect the merged configuration.

Definition at line 232 of file cfg_option_def.cc.

References add(), copyTo(), get(), getAll(), getContainer(), and isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::getOptionSpaceNames().

Here is the call graph for this function:

## ◆ operator!=()

bool isc::dhcp::CfgOptionDef::operator!= | ( | const CfgOptionDef & | other | ) | const
| inline

Inequality operator.

Parameters

  other | An object holding configuration to compare to.

Returns
  true if configurations are unequal, false otherwise.

Definition at line 67 of file cfg_option_def.h.

References equals().

Here is the call graph for this function:

## ◆ operator==()

bool isc::dhcp::CfgOptionDef::operator== | ( | const CfgOptionDef & | other | ) | const
| inline

Equality operator.

Parameters

  other | An object holding configuration to compare to.

Returns
  true if configurations are equal, false otherwise.

Definition at line 58 of file cfg_option_def.h.

References equals().

Here is the call graph for this function:

## ◆ toElement()

ElementPtr isc::dhcp::CfgOptionDef::toElement | ( |  | ) | const
| virtual

Unparse a configuration object.

Returns
  a pointer to unparsed configuration

Implements isc::data::CfgToElement.

Definition at line 167 of file cfg_option_def.cc.

References toElementWithMetadata().

Here is the call graph for this function:

## ◆ toElementWithMetadata()

ElementPtr isc::dhcp::CfgOptionDef::toElementWithMetadata | ( | const bool | include_metadata | ) | const

Unparse a configuration object with optionally including the metadata.

Parameters

  include_metadata | boolean value indicating if the metadata should be included (if true) or not (if false).

Returns
  A pointer to the unparsed configuration.

Definition at line 172 of file cfg_option_def.cc.

References isc::data::Element::create(), isc::data::Element::createList(), isc::data::Element::createMap(), getAll(), isc::dhcp::OptionDataTypeUtil::getDataTypeName(), and isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::getOptionSpaceNames().

Referenced by toElement().

Here is the call graph for this function:

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

- cfg_option_def.h
- cfg_option_def.cc