Kea  2.1.7-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 >:

Public Member Functions

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

Protected Attributes

SharedNetworkCollection networks_
 Multi index container holding shared networks. More...
 

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
Typeof the pointer to a shared network, i.e. SharedNetwork4Ptr or SharedNetwork6Ptr.

Definition at line 34 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
networkPointer to a network
Exceptions
isc::BadValuewhen name is a duplicate of existing network's name.

Definition at line 47 of file cfg_shared_networks.h.

◆ 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
nameName of the network to be deleted.
Exceptions
isc::BadValueif the network can't be found.

Definition at line 61 of file cfg_shared_networks.h.

◆ 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
idIdentifier of the shared networks to be deleted.
Returns
Number of deleted shared networks.

Definition at line 88 of file cfg_shared_networks.h.

◆ 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 37 of file cfg_shared_networks.h.

Referenced by isc::dhcp::CfgSharedNetworks< SharedNetwork4Ptr, SharedNetwork4Collection >::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
nameName of the network to be retrieved.
Returns
Pointer to the shared network or null pointer if the network is not found.

Definition at line 108 of file cfg_shared_networks.h.

Referenced by isc::dhcp::CfgSharedNetworks< SharedNetwork4Ptr, SharedNetwork4Collection >::add().

◆ 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_defset of of user-defined option definitions to use when creating option instances.
otherthe shared network configuration to be merged into this configuration.

Definition at line 162 of file cfg_shared_networks.h.

◆ 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 121 of file cfg_shared_networks.h.

Member Data Documentation

◆ networks_


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