Kea 2.5.8
random_allocator.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 RANDOM_ALLOCATOR_H
8#define RANDOM_ALLOCATOR_H
9
10#include <dhcpsrv/allocator.h>
12#include <dhcpsrv/lease.h>
13#include <cstdint>
14#include <random>
15
16namespace isc {
17namespace dhcp {
18
30class RandomAllocator : public Allocator {
31public:
32
37 RandomAllocator(Lease::Type type, const WeakSubnetPtr& subnet);
38
42 virtual std::string getType() const {
43 return ("random");
44 }
45
46private:
47
57 virtual asiolink::IOAddress pickAddressInternal(const ClientClasses& client_classes,
58 const IdentifierBaseTypePtr& duid,
59 const asiolink::IOAddress& hint);
60
76 virtual asiolink::IOAddress pickPrefixInternal(const ClientClasses& client_classes,
77 Pool6Ptr& pool,
78 const IdentifierBaseTypePtr& duid,
79 PrefixLenMatchType prefix_length_match,
80 const asiolink::IOAddress& hint,
81 uint8_t hint_prefix_length);
82
90 PoolRandomAllocationStatePtr getPoolState(const PoolPtr& pool) const;
91
99 uint64_t getRandomNumber(uint64_t limit);
100
102 std::mt19937 generator_;
103};
104
105} // end of namespace isc::dhcp
106} // end of namespace isc
107
108#endif // RANDOM_ALLOCATOR_H
Base class for all address/prefix allocation algorithms.
Definition: allocator.h:57
PrefixLenMatchType
Type of preferred PD-pool prefix length selection criteria.
Definition: allocator.h:61
Container for storing client class names.
Definition: classify.h:108
An allocator offering addresses in a random order.
virtual std::string getType() const
Returns the allocator type string.
boost::shared_ptr< PoolRandomAllocationState > PoolRandomAllocationStatePtr
Type of the pointer to the PoolRandomAllocationState.
boost::weak_ptr< Subnet > WeakSubnetPtr
Weak pointer to the Subnet.
Definition: allocator.h:32
boost::shared_ptr< IdentifierBaseType > IdentifierBaseTypePtr
Shared pointer to a IdentifierType.
Definition: duid.h:34
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition: pool.h:483
boost::shared_ptr< Pool6 > Pool6Ptr
a pointer an IPv6 Pool
Definition: pool.h:293
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.
Definition: lease.h:46