Kea  1.9.9-git
ip_range_permutation.h
Go to the documentation of this file.
1 // Copyright (C) 2020-2021 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 
13 #include <boost/shared_ptr.hpp>
14 
15 #include <map>
16 #include <random>
17 
18 namespace isc {
19 namespace dhcp {
20 
67 public:
68 
72  IPRangePermutation(const AddressRange& range);
73 
78  IPRangePermutation(const PrefixRange& range);
79 
84  bool exhausted() const {
85  return (done_);
86  }
87 
100  asiolink::IOAddress next(bool& done);
101 
102 private:
103 
105  asiolink::IOAddress range_start_;
106 
110  uint64_t step_;
111 
116  uint64_t cursor_;
117 
121  std::map<uint64_t, asiolink::IOAddress> state_;
122 
124  bool done_;
125 
127  std::mt19937 generator_;
128 };
129 
131 typedef boost::shared_ptr<IPRangePermutation> IPRangePermutationPtr;
132 
133 } // end of namespace isc::dhcp
134 } // end of namespace isc
135 
136 #endif // IP_RANGE_PERMUTATION_H
Structure representing delegated prefix range.
Definition: ip_range.h:32
bool exhausted() const
Checks if the range has been exhausted.
IPRangePermutation(const AddressRange &range)
Constructor for address ranges.
Random IP address/prefix permutation based on Fisher-Yates shuffle.
asiolink::IOAddress next(bool &done)
Returns next random address or prefix from the permutation.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Structure representing IP address range.
Definition: ip_range.h:16
boost::shared_ptr< IPRangePermutation > IPRangePermutationPtr
Pointer to the IPRangePermutation.