Kea: isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection > Class Template Reference

| Kea 3.0.2-git

isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection > Class Template Reference

This class holds configuration of shared networks. More...

`#include <cfg_shared_networks.h>`

Inheritance diagram for isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >:
[legend]

## Public Member Functions
void | add (const SharedNetworkPtrType &network)
| Adds new shared network to the configuration.
void | del (const std::string &name)
| Deletes shared network from the configuration.
uint64_t | del (const uint64_t id)
| Deletes shared networks from the configuration by id.
const SharedNetworkCollection * | getAll () const
| Returns pointer to all configured shared networks.
SharedNetworkPtrType | getByName (const std::string &name) const
| Retrieves shared network by name.
void | merge (CfgOptionDefPtr cfg_def, CfgSharedNetworks &other)
| Merges specified shared network configuration into this configuration.
virtual data::ElementPtr | toElement () const
| Unparses shared networks configuration.
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor.

## Protected Attributes
SharedNetworkCollection | networks_
| Multi index container holding shared networks.

## Detailed Description

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>
class isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >

This class holds configuration of shared networks.

This is a generic class implementing basic functions such as shared network addition, removal and retrieval. It also dumps configuration in the JSON format.

There are specializations of this class implemented as CfgSharedNetworks4 and CfgSharedNetworks6 for IPv4 and IPv6 cases repspectively.

Template Parameters

  Type | of the pointer to a shared network, i.e. SharedNetwork4Ptr or SharedNetwork6Ptr.

Definition at line 35 of file cfg_shared_networks.h.

## Member Function Documentation

## ◆ add()

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>

void isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::add | ( | const SharedNetworkPtrType & | network | ) |
| inline

Adds new shared network to the configuration.

Parameters

  network | Pointer to a network

Exceptions

  isc::BadValue | when name is a duplicate of existing network's name.

Definition at line 48 of file cfg_shared_networks.h.

References getByName(), isc_throw, and networks_.

Here is the call graph for this function:

## ◆ del() [1/2]

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>

void isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::del | ( | const std::string & | name | ) |
| inline

Deletes shared network from the configuration.

Parameters

  name | Name of the network to be deleted.

Exceptions

  isc::BadValue | if the network can't be found.

Definition at line 62 of file cfg_shared_networks.h.

References get(), isc_throw, and networks_.

Here is the call graph for this function:

## ◆ del() [2/2]

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>

uint64_t isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::del | ( | const uint64_t | id | ) |
| inline

Deletes shared networks from the configuration by id.

Note that there are cases when there will be multiple shared networks 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 shared networks that were not added via the database.

Parameters

  id | Identifier of the shared networks to be deleted.

Returns
  Number of deleted shared networks.

Definition at line 89 of file cfg_shared_networks.h.

References get(), and networks_.

Here is the call graph for this function:

## ◆ getAll()

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>

const SharedNetworkCollection * isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::getAll | ( |  | ) | const
| inline

Returns pointer to all configured shared networks.

Definition at line 38 of file cfg_shared_networks.h.

References networks_.

Referenced by merge().

## ◆ getByName()

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>

SharedNetworkPtrType isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::getByName | ( | const std::string & | name | ) | const
| inline

Retrieves shared network by name.

Parameters

  name | Name of the network to be retrieved.

Returns
  Pointer to the shared network or null pointer if the network is not found.

Definition at line 109 of file cfg_shared_networks.h.

References get(), and networks_.

Referenced by add().

Here is the call graph for this function:

## ◆ merge()

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>

void isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::merge | ( | CfgOptionDefPtr | cfg_def,
|  | CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection > & | other )
| inline

Merges specified shared network configuration into this configuration.

This method merges networks from the `other` configuration into this configuration. The general rule is that existing networks are replaced by the networks from `other`.

For each network in `other`, do the following:

- Any associated subnets are removed. Shared networks retrieved from config backends, do not carry their associated subnets (if any) with them. (Subnet assignments are maintained by subnet merges).
- If a shared network of the same name already exists in this configuration:
  - All of its associated subnets are moved to the "other" network.
  - The existing network is removed from this configuration.
- The "other" network's option instances are created.
- The "other" network is added to this configuration.

Warning
  The merge operation may affect the `other` configuration. 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.

Parameters

  cfg_def | set of of user-defined option definitions to use when creating option instances.
  other | the shared network configuration to be merged into this configuration.

Definition at line 162 of file cfg_shared_networks.h.

References get(), getAll(), and networks_.

Here is the call graph for this function:

## ◆ toElement()

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>

virtual data::ElementPtr isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::toElement | ( |  | ) | const
| inlinevirtual

Unparses shared networks configuration.

Returns
  Element object representing a list of shared networks held within configuration. The networks are sorted by their names.

Implements isc::data::CfgToElement.

Definition at line 122 of file cfg_shared_networks.h.

References isc::data::Element::createList(), get(), and networks_.

Here is the call graph for this function:

## Member Data Documentation

## ◆ networks_

template<typename SharedNetworkPtrType, typename SharedNetworkCollection>

SharedNetworkCollection isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::networks_
| protected

Multi index container holding shared networks.

Definition at line 215 of file cfg_shared_networks.h.

Referenced by add(), del(), del(), getAll(), getByName(), merge(), and toElement().

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

- cfg_shared_networks.h