lib_LTLIBRARIES = libkea-dhcpsrv.la
libkea_dhcpsrv_la_SOURCES =
-libkea_dhcpsrv_la_SOURCES += address_range_permutation.h address_range_permutation.cc
libkea_dhcpsrv_la_SOURCES += alloc_engine.cc alloc_engine.h
libkea_dhcpsrv_la_SOURCES += alloc_engine_log.cc alloc_engine_log.h
libkea_dhcpsrv_la_SOURCES += alloc_engine_messages.h alloc_engine_messages.cc
libkea_dhcpsrv_la_SOURCES += hosts_log.cc hosts_log.h
libkea_dhcpsrv_la_SOURCES += hosts_messages.h hosts_messages.cc
libkea_dhcpsrv_la_SOURCES += ip_range.h ip_range.cc
+libkea_dhcpsrv_la_SOURCES += ip_range_permutation.h ip_range_permutation.cc
libkea_dhcpsrv_la_SOURCES += key_from_key.h
libkea_dhcpsrv_la_SOURCES += lease.cc lease.h
libkea_dhcpsrv_la_SOURCES += lease_file_loader.h
# Specify the headers for copying into the installation directory tree.
libkea_dhcpsrv_includedir = $(pkgincludedir)/dhcpsrv
libkea_dhcpsrv_include_HEADERS = \
- address_range_permutation.h \
alloc_engine.h \
alloc_engine_log.h \
alloc_engine_messages.h \
host_mgr.h \
hosts_log.h \
ip_range.h \
+ ip_range_permutation.h \
key_from_key.h \
lease.h \
lease_file_loader.h \
#include <config.h>
#include <asiolink/addr_utilities.h>
-#include <dhcpsrv/address_range_permutation.h>
+#include <dhcpsrv/ip_range_permutation.h>
using namespace isc::asiolink;
namespace isc {
namespace dhcp {
-AddressRangePermutation::AddressRangePermutation(const AddressRangePermutation::Range& range)
+IPRangePermutation::IPRangePermutation(const IPRangePermutation::Range& range)
: range_(range), cursor_(addrsInRange(range_.start_, range_.end_) - 1),
state_(), done_(false), generator_() {
std::random_device rd;
}
IOAddress
-AddressRangePermutation::next(bool& done) {
+IPRangePermutation::next(bool& done) {
// If we're done iterating over the pool let's return zero address and
// set the user supplied done flag to true.
if (done_) {
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef ADDRESS_RANGE_PERMUTATION_H
-#define ADDRESS_RANGE_PERMUTATION_H
+#ifndef IP_RANGE_PERMUTATION_H
+#define IP_RANGE_PERMUTATION_H
#include <asiolink/io_address.h>
#include <dhcpsrv/ip_range.h>
namespace isc {
namespace dhcp {
-/// @brief Random IP address permutation based on Fisher-Yates shuffle.
+/// @brief Random IP address/prefix permutation based on Fisher-Yates shuffle.
///
/// This class is used to shuffle IP addresses within the specified address
/// range. It is following the Fisher-Yates shuffle algorithm described in
/// This algorithm guarantees that all IP addresses beloging to the given
/// address range are returned and no duplicates are returned. The addresses
/// are returned in a random order.
-class AddressRangePermutation {
+class IPRangePermutation {
public:
/// Address range.
/// @brief Constructor.
///
/// @param range address range for which the permutation will be generated.
- AddressRangePermutation(const Range& range);
+ IPRangePermutation(const Range& range);
/// @brief Checks if the address range has been exhausted.
///
std::mt19937 generator_;
};
-/// @brief Pointer to the @c AddressRangePermutation.
-typedef boost::shared_ptr<AddressRangePermutation> AddressRangePermutationPtr;
+/// @brief Pointer to the @c IPRangePermutation.
+typedef boost::shared_ptr<IPRangePermutation> IPRangePermutationPtr;
} // end of namespace isc::dhcp
} // end of namespace isc
#include <cc/user_context.h>
#include <dhcp/classify.h>
#include <dhcp/option6_pdexclude.h>
-#include <dhcpsrv/address_range_permutation.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/lease.h>
+#include <dhcpsrv/ip_range_permutation.h>
#include <boost/shared_ptr.hpp>
/// @brief Returns pointer to the permutation associated with the pool.
///
/// @return Pointer to the address range permutation.
- AddressRangePermutationPtr getPermutation() const {
+ IPRangePermutationPtr getPermutation() const {
return (permutation_);
}
///
/// It may be initialized for certain pools and poo types to provide
/// address randomization capabilities.
- AddressRangePermutationPtr permutation_;
+ IPRangePermutationPtr permutation_;
};
class Pool4;
TESTS += libdhcpsrv_unittests
libdhcpsrv_unittests_SOURCES = run_unittests.cc
-libdhcpsrv_unittests_SOURCES += address_range_permutation_unittest.cc
libdhcpsrv_unittests_SOURCES += alloc_engine_utils.cc alloc_engine_utils.h
libdhcpsrv_unittests_SOURCES += alloc_engine_expiration_unittest.cc
libdhcpsrv_unittests_SOURCES += alloc_engine_hooks_unittest.cc
libdhcpsrv_unittests_SOURCES += host_reservations_list_parser_unittest.cc
libdhcpsrv_unittests_SOURCES += ifaces_config_parser_unittest.cc
libdhcpsrv_unittests_SOURCES += ip_range_unittest.cc
+libdhcpsrv_unittests_SOURCES += ip_range_permutation_unittest.cc
libdhcpsrv_unittests_SOURCES += lease_file_loader_unittest.cc
libdhcpsrv_unittests_SOURCES += lease_unittest.cc
libdhcpsrv_unittests_SOURCES += lease_mgr_factory_unittest.cc
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
-#include <dhcpsrv/address_range_permutation.h>
+#include <dhcpsrv/ip_range_permutation.h>
#include <gtest/gtest.h>
// This test verifies that the object can be successfully constructed for
// both IPv4 and IPv6 address range.
-TEST(AddressRangePermutationTest, constructor) {
+TEST(IPRangePermutationTest, constructor) {
ASSERT_NO_THROW({
- AddressRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
- AddressRangePermutation perm(range);
+ IPRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
+ IPRangePermutation perm(range);
});
ASSERT_NO_THROW({
- AddressRangePermutation::Range range(IOAddress("3000::"), IOAddress("3000::10"));
- AddressRangePermutation perm(range);
+ IPRangePermutation::Range range(IOAddress("3000::"), IOAddress("3000::10"));
+ IPRangePermutation perm(range);
});
}
// This test verifies that a permutation of IPv4 address range can
// be generated.
-TEST(AddressRangePermutationTest, ipv4) {
+TEST(IPRangePermutationTest, ipv4) {
// Create address range with 91 addresses.
- AddressRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
- AddressRangePermutation perm(range);
+ IPRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
+ IPRangePermutation perm(range);
// This set will record unique IP addresses generated.
std::set<IOAddress> addrs;
// This test verifies that a permutation of IPv4 address range can
// be generated.
-TEST(AddressRangePermutationTest, ipv6) {
- AddressRangePermutation::Range range(IOAddress("2001:db8:1::1:fea0"),
+TEST(IPRangePermutationTest, ipv6) {
+ IPRangePermutation::Range range(IOAddress("2001:db8:1::1:fea0"),
IOAddress("2001:db8:1::2:abcd"));
- AddressRangePermutation perm(range);
+ IPRangePermutation perm(range);
std::set<IOAddress> addrs;
bool done = false;