From: Marcin Siodelski Date: Mon, 14 Sep 2020 19:43:12 +0000 (+0200) Subject: [#1415] Renamed address_ to ip_range_permutation X-Git-Tag: Kea-1.9.0~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b14cbc36505891af8f67de7dbed444f03a3ed856;p=thirdparty%2Fkea.git [#1415] Renamed address_ to ip_range_permutation --- diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am index 3dc625078b..3bf9c3455a 100644 --- a/src/lib/dhcpsrv/Makefile.am +++ b/src/lib/dhcpsrv/Makefile.am @@ -63,7 +63,6 @@ CLEANFILES += *.csv 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 @@ -115,6 +114,7 @@ libkea_dhcpsrv_la_SOURCES += host_mgr.cc host_mgr.h 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 @@ -300,7 +300,6 @@ EXTRA_DIST += database_backends.dox libdhcpsrv.dox # 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 \ @@ -352,6 +351,7 @@ libkea_dhcpsrv_include_HEADERS = \ host_mgr.h \ hosts_log.h \ ip_range.h \ + ip_range_permutation.h \ key_from_key.h \ lease.h \ lease_file_loader.h \ diff --git a/src/lib/dhcpsrv/address_range_permutation.cc b/src/lib/dhcpsrv/ip_range_permutation.cc similarity index 94% rename from src/lib/dhcpsrv/address_range_permutation.cc rename to src/lib/dhcpsrv/ip_range_permutation.cc index 7c3d78bb29..b5111a6544 100644 --- a/src/lib/dhcpsrv/address_range_permutation.cc +++ b/src/lib/dhcpsrv/ip_range_permutation.cc @@ -6,14 +6,14 @@ #include #include -#include +#include 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; @@ -21,7 +21,7 @@ AddressRangePermutation::AddressRangePermutation(const AddressRangePermutation:: } 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_) { diff --git a/src/lib/dhcpsrv/address_range_permutation.h b/src/lib/dhcpsrv/ip_range_permutation.h similarity index 93% rename from src/lib/dhcpsrv/address_range_permutation.h rename to src/lib/dhcpsrv/ip_range_permutation.h index c40beff189..77d2984a3c 100644 --- a/src/lib/dhcpsrv/address_range_permutation.h +++ b/src/lib/dhcpsrv/ip_range_permutation.h @@ -4,8 +4,8 @@ // 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 #include @@ -18,7 +18,7 @@ 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 @@ -60,7 +60,7 @@ namespace dhcp { /// 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. @@ -69,7 +69,7 @@ public: /// @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. /// @@ -115,8 +115,8 @@ private: std::mt19937 generator_; }; -/// @brief Pointer to the @c AddressRangePermutation. -typedef boost::shared_ptr AddressRangePermutationPtr; +/// @brief Pointer to the @c IPRangePermutation. +typedef boost::shared_ptr IPRangePermutationPtr; } // end of namespace isc::dhcp } // end of namespace isc diff --git a/src/lib/dhcpsrv/pool.h b/src/lib/dhcpsrv/pool.h index 36be01b243..addf5acb10 100644 --- a/src/lib/dhcpsrv/pool.h +++ b/src/lib/dhcpsrv/pool.h @@ -12,9 +12,9 @@ #include #include #include -#include #include #include +#include #include @@ -170,7 +170,7 @@ public: /// @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_); } @@ -247,7 +247,7 @@ protected: /// /// It may be initialized for certain pools and poo types to provide /// address randomization capabilities. - AddressRangePermutationPtr permutation_; + IPRangePermutationPtr permutation_; }; class Pool4; diff --git a/src/lib/dhcpsrv/tests/Makefile.am b/src/lib/dhcpsrv/tests/Makefile.am index e7ac662e29..8aad886da0 100644 --- a/src/lib/dhcpsrv/tests/Makefile.am +++ b/src/lib/dhcpsrv/tests/Makefile.am @@ -57,7 +57,6 @@ libco3_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere 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 @@ -100,6 +99,7 @@ libdhcpsrv_unittests_SOURCES += host_reservation_parser_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 diff --git a/src/lib/dhcpsrv/tests/address_range_permutation_unittest.cc b/src/lib/dhcpsrv/tests/ip_range_permutation_unittest.cc similarity index 78% rename from src/lib/dhcpsrv/tests/address_range_permutation_unittest.cc rename to src/lib/dhcpsrv/tests/ip_range_permutation_unittest.cc index 2cd010fbee..248dd4c41f 100644 --- a/src/lib/dhcpsrv/tests/address_range_permutation_unittest.cc +++ b/src/lib/dhcpsrv/tests/ip_range_permutation_unittest.cc @@ -5,7 +5,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include -#include +#include #include @@ -19,23 +19,23 @@ namespace { // 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 addrs; @@ -66,10 +66,10 @@ TEST(AddressRangePermutationTest, ipv4) { // 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 addrs; bool done = false;