Kea 2.7.5
flq_allocation_state.h
Go to the documentation of this file.
1// Copyright (C) 2023 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_ALLOCATION_STATE_H
8#define FLQ_ALLOCATION_STATE_H
9
11#include <dhcpsrv/pool.h>
12#include <dhcpsrv/subnet.h>
13#include <boost/shared_ptr.hpp>
14#include <cstdint>
15
16namespace isc {
17namespace dhcp {
18
20class PoolFreeLeaseQueueAllocationState;
21
23typedef boost::shared_ptr<PoolFreeLeaseQueueAllocationState> PoolFreeLeaseQueueAllocationStatePtr;
24
27public:
28
35
42
46 bool exhausted() const;
47
51 void addFreeLease(const asiolink::IOAddress& address);
52
56 void deleteFreeLease(const asiolink::IOAddress& address);
57
63
67 size_t getFreeLeaseCount() const;
68
69private:
70
78 template<typename AddressType>
79 using FreeLeaseQueue = boost::multi_index_container<
80 AddressType,
81 boost::multi_index::indexed_by<
82 boost::multi_index::sequenced<>,
83 boost::multi_index::hashed_unique<
84 boost::multi_index::identity<AddressType>
85 >
86 >
87 >;
88
90 typedef boost::shared_ptr<FreeLeaseQueue<uint32_t>> FreeLease4QueuePtr;
91
93 typedef boost::shared_ptr<FreeLeaseQueue<asiolink::IOAddress>> FreeLease6QueuePtr;
94
97 FreeLease4QueuePtr free_lease4_queue_;
98
101 FreeLease6QueuePtr free_lease6_queue_;
102};
103
104
105} // end of isc::dhcp namespace
106} // end of isc namespace
107
108#endif // FLQ_ALLOCATION_STATE_H
Base class for representing allocation state in pools and subnets.
Pool allocation state used by the FLQ allocator.
asiolink::IOAddress offerFreeLease()
Returns next available lease.
PoolFreeLeaseQueueAllocationState(Lease::Type type)
Constructor.
bool exhausted() const
Checks if the pool has run out of free leases.
void deleteFreeLease(const asiolink::IOAddress &address)
Deletes free lease from the queue.
void addFreeLease(const asiolink::IOAddress &address)
Adds a free lease to the queue.
static PoolFreeLeaseQueueAllocationStatePtr create(const PoolPtr &pool)
Factory function creating the state instance from a pool.
size_t getFreeLeaseCount() const
Returns the current number of free leases in the queue.
boost::shared_ptr< PoolFreeLeaseQueueAllocationState > PoolFreeLeaseQueueAllocationStatePtr
Type of the pointer to the PoolFreeLeaseQueueAllocationState.
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:485
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.
Definition lease.h:46