Kea  2.1.7-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...
 
PoolPtr getAnyPool (Lease::Type type)
 Returns a pool without any address specified. More...
 
SubnetID getID () const
 Returns unique ID for that subnet. More...
 
isc::asiolink::IOAddress getLastAllocated (Lease::Type type) const
 returns the last address that was tried from this subnet. More...
 
boost::posix_time::ptime getLastAllocatedTime (const Lease::Type &lease_type) const
 Returns the timestamp when the setLastAllocated function was called. 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...
 
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 setLastAllocated (Lease::Type type, const isc::asiolink::IOAddress &addr)
 sets the last address that was tried from this subnet. 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< 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 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...
 
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

SubnetID id_
 subnet-id More...
 
isc::asiolink::IOAddress last_allocated_ia_
 last allocated address. More...
 
isc::asiolink::IOAddress last_allocated_pd_
 last allocated IPv6 prefix. More...
 
isc::asiolink::IOAddress last_allocated_ta_
 last allocated temporary address. More...
 
std::map< Lease::Type, boost::posix_time::ptime > last_allocated_time_
 Timestamp indicating when a lease of a specified type has been last allocated from this subnet. 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< 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 39 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 59 of file subnet.cc.

References isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV6(), last_allocated_time_, isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, isc::dhcp::Lease::TYPE_TA, and isc::dhcp::Lease::TYPE_V4.

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 334 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 461 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(), isc::dhcp::Subnet4::get4o6(), getLastAllocated(), and setLastAllocated().

◆ 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 516 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 353 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 130 of file subnet.h.

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

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

References id_.

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

◆ getLastAllocated()

isc::asiolink::IOAddress isc::dhcp::Subnet::getLastAllocated ( Lease::Type  type) const

returns the last address that was tried from this subnet.

This method returns the last address that was attempted to be allocated from this subnet. This is used as helper information for the next iteration of the allocation algorithm.

Note
: this routine is Kea thread safe.
Todo:
: Define map<SubnetID, ClientClass, IOAddress> somewhere in the AllocEngine::IterativeAllocator and keep the data there
Parameters
typelease type to be returned
Returns
address/prefix that was last tried from this subnet

Definition at line 90 of file subnet.cc.

References checkType(), isc_throw, last_allocated_ia_, last_allocated_pd_, last_allocated_ta_, 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:

◆ getLastAllocatedTime()

boost::posix_time::ptime isc::dhcp::Subnet::getLastAllocatedTime ( const Lease::Type lease_type) const

Returns the timestamp when the setLastAllocated function was called.

Note
: this routine is Kea thread safe.
Parameters
lease_typeLease type for which last allocation timestamp should be returned.
Returns
Time when a lease of a specified type has been allocated from this subnet. The negative infinity time is returned if a lease type is not recognized (which is unlikely).

Definition at line 117 of file subnet.cc.

References last_allocated_time_.

◆ 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 393 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 432 of file subnet.cc.

References getPools().

+ Here is the call graph for this function:

◆ getPoolCapacity() [1/2]

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 181 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/2]

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 197 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 357 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 375 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 264 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 283 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 521 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 541 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 83 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 254 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 566 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 243 of file subnet.h.

References static_id_.

Referenced by generateNextID().

◆ setLastAllocated()

void isc::dhcp::Subnet::setLastAllocated ( Lease::Type  type,
const isc::asiolink::IOAddress addr 
)

sets the last address that was tried from this subnet.

This method sets the last address that was attempted to be allocated from this subnet. This is used as helper information for the next iteration of the allocation algorithm.

Note
: this routine is Kea thread safe.
Todo:
: Define map<SubnetID, ClientClass, IOAddress> somewhere in the AllocEngine::IterativeAllocator and keep the data there
Parameters
addraddress/prefix to that was tried last
typelease type to be set

Definition at line 138 of file subnet.cc.

References checkType(), isc_throw, last_allocated_ia_, last_allocated_pd_, last_allocated_ta_, last_allocated_time_, 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:

◆ 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 276 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 299 of file subnet.h.

References getPoolsWritable(), shared_network_name_, and Subnet().

+ Here is the call graph for this function:

◆ sumPoolCapacity() [1/2]

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 214 of file subnet.cc.

Referenced by generateNextID(), and getPoolCapacity().

◆ sumPoolCapacity() [2/2]

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 232 of file subnet.cc.

◆ 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 721 of file subnet.cc.

References isc::data::UserContext::contextToElement(), 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 174 of file subnet.cc.

References prefix_, and prefix_len_.

Referenced by getAnyPool(), isc::dhcp::Subnet6ConfigParser::initSubnet(), and toElement().

Member Data Documentation

◆ 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 415 of file subnet.h.

Referenced by getID().

◆ last_allocated_ia_

isc::asiolink::IOAddress isc::dhcp::Subnet::last_allocated_ia_
protected

last allocated address.

This is the last allocated address that was previously allocated from this particular subnet. Some allocation algorithms (e.g. iterative) use that value, others do not. It should be noted that although the value is usually correct, there are cases when it is invalid, e.g. after removing a pool, restarting or changing allocation algorithms. For that purpose it should be only considered a help that should not be fully trusted.

Definition at line 441 of file subnet.h.

Referenced by getLastAllocated(), and setLastAllocated().

◆ last_allocated_pd_

isc::asiolink::IOAddress isc::dhcp::Subnet::last_allocated_pd_
protected

last allocated IPv6 prefix.

See last_allocated_ia_ for details.

Definition at line 451 of file subnet.h.

Referenced by getLastAllocated(), and setLastAllocated().

◆ last_allocated_ta_

isc::asiolink::IOAddress isc::dhcp::Subnet::last_allocated_ta_
protected

last allocated temporary address.

See last_allocated_ia_ for details.

Definition at line 446 of file subnet.h.

Referenced by getLastAllocated(), and setLastAllocated().

◆ last_allocated_time_

std::map<Lease::Type, boost::posix_time::ptime> isc::dhcp::Subnet::last_allocated_time_
protected

Timestamp indicating when a lease of a specified type has been last allocated from this subnet.

Note
: This map is protected by the mutex.

Definition at line 457 of file subnet.h.

Referenced by getLastAllocatedTime(), setLastAllocated(), and Subnet().

◆ pools_

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

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

Definition at line 418 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 424 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 421 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 427 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 430 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 460 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 334 of file subnet.h.

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


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