Kea 2.7.6
iterative_allocation_state.h
Go to the documentation of this file.
1// Copyright (C) 2022-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 ITERATIVE_ALLOCATION_STATE_H
8#define ITERATIVE_ALLOCATION_STATE_H
9
10#include <asiolink/io_address.h>
12#include <dhcpsrv/lease.h>
13#include <dhcpsrv/subnet.h>
14#include <boost/shared_ptr.hpp>
15#include <cstdint>
16#include <map>
17
18namespace isc {
19namespace dhcp {
20
22class SubnetIterativeAllocationState;
23
25typedef boost::shared_ptr<SubnetIterativeAllocationState> SubnetIterativeAllocationStatePtr;
26
34public:
35
42
48 const uint8_t prefix_length);
49
54
58 void setLastAllocated(const asiolink::IOAddress& address);
59
60private:
61
71 asiolink::IOAddress last_allocated_;
72};
73
76
78typedef boost::shared_ptr<PoolIterativeAllocationState> PoolIterativeAllocationStatePtr;
79
85public:
86
93
98
103 return (last_allocated_);
104 }
105
109 bool isLastAllocatedValid() const {
110 return last_allocated_valid_;
111 }
112
117 last_allocated_ = address;
118 last_allocated_valid_ = true;
119 }
120
123 last_allocated_valid_ = false;
124 }
125
126private:
127
129 isc::asiolink::IOAddress last_allocated_;
130
132 bool last_allocated_valid_;
133};
134
135} // end of namespace isc::dhcp
136} // end of namespace isc
137
138#endif // ITERATIVE_ALLOCATION_STATE_H
Base class for representing allocation state in pools and subnets.
Pool allocation state used by the iterative allocator.
void resetLastAllocated()
Resets the last address to invalid.
void setLastAllocated(const asiolink::IOAddress &address)
Sets the last address that was tried from this pool.
static PoolIterativeAllocationStatePtr create(const PoolPtr &pool)
Factory function creating the state instance from pool.
isc::asiolink::IOAddress getLastAllocated() const
Returns the last address that was tried from this pool.
bool isLastAllocatedValid() const
Checks if the last address is valid.
PoolIterativeAllocationState(const asiolink::IOAddress &first)
Constructor.
Common base class for subnet-specific allocation states.
Subnet allocation state used by the iterative allocator.
asiolink::IOAddress getLastAllocated() const
Returns last allocated address or prefix.
SubnetIterativeAllocationState(const asiolink::IOAddress &prefix, const uint8_t prefix_length)
Constructor.
void setLastAllocated(const asiolink::IOAddress &address)
Sets last allocated address or prefix.
static SubnetIterativeAllocationStatePtr create(const SubnetPtr &subnet)
Factory function creating the state instance from subnet.
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
Definition subnet.h:449
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:485
boost::shared_ptr< PoolIterativeAllocationState > PoolIterativeAllocationStatePtr
Type of the pointer to the PoolIterativeAllocationState.
boost::shared_ptr< SubnetIterativeAllocationState > SubnetIterativeAllocationStatePtr
Type of the pointer to the SubnetIterativeAllocationState.
Defines the logger used by the top-level component of kea-lfc.