]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1415] Renamed address_ to ip_range_permutation
authorMarcin Siodelski <marcin@isc.org>
Mon, 14 Sep 2020 19:43:12 +0000 (21:43 +0200)
committerMarcin Siodelski <marcin@isc.org>
Wed, 16 Sep 2020 14:39:12 +0000 (14:39 +0000)
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/ip_range_permutation.cc [moved from src/lib/dhcpsrv/address_range_permutation.cc with 94% similarity]
src/lib/dhcpsrv/ip_range_permutation.h [moved from src/lib/dhcpsrv/address_range_permutation.h with 93% similarity]
src/lib/dhcpsrv/pool.h
src/lib/dhcpsrv/tests/Makefile.am
src/lib/dhcpsrv/tests/ip_range_permutation_unittest.cc [moved from src/lib/dhcpsrv/tests/address_range_permutation_unittest.cc with 78% similarity]

index 3dc625078b97f7a557f7cc1b590488c81439b902..3bf9c3455abc9cfc0573e3c5b2b049f644713582 100644 (file)
@@ -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 \
similarity index 94%
rename from src/lib/dhcpsrv/address_range_permutation.cc
rename to src/lib/dhcpsrv/ip_range_permutation.cc
index 7c3d78bb293cac7fa663afbcfd5eb9cecfc694ba..b5111a6544ecfcd1e287fbc8ed877b811dc6a7a0 100644 (file)
@@ -6,14 +6,14 @@
 
 #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;
@@ -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_) {
similarity index 93%
rename from src/lib/dhcpsrv/address_range_permutation.h
rename to src/lib/dhcpsrv/ip_range_permutation.h
index c40beff189da78e9f40cc22a9f92e830997c203a..77d2984a3cfe80767f831df14e853733daf67c20 100644 (file)
@@ -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 <asiolink/io_address.h>
 #include <dhcpsrv/ip_range.h>
@@ -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<AddressRangePermutation> AddressRangePermutationPtr;
+/// @brief Pointer to the @c IPRangePermutation.
+typedef boost::shared_ptr<IPRangePermutation> IPRangePermutationPtr;
 
 } // end of namespace isc::dhcp
 } // end of namespace isc
index 36be01b2439003ab4ea0cf68af810961df3d01c2..addf5acb10ed3f1df3e2652640248a75b196f38c 100644 (file)
@@ -12,9 +12,9 @@
 #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>
 
@@ -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;
index e7ac662e29e7ed3dfdcbec3ce77cee97c60677fc..8aad886da0fdd6bc4d1e39858781e80c5ad1c0b9 100644 (file)
@@ -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
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 2cd010fbee68584645f08b59ffc67e32098944c7..248dd4c41ffbda5532c56ffbdd155b8614521d16 100644 (file)
@@ -5,7 +5,7 @@
 // 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>
 
@@ -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<IOAddress> 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<IOAddress> addrs;
     bool done = false;