Kea: iterative_allocation_state.h Source File

| Kea 3.2.0-git

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>
11#include <dhcpsrv/allocation_state.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
25 typedef boost::shared_ptr<SubnetIterativeAllocationState> SubnetIterativeAllocationStatePtr;
26
33 class SubnetIterativeAllocationState : public SubnetAllocationState {
34public:
35
41 static SubnetIterativeAllocationStatePtr create(const SubnetPtr& subnet);
42
47 SubnetIterativeAllocationState(const asiolink::IOAddress& prefix,
48 const uint8_t prefix_length);
49
53 asiolink::IOAddress getLastAllocated() const;
54
58 void setLastAllocated(const asiolink::IOAddress& address);
59
60private:
61
71 asiolink::IOAddress last_allocated_;
72};
73
75class PoolIterativeAllocationState;
76
78 typedef boost::shared_ptr<PoolIterativeAllocationState> PoolIterativeAllocationStatePtr;
79
84 class PoolIterativeAllocationState : public AllocationState {
85public:
86
92 static PoolIterativeAllocationStatePtr create(const PoolPtr& pool);
93
97 PoolIterativeAllocationState(const asiolink::IOAddress& first);
98
102 isc::asiolink::IOAddress getLastAllocated() const {
103 return (last_allocated_);
104 }
105
109 bool isLastAllocatedValid() const {
110 return last_allocated_valid_;
111 }
112
116 void setLastAllocated(const asiolink::IOAddress& address) {
117 last_allocated_ = address;
118 last_allocated_valid_ = true;
119 }
120
122 void resetLastAllocated() {
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
allocation_state.h
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::dhcp::AllocationState
Base class for representing allocation state in pools and subnets.
Definition allocation_state.h:31
isc::dhcp::PoolIterativeAllocationState
Pool allocation state used by the iterative allocator.
Definition iterative_allocation_state.h:84
isc::dhcp::PoolIterativeAllocationState::resetLastAllocated
void resetLastAllocated()
Resets the last address to invalid.
Definition iterative_allocation_state.h:122
isc::dhcp::PoolIterativeAllocationState::setLastAllocated
void setLastAllocated(const asiolink::IOAddress &address)
Sets the last address that was tried from this pool.
Definition iterative_allocation_state.h:116
isc::dhcp::PoolIterativeAllocationState::create
static PoolIterativeAllocationStatePtr create(const PoolPtr &pool)
Factory function creating the state instance from pool.
Definition iterative_allocation_state.cc:47
isc::dhcp::PoolIterativeAllocationState::getLastAllocated
isc::asiolink::IOAddress getLastAllocated() const
Returns the last address that was tried from this pool.
Definition iterative_allocation_state.h:102
isc::dhcp::PoolIterativeAllocationState::isLastAllocatedValid
bool isLastAllocatedValid() const
Checks if the last address is valid.
Definition iterative_allocation_state.h:109
isc::dhcp::PoolIterativeAllocationState::PoolIterativeAllocationState
PoolIterativeAllocationState(const asiolink::IOAddress &first)
Constructor.
Definition iterative_allocation_state.cc:51
isc::dhcp::SubnetAllocationState::SubnetAllocationState
SubnetAllocationState()
Constructor.
Definition allocation_state.cc:17
isc::dhcp::SubnetIterativeAllocationState
Subnet allocation state used by the iterative allocator.
Definition iterative_allocation_state.h:33
isc::dhcp::SubnetIterativeAllocationState::getLastAllocated
asiolink::IOAddress getLastAllocated() const
Returns last allocated address or prefix.
Definition iterative_allocation_state.cc:33
isc::dhcp::SubnetIterativeAllocationState::SubnetIterativeAllocationState
SubnetIterativeAllocationState(const asiolink::IOAddress &prefix, const uint8_t prefix_length)
Constructor.
Definition iterative_allocation_state.cc:26
isc::dhcp::SubnetIterativeAllocationState::setLastAllocated
void setLastAllocated(const asiolink::IOAddress &address)
Sets last allocated address or prefix.
Definition iterative_allocation_state.cc:39
isc::dhcp::SubnetIterativeAllocationState::create
static SubnetIterativeAllocationStatePtr create(const SubnetPtr &subnet)
Factory function creating the state instance from subnet.
Definition iterative_allocation_state.cc:21
io_address.h
lease.h
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::SubnetPtr
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
Definition subnet.h:446
isc::dhcp::PoolPtr
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:726
isc::dhcp::PoolIterativeAllocationStatePtr
boost::shared_ptr< PoolIterativeAllocationState > PoolIterativeAllocationStatePtr
Type of the pointer to the PoolIterativeAllocationState.
Definition iterative_allocation_state.h:78
isc::dhcp::SubnetIterativeAllocationStatePtr
boost::shared_ptr< SubnetIterativeAllocationState > SubnetIterativeAllocationStatePtr
Type of the pointer to the SubnetIterativeAllocationState.
Definition iterative_allocation_state.h:25
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
subnet.h