Kea 2.7.6
iterative_allocation_state.cc
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#include <config.h>
11#include <boost/date_time/posix_time/posix_time.hpp>
12#include <boost/make_shared.hpp>
13
14using namespace isc::asiolink;
15using namespace isc::util;
16
17namespace isc {
18namespace dhcp {
19
22 auto subnet_prefix = subnet->get();
23 return (boost::make_shared<SubnetIterativeAllocationState>(subnet_prefix.first, subnet_prefix.second));
24}
25
27 const uint8_t prefix_length)
29 last_allocated_(lastAddrInPrefix(prefix, prefix_length)) {
30}
31
35 return (last_allocated_);
36}
37
38void
41 last_allocated_ = address;
42 // Update the timestamp of the last allocation.
44}
45
48 return (boost::make_shared<PoolIterativeAllocationState>(pool->getFirstAddress()));
49}
50
52 : last_allocated_(first), last_allocated_valid_(false) {
53}
54
55} // end of namespace isc::dhcp
56} // end of namespace isc
static PoolIterativeAllocationStatePtr create(const PoolPtr &pool)
Factory function creating the state instance from pool.
PoolIterativeAllocationState(const asiolink::IOAddress &first)
Constructor.
Common base class for subnet-specific allocation states.
boost::scoped_ptr< std::mutex > mutex_
Mutex used for thread-safe access to the state members.
void setCurrentAllocatedTimeInternal()
Sets the last allocation time to current.
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.
RAII lock object to protect the code in the same scope with a mutex.