Skip to content

Commit b14cbc3

Browse files
committed
[#1415] Renamed address_ to ip_range_permutation
1 parent 8e627f3 commit b14cbc3

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

src/lib/dhcpsrv/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ CLEANFILES += *.csv
6363

6464
lib_LTLIBRARIES = libkea-dhcpsrv.la
6565
libkea_dhcpsrv_la_SOURCES =
66-
libkea_dhcpsrv_la_SOURCES += address_range_permutation.h address_range_permutation.cc
6766
libkea_dhcpsrv_la_SOURCES += alloc_engine.cc alloc_engine.h
6867
libkea_dhcpsrv_la_SOURCES += alloc_engine_log.cc alloc_engine_log.h
6968
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
115114
libkea_dhcpsrv_la_SOURCES += hosts_log.cc hosts_log.h
116115
libkea_dhcpsrv_la_SOURCES += hosts_messages.h hosts_messages.cc
117116
libkea_dhcpsrv_la_SOURCES += ip_range.h ip_range.cc
117+
libkea_dhcpsrv_la_SOURCES += ip_range_permutation.h ip_range_permutation.cc
118118
libkea_dhcpsrv_la_SOURCES += key_from_key.h
119119
libkea_dhcpsrv_la_SOURCES += lease.cc lease.h
120120
libkea_dhcpsrv_la_SOURCES += lease_file_loader.h
@@ -300,7 +300,6 @@ EXTRA_DIST += database_backends.dox libdhcpsrv.dox
300300
# Specify the headers for copying into the installation directory tree.
301301
libkea_dhcpsrv_includedir = $(pkgincludedir)/dhcpsrv
302302
libkea_dhcpsrv_include_HEADERS = \
303-
address_range_permutation.h \
304303
alloc_engine.h \
305304
alloc_engine_log.h \
306305
alloc_engine_messages.h \
@@ -352,6 +351,7 @@ libkea_dhcpsrv_include_HEADERS = \
352351
host_mgr.h \
353352
hosts_log.h \
354353
ip_range.h \
354+
ip_range_permutation.h \
355355
key_from_key.h \
356356
lease.h \
357357
lease_file_loader.h \

src/lib/dhcpsrv/address_range_permutation.cc renamed to src/lib/dhcpsrv/ip_range_permutation.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
#include <config.h>
88
#include <asiolink/addr_utilities.h>
9-
#include <dhcpsrv/address_range_permutation.h>
9+
#include <dhcpsrv/ip_range_permutation.h>
1010

1111
using namespace isc::asiolink;
1212

1313
namespace isc {
1414
namespace dhcp {
1515

16-
AddressRangePermutation::AddressRangePermutation(const AddressRangePermutation::Range& range)
16+
IPRangePermutation::IPRangePermutation(const IPRangePermutation::Range& range)
1717
: range_(range), cursor_(addrsInRange(range_.start_, range_.end_) - 1),
1818
state_(), done_(false), generator_() {
1919
std::random_device rd;
2020
generator_.seed(rd());
2121
}
2222

2323
IOAddress
24-
AddressRangePermutation::next(bool& done) {
24+
IPRangePermutation::next(bool& done) {
2525
// If we're done iterating over the pool let's return zero address and
2626
// set the user supplied done flag to true.
2727
if (done_) {

src/lib/dhcpsrv/address_range_permutation.h renamed to src/lib/dhcpsrv/ip_range_permutation.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// License, v. 2.0. If a copy of the MPL was not distributed with this
55
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7-
#ifndef ADDRESS_RANGE_PERMUTATION_H
8-
#define ADDRESS_RANGE_PERMUTATION_H
7+
#ifndef IP_RANGE_PERMUTATION_H
8+
#define IP_RANGE_PERMUTATION_H
99

1010
#include <asiolink/io_address.h>
1111
#include <dhcpsrv/ip_range.h>
@@ -18,7 +18,7 @@
1818
namespace isc {
1919
namespace dhcp {
2020

21-
/// @brief Random IP address permutation based on Fisher-Yates shuffle.
21+
/// @brief Random IP address/prefix permutation based on Fisher-Yates shuffle.
2222
///
2323
/// This class is used to shuffle IP addresses within the specified address
2424
/// range. It is following the Fisher-Yates shuffle algorithm described in
@@ -60,7 +60,7 @@ namespace dhcp {
6060
/// This algorithm guarantees that all IP addresses beloging to the given
6161
/// address range are returned and no duplicates are returned. The addresses
6262
/// are returned in a random order.
63-
class AddressRangePermutation {
63+
class IPRangePermutation {
6464
public:
6565

6666
/// Address range.
@@ -69,7 +69,7 @@ class AddressRangePermutation {
6969
/// @brief Constructor.
7070
///
7171
/// @param range address range for which the permutation will be generated.
72-
AddressRangePermutation(const Range& range);
72+
IPRangePermutation(const Range& range);
7373

7474
/// @brief Checks if the address range has been exhausted.
7575
///
@@ -115,8 +115,8 @@ class AddressRangePermutation {
115115
std::mt19937 generator_;
116116
};
117117

118-
/// @brief Pointer to the @c AddressRangePermutation.
119-
typedef boost::shared_ptr<AddressRangePermutation> AddressRangePermutationPtr;
118+
/// @brief Pointer to the @c IPRangePermutation.
119+
typedef boost::shared_ptr<IPRangePermutation> IPRangePermutationPtr;
120120

121121
} // end of namespace isc::dhcp
122122
} // end of namespace isc

src/lib/dhcpsrv/pool.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include <cc/user_context.h>
1313
#include <dhcp/classify.h>
1414
#include <dhcp/option6_pdexclude.h>
15-
#include <dhcpsrv/address_range_permutation.h>
1615
#include <dhcpsrv/cfg_option.h>
1716
#include <dhcpsrv/lease.h>
17+
#include <dhcpsrv/ip_range_permutation.h>
1818

1919
#include <boost/shared_ptr.hpp>
2020

@@ -170,7 +170,7 @@ class Pool : public isc::data::UserContext, public isc::data::CfgToElement {
170170
/// @brief Returns pointer to the permutation associated with the pool.
171171
///
172172
/// @return Pointer to the address range permutation.
173-
AddressRangePermutationPtr getPermutation() const {
173+
IPRangePermutationPtr getPermutation() const {
174174
return (permutation_);
175175
}
176176

@@ -247,7 +247,7 @@ class Pool : public isc::data::UserContext, public isc::data::CfgToElement {
247247
///
248248
/// It may be initialized for certain pools and poo types to provide
249249
/// address randomization capabilities.
250-
AddressRangePermutationPtr permutation_;
250+
IPRangePermutationPtr permutation_;
251251
};
252252

253253
class Pool4;

src/lib/dhcpsrv/tests/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ libco3_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
5757
TESTS += libdhcpsrv_unittests
5858

5959
libdhcpsrv_unittests_SOURCES = run_unittests.cc
60-
libdhcpsrv_unittests_SOURCES += address_range_permutation_unittest.cc
6160
libdhcpsrv_unittests_SOURCES += alloc_engine_utils.cc alloc_engine_utils.h
6261
libdhcpsrv_unittests_SOURCES += alloc_engine_expiration_unittest.cc
6362
libdhcpsrv_unittests_SOURCES += alloc_engine_hooks_unittest.cc
@@ -100,6 +99,7 @@ libdhcpsrv_unittests_SOURCES += host_reservation_parser_unittest.cc
10099
libdhcpsrv_unittests_SOURCES += host_reservations_list_parser_unittest.cc
101100
libdhcpsrv_unittests_SOURCES += ifaces_config_parser_unittest.cc
102101
libdhcpsrv_unittests_SOURCES += ip_range_unittest.cc
102+
libdhcpsrv_unittests_SOURCES += ip_range_permutation_unittest.cc
103103
libdhcpsrv_unittests_SOURCES += lease_file_loader_unittest.cc
104104
libdhcpsrv_unittests_SOURCES += lease_unittest.cc
105105
libdhcpsrv_unittests_SOURCES += lease_mgr_factory_unittest.cc

src/lib/dhcpsrv/tests/address_range_permutation_unittest.cc renamed to src/lib/dhcpsrv/tests/ip_range_permutation_unittest.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

77
#include <config.h>
8-
#include <dhcpsrv/address_range_permutation.h>
8+
#include <dhcpsrv/ip_range_permutation.h>
99

1010
#include <gtest/gtest.h>
1111

@@ -19,23 +19,23 @@ namespace {
1919

2020
// This test verifies that the object can be successfully constructed for
2121
// both IPv4 and IPv6 address range.
22-
TEST(AddressRangePermutationTest, constructor) {
22+
TEST(IPRangePermutationTest, constructor) {
2323
ASSERT_NO_THROW({
24-
AddressRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
25-
AddressRangePermutation perm(range);
24+
IPRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
25+
IPRangePermutation perm(range);
2626
});
2727
ASSERT_NO_THROW({
28-
AddressRangePermutation::Range range(IOAddress("3000::"), IOAddress("3000::10"));
29-
AddressRangePermutation perm(range);
28+
IPRangePermutation::Range range(IOAddress("3000::"), IOAddress("3000::10"));
29+
IPRangePermutation perm(range);
3030
});
3131
}
3232

3333
// This test verifies that a permutation of IPv4 address range can
3434
// be generated.
35-
TEST(AddressRangePermutationTest, ipv4) {
35+
TEST(IPRangePermutationTest, ipv4) {
3636
// Create address range with 91 addresses.
37-
AddressRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
38-
AddressRangePermutation perm(range);
37+
IPRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
38+
IPRangePermutation perm(range);
3939

4040
// This set will record unique IP addresses generated.
4141
std::set<IOAddress> addrs;
@@ -66,10 +66,10 @@ TEST(AddressRangePermutationTest, ipv4) {
6666

6767
// This test verifies that a permutation of IPv4 address range can
6868
// be generated.
69-
TEST(AddressRangePermutationTest, ipv6) {
70-
AddressRangePermutation::Range range(IOAddress("2001:db8:1::1:fea0"),
69+
TEST(IPRangePermutationTest, ipv6) {
70+
IPRangePermutation::Range range(IOAddress("2001:db8:1::1:fea0"),
7171
IOAddress("2001:db8:1::2:abcd"));
72-
AddressRangePermutation perm(range);
72+
IPRangePermutation perm(range);
7373

7474
std::set<IOAddress> addrs;
7575
bool done = false;

0 commit comments

Comments
 (0)