Kea: ip_range_permutation.h Source File

| Kea 3.2.0-git

ip_range_permutation.h
Go to the documentation of this file.
1// Copyright (C) 2020-2024 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 IP_RANGE_PERMUTATION_H
8#define IP_RANGE_PERMUTATION_H
9
10#include <asiolink/io_address.h>
11#include <dhcpsrv/ip_range.h>
12#include <util/bigints.h>
13
14#include <boost/shared_ptr.hpp>
15
16#include <map>
17#include <random>
18
19namespace isc {
20namespace dhcp {
21
67 class IPRangePermutation {
68public:
69
73 IPRangePermutation(const AddressRange& range);
74
79 IPRangePermutation(const PrefixRange& range);
80
85 bool exhausted() const {
86 return (done_);
87 }
88
101 asiolink::IOAddress next(bool& done);
102
108 void reset();
109
110private:
111
113 asiolink::IOAddress range_start_;
114
118 isc::util::uint128_t step_;
119
124 isc::util::uint128_t cursor_;
125
127 isc::util::uint128_t initial_cursor_;
128
132 std::map<isc::util::uint128_t, asiolink::IOAddress> state_;
133
135 bool done_;
136
138 std::mt19937 generator_;
139};
140
142 typedef boost::shared_ptr<IPRangePermutation> IPRangePermutationPtr;
143
144} // end of namespace isc::dhcp
145} // end of namespace isc
146
147#endif // IP_RANGE_PERMUTATION_H
bigints.h
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::dhcp::IPRangePermutation::next
asiolink::IOAddress next(bool &done)
Returns next random address or prefix from the permutation.
Definition ip_range_permutation.cc:42
isc::dhcp::IPRangePermutation::reset
void reset()
Resets the permutation state.
Definition ip_range_permutation.cc:115
isc::dhcp::IPRangePermutation::IPRangePermutation
IPRangePermutation(const AddressRange &range)
Constructor for address ranges.
Definition ip_range_permutation.cc:18
isc::dhcp::IPRangePermutation::exhausted
bool exhausted() const
Checks if the range has been exhausted.
Definition ip_range_permutation.h:85
io_address.h
ip_range.h
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::IPRangePermutationPtr
boost::shared_ptr< IPRangePermutation > IPRangePermutationPtr
Pointer to the IPRangePermutation.
Definition ip_range_permutation.h:142
isc::util::uint128_t
boost::multiprecision::checked_uint128_t uint128_t
Definition bigints.h:21
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
isc::dhcp::AddressRange
Structure representing IP address range.
Definition ip_range.h:16
isc::dhcp::PrefixRange
Structure representing delegated prefix range.
Definition ip_range.h:32