9#include <boost/make_shared.hpp>
18 return (boost::make_shared<PoolFreeLeaseQueueAllocationState>(pool->getType()));
24 free_lease4_queue_ = boost::make_shared<FreeLeaseQueue<uint32_t>>();
26 free_lease6_queue_ = boost::make_shared<FreeLeaseQueue<IOAddress>>();
32 return ((free_lease4_queue_ && free_lease4_queue_->empty()) ||
33 (free_lease6_queue_ && free_lease6_queue_->empty()));
38 if (free_lease4_queue_) {
39 free_lease4_queue_->push_back(address.toUint32());
41 free_lease6_queue_->push_back(address);
47 if (free_lease4_queue_) {
48 auto& idx = free_lease4_queue_->get<1>();
49 idx.erase(address.toUint32());
51 auto& idx = free_lease6_queue_->get<1>();
58 if (free_lease4_queue_) {
59 if (free_lease4_queue_->empty()) {
62 uint32_t lease = free_lease4_queue_->front();
63 free_lease4_queue_->pop_front();
64 free_lease4_queue_->push_back(lease);
68 if (free_lease6_queue_->empty()) {
71 IOAddress lease = free_lease6_queue_->front();
72 free_lease6_queue_->pop_front();
73 free_lease6_queue_->push_back(lease);
79 if (free_lease4_queue_) {
80 return (free_lease4_queue_->size());
82 return (free_lease6_queue_->size());
The IOAddress class represents an IP addresses (version agnostic)
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
Base class for representing allocation state in pools and subnets.
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
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.