Skip to content

Commit cba758e

Browse files
committed
[#1415] Added permutation ptr to the pool
1 parent 8c54ebb commit cba758e

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/lib/dhcpsrv/address_range_permutation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <asiolink/io_address.h>
1111
#include <dhcpsrv/address_range.h>
1212

13+
#include <boost/shared_ptr.hpp>
14+
1315
#include <map>
1416
#include <random>
1517

@@ -113,6 +115,9 @@ class AddressRangePermutation {
113115
std::mt19937 generator_;
114116
};
115117

118+
/// @brief Pointer to the @c AddressRangePermutation.
119+
typedef boost::shared_ptr<AddressRangePermutation> AddressRangePermutationPtr;
120+
116121
} // end of namespace isc::dhcp
117122
} // end of namespace isc
118123

src/lib/dhcpsrv/pool.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Pool::Pool(Lease::Type type, const isc::asiolink::IOAddress& first,
2222
const isc::asiolink::IOAddress& last)
2323
:id_(getNextID()), first_(first), last_(last), type_(type),
2424
capacity_(0), cfg_option_(new CfgOption()), client_class_(""),
25-
last_allocated_(first), last_allocated_valid_(false) {
25+
last_allocated_(first), last_allocated_valid_(false),
26+
permutation_() {
2627
}
2728

2829
bool Pool::inRange(const isc::asiolink::IOAddress& addr) const {

src/lib/dhcpsrv/pool.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC")
1+
// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC")
22
//
33
// This Source Code Form is subject to the terms of the Mozilla Public
44
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -8,13 +8,14 @@
88
#define POOL_H
99

1010
#include <asiolink/io_address.h>
11-
#include <dhcp/classify.h>
12-
#include <dhcp/option6_pdexclude.h>
13-
#include <boost/shared_ptr.hpp>
1411
#include <cc/data.h>
1512
#include <cc/user_context.h>
13+
#include <dhcp/classify.h>
14+
#include <dhcp/option6_pdexclude.h>
15+
#include <dhcpsrv/address_range_permutation.h>
1616
#include <dhcpsrv/cfg_option.h>
1717
#include <dhcpsrv/lease.h>
18+
1819
#include <boost/shared_ptr.hpp>
1920

2021
#include <vector>
@@ -166,6 +167,13 @@ class Pool : public isc::data::UserContext, public isc::data::CfgToElement {
166167
/// @return A pointer to unparsed pool configuration.
167168
virtual data::ElementPtr toElement() const;
168169

170+
/// @brief Returns pointer to the permutation associated with the pool.
171+
///
172+
/// @return Pointer to the address range permutation.
173+
AddressRangePermutationPtr getPermutation() const {
174+
return (permutation_);
175+
}
176+
169177
protected:
170178

171179
/// @brief protected constructor
@@ -234,6 +242,12 @@ class Pool : public isc::data::UserContext, public isc::data::CfgToElement {
234242

235243
/// @brief Status of last allocated address
236244
bool last_allocated_valid_;
245+
246+
/// @brief Pointer to the permutation object.
247+
///
248+
/// It may be initialized for certain pools and poo types to provide
249+
/// address randomization capabilities.
250+
AddressRangePermutationPtr permutation_;
237251
};
238252

239253
class Pool4;

0 commit comments

Comments
 (0)