Kea 2.7.5
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.
 
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
Typeof 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
networkPointer to a network
Exceptions
isc::BadValuewhen name is a duplicate of existing network's name.

Definition at line 48 of file cfg_shared_networks.h.

References isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::getByName(), isc_throw, and isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::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
nameName of the network to be deleted.
Exceptions
isc::BadValueif the network can't be found.

Definition at line 62 of file cfg_shared_networks.h.

References isc_throw, and isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::networks_.

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

References isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::networks_.

◆ 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 isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::networks_.

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

References isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::networks_.

Referenced by isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::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.

References isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::networks_.

◆ 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(), and isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::networks_.

+ Here is the call graph for this function:

Member Data Documentation

◆ networks_


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