Kea  2.3.5-git
isc::dhcp::Subnet Class Referenceabstract

#include <subnet.h>

+ Inheritance diagram for isc::dhcp::Subnet:

Public Member Functions

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

Static Public Member Functions

static void resetSubnetID ()
 Resets subnet-id counter to its initial value (1). More...
 
- Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr toElement (data::ConstElementPtr map)
 Copy an Element map. More...
 

Protected Member Functions

 Subnet (const isc::asiolink::IOAddress &prefix, uint8_t len, const SubnetID id)
 Protected constructor. More...
 
virtual ~Subnet ()
 virtual destructor. More...
 
virtual void checkType (Lease::Type type) const =0
 Checks if used pool type is valid. More...
 
bool poolOverlaps (const Lease::Type &pool_type, const PoolPtr &pool) const
 Checks if the specified pool overlaps with an existing pool. More...
 
uint64_t sumPoolCapacity (const PoolCollection &pools) const
 Returns a sum of possible leases in all pools. More...
 
uint64_t sumPoolCapacity (const PoolCollection &pools, const ClientClasses &client_classes) const
 Returns a sum of possible leases in all pools allowing classes. More...
 
uint64_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. More...
 
virtual data::ElementPtr toElement () const
 Unparse a subnet object. More...
 
- Protected Member Functions inherited from isc::dhcp::Network
FetchNetworkGlobalsFn getFetchGlobalsFn () const
 Gets the optional callback function used to fetch globally configured parameters. More...
 
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. More...
 
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>. More...
 
util::Optional< asiolink::IOAddressgetGlobalProperty (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>. More...
 
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. More...
 
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. More...
 

Static Protected Member Functions

static SubnetID generateNextID ()
 returns the next unique Subnet-ID. More...
 
static std::pair< asiolink::IOAddress, uint8_t > parsePrefixCommon (const std::string &prefix)
 Converts subnet prefix to a pair of prefix/length pair. More...
 

Protected Attributes

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

Static Protected Attributes

static SubnetID static_id_ = 1
 keeps the subnet-id value. More...
 

Additional Inherited Members

- Public Types inherited from isc::dhcp::Network
enum  Inheritance { Inheritance::NONE, Inheritance::PARENT_NETWORK, Inheritance::GLOBAL, Inheritance::ALL }
 Inheritance "mode" used when fetching an optional Network parameter. More...
 
typedef boost::shared_ptr< Network::RelayInfoRelayInfoPtr
 Pointer to the RelayInfo structure. More...
 

Detailed Description

Definition at line 40 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.

This constructor assigns a new subnet-id (see generateNextID). This subnet-id has unique value that is strictly monotonously increasing for each subnet, until it is explicitly reset back to 1 during reconfiguration process.

Parameters
prefixsubnet prefix
lenprefix length for the subnet
idarbitrary subnet id, value of 0 triggers autogeneration of subnet id

Definition at line 60 of file subnet.cc.

References isc_throw, isc::asiolink::IOAddress::isV4(), and isc::asiolink::IOAddress::isV6().

Referenced by setSharedNetworkName().

+ Here is the call graph for this function:

◆ ~Subnet()

virtual isc::dhcp::Subnet::~Subnet ( )
inlineprotectedvirtual

virtual destructor.

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

Definition at line 342 of file subnet.h.

References static_id_.

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
poolpool to be added
Exceptions
isc::BadValueif 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 455 of file subnet.cc.

References 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().

Referenced by get().

+ Here is the call graph for this function:

◆ checkType()

virtual void isc::dhcp::Subnet::checkType ( Lease::Type  type) const
protectedpure 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
typetype to be checked
Exceptions
BadValueif invalid value is used

Referenced by generateNextID(), and isc::dhcp::Subnet4::get4o6().

◆ 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 isc::dhcp::Subnet4::get4o6(), and 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
typetype of pools to be deleted

Definition at line 510 of file subnet.cc.

References getPoolsWritable().

Referenced by get().

+ Here is the call graph for this function:

◆ generateNextID()

static SubnetID isc::dhcp::Subnet::generateNextID ( )
inlinestaticprotected

returns the next unique Subnet-ID.

This method generates and returns the next unique subnet-id. It is a strictly monotonously increasing value (1,2,3,...) for each new Subnet object created. It can be explicitly reset back to 1 during reconfiguration (resetSubnetID).

Returns
the next unique Subnet-ID

Definition at line 361 of file subnet.h.

References checkType(), parsePrefixCommon(), poolOverlaps(), resetSubnetID(), sumPoolCapacity(), and toElement().

+ 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 87 of file subnet.h.

References addPool(), delPools(), getPool(), prefix_, and prefix_len_.

+ Here is the call graph for this function:

◆ 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
typelease type for which the allocation state is returned.
Returns
allocation state.

Definition at line 372 of file subnet.cc.

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

Referenced by setSharedNetworkName().

+ 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
typelease type for which the allocator instance should be returned.
Returns
Allocator instance.

Definition at line 356 of file subnet.cc.

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

Referenced by setSharedNetworkName().

+ 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
typepool type that the pool is looked for
Returns
returns one of the pools defined

Definition at line 157 of file subnet.h.

References default_pool(), getPool(), getPoolCapacity(), getPools(), and toText().

+ 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 82 of file subnet.h.

References id_.

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

◆ getPool() [1/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 is 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
typepool type that the pool is looked for
addraddress that the returned pool should cover (optional)
anypoolother pool may be returned as well, not only the one that addr belongs to
Returns
found pool (or NULL)

Definition at line 387 of file subnet.cc.

References getPools().

Referenced by get(), and getAnyPool().

+ Here is the call graph for this function:

◆ getPool() [2/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
typepool type that the pool is looked for
client_classesclient class list which must be allowed
addraddress that the returned pool should cover (optional)

Definition at line 426 of file subnet.cc.

References getPools().

+ Here is the call graph for this function:

◆ getPoolCapacity() [1/3]

uint64_t isc::dhcp::Subnet::getPoolCapacity ( Lease::Type  type) const

Returns the number of possible leases for specified lease type.

Parameters
typetype of the lease

Definition at line 88 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.

Referenced by getAnyPool().

+ Here is the call graph for this function:

◆ getPoolCapacity() [2/3]

uint64_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
typetype of the lease
client_classeslist of classes the client belongs to
Returns
number of leases matching lease type and classes

Definition at line 104 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]

uint64_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
typetype of the lease
client_classeslist of classes the client belongs to
prefix_length_matchtype which indicates the selection criteria for the pools relative to the provided hint prefix length
hint_prefix_lengththe hint prefix length that the client provided
Returns
number of leases matching lease type and classes

Definition at line 121 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
typelease type to be set
Returns
a collection of all pools

Definition at line 319 of file subnet.cc.

References 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 getAnyPool(), getPool(), inPool(), poolOverlaps(), isc::dhcp::Subnet4::toElement(), and isc::dhcp::Subnet6::toElement().

◆ 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
typelease type to be set
Returns
a collection of all pools

Definition at line 337 of file subnet.cc.

References 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(), delPools(), and setSharedNetworkName().

◆ 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_networkPointer to the shared network where returned value should be assigned.
Template Parameters
Typeof the shared network, i.e. SharedNetwork4 or a SharedNetwork6.

Definition at line 237 of file subnet.h.

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

Referenced by isc::dhcp::Subnet4::clientSupported(), isc::dhcp::Subnet6::clientSupported(), isc::dhcp::Subnet4::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 256 of file subnet.h.

References shared_network_name_.

◆ 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
typetype of pools to iterate over
addrthis 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 515 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
typetype of pools to iterate over
addrthis address will be checked if it belongs to any pools in that subnet
client_classesclient class list which must be allowed
Returns
true if the address is in any of the allowed pools

Definition at line 534 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
addrthis address will be checked if it is included in a specific range
Returns
true if address is in range, false otherwise

Definition at line 73 of file subnet.cc.

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

Referenced by addPool(), and inPool().

+ Here is the call graph for this function:

◆ parsePrefixCommon()

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

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
prefixPrefix to be parsed.
Exceptions
BadValueif provided prefix is not valid.

Definition at line 211 of file subnet.cc.

References isc_throw, and isc::dhcp::Lease::TYPE_V4.

Referenced by generateNextID(), 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_typePool type.
poolPointer 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 558 of file subnet.cc.

References getPools().

Referenced by addPool(), and generateNextID().

+ Here is the call graph for this function:

◆ resetSubnetID()

static void isc::dhcp::Subnet::resetSubnetID ( )
inlinestatic

Resets subnet-id counter to its initial value (1).

This should be called during reconfiguration, before any new subnet objects are created. It will ensure that the subnet_id will be consistent between reconfigures.

Definition at line 216 of file subnet.h.

References static_id_.

Referenced by generateNextID().

◆ setAllocationState()

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

Sets subnet-specific allocation state.

Parameters
typelease type for which the allocation state is set.
allocation_stateallocation state instance.

Definition at line 383 of file subnet.cc.

References allocation_states_.

Referenced by setSharedNetworkName().

◆ 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
typelease type for which the allocator is set.
allocatornew allocator instance.

Definition at line 367 of file subnet.cc.

References allocators_.

Referenced by setSharedNetworkName().

◆ 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_networkPointer to a new shared network to be associated with the subnet.

Definition at line 249 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_nameNew shared network name.

Definition at line 272 of file subnet.h.

References getAllocationState(), getAllocator(), getPoolsWritable(), setAllocationState(), setAllocator(), shared_network_name_, and Subnet().

+ Here is the call graph for this function:

◆ sumPoolCapacity() [1/3]

uint64_t isc::dhcp::Subnet::sumPoolCapacity ( const PoolCollection pools) const
protected

Returns a sum of possible leases in all pools.

Parameters
poolslist of pools
Returns
sum of possible leases

Definition at line 141 of file subnet.cc.

Referenced by generateNextID(), and getPoolCapacity().

◆ sumPoolCapacity() [2/3]

uint64_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
poolslist of pools
client_classeslist of classes
Returns
sum of possible/allowed leases

Definition at line 159 of file subnet.cc.

◆ sumPoolCapacity() [3/3]

uint64_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
poolslist of pools
client_classeslist of classes
prefix_length_matchtype which indicates the selection criteria for the pools relative to the provided hint prefix length
hint_prefix_lengththe hint prefix length that the client provided
Returns
sum of possible/allowed leases

Definition at line 181 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
protectedvirtual

Unparse a subnet object.

Returns
A pointer to unparsed subnet configuration.

Reimplemented from isc::dhcp::Network.

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

Definition at line 723 of file subnet.cc.

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

Referenced by generateNextID(), isc::dhcp::Subnet4::get4o6(), 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 81 of file subnet.cc.

References prefix_, and prefix_len_.

Referenced by getAnyPool(), 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 464 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 461 of file subnet.h.

Referenced by getAllocator(), 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 440 of file subnet.h.

Referenced by getID().

◆ pools_

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

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

Definition at line 443 of file subnet.h.

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

◆ pools_pd_

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

collection of IPv6 prefix pools in that subnet.

Definition at line 449 of file subnet.h.

Referenced by 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 446 of file subnet.h.

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

◆ prefix_

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

a prefix of the subnet.

Definition at line 452 of file subnet.h.

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

◆ prefix_len_

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

a prefix length of the subnet.

Definition at line 455 of file subnet.h.

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

◆ shared_network_name_

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

Shared network name.

Definition at line 458 of file subnet.h.

Referenced by getSharedNetworkName(), and setSharedNetworkName().

◆ static_id_

SubnetID isc::dhcp::Subnet::static_id_ = 1
staticprotected

keeps the subnet-id value.

It is incremented every time a new Subnet object is created. It is reset (resetSubnetID) every time reconfiguration occurs.

Static value initialized in subnet.cc.

Definition at line 342 of file subnet.h.

Referenced by resetSubnetID(), and ~Subnet().


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