Skip to content

Commit 38f142a

Browse files
committed
[#1415] Do not use nested types
Removed Range and PrefixRange typedefs from FreeLeaseQueue and IPRangePermutation. This prevents compilation failures with g++.
1 parent 03330c8 commit 38f142a

File tree

6 files changed

+63
-75
lines changed

6 files changed

+63
-75
lines changed

src/lib/dhcpsrv/free_lease_queue.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ FreeLeaseQueue::FreeLeaseQueue()
2424
}
2525

2626
void
27-
FreeLeaseQueue::addRange(const Range& range) {
27+
FreeLeaseQueue::addRange(const AddressRange& range) {
2828
// If the container with ranges is empty, there are is no need for
2929
// doing any checks. Let's just add the new range.
3030
if (!containers_.empty()) {
@@ -36,7 +36,7 @@ FreeLeaseQueue::addRange(const Range& range) {
3636

3737
void
3838
FreeLeaseQueue::addRange(const IOAddress& start, const IOAddress& end) {
39-
addRange(FreeLeaseQueue::Range(start, end));
39+
addRange(AddressRange(start, end));
4040
}
4141

4242
void
@@ -52,7 +52,7 @@ FreeLeaseQueue::addRange(const PrefixRange& range) {
5252
void
5353
FreeLeaseQueue::addRange(const asiolink::IOAddress& prefix, const uint8_t prefix_length,
5454
const uint8_t delegated_length) {
55-
addRange(FreeLeaseQueue::PrefixRange(prefix, prefix_length, delegated_length));
55+
addRange(PrefixRange(prefix, prefix_length, delegated_length));
5656
}
5757

5858
bool
@@ -76,7 +76,7 @@ FreeLeaseQueue::append(const IOAddress& address) {
7676
return (false);
7777
}
7878
// Use the range we found and append the address to it.
79-
FreeLeaseQueue::Range range(lb->range_start_, lb->range_end_);
79+
AddressRange range(lb->range_start_, lb->range_end_);
8080
append(range, address);
8181

8282
// Everything is fine.
@@ -105,15 +105,15 @@ FreeLeaseQueue::append(const IOAddress& prefix, const uint8_t delegated_length)
105105
return (false);
106106
}
107107
// Use the range we found and append the prefix to it.
108-
FreeLeaseQueue::PrefixRange range(lb->range_start_, lb->range_end_, lb->delegated_length_);
108+
PrefixRange range(lb->range_start_, lb->range_end_, lb->delegated_length_);
109109
append(range, prefix);
110110

111111
// Everything is fine.
112112
return (true);
113113
}
114114

115115
void
116-
FreeLeaseQueue::append(const FreeLeaseQueue::Range& range, const IOAddress& address) {
116+
FreeLeaseQueue::append(const AddressRange& range, const IOAddress& address) {
117117
// Make sure the address is within the range boundaries.
118118
checkRangeBoundaries(range, address);
119119
auto cont = getContainer(range);
@@ -131,14 +131,14 @@ FreeLeaseQueue::append(const uint64_t range_index, const IOAddress& ip) {
131131
}
132132

133133
void
134-
FreeLeaseQueue::append(const FreeLeaseQueue::PrefixRange& range, const asiolink::IOAddress& prefix) {
134+
FreeLeaseQueue::append(const PrefixRange& range, const asiolink::IOAddress& prefix) {
135135
checkRangeBoundaries(range, prefix, true);
136136
auto cont = getContainer(range);
137137
cont->insert(prefix);
138138
}
139139

140140
bool
141-
FreeLeaseQueue::use(const FreeLeaseQueue::Range& range, const IOAddress& address) {
141+
FreeLeaseQueue::use(const AddressRange& range, const IOAddress& address) {
142142
checkRangeBoundaries(range, address);
143143
auto cont = getContainer(range);
144144
auto found = cont->find(address);
@@ -150,7 +150,7 @@ FreeLeaseQueue::use(const FreeLeaseQueue::Range& range, const IOAddress& address
150150
}
151151

152152
bool
153-
FreeLeaseQueue::use(const FreeLeaseQueue::PrefixRange& range, const IOAddress& prefix) {
153+
FreeLeaseQueue::use(const PrefixRange& range, const IOAddress& prefix) {
154154
checkRangeBoundaries(range, prefix, true);
155155
auto cont = getContainer(range);
156156
auto found = cont->find(prefix);
@@ -216,7 +216,7 @@ FreeLeaseQueue::checkRangeOverlaps(const IOAddress& start, const IOAddress& end)
216216

217217

218218
FreeLeaseQueue::ContainerPtr
219-
FreeLeaseQueue::getContainer(const FreeLeaseQueue::Range& range) const {
219+
FreeLeaseQueue::getContainer(const AddressRange& range) const {
220220
auto cont = containers_.find(range.start_);
221221
if (cont == containers_.end()) {
222222
isc_throw(BadValue, "conatiner for the specified address range " << range.start_
@@ -226,7 +226,7 @@ FreeLeaseQueue::getContainer(const FreeLeaseQueue::Range& range) const {
226226
}
227227

228228
FreeLeaseQueue::ContainerPtr
229-
FreeLeaseQueue::getContainer(const FreeLeaseQueue::PrefixRange& range) const {
229+
FreeLeaseQueue::getContainer(const PrefixRange& range) const {
230230
auto cont = containers_.find(range.start_);
231231
if (cont == containers_.end()) {
232232
isc_throw(BadValue, "conatiner for the specified prefix " << range.start_

src/lib/dhcpsrv/free_lease_queue.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ namespace dhcp {
7676
class FreeLeaseQueue {
7777
public:
7878

79-
/// @brief Structure representing address range in the @c FreeLeaseQueue.
80-
typedef AddressRange Range;
81-
82-
/// @brief Structure representing delegated prefix range in @c FreeLeaseQueue.
83-
typedef PrefixRange PrefixRange;
84-
8579
/// @brief Constructor.
8680
FreeLeaseQueue();
8781

@@ -91,7 +85,7 @@ class FreeLeaseQueue {
9185
///
9286
/// @param range the new range to be added.
9387
/// @throw BadValue if the new range overlaps with any of the existing ranges.
94-
void addRange(const Range& range);
88+
void addRange(const AddressRange& range);
9589

9690
/// @brief Adds new address range to the container.
9791
///
@@ -169,7 +163,7 @@ class FreeLeaseQueue {
169163
/// @param address address to be appended to the range queue.
170164
/// @throw BadValue if the address does not belong to the specified
171165
/// range or if the given range does not exist.
172-
void append(const Range& range, const asiolink::IOAddress& address);
166+
void append(const AddressRange& range, const asiolink::IOAddress& address);
173167

174168
/// @brief Appends a prefix at the end of the queue for a range.
175169
///
@@ -209,7 +203,7 @@ class FreeLeaseQueue {
209203
/// @return true if the address was found and successfully removed,
210204
/// false otherwise.
211205
/// @throw BadValue if the range does not exist.
212-
bool use(const Range& range, const asiolink::IOAddress& address);
206+
bool use(const AddressRange& range, const asiolink::IOAddress& address);
213207

214208
/// @brief Removes the specified delegated prefix from the free prefixes.
215209
///
@@ -228,7 +222,7 @@ class FreeLeaseQueue {
228222
/// for the range.
229223
///
230224
/// @param range range for which next address is to be returned.
231-
/// @tparam RangeType type of the range, i.e. @c Range or @c PrefixRange.
225+
/// @tparam RangeType type of the range, i.e. @c AddressRange or @c PrefixRange.
232226
/// @return Next free address or delegated prefix in that range.
233227
/// @throw BadValue if the range does not exist.
234228
template<typename RangeType>
@@ -243,7 +237,7 @@ class FreeLeaseQueue {
243237
/// should be appended to the queue using the @c append method.
244238
///
245239
/// @param range range for which next address or prefix is to be returned.
246-
/// @tparam RangeType type of the range, i.e. @c Range or @c PrefixRange.
240+
/// @tparam RangeType type of the range, i.e. @c AddressRange or @c PrefixRange.
247241
/// @return Next free address or delegated prefix in that range.
248242
/// @throw BadValue if the range does not exist.
249243
template<typename RangeType>
@@ -258,7 +252,7 @@ class FreeLeaseQueue {
258252
/// range itself because it uses random access index.
259253
///
260254
/// @param range range which index is to be returned.
261-
/// @tparam RangeType type of the range, i.e. @c Range or PrefixRange.
255+
/// @tparam RangeType type of the range, i.e. @c AddressRange or PrefixRange.
262256
/// @return range index.
263257
/// @throw BadValue if the range does not exist.
264258
template<typename RangeType>
@@ -333,7 +327,7 @@ class FreeLeaseQueue {
333327
/// @param ip address or delegated prefix for which the check should be performed.
334328
/// @param prefix boolean value indicating if the specified IP is an address or
335329
/// delegated prefix - used in error logging.
336-
/// @tparam RangeType type of the range used, i.e. @c Range or @c PrefixRange.
330+
/// @tparam RangeType type of the range used, i.e. @c AddressRange or @c PrefixRange.
337331
/// @throw BadValue of the address or delegated prefix does not belong to the range.
338332
template<typename RangeType>
339333
void checkRangeBoundaries(const RangeType& range, const asiolink::IOAddress& ip,
@@ -353,7 +347,7 @@ class FreeLeaseQueue {
353347
/// @param range range for which the container should be returned.
354348
/// @return Pointer to the container (if found).
355349
/// @throw BadValue if the specified range does not exist.
356-
ContainerPtr getContainer(const Range& range) const;
350+
ContainerPtr getContainer(const AddressRange& range) const;
357351

358352
/// @brief Returns container for a given prefix range.
359353
///

src/lib/dhcpsrv/ip_range_permutation.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ using namespace isc::asiolink;
1515
namespace isc {
1616
namespace dhcp {
1717

18-
IPRangePermutation::IPRangePermutation(const IPRangePermutation::Range& range)
18+
IPRangePermutation::IPRangePermutation(const AddressRange& range)
1919
: range_start_(range.start_), step_(1), cursor_(addrsInRange(range_start_, range.end_) - 1),
2020
state_(), done_(false), generator_() {
2121
std::random_device rd;
2222
generator_.seed(rd());
2323
}
2424

25-
IPRangePermutation::IPRangePermutation(const IPRangePermutation::PrefixRange& range)
25+
IPRangePermutation::IPRangePermutation(const PrefixRange& range)
2626
: range_start_(range.start_), step_(static_cast<uint64_t>(1) << (128 - range.delegated_length_)),
2727
cursor_(prefixesInRange(range.prefix_length_, range.delegated_length_) - 1),
2828
state_(), done_(false), generator_() {

src/lib/dhcpsrv/ip_range_permutation.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,10 @@ namespace dhcp {
6363
class IPRangePermutation {
6464
public:
6565

66-
/// Address range.
67-
typedef AddressRange Range;
68-
69-
/// Prefix range.
70-
typedef PrefixRange PrefixRange;
71-
7266
/// @brief Constructor for address ranges.
7367
///
7468
/// @param range address range for which the permutation will be generated.
75-
IPRangePermutation(const Range& range);
69+
IPRangePermutation(const AddressRange& range);
7670

7771
/// @brief Constructor for prefix ranges.
7872
///

0 commit comments

Comments
 (0)