Kea 2.7.6
|
Holds subnets configured for the DHCPv6 server. More...
#include <cfg_subnets6.h>
Public Member Functions | |
void | add (const Subnet6Ptr &subnet) |
Adds new subnet to the configuration. | |
void | clear () |
Clears all subnets from the configuration. | |
void | del (const ConstSubnet6Ptr &subnet) |
Removes subnet from the configuration. | |
void | del (const SubnetID &subnet_id) |
Removes subnet from the configuration. | |
const Subnet6Collection * | getAll () const |
Returns pointer to the collection of all IPv6 subnets. | |
ConstSubnet6Ptr | getByPrefix (const std::string &subnet_prefix) const |
Returns const pointer to a subnet which matches the specified prefix in the canonical form. | |
ConstSubnet6Ptr | getBySubnetId (const SubnetID &subnet_id) const |
Returns const pointer to a subnet identified by the specified subnet identifier. | |
SubnetIDSet | getLinks (const asiolink::IOAddress &link_addr) const |
Convert a link address into a link set. | |
Subnet6Ptr | getSubnet (const SubnetID id) const |
Returns subnet with specified subnet-id value. | |
void | initAllocatorsAfterConfigure () |
Calls initAllocatorsAfterConfigure for each subnet. | |
void | merge (CfgOptionDefPtr cfg_def, CfgSharedNetworks6Ptr networks, CfgSubnets6 &other) |
Merges specified subnet configuration into this configuration. | |
void | removeStatistics () |
Removes statistics. | |
Subnet6Ptr | replace (const Subnet6Ptr &subnet) |
Replaces subnet in the configuration. | |
ConstSubnet6Ptr | selectSubnet (const asiolink::IOAddress &address, const ClientClasses &client_classes=ClientClasses(), const bool is_relay_address=false) const |
Selects the subnet using a specified address. | |
ConstSubnet6Ptr | selectSubnet (const SubnetSelector &selector) const |
Selects a subnet using parameters specified in the selector. | |
virtual isc::data::ElementPtr | toElement () const |
Unparse a configuration object. | |
void | updateStatistics () |
Updates statistics. | |
Public Member Functions inherited from isc::data::CfgToElement | |
virtual | ~CfgToElement () |
Destructor. | |
Static Public Member Functions | |
static SubnetSelector | initSelector (const Pkt6Ptr &query) |
Build selector from a client's message. | |
Holds subnets configured for the DHCPv6 server.
This class holds a collection of subnets configured for the DHCPv6 server. It allows for retrieving a subnet for the particular client using various parameters extracted from the DHCPv6 message. These parameters must be assigned to the appropriate members of the SubnetSelector
structure.
See CfgSubnets6::selectSubnet
documentation for more details on how the subnet is selected for the client.
Definition at line 34 of file cfg_subnets6.h.
void isc::dhcp::CfgSubnets6::add | ( | const Subnet6Ptr & | subnet | ) |
Adds new subnet to the configuration.
subnet | Pointer to the subnet being added. |
isc::DuplicateSubnetID | If the subnet id for the new subnet duplicates id of an existing subnet. |
Definition at line 29 of file cfg_subnets6.cc.
References isc::dhcp::DHCPSRV_CFGMGR_ADD_SUBNET6, isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, getByPrefix(), getBySubnetId(), isc_throw, and LOG_DEBUG.
void isc::dhcp::CfgSubnets6::clear | ( | ) |
Clears all subnets from the configuration.
Definition at line 568 of file cfg_subnets6.cc.
void isc::dhcp::CfgSubnets6::del | ( | const ConstSubnet6Ptr & | subnet | ) |
Removes subnet from the configuration.
subnet | Pointer to the subnet to be removed. |
isc::BadValue | if such subnet doesn't exist. |
Definition at line 68 of file cfg_subnets6.cc.
References del().
Referenced by del().
void isc::dhcp::CfgSubnets6::del | ( | const SubnetID & | subnet_id | ) |
Removes subnet from the configuration.
subnet_id | Identifier of the subnet to be removed. |
isc::BadValue | if such subnet doesn't exist. |
Definition at line 73 of file cfg_subnets6.cc.
References isc::dhcp::DHCPSRV_CFGMGR_DEL_SUBNET6, isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, isc_throw, and LOG_DEBUG.
|
inline |
Returns pointer to the collection of all IPv6 subnets.
This is used in a hook (subnet6_select), where the hook is able to choose a different subnet. Server code has to offer a list of possible choices (i.e. all subnets).
Definition at line 120 of file cfg_subnets6.h.
Referenced by merge().
ConstSubnet6Ptr isc::dhcp::CfgSubnets6::getByPrefix | ( | const std::string & | subnet_prefix | ) | const |
Returns const pointer to a subnet which matches the specified prefix in the canonical form.
The const pointer is returned by this method to prevent a caller from modifying the subnet configuration. Modifications to subnet configuration is dangerous and must be done carefully. The subnets' configuration is held in the multi index container and any modifications to the subnet id or subnet prefix must trigger re-indexing of multi index container. There is no possibility to enforce this when the non-const pointer is returned.
subnet_prefix | Subnet prefix, e.g. 2001:db8:1::/64 |
Subnet6
object or null pointer if such subnet doesn't exist. Definition at line 195 of file cfg_subnets6.cc.
Referenced by add().
|
inline |
Returns const pointer to a subnet identified by the specified subnet identifier.
The const pointer is returned by this method to prevent a caller from modifying the subnet configuration. Modifications to subnet configuration is dangerous and must be done carefully. The subnets' configuration is held in the multi index container and any modifications to the subnet id or subnet prefix must trigger re-indexing of multi index container. There is no possibility to enforce this when the non-const pointer is returned.
subnet_id | Subnet identifier. |
Subnet6
object or null pointer if such subnet doesn't exist. Definition at line 139 of file cfg_subnets6.h.
References getSubnet().
Referenced by add().
SubnetIDSet isc::dhcp::CfgSubnets6::getLinks | ( | const asiolink::IOAddress & | link_addr | ) | const |
Convert a link address into a link set.
Given a link address this returns the ordered list aka set of id of subnets the address belongs to.
link_addr | The link address. |
Definition at line 384 of file cfg_subnets6.cc.
Subnet6Ptr isc::dhcp::CfgSubnets6::getSubnet | ( | const SubnetID | id | ) | const |
Returns subnet with specified subnet-id value.
Please use getBySubnetId instead when possible.
Definition at line 377 of file cfg_subnets6.cc.
Referenced by getBySubnetId().
void isc::dhcp::CfgSubnets6::initAllocatorsAfterConfigure | ( | ) |
Calls initAllocatorsAfterConfigure
for each subnet.
Definition at line 561 of file cfg_subnets6.cc.
|
static |
Build selector from a client's message.
query | client's message. |
Definition at line 202 of file cfg_subnets6.cc.
References isc::dhcp::SubnetSelector::client_classes_, D6O_INTERFACE_ID, isc::dhcp::SubnetSelector::first_relay_linkaddr_, isc::dhcp::SubnetSelector::iface_name_, isc::dhcp::SubnetSelector::interface_id_, isc::dhcp::Pkt6::RELAY_GET_FIRST, and isc::dhcp::SubnetSelector::remote_address_.
Referenced by isc::dhcp::Dhcpv6Srv::selectSubnet().
void isc::dhcp::CfgSubnets6::merge | ( | CfgOptionDefPtr | cfg_def, |
CfgSharedNetworks6Ptr | networks, | ||
CfgSubnets6 & | other ) |
Merges specified subnet configuration into this configuration.
This method merges subnets from the other
configuration into this configuration. The general rule is that existing subnets are replaced by the subnets from other
. If there is no corresponding subnet in this configuration the subnet from other
configuration is inserted.
The complexity of the merge process stems from the associations between the subnets and shared networks. It is assumed that subnets in other
are the authority on their shared network assignments. It is also assumed that @ networks is the list of shared networks that should be used in making assignments. The general concept is that the overarching merge process will first merge shared networks and then pass that list of networks into this method. Subnets from other
are then merged into this configuration as follows:
For each subnet in other:
other
to this configuration.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.cfg_def | set of user-defined option definitions to use when creating option instances. |
networks | collection of shared networks that to which assignments should be added. In other words, the list of shared networks that belong to the same SrvConfig instance we are merging into. |
other | the subnet configuration to be merged into this configuration. |
Definition at line 90 of file cfg_subnets6.cc.
References getAll(), isc_throw, isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.
void isc::dhcp::CfgSubnets6::removeStatistics | ( | ) |
Removes statistics.
During commitment of a new configuration, we need to get rid of the old statistics for the old configuration. In particular, we need to remove anything related to subnets, as there may be fewer subnets in the new configuration and also subnet-ids may change.
Definition at line 396 of file cfg_subnets6.cc.
References isc::stats::StatsMgr::del(), isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.
Subnet6Ptr isc::dhcp::CfgSubnets6::replace | ( | const Subnet6Ptr & | subnet | ) |
Replaces subnet in the configuration.
This method replaces a subnet by another subnet with the same ID. The prefix should be the same too.
subnet | Pointer to the subnet being updated. |
BadValue | if the subnet to update does not exit. |
Definition at line 47 of file cfg_subnets6.cc.
References isc::dhcp::DHCPSRV_CFGMGR_UPDATE_SUBNET6, isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, isc_throw, and LOG_DEBUG.
ConstSubnet6Ptr isc::dhcp::CfgSubnets6::selectSubnet | ( | const asiolink::IOAddress & | address, |
const ClientClasses & | client_classes = ClientClasses(), | ||
const bool | is_relay_address = false ) const |
Selects the subnet using a specified address.
This method searches for the subnet using the specified address. If the specified address is a link address on the relay agent (which is indicated by the 3rd argument) the method will first try to match the specified address with the relay addresses explicitly specified for existing subnets. If no match is found, the method will check if the address is in range with any of the subnets.
If the address is not a relay agent link address (is_relay_address
is set to false), the method will simply check if the address is in range with any of the subnets.
selectSubnet(SubnetSelector)
should rather be used instead.address | Address for which the subnet is searched. |
client_classes | Optional parameter specifying the classes that the client belongs to. |
is_relay_address | Specifies if the provided address is an address of the relay agent (true) or not (false). |
Definition at line 266 of file cfg_subnets6.cc.
References isc::dhcp::DHCPSRV_CFGMGR_SUBNET6, isc::dhcp::DHCPSRV_CFGMGR_SUBNET6_RELAY, isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_SUBNET6_SELECT_BY_ADDRESS_NO_MATCH, LOG_DEBUG, and isc::asiolink::IOAddress::toText().
ConstSubnet6Ptr isc::dhcp::CfgSubnets6::selectSubnet | ( | const SubnetSelector & | selector | ) | const |
Selects a subnet using parameters specified in the selector.
This method tries to retrieve the subnet for the client using various parameters extracted from the client's message using the following logic.
If the relay agent link address is set to zero it is assumed that the subnet is selected for the directly connected client. In this case it is checked if there is any subnet associated with the interface over which the message has been received. If there is no subnet explicitly associated with this interface the client's address will be used to check if the address is in range with any of the subnets.
If the message was relayed it is possible that the relay agent has appended an Interface ID option. If this option is present, the method will check if it matches with any explicitly specified interface id for any subnet. If it does, the subnet is returned. Otherwise, the relay agents link address is used to select the subnet. In this case, the method will first check if this link address is explicitly associated with any subnet. If not, it is checked if the link address is in range with any of the subnets.
selector | Const reference to the selector structure which holds various information extracted from the client's packet which are used to find appropriate subnet. |
Definition at line 228 of file cfg_subnets6.cc.
References isc::dhcp::SubnetSelector::client_classes_, isc::dhcp::SubnetSelector::first_relay_linkaddr_, isc::dhcp::SubnetSelector::iface_name_, isc::dhcp::SubnetSelector::interface_id_, isc::dhcp::SubnetSelector::remote_address_, and selectSubnet().
Referenced by selectSubnet().
|
virtual |
Unparse a configuration object.
Implements isc::data::CfgToElement.
Definition at line 573 of file cfg_subnets6.cc.
References isc::data::Element::createList().
void isc::dhcp::CfgSubnets6::updateStatistics | ( | ) |
Updates statistics.
This method updates statistics that are affected by the newly committed configuration. In particular, it updates the number of available addresses and prefixes in each subnet. Other statistics may be added in the future. In general, these are statistics that are dependent only on configuration, so they are not expected to change until the next reconfiguration event.
Definition at line 477 of file cfg_subnets6.cc.
References isc::stats::StatsMgr::addValue(), isc::stats::StatsMgr::getObservation(), isc::dhcp::LeaseMgrFactory::instance(), isc::dhcp::LeaseMgr::recountLeaseStats6(), isc::stats::StatsMgr::setValue(), isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.