| Kea 3.0.2-git

isc::dhcp::Subnet Class Referenceabstract

`#include <subnet.h>`

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

## Public Member Functions
void | addPool (const PoolPtr &pool)
| Adds a new pool for the subnet.
virtual void | createAllocators ()=0
| Instantiates the allocators and their states.
virtual isc::asiolink::IOAddress | default_pool () const =0
| Returns the default address that will be used for pool selection.
void | delPools (Lease::Type type)
| Deletes all pools of specified type.
std::pair< isc::asiolink::IOAddress, uint8_t > | get () const
| Returns subnet parameters (prefix and prefix length).
SubnetAllocationStatePtr | getAllocationState (Lease::Type type) const
| Returns subnet-specific allocation state.
AllocatorPtr | getAllocator (Lease::Type type) const
| Returns lease allocator instance.
PoolPtr | getAnyPool (Lease::Type type)
| Returns a pool without any address specified.
SubnetID | getID () const
| Returns unique ID for that subnet.
const PoolPtr | getPool (Lease::Type type, const ClientClasses &client_classes, const isc::asiolink::IOAddress &addr) const
| Returns a pool that specified address belongs to with classes.
const PoolPtr | getPool (Lease::Type type, const isc::asiolink::IOAddress &addr, bool anypool=true) const
| Returns a pool that specified address belongs to.
isc::util::uint128_t | getPoolCapacity (Lease::Type type) const
| Returns the number of possible leases for specified lease type.
isc::util::uint128_t | getPoolCapacity (Lease::Type type, const ClientClasses &client_classes) const
| Returns the number of possible leases for specified lease type allowed for a client which belongs to classes.
isc::util::uint128_t | getPoolCapacity (Lease::Type type, const ClientClasses &client_classes, Allocator::PrefixLenMatchType prefix_length_match, uint8_t hint_prefix_length) const
| Returns the number of possible leases for specified lease type allowed for a client which belongs to classes and matching selection criteria relative to provided hint prefix length.
const PoolCollection & | getPools (Lease::Type type) const
| Returns all pools (const variant).
PoolCollection & | getPoolsWritable (Lease::Type type)
| Returns all pools (non-const variant).
template<typename SharedNetworkPtrType>
void | getSharedNetwork (SharedNetworkPtrType &shared_network) const
| Retrieves pointer to a shared network associated with a subnet.
std::string | getSharedNetworkName () const
| Returns shared network name.
void | initAllocatorsAfterConfigure ()
| Calls `initAfterConfigure` for each allocator.
bool | inPool (Lease::Type type, const isc::asiolink::IOAddress &addr) const
| checks if the specified address is in pools.
bool | inPool (Lease::Type type, const isc::asiolink::IOAddress &addr, const ClientClasses &client_classes) const
| checks if the specified address is in allowed pools.
bool | inRange (const isc::asiolink::IOAddress &addr) const
| checks if specified address is in range.
void | setAllocationState (Lease::Type type, const SubnetAllocationStatePtr &allocation_state)
| Sets subnet-specific allocation state.
void | setAllocator (Lease::Type type, const AllocatorPtr &allocator)
| Sets new allocator instance.
void | setSharedNetwork (const NetworkPtr &shared_network)
| Assigns shared network to a subnet.
void | setSharedNetworkName (const std::string &shared_network_name)
| Sets new shared network name.
virtual std::string | toText () const
| Returns textual representation of the subnet (e.g.
Public Member Functions inherited from isc::dhcp::Network
| Network ()
| Constructor.
virtual | ~Network ()
| Virtual destructor.
void | addAdditionalClass (const isc::dhcp::ClientClass &class_name)
| Adds class class_name to the additional classes list.
void | addRelayAddress (const asiolink::IOAddress &addr)
| Adds an address to the list addresses in the network's relay info.
void | allowClientClass (const isc::dhcp::ClientClass &class_name)
| Adds class clas_name to the allowed client classes list.
virtual bool | clientSupported (const isc::dhcp::ClientClasses &client_classes) const
| Checks whether this network supports a client that belongs to the specified classes.
const ClientClasses & | getAdditionalClasses () const
| Returns the additional classes list.
util::Optional< std::string > | getAllocatorType (const Inheritance &inheritance=Inheritance::ALL) const
| Returns allocator type.
util::Optional< uint32_t > | getCacheMaxAge (const Inheritance &inheritance=Inheritance::ALL) const
| Returns value in seconds to use as cache maximum age.
util::Optional< double > | getCacheThreshold (const Inheritance &inheritance=Inheritance::ALL) const
| Returns percentage to use as cache threshold.
util::Optional< bool > | getCalculateTeeTimes (const Inheritance &inheritance=Inheritance::ALL) const
| Returns whether or not T1/T2 calculation is enabled.
CfgOptionPtr | getCfgOption ()
| Returns pointer to the option data configuration for this network.
ConstCfgOptionPtr | getCfgOption () const
| Returns const pointer to the option data configuration for this network.
const ClientClasses & | getClientClasses () const
| Returns the list of allowed client classes.
util::Optional< std::string > | getDdnsConflictResolutionMode (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-conflict-resolution-mode.
util::Optional< std::string > | getDdnsGeneratedPrefix (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-generated-prefix.
util::Optional< bool > | getDdnsOverrideClientUpdate (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-override-client-update.
util::Optional< bool > | getDdnsOverrideNoUpdate (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-override-no-update.
util::Optional< std::string > | getDdnsQualifyingSuffix (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-qualifying-suffix.
util::Optional< D2ClientConfig::ReplaceClientNameMode > | getDdnsReplaceClientNameMode (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-replace-client-name-mode.
util::Optional< bool > | getDdnsSendUpdates (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-send-updates.
util::Optional< uint32_t > | getDdnsTtl (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-ttl.
util::Optional< uint32_t > | getDdnsTtlMax (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-ttl-max.
util::Optional< uint32_t > | getDdnsTtlMin (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-ttl-min.
util::Optional< double > | getDdnsTtlPercent (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-ttl-percent.
util::Optional< bool > | getDdnsUpdateOnRenew (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-update-on-renew.
util::Optional< std::string > | getDefaultAllocatorType (const Inheritance &inheritance=Inheritance::ALL) const
| Returns a default allocator type.
util::Optional< std::string > | getHostnameCharReplacement (const Inheritance &inheritance=Inheritance::ALL) const
| Return the invalid char replacement used to sanitize client hostnames.
util::Optional< std::string > | getHostnameCharSet (const Inheritance &inheritance=Inheritance::ALL) const
| Return the char set regexp used to sanitize client hostnames.
util::Optional< std::string > | getIface (const Inheritance &inheritance=Inheritance::ALL) const
| Returns name of the local interface for which this network is selected.
ClientClasses & | getMutableAdditionalClasses ()
| Returns the mutable additional classes list.
ClientClasses & | getMutableClientClasses ()
| Returns the mutable list of allowed client classes.
const IOAddressList & | getRelayAddresses () const
| Returns the list of relay addresses from the network's relay info.
const RelayInfo & | getRelayInfo () const
| Returns const reference to relay information.
util::Optional< bool > | getReservationsGlobal (const Inheritance &inheritance=Inheritance::ALL) const
| Returns whether global reservations should be fetched.
util::Optional< bool > | getReservationsInSubnet (const Inheritance &inheritance=Inheritance::ALL) const
| Returns whether subnet reservations should be fetched.
util::Optional< bool > | getReservationsOutOfPool (const Inheritance &inheritance=Inheritance::ALL) const
| Returns whether only out-of-pool reservations are allowed.
util::Optional< bool > | getStoreExtendedInfo (const Inheritance &inheritance=Inheritance::ALL) const
| Returns store-extended-info.
isc::util::Triplet< uint32_t > | getT1 (const Inheritance &inheritance=Inheritance::ALL) const
| Returns T1 (renew timer), expressed in seconds.
util::Optional< double > | getT1Percent (const Inheritance &inheritance=Inheritance::ALL) const
| Returns percentage to use when calculating the T1 (renew timer).
isc::util::Triplet< uint32_t > | getT2 (const Inheritance &inheritance=Inheritance::ALL) const
| Returns T2 (rebind timer), expressed in seconds.
util::Optional< double > | getT2Percent (const Inheritance &inheritance=Inheritance::ALL) const
| Returns percentage to use when calculating the T2 (rebind timer).
isc::util::Triplet< uint32_t > | getValid (const Inheritance &inheritance=Inheritance::ALL) const
| Return valid-lifetime for addresses in that prefix.
bool | hasFetchGlobalsFn () const
| Checks if the network is associated with a function used to fetch globally configured parameters.
bool | hasRelayAddress (const asiolink::IOAddress &address) const
| Tests if the network's relay info contains the given address.
bool | hasRelays () const
| Indicates if network's relay info has relay addresses.
void | setAllocatorType (const util::Optional< std::string > &allocator_type)
| Sets new allocator type.
void | setCacheMaxAge (const util::Optional< uint32_t > &cache_max_age)
| Sets cache max for a network.
void | setCacheThreshold (const util::Optional< double > &cache_threshold)
| Sets cache threshold for a network.
void | setCalculateTeeTimes (const util::Optional< bool > &calculate_tee_times)
| Sets whether or not T1/T2 calculation is enabled.
void | setDdnsConflictResolutionMode (const util::Optional< std::string > &ddns_conflict_resolution_mode)
| Sets new ddns-conflict-resolution-mode.
void | setDdnsGeneratedPrefix (const util::Optional< std::string > &ddns_generated_prefix)
| Sets new ddns-generated-prefix.
void | setDdnsOverrideClientUpdate (const util::Optional< bool > &ddns_override_client_update)
| Sets new ddns-override-client-update.
void | setDdnsOverrideNoUpdate (const util::Optional< bool > &ddns_override_no_update)
| Sets new ddns-override-no-update.
void | setDdnsQualifyingSuffix (const util::Optional< std::string > &ddns_qualifying_suffix)
| Sets new ddns-qualifying-suffix.
void | setDdnsReplaceClientNameMode (const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
| Sets new ddns-replace-client-name-mode.
void | setDdnsSendUpdates (const util::Optional< bool > &ddns_send_updates)
| Sets new ddns-send-updates.
void | setDdnsTtl (const util::Optional< uint32_t > &ddns_ttl)
| Sets new ddns-ttl.
void | setDdnsTtlMax (const util::Optional< uint32_t > &ddns_ttl_max)
| Sets new ddns-ttl-max.
void | setDdnsTtlMin (const util::Optional< uint32_t > &ddns_ttl_min)
| Sets new ddns-ttl-min.
void | setDdnsTtlPercent (const util::Optional< double > &ddns_ttl_percent)
| Sets new ddns-ttl-percent.
void | setDdnsUpdateOnRenew (const util::Optional< bool > &ddns_update_on_renew)
| Sets new ddns-update-on-renew.
void | setDefaultAllocatorType (const std::string &allocator_type)
| Sets a defalt allocator type.
void | setFetchGlobalsFn (FetchNetworkGlobalsFn fetch_globals_fn)
| Sets the optional callback function used to fetch globally configured parameters.
void | setHostnameCharReplacement (const util::Optional< std::string > &hostname_char_replacement)
| Sets new hostname-char-replacement.
void | setHostnameCharSet (const util::Optional< std::string > &hostname_char_set)
| Sets new hostname-char-set.
void | setIface (const util::Optional< std::string > &iface_name)
| Sets local name of the interface for which this network is selected.
void | setRelayInfo (const RelayInfo &relay)
| Sets information about relay.
void | setReservationsGlobal (const util::Optional< bool > &reservations_global)
| Sets whether global reservations should be fetched.
void | setReservationsInSubnet (const util::Optional< bool > &reservations_in_subnet)
| Sets whether subnet reservations should be fetched.
void | setReservationsOutOfPool (const util::Optional< bool > &reservations_out_of_pool)
| Sets whether only out-of-pool reservations are allowed.
void | setStoreExtendedInfo (const util::Optional< bool > &store_extended_info)
| Sets new store-extended-info.
void | setT1 (const isc::util::Triplet< uint32_t > &t1)
| Sets new renew timer for a network.
void | setT1Percent (const util::Optional< double > &t1_percent)
| Sets new percentage for calculating T1 (renew timer).
void | setT2 (const isc::util::Triplet< uint32_t > &t2)
| Sets new rebind timer for a network.
void | setT2Percent (const util::Optional< double > &t2_percent)
| Sets new percentage for calculating T2 (rebind timer).
void | setValid (const isc::util::Triplet< uint32_t > &valid)
| Sets new valid lifetime for a network.
Public Member Functions inherited from isc::data::StampedElement
| StampedElement ()
| Constructor.
void | delServerTag (const std::string &server_tag)
| Deletes server tag.
isc::data::ElementPtr | getMetadata () const
| Returns an object representing metadata to be returned with objects from the configuration backend.
std::set< ServerTag > | getServerTags () const
| Returns server tags.
bool | hasAllServerTag () const
| Checks if the element has 'all' server tag.
bool | hasServerTag (const ServerTag &server_tag) const
| Checks if the element has the given server tag.
void | setServerTag (const std::string &server_tag)
| Adds new server tag.
Public Member Functions inherited from isc::data::BaseStampedElement
| BaseStampedElement ()
| Constructor.
uint64_t | getId () const
| Returns element's database identifier.
boost::posix_time::ptime | getModificationTime () const
| Returns timestamp.
void | setId (const uint64_t id)
| Sets element's database identifier.
void | setModificationTime (const boost::posix_time::ptime &timestamp)
| Sets timestamp to the explicitly provided value.
void | updateModificationTime ()
| Sets timestamp to the current time.
Public Member Functions inherited from isc::data::UserContext
void | contextToElement (data::ElementPtr map) const
| Merge unparse a user_context object.
data::ConstElementPtr | getContext () const
| Returns const pointer to the user context.
void | setContext (const data::ConstElementPtr &ctx)
| Sets user context.
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor.

## Protected Member Functions
| Subnet (const isc::asiolink::IOAddress &prefix, uint8_t len, const SubnetID id)
| Protected constructor.
virtual | ~Subnet ()
| virtual destructor.
virtual void | checkType (Lease::Type type) const =0
| Checks if used pool type is valid.
virtual std::string | getLabel () const
| Generates an identifying label for logging.
bool | poolOverlaps (const Lease::Type &pool_type, const PoolPtr &pool) const
| Checks if the specified pool overlaps with an existing pool.
isc::util::uint128_t | sumPoolCapacity (const PoolCollection &pools) const
| Returns a sum of possible leases in all pools.
isc::util::uint128_t | sumPoolCapacity (const PoolCollection &pools, const ClientClasses &client_classes) const
| Returns a sum of possible leases in all pools allowing classes.
isc::util::uint128_t | sumPoolCapacity (const PoolCollection &pools, const ClientClasses &client_classes, Allocator::PrefixLenMatchType prefix_length_match, uint8_t hint_prefix_length) const
| Returns a sum of possible leases in all pools allowing classes and matching selection criteria relative to provided hint prefix length.
virtual data::ElementPtr | toElement () const
| Unparse a subnet object.
Protected Member Functions inherited from isc::dhcp::Network
FetchNetworkGlobalsFn | getFetchGlobalsFn () const
| Gets the optional callback function used to fetch globally configured parameters.
template<typename NumType>
isc::util::Triplet< NumType > | getGlobalProperty (isc::util::Triplet< NumType > property, const int global_index, const int min_index=-1, const int max_index=-1) const
| The `getGlobalProperty` specialization for isc::util::Triplet<T>.
template<typename ReturnType>
ReturnType | getGlobalProperty (ReturnType property, const int global_index, const int min_index=-1, const int max_index=-1) const
| Returns a value of global configuration parameter with a given index.
util::Optional< asiolink::IOAddress > | getGlobalProperty (util::Optional< asiolink::IOAddress > property, const int global_index, const int min_index=-1, const int max_index=-1) const
| The `getGlobalProperty` specialization for Optional<IOAddress>.
template<typename BaseType>
OptionPtr | getOptionProperty (OptionPtr(BaseType::*MethodPointer)(const Inheritance &inheritance) const, OptionPtr property, const Inheritance &inheritance) const
| Returns option pointer associated with a network using inheritance.
template<typename BaseType, typename ReturnType>
ReturnType | getProperty (ReturnType(BaseType::*MethodPointer)(const Inheritance &) const, ReturnType property, const Inheritance &inheritance, const int global_index=-1, const int min_index=-1, const int max_index=-1) const
| Returns a value associated with a network using inheritance.

## Static Protected Member Functions
static std::pair< asiolink::IOAddress, uint8_t > | parsePrefixCommon (const std::string &prefix)
| Converts subnet prefix to a pair of prefix/length pair.

## Protected Attributes
std::map< Lease::Type, SubnetAllocationStatePtr > | allocation_states_
| Holds subnet-specific allocation state.
std::map< Lease::Type, AllocatorPtr > | allocators_
| Lease allocators used by the subnet.
SubnetID | id_
| subnet-id
PoolCollection | pools_
| collection of IPv4 or non-temporary IPv6 pools in that subnet.
PoolCollection | pools_pd_
| collection of IPv6 prefix pools in that subnet.
PoolCollection | pools_ta_
| collection of IPv6 temporary address pools in that subnet.
isc::asiolink::IOAddress | prefix_
| a prefix of the subnet.
uint8_t | prefix_len_
| a prefix length of the subnet.
std::string | shared_network_name_
| Shared network name.
Protected Attributes inherited from isc::dhcp::Network
ClientClasses | additional_classes_
| Additional classes.
util::Optional< std::string > | allocator_type_
| Allocator used for IP address allocations.
util::Optional< uint32_t > | cache_max_age_
| Value in seconds to use as cache maximal age.
util::Optional< double > | cache_threshold_
| Percentage of the lease lifetime to use as cache threshold.
util::Optional< bool > | calculate_tee_times_
| Enables calculation of T1 and T2 timers.
CfgOptionPtr | cfg_option_
| Pointer to the option data configuration for this subnet.
ClientClasses | client_classes_
| List of client classes allowed to use this network.
util::Optional< std::string > | ddns_conflict_resolution_mode_
| DDNS conflict resolution mode.
util::Optional< std::string > | ddns_generated_prefix_
| Prefix Kea should use when generating domain-names.
util::Optional< bool > | ddns_override_client_update_
| Should Kea perform updates, even if client requested delegation.
util::Optional< bool > | ddns_override_no_update_
| Should Kea perform updates, even if client requested no updates.
util::Optional< std::string > | ddns_qualifying_suffix_
| Suffix Kea should use when to qualify partial domain-names.
util::Optional< D2ClientConfig::ReplaceClientNameMode > | ddns_replace_client_name_mode_
| How Kea should handle the domain-name supplied by the client.
util::Optional< bool > | ddns_send_updates_
| Should Kea perform DNS updates.
util::Optional< uint32_t > | ddns_ttl_
| Explicit value to use for DNS TTL.
util::Optional< uint32_t > | ddns_ttl_max_
| Maximum value to use for DNS TTL.
util::Optional< uint32_t > | ddns_ttl_min_
| Minimum value to use for DNS TTL.
util::Optional< double > | ddns_ttl_percent_
| Percentage of the lease lifetime to use for DNS TTL.
util::Optional< bool > | ddns_update_on_renew_
| Should Kea perform updates when leases are extended.
util::Optional< std::string > | default_allocator_type_
| Default allocator type.
FetchNetworkGlobalsFn | fetch_globals_fn_
| Pointer to the optional callback used to fetch globally configured parameters inherited to the `Network` object.
util::Optional< std::string > | hostname_char_replacement_
| A string to replace invalid characters when scrubbing hostnames.
util::Optional< std::string > | hostname_char_set_
| Regular expression describing invalid characters for client hostnames.
util::Optional< std::string > | iface_name_
| Holds interface name for which this network is selected.
WeakNetworkPtr | parent_network_
| Pointer to another network that this network belongs to.
RelayInfo | relay_
| Relay information.
util::Optional< bool > | reservations_global_
| Enables global reservations.
util::Optional< bool > | reservations_in_subnet_
| Enables subnet reservations.
util::Optional< bool > | reservations_out_of_pool_
| Enables out-of-pool reservations optimization.
util::Optional< bool > | store_extended_info_
| Should Kea store additional client query data (e.g.
isc::util::Triplet< uint32_t > | t1_
| a isc::util::Triplet (min/default/max) holding allowed renew timer values
util::Optional< double > | t1_percent_
| Percentage of the lease lifetime to use when calculating T1 timer.
isc::util::Triplet< uint32_t > | t2_
| a isc::util::Triplet (min/default/max) holding allowed rebind timer values
util::Optional< double > | t2_percent_
| Percentage of the lease lifetime to use when calculating T2 timer.
isc::util::Triplet< uint32_t > | valid_
| a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Protected Attributes inherited from isc::data::BaseStampedElement
uint64_t | id_
| Database identifier of the configuration element.
boost::posix_time::ptime | timestamp_
| Holds timestamp value.
Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr | user_context_
| Pointer to the user context (may be NULL).

## Additional Inherited Members
Public Types inherited from isc::dhcp::Network
enum class | Inheritance { NONE , PARENT_NETWORK , GLOBAL , ALL }
| Inheritance "mode" used when fetching an optional `Network` parameter. More...
typedef boost::shared_ptr< Network::RelayInfo > | RelayInfoPtr
| Pointer to the RelayInfo structure.
Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr | toElement (data::ConstElementPtr map)
| Copy an Element map.

## Detailed Description

Definition at line 41 of file subnet.h.

## Constructor & Destructor Documentation

## ◆ Subnet()

isc::dhcp::Subnet::Subnet | ( | const isc::asiolink::IOAddress & | prefix,
|  | uint8_t | len,
|  | const SubnetID | id )
| protected

Protected constructor.

By making the constructor protected, we make sure that no one will ever instantiate that class. Subnet4 and Subnet6 should be used instead.

Parameters

  prefix | subnet prefix
  len | prefix length for the subnet
  id | arbitrary subnet id between 0 and 2^32-1 excluded.

Definition at line 68 of file subnet.cc.

References id_, isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV6(), prefix_, prefix_len_, and shared_network_name_.

Referenced by isc::dhcp::Subnet4::Subnet4(), and isc::dhcp::Subnet6::Subnet6().

Here is the call graph for this function:

## ◆ ~Subnet()

virtual isc::dhcp::Subnet::~Subnet | ( |  | ) |
| inline protected virtual

virtual destructor.

A virtual destructor is needed because other classes derive from this class.

Definition at line 342 of file subnet.h.

## Member Function Documentation

## ◆ addPool()

void isc::dhcp::Subnet::addPool | ( | const PoolPtr & | pool | ) |

Adds a new pool for the subnet.

This method checks that the address range represented by the pool matches the subnet prefix, if the pool type is different than IA_PD. The prefixes from the IA_PD pools don't need to match the prefix from the subnet from which they are handed out to the requesting router because the requesting router may use the delegated prefixes in different networks (using different subnets).

A DHCPv4 pool being added must not overlap with any existing DHCPv4 pool. A DHCPv6 pool being added must not overlap with any existing DHCPv6 pool.

Pools held within a subnet are sorted by first pool address/prefix from the lowest to the highest.

Parameters

  pool | pool to be added

Exceptions

  isc::BadValue | if the pool type is invalid, in the case of address pools if the address range of the pool does not match the subnet prefix, or if the pool overlaps with an existing pool within the subnet.

Definition at line 472 of file subnet.cc.

References checkType(), getPoolsWritable(), inRange(), isc_throw, poolOverlaps(), prefix_, prefix_len_, isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, isc::dhcp::Lease::TYPE_TA, isc::dhcp::Lease::TYPE_V4, and isc::dhcp::Lease::typeToText().

Here is the call graph for this function:

## ◆ checkType()

virtual void isc::dhcp::Subnet::checkType | ( | Lease::Type | type | ) | const
| protected pure virtual

Checks if used pool type is valid.

Allowed type for Subnet4 is Pool::TYPE_V4. Allowed types for Subnet6 are Pool::TYPE_{IA,TA,PD}. This method is implemented in derived classes.

Parameters

  type | type to be checked

Exceptions

  BadValue | if invalid value is used

Referenced by addPool(), getPool(), getPool(), getPools(), and getPoolsWritable().

## ◆ createAllocators()

virtual void isc::dhcp::Subnet::createAllocators | ( |  | ) |
| pure virtual

Instantiates the allocators and their states.

It determines the types of the allocators to create using the list of the allocator types specified with the `Network::setAllocatorType` method.

This function is called from the subnet parsers and after fetching the subnet configuration from a configuration backend.

Implemented in isc::dhcp::Subnet4, and isc::dhcp::Subnet6.

## ◆ default_pool()

virtual isc::asiolink::IOAddress isc::dhcp::Subnet::default_pool | ( |  | ) | const
| pure virtual

Returns the default address that will be used for pool selection.

It must be implemented in derived classes (should return :: for Subnet6 and 0.0.0.0 for Subnet4).

Referenced by getAnyPool().

## ◆ delPools()

void isc::dhcp::Subnet::delPools | ( | Lease::Type | type | ) |

Deletes all pools of specified type.

This method is used for testing purposes only

Parameters

  type | type of pools to be deleted

Definition at line 527 of file subnet.cc.

References getPoolsWritable().

Here is the call graph for this function:

## ◆ get()

std::pair< isc::asiolink::IOAddress, uint8_t > isc::dhcp::Subnet::get | ( |  | ) | const
| inline

Returns subnet parameters (prefix and prefix length).

Returns
  (prefix, prefix length) pair

Definition at line 90 of file subnet.h.

References prefix_, and prefix_len_.

## ◆ getAllocationState()

SubnetAllocationStatePtr isc::dhcp::Subnet::getAllocationState | ( | Lease::Type | type | ) | const

Returns subnet-specific allocation state.

The actual type of the state depends on the allocator type.

Parameters

  type | lease type for which the allocation state is returned.

Returns
  allocation state.

Definition at line 382 of file subnet.cc.

References allocation_states_, isc_throw, and isc::dhcp::Lease::typeToText().

Here is the call graph for this function:

## ◆ getAllocator()

AllocatorPtr isc::dhcp::Subnet::getAllocator | ( | Lease::Type | type | ) | const

Returns lease allocator instance.

An allocator is responsible for selecting leases from the subnet's pools. Each subnet has one allocator common for all pools belonging to the subnet. The allocation engine uses this function to get the current subnet allocator and uses it to select and offer an address.

Parameters

  type | lease type for which the allocator instance should be returned.

Returns
  Allocator instance.

Definition at line 366 of file subnet.cc.

References allocators_, isc_throw, and isc::dhcp::Lease::typeToText().

Here is the call graph for this function:

## ◆ getAnyPool()

PoolPtr isc::dhcp::Subnet::getAnyPool | ( | Lease::Type | type | ) |
| inline

Returns a pool without any address specified.

Parameters

  type | pool type that the pool is looked for

Returns
  returns one of the pools defined

Definition at line 160 of file subnet.h.

References default_pool(), and getPool().

Here is the call graph for this function:

## ◆ getID()

SubnetID isc::dhcp::Subnet::getID | ( |  | ) | const
| inline

Returns unique ID for that subnet.

Returns
  unique ID for that subnet

Definition at line 83 of file subnet.h.

References id_.

Referenced by isc::dhcp::Subnet4::getNextSubnet(), isc::dhcp::Subnet4::getNextSubnet(), isc::dhcp::Subnet6::getNextSubnet(), isc::dhcp::Subnet6::getNextSubnet(), isc::subnet_cmds::SubnetCmdsImpl::subnetToElement(), and toElement().

## ◆ getLabel()

virtual std::string isc::dhcp::Subnet::getLabel | ( |  | ) | const
| inline protected virtual

Generates an identifying label for logging.

Returns
  string containing the label

Reimplemented from isc::dhcp::Network.

Definition at line 400 of file subnet.h.

References id_.

## ◆ getPool() [1/2]

const PoolPtr isc::dhcp::Subnet::getPool | ( | Lease::Type | type,
|  | const ClientClasses & | client_classes,
|  | const isc::asiolink::IOAddress & | addr ) const

Returns a pool that specified address belongs to with classes.

Variant using only pools allowing given classes.

Parameters

  type | pool type that the pool is looked for
  client_classes | client class list which must be allowed
  addr | address that the returned pool should cover (optional)

Definition at line 443 of file subnet.cc.

References checkType(), and getPools().

Here is the call graph for this function:

## ◆ getPool() [2/2]

const PoolPtr isc::dhcp::Subnet::getPool | ( | Lease::Type | type,
|  | const isc::asiolink::IOAddress & | addr,
|  | bool | anypool = true ) const

Returns a pool that specified address belongs to.

This method uses binary search to retrieve the pool. Thus, the number of comparisons performed by this method is logarithmic in the number of pools belonging to a subnet.

If there is no pool that the address belongs to (hint is invalid), other pool of specified type will be returned.

With anypool set to true, this means give me a pool, preferably the one that addr belongs to. With anypool set to false, it means give me a pool that addr belongs to (or null if here is no such pool)

Parameters

  type | pool type that the pool is looked for
  addr | address that the returned pool should cover (optional)
  anypool | other pool may be returned as well, not only the one that addr belongs to

Returns
  found pool (or null)

Definition at line 397 of file subnet.cc.

References checkType(), and getPools().

Referenced by getAnyPool().

Here is the call graph for this function:

## ◆ getPoolCapacity() [1/3]

uint128_t isc::dhcp::Subnet::getPoolCapacity | ( | Lease::Type | type | ) | const

Returns the number of possible leases for specified lease type.

Parameters

  type | type of the lease

Definition at line 97 of file subnet.cc.

References isc_throw, pools_, pools_pd_, pools_ta_, sumPoolCapacity(), isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, isc::dhcp::Lease::TYPE_TA, and isc::dhcp::Lease::TYPE_V4.

Here is the call graph for this function:

## ◆ getPoolCapacity() [2/3]

uint128_t isc::dhcp::Subnet::getPoolCapacity | ( | Lease::Type | type,
|  | const ClientClasses & | client_classes ) const

Returns the number of possible leases for specified lease type allowed for a client which belongs to classes.

Parameters

  type | type of the lease
  client_classes | list of classes the client belongs to

Returns
  number of leases matching lease type and classes

Definition at line 113 of file subnet.cc.

References isc_throw, pools_, pools_pd_, pools_ta_, sumPoolCapacity(), isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, isc::dhcp::Lease::TYPE_TA, and isc::dhcp::Lease::TYPE_V4.

Here is the call graph for this function:

## ◆ getPoolCapacity() [3/3]

uint128_t isc::dhcp::Subnet::getPoolCapacity | ( | Lease::Type | type,
|  | const ClientClasses & | client_classes,
|  | Allocator::PrefixLenMatchType | prefix_length_match,
|  | uint8_t | hint_prefix_length ) const

Returns the number of possible leases for specified lease type allowed for a client which belongs to classes and matching selection criteria relative to provided hint prefix length.

Parameters

  type | type of the lease
  client_classes | list of classes the client belongs to
  prefix_length_match | type which indicates the selection criteria for the pools relative to the provided hint prefix length
  hint_prefix_length | the hint prefix length that the client provided

Returns
  number of leases matching lease type and classes

Definition at line 130 of file subnet.cc.

References isc_throw, pools_, pools_pd_, pools_ta_, sumPoolCapacity(), isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, isc::dhcp::Lease::TYPE_TA, and isc::dhcp::Lease::TYPE_V4.

Here is the call graph for this function:

## ◆ getPools()

const PoolCollection & isc::dhcp::Subnet::getPools | ( | Lease::Type | type | ) | const

Returns all pools (const variant).

The reference is only valid as long as the object that returned it.

Parameters

  type | lease type to be set

Returns
  a collection of all pools

Definition at line 329 of file subnet.cc.

References checkType(), isc_throw, pools_, pools_pd_, pools_ta_, isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, isc::dhcp::Lease::TYPE_TA, and isc::dhcp::Lease::TYPE_V4.

Referenced by getPool(), getPool(), inPool(), inPool(), poolOverlaps(), isc::dhcp::Subnet4::toElement(), and isc::dhcp::Subnet6::toElement().

Here is the call graph for this function:

## ◆ getPoolsWritable()

PoolCollection & isc::dhcp::Subnet::getPoolsWritable | ( | Lease::Type | type | ) |

Returns all pools (non-const variant).

The reference is only valid as long as the object that returned it.

Parameters

  type | lease type to be set

Returns
  a collection of all pools

Definition at line 347 of file subnet.cc.

References checkType(), isc_throw, pools_, pools_pd_, pools_ta_, isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, isc::dhcp::Lease::TYPE_TA, and isc::dhcp::Lease::TYPE_V4.

Referenced by addPool(), and delPools().

Here is the call graph for this function:

## ◆ getSharedNetwork()

template<typename SharedNetworkPtrType>

void isc::dhcp::Subnet::getSharedNetwork | ( | SharedNetworkPtrType & | shared_network | ) | const
| inline

Retrieves pointer to a shared network associated with a subnet.

By implementing it as a template function we overcome a need to include shared_network.h header file to specify return type explicitly. The header can't be included because it would cause circular dependency between subnet.h and shared_network.h.

This method uses an argument to hold a return value to allow the compiler to infer the return type without a need to call this function with an explicit return type as template argument.

Parameters

  [out] | shared_network | Pointer to the shared network where returned value should be assigned.

Template Parameters

  Type | of the shared network, i.e. SharedNetwork4 or a SharedNetwork6.

Definition at line 231 of file subnet.h.

References isc::dhcp::Network::parent_network_.

Referenced by isc::dhcp::Subnet4::clientSupported(), isc::dhcp::Subnet6::clientSupported(), isc::dhcp::Subnet4::getNextSubnet(), isc::dhcp::Subnet4::getNextSubnet(), isc::dhcp::Subnet6::getNextSubnet(), and isc::dhcp::Subnet6::getNextSubnet().

## ◆ getSharedNetworkName()

std::string isc::dhcp::Subnet::getSharedNetworkName | ( |  | ) | const
| inline

Returns shared network name.

Returns
  shared network name

Definition at line 250 of file subnet.h.

References shared_network_name_.

Referenced by isc::subnet_cmds::SubnetCmdsImpl::subnetToElement().

## ◆ initAllocatorsAfterConfigure()

void isc::dhcp::Subnet::initAllocatorsAfterConfigure | ( |  | ) |

Calls `initAfterConfigure` for each allocator.

Definition at line 437 of file subnet.cc.

References allocators_.

## ◆ inPool() [1/2]

bool isc::dhcp::Subnet::inPool | ( | Lease::Type | type,
|  | const isc::asiolink::IOAddress & | addr ) const

checks if the specified address is in pools.

Note the difference between inRange() and inPool() for addresses (i.e. not prefixes). For a given subnet (e.g. 2001::/64) there may be one or more pools defined that may or may not cover entire subnet, e.g. pool 2001::1-2001::10). inPool() returning true implies inRange(), but the reverse implication is not always true. For the given example, 2001::1234:abcd would return true for inRange(), but false for inPool() check.

Parameters

  type | type of pools to iterate over
  addr | this address will be checked if it belongs to any pools in that subnet

Returns
  true if the address is in any of the pools

Definition at line 532 of file subnet.cc.

References getPools(), inRange(), and isc::dhcp::Lease::TYPE_PD.

Here is the call graph for this function:

## ◆ inPool() [2/2]

bool isc::dhcp::Subnet::inPool | ( | Lease::Type | type,
|  | const isc::asiolink::IOAddress & | addr,
|  | const ClientClasses & | client_classes ) const

checks if the specified address is in allowed pools.

This takes also into account client classes

Parameters

  type | type of pools to iterate over
  addr | this address will be checked if it belongs to any pools in that subnet
  client_classes | client class list which must be allowed

Returns
  true if the address is in any of the allowed pools

Definition at line 550 of file subnet.cc.

References getPools(), inRange(), and isc::dhcp::Lease::TYPE_PD.

Here is the call graph for this function:

## ◆ inRange()

bool isc::dhcp::Subnet::inRange | ( | const isc::asiolink::IOAddress & | addr | ) | const

checks if specified address is in range.

Parameters

  addr | this address will be checked if it is included in a specific range

Returns
  true if address is in range, false otherwise

Definition at line 82 of file subnet.cc.

References isc::asiolink::firstAddrInPrefix(), isc::asiolink::lastAddrInPrefix(), prefix_, and prefix_len_.

Referenced by addPool(), inPool(), and inPool().

Here is the call graph for this function:

## ◆ parsePrefixCommon()

std::pair< IOAddress, uint8_t > isc::dhcp::Subnet::parsePrefixCommon | ( | const std::string & | prefix | ) |
| static protected

Converts subnet prefix to a pair of prefix/length pair.

IPv4 and IPv6 specific conversion functions should apply extra checks on the returned values, i.e. whether length is in range and the IP address has a valid type.

Parameters

  prefix | Prefix to be parsed.

Exceptions

  BadValue | if provided prefix is not valid.

Definition at line 221 of file subnet.cc.

References isc_throw.

Referenced by isc::dhcp::Subnet4::parsePrefix(), and isc::dhcp::Subnet6::parsePrefix().

## ◆ poolOverlaps()

bool isc::dhcp::Subnet::poolOverlaps | ( | const Lease::Type & | pool_type,
|  | const PoolPtr & | pool ) const
| protected

Checks if the specified pool overlaps with an existing pool.

Parameters

  pool_type | Pool type.
  pool | Pointer to a pool for which the method should check if it overlaps with any existing pool within this subnet.

Returns
  true if pool overlaps with an existing pool of a specified type, false otherwise

Definition at line 573 of file subnet.cc.

References getPools().

Referenced by addPool().

Here is the call graph for this function:

## ◆ setAllocationState()

void isc::dhcp::Subnet::setAllocationState | ( | Lease::Type | type,
|  | const SubnetAllocationStatePtr & | allocation_state )

Sets subnet-specific allocation state.

Parameters

  type | lease type for which the allocation state is set.
  allocation_state | allocation state instance.

Definition at line 393 of file subnet.cc.

References allocation_states_.

Referenced by isc::dhcp::Subnet4::createAllocators(), and isc::dhcp::Subnet6::createAllocators().

## ◆ setAllocator()

void isc::dhcp::Subnet::setAllocator | ( | Lease::Type | type,
|  | const AllocatorPtr & | allocator )

Sets new allocator instance.

If the server is configured to use a different allocator for the subnet, it can set the current allocator with this function.

Parameters

  type | lease type for which the allocator is set.
  allocator | new allocator instance.

Definition at line 377 of file subnet.cc.

References allocators_.

Referenced by isc::dhcp::Subnet4::createAllocators(), and isc::dhcp::Subnet6::createAllocators().

## ◆ setSharedNetwork()

void isc::dhcp::Subnet::setSharedNetwork | ( | const NetworkPtr & | shared_network | ) |
| inline

Assigns shared network to a subnet.

This method replaces any shared network associated with a subnet with a new shared network.

Parameters

  shared_network | Pointer to a new shared network to be associated with the subnet.

Definition at line 243 of file subnet.h.

References isc::dhcp::Network::parent_network_.

## ◆ setSharedNetworkName()

void isc::dhcp::Subnet::setSharedNetworkName | ( | const std::string & | shared_network_name | ) |
| inline

Sets new shared network name.

In certain cases the subnet must be associated with the shared network but the shared network object is not available. In particular, subnets are returned from the configuration database with only names of the shared networks. The actual shared networks must be fetched from the database using a separate query. In order to not loose associations of subnets with shared networks, the configuration backends will use this method to store the shared network names. The servers will later use those names to associate subnets with shared network instances.

Parameters

  shared_network_name | New shared network name.

Definition at line 266 of file subnet.h.

References shared_network_name_.

## ◆ sumPoolCapacity() [1/3]

uint128_t isc::dhcp::Subnet::sumPoolCapacity | ( | const PoolCollection & | pools | ) | const
| protected

Returns a sum of possible leases in all pools.

Parameters

  pools | list of pools

Returns
  sum of possible leases

Definition at line 150 of file subnet.cc.

Referenced by getPoolCapacity(), getPoolCapacity(), and getPoolCapacity().

## ◆ sumPoolCapacity() [2/3]

uint128_t isc::dhcp::Subnet::sumPoolCapacity | ( | const PoolCollection & | pools,
|  | const ClientClasses & | client_classes ) const
| protected

Returns a sum of possible leases in all pools allowing classes.

Parameters

  pools | list of pools
  client_classes | list of classes

Returns
  sum of possible/allowed leases

Definition at line 168 of file subnet.cc.

## ◆ sumPoolCapacity() [3/3]

uint128_t isc::dhcp::Subnet::sumPoolCapacity | ( | const PoolCollection & | pools,
|  | const ClientClasses & | client_classes,
|  | Allocator::PrefixLenMatchType | prefix_length_match,
|  | uint8_t | hint_prefix_length ) const
| protected

Returns a sum of possible leases in all pools allowing classes and matching selection criteria relative to provided hint prefix length.

Note
  This function should be called only for PD pools.

Parameters

  pools | list of pools
  client_classes | list of classes
  prefix_length_match | type which indicates the selection criteria for the pools relative to the provided hint prefix length
  hint_prefix_length | the hint prefix length that the client provided

Returns
  sum of possible/allowed leases

Definition at line 191 of file subnet.cc.

References isc::dhcp::Allocator::isValidPrefixPool().

Here is the call graph for this function:

## ◆ toElement()

data::ElementPtr isc::dhcp::Subnet::toElement | ( |  | ) | const
| protected virtual

Unparse a subnet object.

Returns
  A pointer to unparsed subnet configuration.

Reimplemented from isc::dhcp::Network.

Reimplemented in isc::dhcp::Subnet4, and isc::dhcp::Subnet6.

Definition at line 738 of file subnet.cc.

References isc::data::UserContext::contextToElement(), isc::data::Element::create(), isc::data::Element::createMap(), getID(), and toText().

Referenced by isc::dhcp::Subnet4::toElement(), and isc::dhcp::Subnet6::toElement().

Here is the call graph for this function:

## ◆ toText()

std::string isc::dhcp::Subnet::toText | ( |  | ) | const
| virtual

Returns textual representation of the subnet (e.g.

"2001:db8::/64").

Returns
  textual representation

Definition at line 90 of file subnet.cc.

References prefix_, and prefix_len_.

Referenced by isc::subnet_cmds::SubnetCmdsImpl::subnetToElement(), and toElement().

## Member Data Documentation

## ◆ allocation_states_

std::map<Lease::Type, SubnetAllocationStatePtr> isc::dhcp::Subnet::allocation_states_
| protected

Holds subnet-specific allocation state.

Definition at line 445 of file subnet.h.

Referenced by getAllocationState(), and setAllocationState().

## ◆ allocators_

std::map<Lease::Type, AllocatorPtr> isc::dhcp::Subnet::allocators_
| protected

Lease allocators used by the subnet.

Definition at line 442 of file subnet.h.

Referenced by getAllocator(), initAllocatorsAfterConfigure(), and setAllocator().

## ◆ id_

SubnetID isc::dhcp::Subnet::id_
| protected

subnet-id

Subnet-id is a unique value that can be used to find or identify a Subnet4 or Subnet6.

Definition at line 421 of file subnet.h.

Referenced by Subnet(), getID(), and getLabel().

## ◆ pools_

PoolCollection isc::dhcp::Subnet::pools_
| protected

collection of IPv4 or non-temporary IPv6 pools in that subnet.

Definition at line 424 of file subnet.h.

Referenced by isc::dhcp::Subnet4::createAllocators(), isc::dhcp::Subnet6::createAllocators(), getPoolCapacity(), getPoolCapacity(), getPoolCapacity(), getPools(), and getPoolsWritable().

## ◆ pools_pd_

PoolCollection isc::dhcp::Subnet::pools_pd_
| protected

collection of IPv6 prefix pools in that subnet.

Definition at line 430 of file subnet.h.

Referenced by isc::dhcp::Subnet6::createAllocators(), getPoolCapacity(), getPoolCapacity(), getPoolCapacity(), getPools(), and getPoolsWritable().

## ◆ pools_ta_

PoolCollection isc::dhcp::Subnet::pools_ta_
| protected

collection of IPv6 temporary address pools in that subnet.

Definition at line 427 of file subnet.h.

Referenced by isc::dhcp::Subnet6::createAllocators(), getPoolCapacity(), getPoolCapacity(), getPoolCapacity(), getPools(), and getPoolsWritable().

## ◆ prefix_

isc::asiolink::IOAddress isc::dhcp::Subnet::prefix_
| protected

a prefix of the subnet.

Definition at line 433 of file subnet.h.

Referenced by Subnet(), addPool(), get(), inRange(), and toText().

## ◆ prefix_len_

uint8_t isc::dhcp::Subnet::prefix_len_
| protected

a prefix length of the subnet.

Definition at line 436 of file subnet.h.

Referenced by Subnet(), addPool(), get(), inRange(), and toText().

## ◆ shared_network_name_

std::string isc::dhcp::Subnet::shared_network_name_
| protected

Shared network name.

Definition at line 439 of file subnet.h.

Referenced by Subnet(), getSharedNetworkName(), and setSharedNetworkName().

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

- subnet.h
- subnet.cc