Kea 2.7.5
|
Base class for all address/prefix allocation algorithms. More...
#include <allocator.h>
Public Types | |
enum | PrefixLenMatchType { PREFIX_LEN_EQUAL , PREFIX_LEN_LOWER , PREFIX_LEN_HIGHER } |
Type of preferred PD-pool prefix length selection criteria. More... | |
Public Member Functions | |
Allocator (Lease::Type type, const WeakSubnetPtr &subnet) | |
Constructor. | |
virtual | ~Allocator () |
Virtual destructor. | |
virtual std::string | getType () const =0 |
Returns allocator type string. | |
void | initAfterConfigure () |
Performs allocator initialization after server's reconfiguration. | |
virtual isc::asiolink::IOAddress | pickAddress (const ClientClasses &client_classes, const IdentifierBaseTypePtr &duid, const asiolink::IOAddress &hint) |
Picks an address. | |
virtual isc::asiolink::IOAddress | pickPrefix (const ClientClasses &client_classes, Pool6Ptr &pool, const IdentifierBaseTypePtr &duid, PrefixLenMatchType prefix_length_match, const asiolink::IOAddress &hint, uint8_t hint_prefix_length) |
Picks a delegated prefix. | |
Static Public Member Functions | |
static bool | isValidPrefixPool (Allocator::PrefixLenMatchType prefix_length_match, PoolPtr pool, uint8_t hint_prefix_length) |
Check if the pool matches the selection criteria relative to the provided hint prefix length. | |
Protected Member Functions | |
virtual void | initAfterConfigureInternal () |
Allocator-specific initialization function. | |
Protected Attributes | |
bool | inited_ |
Indicates if the allocator has been initialized. | |
std::mutex | mutex_ |
The mutex to protect the allocated lease. | |
Lease::Type | pool_type_ |
Defines pool type allocation. | |
WeakSubnetPtr | subnet_ |
Weak pointer to the subnet owning the allocator. | |
SubnetID | subnet_id_ |
ID of a subnet to which the allocator belongs. | |
Base class for all address/prefix allocation algorithms.
This is an abstract class that should not be used directly, but rather specialized implementations should be used instead.
This class holds a weak pointer to the subnet owning it because it must not exist without the subnet. Also, it can't hold a shared pointer to the subnet because it would cause a circular dependency between the two.
Definition at line 57 of file allocator.h.
Type of preferred PD-pool prefix length selection criteria.
Enumerator | |
---|---|
PREFIX_LEN_EQUAL | |
PREFIX_LEN_LOWER | |
PREFIX_LEN_HIGHER |
Definition at line 61 of file allocator.h.
isc::dhcp::Allocator::Allocator | ( | Lease::Type | type, |
const WeakSubnetPtr & | subnet ) |
Constructor.
Specifies which type of leases this allocator will assign.
type | specifies pool type (addresses, temporary addresses or prefixes). |
subnet | weak pointer to the subnet owning the allocator. |
Definition at line 17 of file allocator.cc.
References subnet_, and subnet_id_.
|
virtual |
Virtual destructor.
Removes all LeaseMgr callbacks it installed.
Definition at line 27 of file allocator.cc.
References isc::dhcp::LeaseMgrFactory::haveInstance(), isc::dhcp::LeaseMgrFactory::instance(), pool_type_, and subnet_id_.
|
pure virtual |
Returns allocator type string.
Implemented in isc::dhcp::FreeLeaseQueueAllocator, isc::dhcp::IterativeAllocator, and isc::dhcp::RandomAllocator.
Referenced by initAfterConfigure().
void isc::dhcp::Allocator::initAfterConfigure | ( | ) |
Performs allocator initialization after server's reconfiguration.
Some allocators install callbacks in the lease manager to keep track of the lease allocations. These callbacks may only be installed when the lease manager instance is available (i.e., when the server finishes the reconfiguration). Such callbacks can be installed in this function.
In this function, the allocators can also re-build their allocation states.
Definition at line 68 of file allocator.cc.
References isc::dhcp::DHCPSRV_CFGMGR_USE_ALLOCATOR, isc::dhcp::dhcpsrv_logger, getType(), initAfterConfigureInternal(), inited_, LOG_INFO, pool_type_, subnet_, and isc::dhcp::Lease::typeToText().
|
inlineprotectedvirtual |
Allocator-specific initialization function.
It is called by the initAfterConfigure
and can be overridden in the derived allocators.
Definition at line 172 of file allocator.h.
Referenced by initAfterConfigure().
|
static |
Check if the pool matches the selection criteria relative to the provided hint prefix length.
prefix_length_match | type which indicates the selection criteria for the pools relative to the provided hint prefix length. |
pool | the pool checked for restricted delegated prefix length value. |
hint_prefix_length | The hint prefix length that the client provided. The 0 value means that there is no hint and that any pool will suffice. |
Definition at line 38 of file allocator.cc.
References PREFIX_LEN_EQUAL, PREFIX_LEN_HIGHER, and PREFIX_LEN_LOWER.
Referenced by isc::dhcp::Subnet::sumPoolCapacity().
|
inlinevirtual |
Picks an address.
This method returns one address from the available pools in the specified subnet. It should not check if the address is used or reserved - AllocEngine will check that and will call pickAddress again if necessary. The number of times this method is called will increase as the number of available leases will decrease.
Pools which are not allowed for client classes are skipped.
client_classes | list of classes client belongs to. |
duid | Client's DUID. |
hint | Client's hint. |
Definition at line 102 of file allocator.h.
References mutex_.
|
inlinevirtual |
Picks a delegated prefix.
This method returns one prefix from the available pools in the specified subnet. It should not check if the prefix is used or reserved - AllocEngine will check that and will call pickPrefix again if necessary. The number of times this method is called will increase as the number of available leases will decrease.
Pools which are not allowed for client classes are skipped.
client_classes | list of classes client belongs to. |
pool | the selected pool satisfying all required conditions. |
duid | Client's DUID. |
prefix_length_match | type which indicates the selection criteria for the pools relative to the provided hint prefix length. |
hint | Client's hint. |
hint_prefix_length | the hint prefix length that the client provided. The 0 value means that there is no hint and that any pool will suffice. |
Definition at line 131 of file allocator.h.
References mutex_.
|
protected |
Indicates if the allocator has been initialized.
It is set to true when initAfterConfigure
has been called. It prevents initializing the allocator several times.
Definition at line 223 of file allocator.h.
Referenced by initAfterConfigure().
|
protected |
The mutex to protect the allocated lease.
Definition at line 235 of file allocator.h.
Referenced by pickAddress(), and pickPrefix().
|
protected |
Defines pool type allocation.
Definition at line 226 of file allocator.h.
Referenced by ~Allocator(), and initAfterConfigure().
|
protected |
Weak pointer to the subnet owning the allocator.
Definition at line 232 of file allocator.h.
Referenced by Allocator(), and initAfterConfigure().
|
protected |
ID of a subnet to which the allocator belongs.
Definition at line 229 of file allocator.h.
Referenced by Allocator(), and ~Allocator().