Kea: flq_allocator.h Source File

| Kea 3.2.0-git

flq_allocator.h
Go to the documentation of this file.
1// Copyright (C) 2023-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef FLQ_ALLOCATOR_H
8#define FLQ_ALLOCATOR_H
9
10#include <dhcpsrv/allocator.h>
11#include <dhcpsrv/flq_allocation_state.h>
12#include <dhcpsrv/lease.h>
13#include <cstdint>
14
15namespace isc {
16namespace dhcp {
17
38 class FreeLeaseQueueAllocator : public Allocator {
39public:
40
45 FreeLeaseQueueAllocator(Lease::Type type, const WeakSubnetPtr& subnet);
46
50 virtual std::string getType() const {
51 return ("flq");
52 }
53
64 virtual double
65 getOccupancyRate(const asiolink::IOAddress& addr,
66 const ClientClasses& client_classes);
67
79 virtual double
80 getOccupancyRate(const asiolink::IOAddress& pref,
81 const uint8_t plen,
82 const ClientClasses& client_classes);
83
84private:
85
90 virtual void initAfterConfigureInternal();
91
102 template<typename LeaseCollectionType>
103 void populateFreeAddressLeases(const LeaseCollectionType& leases, const PoolCollection& pools);
104
113 void populateFreePrefixDelegationLeases(const Lease6Collection& leases, const PoolCollection& pools);
114
124 virtual asiolink::IOAddress pickAddressInternal(const ClientClasses& client_classes,
125 const IdentifierBaseTypePtr& duid,
126 const asiolink::IOAddress& hint);
127
143 virtual isc::asiolink::IOAddress
144 pickPrefixInternal(const ClientClasses& client_classes,
145 Pool6Ptr& pool,
146 const IdentifierBaseTypePtr& duid,
147 PrefixLenMatchType prefix_length_match,
148 const isc::asiolink::IOAddress& hint,
149 uint8_t hint_prefix_length);
150
163 virtual double
164 getOccupancyRateInternal(const asiolink::IOAddress& addr,
165 const ClientClasses& client_classes);
166
180 virtual double
181 getOccupancyRateInternal(const asiolink::IOAddress& pref,
182 const uint8_t plen,
183 const ClientClasses& client_classes);
184
192 PoolFreeLeaseQueueAllocationStatePtr getPoolState(const PoolPtr& pool) const;
193
202 PoolPtr getLeasePool(const LeasePtr& lease) const;
203
209 void addLeaseCallback(LeasePtr lease);
210
216 void addLeaseCallbackInternal(LeasePtr lease);
217
225 void updateLeaseCallback(LeasePtr lease);
226
234 void updateLeaseCallbackInternal(LeasePtr lease);
235
241 void deleteLeaseCallback(LeasePtr lease);
242
248 void deleteLeaseCallbackInternal(LeasePtr lease);
249
257 uint64_t getRandomNumber(uint64_t limit);
258
260 std::mt19937 generator_;
261};
262
263} // end of namespace isc::dhcp
264} // end of namespace isc
265
266#endif // FLQ_ALLOCATOR_H
allocator.h
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::dhcp::Allocator::initAfterConfigureInternal
virtual void initAfterConfigureInternal()
Allocator-specific initialization function.
Definition allocator.h:202
isc::dhcp::Allocator::PrefixLenMatchType
PrefixLenMatchType
Type of preferred PD-pool prefix length selection criteria.
Definition allocator.h:61
isc::dhcp::Allocator::Allocator
Allocator(Lease::Type type, const WeakSubnetPtr &subnet)
Constructor.
Definition allocator.cc:17
isc::dhcp::ClientClasses
Container for storing client class names.
Definition classify.h:110
isc::dhcp::FreeLeaseQueueAllocator::getOccupancyRate
virtual double getOccupancyRate(const asiolink::IOAddress &addr, const ClientClasses &client_classes)
Returns the occupancy rate (v4 addresses).
Definition flq_allocator.cc:139
isc::dhcp::FreeLeaseQueueAllocator::getType
virtual std::string getType() const
Returns the allocator type string.
Definition flq_allocator.h:50
isc::dhcp::FreeLeaseQueueAllocator::FreeLeaseQueueAllocator
FreeLeaseQueueAllocator(Lease::Type type, const WeakSubnetPtr &subnet)
Constructor.
Definition flq_allocator.cc:32
flq_allocation_state.h
lease.h
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::PoolFreeLeaseQueueAllocationStatePtr
boost::shared_ptr< PoolFreeLeaseQueueAllocationState > PoolFreeLeaseQueueAllocationStatePtr
Type of the pointer to the PoolFreeLeaseQueueAllocationState.
Definition flq_allocation_state.h:23
isc::dhcp::WeakSubnetPtr
boost::weak_ptr< Subnet > WeakSubnetPtr
Weak pointer to the Subnet.
Definition allocator.h:32
isc::dhcp::Lease6Collection
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
Definition lease.h:693
isc::dhcp::PoolCollection
std::vector< PoolPtr > PoolCollection
a container for either IPv4 or IPv6 Pools
Definition pool.h:729
isc::dhcp::IdentifierBaseTypePtr
boost::shared_ptr< IdentifierBaseType > IdentifierBaseTypePtr
Shared pointer to a IdentifierType.
Definition duid.h:34
isc::dhcp::PoolPtr
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:726
isc::dhcp::LeasePtr
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
Definition lease.h:25
isc::dhcp::Pool6Ptr
boost::shared_ptr< Pool6 > Pool6Ptr
a pointer an IPv6 Pool
Definition pool.h:536
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
isc::dhcp::Lease::Type
Type
Type of lease or pool.
Definition lease.h:46