mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-02 15:05:16 +00:00
[#1415] Do not use nested types
Removed Range and PrefixRange typedefs from FreeLeaseQueue and IPRangePermutation. This prevents compilation failures with g++.
This commit is contained in:
@@ -24,7 +24,7 @@ FreeLeaseQueue::FreeLeaseQueue()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FreeLeaseQueue::addRange(const Range& range) {
|
FreeLeaseQueue::addRange(const AddressRange& range) {
|
||||||
// If the container with ranges is empty, there are is no need for
|
// If the container with ranges is empty, there are is no need for
|
||||||
// doing any checks. Let's just add the new range.
|
// doing any checks. Let's just add the new range.
|
||||||
if (!containers_.empty()) {
|
if (!containers_.empty()) {
|
||||||
@@ -36,7 +36,7 @@ FreeLeaseQueue::addRange(const Range& range) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
FreeLeaseQueue::addRange(const IOAddress& start, const IOAddress& end) {
|
FreeLeaseQueue::addRange(const IOAddress& start, const IOAddress& end) {
|
||||||
addRange(FreeLeaseQueue::Range(start, end));
|
addRange(AddressRange(start, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -52,7 +52,7 @@ FreeLeaseQueue::addRange(const PrefixRange& range) {
|
|||||||
void
|
void
|
||||||
FreeLeaseQueue::addRange(const asiolink::IOAddress& prefix, const uint8_t prefix_length,
|
FreeLeaseQueue::addRange(const asiolink::IOAddress& prefix, const uint8_t prefix_length,
|
||||||
const uint8_t delegated_length) {
|
const uint8_t delegated_length) {
|
||||||
addRange(FreeLeaseQueue::PrefixRange(prefix, prefix_length, delegated_length));
|
addRange(PrefixRange(prefix, prefix_length, delegated_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -76,7 +76,7 @@ FreeLeaseQueue::append(const IOAddress& address) {
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
// Use the range we found and append the address to it.
|
// Use the range we found and append the address to it.
|
||||||
FreeLeaseQueue::Range range(lb->range_start_, lb->range_end_);
|
AddressRange range(lb->range_start_, lb->range_end_);
|
||||||
append(range, address);
|
append(range, address);
|
||||||
|
|
||||||
// Everything is fine.
|
// Everything is fine.
|
||||||
@@ -105,7 +105,7 @@ FreeLeaseQueue::append(const IOAddress& prefix, const uint8_t delegated_length)
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
// Use the range we found and append the prefix to it.
|
// Use the range we found and append the prefix to it.
|
||||||
FreeLeaseQueue::PrefixRange range(lb->range_start_, lb->range_end_, lb->delegated_length_);
|
PrefixRange range(lb->range_start_, lb->range_end_, lb->delegated_length_);
|
||||||
append(range, prefix);
|
append(range, prefix);
|
||||||
|
|
||||||
// Everything is fine.
|
// Everything is fine.
|
||||||
@@ -113,7 +113,7 @@ FreeLeaseQueue::append(const IOAddress& prefix, const uint8_t delegated_length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FreeLeaseQueue::append(const FreeLeaseQueue::Range& range, const IOAddress& address) {
|
FreeLeaseQueue::append(const AddressRange& range, const IOAddress& address) {
|
||||||
// Make sure the address is within the range boundaries.
|
// Make sure the address is within the range boundaries.
|
||||||
checkRangeBoundaries(range, address);
|
checkRangeBoundaries(range, address);
|
||||||
auto cont = getContainer(range);
|
auto cont = getContainer(range);
|
||||||
@@ -131,14 +131,14 @@ FreeLeaseQueue::append(const uint64_t range_index, const IOAddress& ip) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FreeLeaseQueue::append(const FreeLeaseQueue::PrefixRange& range, const asiolink::IOAddress& prefix) {
|
FreeLeaseQueue::append(const PrefixRange& range, const asiolink::IOAddress& prefix) {
|
||||||
checkRangeBoundaries(range, prefix, true);
|
checkRangeBoundaries(range, prefix, true);
|
||||||
auto cont = getContainer(range);
|
auto cont = getContainer(range);
|
||||||
cont->insert(prefix);
|
cont->insert(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FreeLeaseQueue::use(const FreeLeaseQueue::Range& range, const IOAddress& address) {
|
FreeLeaseQueue::use(const AddressRange& range, const IOAddress& address) {
|
||||||
checkRangeBoundaries(range, address);
|
checkRangeBoundaries(range, address);
|
||||||
auto cont = getContainer(range);
|
auto cont = getContainer(range);
|
||||||
auto found = cont->find(address);
|
auto found = cont->find(address);
|
||||||
@@ -150,7 +150,7 @@ FreeLeaseQueue::use(const FreeLeaseQueue::Range& range, const IOAddress& address
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FreeLeaseQueue::use(const FreeLeaseQueue::PrefixRange& range, const IOAddress& prefix) {
|
FreeLeaseQueue::use(const PrefixRange& range, const IOAddress& prefix) {
|
||||||
checkRangeBoundaries(range, prefix, true);
|
checkRangeBoundaries(range, prefix, true);
|
||||||
auto cont = getContainer(range);
|
auto cont = getContainer(range);
|
||||||
auto found = cont->find(prefix);
|
auto found = cont->find(prefix);
|
||||||
@@ -216,7 +216,7 @@ FreeLeaseQueue::checkRangeOverlaps(const IOAddress& start, const IOAddress& end)
|
|||||||
|
|
||||||
|
|
||||||
FreeLeaseQueue::ContainerPtr
|
FreeLeaseQueue::ContainerPtr
|
||||||
FreeLeaseQueue::getContainer(const FreeLeaseQueue::Range& range) const {
|
FreeLeaseQueue::getContainer(const AddressRange& range) const {
|
||||||
auto cont = containers_.find(range.start_);
|
auto cont = containers_.find(range.start_);
|
||||||
if (cont == containers_.end()) {
|
if (cont == containers_.end()) {
|
||||||
isc_throw(BadValue, "conatiner for the specified address range " << range.start_
|
isc_throw(BadValue, "conatiner for the specified address range " << range.start_
|
||||||
@@ -226,7 +226,7 @@ FreeLeaseQueue::getContainer(const FreeLeaseQueue::Range& range) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FreeLeaseQueue::ContainerPtr
|
FreeLeaseQueue::ContainerPtr
|
||||||
FreeLeaseQueue::getContainer(const FreeLeaseQueue::PrefixRange& range) const {
|
FreeLeaseQueue::getContainer(const PrefixRange& range) const {
|
||||||
auto cont = containers_.find(range.start_);
|
auto cont = containers_.find(range.start_);
|
||||||
if (cont == containers_.end()) {
|
if (cont == containers_.end()) {
|
||||||
isc_throw(BadValue, "conatiner for the specified prefix " << range.start_
|
isc_throw(BadValue, "conatiner for the specified prefix " << range.start_
|
||||||
|
@@ -76,12 +76,6 @@ namespace dhcp {
|
|||||||
class FreeLeaseQueue {
|
class FreeLeaseQueue {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// @brief Structure representing address range in the @c FreeLeaseQueue.
|
|
||||||
typedef AddressRange Range;
|
|
||||||
|
|
||||||
/// @brief Structure representing delegated prefix range in @c FreeLeaseQueue.
|
|
||||||
typedef PrefixRange PrefixRange;
|
|
||||||
|
|
||||||
/// @brief Constructor.
|
/// @brief Constructor.
|
||||||
FreeLeaseQueue();
|
FreeLeaseQueue();
|
||||||
|
|
||||||
@@ -91,7 +85,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param range the new range to be added.
|
/// @param range the new range to be added.
|
||||||
/// @throw BadValue if the new range overlaps with any of the existing ranges.
|
/// @throw BadValue if the new range overlaps with any of the existing ranges.
|
||||||
void addRange(const Range& range);
|
void addRange(const AddressRange& range);
|
||||||
|
|
||||||
/// @brief Adds new address range to the container.
|
/// @brief Adds new address range to the container.
|
||||||
///
|
///
|
||||||
@@ -169,7 +163,7 @@ public:
|
|||||||
/// @param address address to be appended to the range queue.
|
/// @param address address to be appended to the range queue.
|
||||||
/// @throw BadValue if the address does not belong to the specified
|
/// @throw BadValue if the address does not belong to the specified
|
||||||
/// range or if the given range does not exist.
|
/// range or if the given range does not exist.
|
||||||
void append(const Range& range, const asiolink::IOAddress& address);
|
void append(const AddressRange& range, const asiolink::IOAddress& address);
|
||||||
|
|
||||||
/// @brief Appends a prefix at the end of the queue for a range.
|
/// @brief Appends a prefix at the end of the queue for a range.
|
||||||
///
|
///
|
||||||
@@ -209,7 +203,7 @@ public:
|
|||||||
/// @return true if the address was found and successfully removed,
|
/// @return true if the address was found and successfully removed,
|
||||||
/// false otherwise.
|
/// false otherwise.
|
||||||
/// @throw BadValue if the range does not exist.
|
/// @throw BadValue if the range does not exist.
|
||||||
bool use(const Range& range, const asiolink::IOAddress& address);
|
bool use(const AddressRange& range, const asiolink::IOAddress& address);
|
||||||
|
|
||||||
/// @brief Removes the specified delegated prefix from the free prefixes.
|
/// @brief Removes the specified delegated prefix from the free prefixes.
|
||||||
///
|
///
|
||||||
@@ -228,7 +222,7 @@ public:
|
|||||||
/// for the range.
|
/// for the range.
|
||||||
///
|
///
|
||||||
/// @param range range for which next address is to be returned.
|
/// @param range range for which next address is to be returned.
|
||||||
/// @tparam RangeType type of the range, i.e. @c Range or @c PrefixRange.
|
/// @tparam RangeType type of the range, i.e. @c AddressRange or @c PrefixRange.
|
||||||
/// @return Next free address or delegated prefix in that range.
|
/// @return Next free address or delegated prefix in that range.
|
||||||
/// @throw BadValue if the range does not exist.
|
/// @throw BadValue if the range does not exist.
|
||||||
template<typename RangeType>
|
template<typename RangeType>
|
||||||
@@ -243,7 +237,7 @@ public:
|
|||||||
/// should be appended to the queue using the @c append method.
|
/// should be appended to the queue using the @c append method.
|
||||||
///
|
///
|
||||||
/// @param range range for which next address or prefix is to be returned.
|
/// @param range range for which next address or prefix is to be returned.
|
||||||
/// @tparam RangeType type of the range, i.e. @c Range or @c PrefixRange.
|
/// @tparam RangeType type of the range, i.e. @c AddressRange or @c PrefixRange.
|
||||||
/// @return Next free address or delegated prefix in that range.
|
/// @return Next free address or delegated prefix in that range.
|
||||||
/// @throw BadValue if the range does not exist.
|
/// @throw BadValue if the range does not exist.
|
||||||
template<typename RangeType>
|
template<typename RangeType>
|
||||||
@@ -258,7 +252,7 @@ public:
|
|||||||
/// range itself because it uses random access index.
|
/// range itself because it uses random access index.
|
||||||
///
|
///
|
||||||
/// @param range range which index is to be returned.
|
/// @param range range which index is to be returned.
|
||||||
/// @tparam RangeType type of the range, i.e. @c Range or PrefixRange.
|
/// @tparam RangeType type of the range, i.e. @c AddressRange or PrefixRange.
|
||||||
/// @return range index.
|
/// @return range index.
|
||||||
/// @throw BadValue if the range does not exist.
|
/// @throw BadValue if the range does not exist.
|
||||||
template<typename RangeType>
|
template<typename RangeType>
|
||||||
@@ -333,7 +327,7 @@ private:
|
|||||||
/// @param ip address or delegated prefix for which the check should be performed.
|
/// @param ip address or delegated prefix for which the check should be performed.
|
||||||
/// @param prefix boolean value indicating if the specified IP is an address or
|
/// @param prefix boolean value indicating if the specified IP is an address or
|
||||||
/// delegated prefix - used in error logging.
|
/// delegated prefix - used in error logging.
|
||||||
/// @tparam RangeType type of the range used, i.e. @c Range or @c PrefixRange.
|
/// @tparam RangeType type of the range used, i.e. @c AddressRange or @c PrefixRange.
|
||||||
/// @throw BadValue of the address or delegated prefix does not belong to the range.
|
/// @throw BadValue of the address or delegated prefix does not belong to the range.
|
||||||
template<typename RangeType>
|
template<typename RangeType>
|
||||||
void checkRangeBoundaries(const RangeType& range, const asiolink::IOAddress& ip,
|
void checkRangeBoundaries(const RangeType& range, const asiolink::IOAddress& ip,
|
||||||
@@ -353,7 +347,7 @@ private:
|
|||||||
/// @param range range for which the container should be returned.
|
/// @param range range for which the container should be returned.
|
||||||
/// @return Pointer to the container (if found).
|
/// @return Pointer to the container (if found).
|
||||||
/// @throw BadValue if the specified range does not exist.
|
/// @throw BadValue if the specified range does not exist.
|
||||||
ContainerPtr getContainer(const Range& range) const;
|
ContainerPtr getContainer(const AddressRange& range) const;
|
||||||
|
|
||||||
/// @brief Returns container for a given prefix range.
|
/// @brief Returns container for a given prefix range.
|
||||||
///
|
///
|
||||||
|
@@ -15,14 +15,14 @@ using namespace isc::asiolink;
|
|||||||
namespace isc {
|
namespace isc {
|
||||||
namespace dhcp {
|
namespace dhcp {
|
||||||
|
|
||||||
IPRangePermutation::IPRangePermutation(const IPRangePermutation::Range& range)
|
IPRangePermutation::IPRangePermutation(const AddressRange& range)
|
||||||
: range_start_(range.start_), step_(1), cursor_(addrsInRange(range_start_, range.end_) - 1),
|
: range_start_(range.start_), step_(1), cursor_(addrsInRange(range_start_, range.end_) - 1),
|
||||||
state_(), done_(false), generator_() {
|
state_(), done_(false), generator_() {
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
generator_.seed(rd());
|
generator_.seed(rd());
|
||||||
}
|
}
|
||||||
|
|
||||||
IPRangePermutation::IPRangePermutation(const IPRangePermutation::PrefixRange& range)
|
IPRangePermutation::IPRangePermutation(const PrefixRange& range)
|
||||||
: range_start_(range.start_), step_(static_cast<uint64_t>(1) << (128 - range.delegated_length_)),
|
: range_start_(range.start_), step_(static_cast<uint64_t>(1) << (128 - range.delegated_length_)),
|
||||||
cursor_(prefixesInRange(range.prefix_length_, range.delegated_length_) - 1),
|
cursor_(prefixesInRange(range.prefix_length_, range.delegated_length_) - 1),
|
||||||
state_(), done_(false), generator_() {
|
state_(), done_(false), generator_() {
|
||||||
|
@@ -63,16 +63,10 @@ namespace dhcp {
|
|||||||
class IPRangePermutation {
|
class IPRangePermutation {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Address range.
|
|
||||||
typedef AddressRange Range;
|
|
||||||
|
|
||||||
/// Prefix range.
|
|
||||||
typedef PrefixRange PrefixRange;
|
|
||||||
|
|
||||||
/// @brief Constructor for address ranges.
|
/// @brief Constructor for address ranges.
|
||||||
///
|
///
|
||||||
/// @param range address range for which the permutation will be generated.
|
/// @param range address range for which the permutation will be generated.
|
||||||
IPRangePermutation(const Range& range);
|
IPRangePermutation(const AddressRange& range);
|
||||||
|
|
||||||
/// @brief Constructor for prefix ranges.
|
/// @brief Constructor for prefix ranges.
|
||||||
///
|
///
|
||||||
|
@@ -145,8 +145,8 @@ TEST(FreeLeaseQueueTest, removeRange) {
|
|||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
// Add two ranges.
|
// Add two ranges.
|
||||||
FreeLeaseQueue::Range range1(IOAddress("192.0.2.99"), IOAddress("192.0.2.100"));
|
AddressRange range1(IOAddress("192.0.2.99"), IOAddress("192.0.2.100"));
|
||||||
FreeLeaseQueue::Range range2(IOAddress("192.0.3.99"), IOAddress("192.0.3.100"));
|
AddressRange range2(IOAddress("192.0.3.99"), IOAddress("192.0.3.100"));
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
ASSERT_NO_THROW(lq.addRange(range2));
|
ASSERT_NO_THROW(lq.addRange(range2));
|
||||||
|
|
||||||
@@ -177,8 +177,8 @@ TEST(FreeLeaseQueueTest, removePrefixRange) {
|
|||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
// Add two ranges.
|
// Add two ranges.
|
||||||
FreeLeaseQueue::PrefixRange range1(IOAddress("3000::"), 64, 96);
|
PrefixRange range1(IOAddress("3000::"), 64, 96);
|
||||||
FreeLeaseQueue::PrefixRange range2(IOAddress("3001::"), 64, 96);
|
PrefixRange range2(IOAddress("3001::"), 64, 96);
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
ASSERT_NO_THROW(lq.addRange(range2));
|
ASSERT_NO_THROW(lq.addRange(range2));
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ TEST(FreeLeaseQueueTest, removePrefixRange) {
|
|||||||
// given range throws and that an attempt to use non-existing in-range
|
// given range throws and that an attempt to use non-existing in-range
|
||||||
// address returns false.
|
// address returns false.
|
||||||
TEST(FreeLeaseQueueTest, useInvalidAddress) {
|
TEST(FreeLeaseQueueTest, useInvalidAddress) {
|
||||||
FreeLeaseQueue::Range range(IOAddress("192.0.2.99"), IOAddress("192.0.2.100"));
|
AddressRange range(IOAddress("192.0.2.99"), IOAddress("192.0.2.100"));
|
||||||
|
|
||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
ASSERT_NO_THROW(lq.addRange(range));
|
ASSERT_NO_THROW(lq.addRange(range));
|
||||||
@@ -226,7 +226,7 @@ TEST(FreeLeaseQueueTest, useInvalidAddress) {
|
|||||||
// given range throws and that an attempt to use non-existing in-range
|
// given range throws and that an attempt to use non-existing in-range
|
||||||
// address returns false.
|
// address returns false.
|
||||||
TEST(FreeLeaseQueueTest, useInvalidPrefix) {
|
TEST(FreeLeaseQueueTest, useInvalidPrefix) {
|
||||||
FreeLeaseQueue::PrefixRange range(IOAddress("2001:db8:1::"), 64, 96);
|
PrefixRange range(IOAddress("2001:db8:1::"), 64, 96);
|
||||||
|
|
||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
ASSERT_NO_THROW(lq.addRange(range));
|
ASSERT_NO_THROW(lq.addRange(range));
|
||||||
@@ -245,7 +245,7 @@ TEST(FreeLeaseQueueTest, useInvalidPrefix) {
|
|||||||
TEST(FreeLeaseQueueTest, appendDuplicates) {
|
TEST(FreeLeaseQueueTest, appendDuplicates) {
|
||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
FreeLeaseQueue::Range range(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
AddressRange range(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
||||||
ASSERT_NO_THROW(lq.addRange(range));
|
ASSERT_NO_THROW(lq.addRange(range));
|
||||||
|
|
||||||
ASSERT_NO_THROW(lq.append(range, IOAddress("192.0.2.10")));
|
ASSERT_NO_THROW(lq.append(range, IOAddress("192.0.2.10")));
|
||||||
@@ -270,16 +270,16 @@ TEST(FreeLeaseQueueTest, next) {
|
|||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
// Let's create two distinct address ranges.
|
// Let's create two distinct address ranges.
|
||||||
FreeLeaseQueue::Range range1(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
AddressRange range1(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
||||||
FreeLeaseQueue::Range range2(IOAddress("192.0.3.1"), IOAddress("192.0.3.255"));
|
AddressRange range2(IOAddress("192.0.3.1"), IOAddress("192.0.3.255"));
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
ASSERT_NO_THROW(lq.addRange(range2));
|
ASSERT_NO_THROW(lq.addRange(range2));
|
||||||
|
|
||||||
// Append some IP addresses to those address ranges.
|
// Append some IP addresses to those address ranges.
|
||||||
ASSERT_NO_THROW(lq.append(FreeLeaseQueue::Range(range1), IOAddress("192.0.2.10")));
|
ASSERT_NO_THROW(lq.append(AddressRange(range1), IOAddress("192.0.2.10")));
|
||||||
ASSERT_NO_THROW(lq.append(FreeLeaseQueue::Range(range1), IOAddress("192.0.2.5")));
|
ASSERT_NO_THROW(lq.append(AddressRange(range1), IOAddress("192.0.2.5")));
|
||||||
ASSERT_NO_THROW(lq.append(FreeLeaseQueue::Range(range2), IOAddress("192.0.3.23")));
|
ASSERT_NO_THROW(lq.append(AddressRange(range2), IOAddress("192.0.3.23")));
|
||||||
ASSERT_NO_THROW(lq.append(FreeLeaseQueue::Range(range2), IOAddress("192.0.3.46")));
|
ASSERT_NO_THROW(lq.append(AddressRange(range2), IOAddress("192.0.3.46")));
|
||||||
|
|
||||||
// Get the first address from the first range.
|
// Get the first address from the first range.
|
||||||
IOAddress next(0);
|
IOAddress next(0);
|
||||||
@@ -328,7 +328,7 @@ TEST(FreeLeaseQueueTest, next) {
|
|||||||
TEST(FreeLeaseQueueTest, nextPrefix) {
|
TEST(FreeLeaseQueueTest, nextPrefix) {
|
||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
FreeLeaseQueue::PrefixRange range1(IOAddress("2001:db8:1::"), 64, 96);
|
PrefixRange range1(IOAddress("2001:db8:1::"), 64, 96);
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
|
|
||||||
ASSERT_NO_THROW(lq.append(range1, IOAddress("2001:db8:1::4:0")));
|
ASSERT_NO_THROW(lq.append(range1, IOAddress("2001:db8:1::4:0")));
|
||||||
@@ -369,16 +369,16 @@ TEST(FreeLeaseQueueTest, pop) {
|
|||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
// Let's create two distinct address ranges.
|
// Let's create two distinct address ranges.
|
||||||
FreeLeaseQueue::Range range1(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
AddressRange range1(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
||||||
FreeLeaseQueue::Range range2(IOAddress("192.0.3.1"), IOAddress("192.0.3.255"));
|
AddressRange range2(IOAddress("192.0.3.1"), IOAddress("192.0.3.255"));
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
ASSERT_NO_THROW(lq.addRange(range2));
|
ASSERT_NO_THROW(lq.addRange(range2));
|
||||||
|
|
||||||
// Append some IP addresses to those address ranges.
|
// Append some IP addresses to those address ranges.
|
||||||
ASSERT_NO_THROW(lq.append(FreeLeaseQueue::Range(range1), IOAddress("192.0.2.10")));
|
ASSERT_NO_THROW(lq.append(AddressRange(range1), IOAddress("192.0.2.10")));
|
||||||
ASSERT_NO_THROW(lq.append(FreeLeaseQueue::Range(range1), IOAddress("192.0.2.5")));
|
ASSERT_NO_THROW(lq.append(AddressRange(range1), IOAddress("192.0.2.5")));
|
||||||
ASSERT_NO_THROW(lq.append(FreeLeaseQueue::Range(range2), IOAddress("192.0.3.23")));
|
ASSERT_NO_THROW(lq.append(AddressRange(range2), IOAddress("192.0.3.23")));
|
||||||
ASSERT_NO_THROW(lq.append(FreeLeaseQueue::Range(range2), IOAddress("192.0.3.46")));
|
ASSERT_NO_THROW(lq.append(AddressRange(range2), IOAddress("192.0.3.46")));
|
||||||
|
|
||||||
// Pop first from first range.
|
// Pop first from first range.
|
||||||
IOAddress next(0);
|
IOAddress next(0);
|
||||||
@@ -410,7 +410,7 @@ TEST(FreeLeaseQueueTest, popPrefix) {
|
|||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
// Add the range.
|
// Add the range.
|
||||||
FreeLeaseQueue::PrefixRange range1(IOAddress("2001:db8:1::"), 64, 96);
|
PrefixRange range1(IOAddress("2001:db8:1::"), 64, 96);
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
|
|
||||||
// Append several prefixes to that range.
|
// Append several prefixes to that range.
|
||||||
@@ -443,10 +443,10 @@ TEST(FreeLeaseQueueTest, popPrefix) {
|
|||||||
|
|
||||||
// Check that out of bounds address can't be appended to the range.
|
// Check that out of bounds address can't be appended to the range.
|
||||||
TEST(FreeLeaseQueueTest, nextRangeMismatch) {
|
TEST(FreeLeaseQueueTest, nextRangeMismatch) {
|
||||||
FreeLeaseQueue::Range range(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
AddressRange range(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
||||||
|
|
||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
EXPECT_THROW(lq.append(FreeLeaseQueue::Range(range), IOAddress("192.0.3.1")),
|
EXPECT_THROW(lq.append(AddressRange(range), IOAddress("192.0.3.1")),
|
||||||
isc::BadValue);
|
isc::BadValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,9 +456,9 @@ TEST(FreeLeaseQueueTest, detectRange) {
|
|||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
// Create three ranges.
|
// Create three ranges.
|
||||||
FreeLeaseQueue::Range range1(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
AddressRange range1(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
||||||
FreeLeaseQueue::Range range2(IOAddress("192.0.3.1"), IOAddress("192.0.3.255"));
|
AddressRange range2(IOAddress("192.0.3.1"), IOAddress("192.0.3.255"));
|
||||||
FreeLeaseQueue::Range range3(IOAddress("10.0.0.1"), IOAddress("10.8.1.45"));
|
AddressRange range3(IOAddress("10.0.0.1"), IOAddress("10.8.1.45"));
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
ASSERT_NO_THROW(lq.addRange(range2));
|
ASSERT_NO_THROW(lq.addRange(range2));
|
||||||
ASSERT_NO_THROW(lq.addRange(range3));
|
ASSERT_NO_THROW(lq.addRange(range3));
|
||||||
@@ -499,9 +499,9 @@ TEST(FreeLeaseQueueTest, detectPrefixRange) {
|
|||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
// Create three ranges.
|
// Create three ranges.
|
||||||
FreeLeaseQueue::PrefixRange range1(IOAddress("2001:db8:1::"), 64, 96);
|
PrefixRange range1(IOAddress("2001:db8:1::"), 64, 96);
|
||||||
FreeLeaseQueue::PrefixRange range2(IOAddress("2001:db8:2::"), 112, 120);
|
PrefixRange range2(IOAddress("2001:db8:2::"), 112, 120);
|
||||||
FreeLeaseQueue::PrefixRange range3(IOAddress("2001:db8:3::"), 96, 104);
|
PrefixRange range3(IOAddress("2001:db8:3::"), 96, 104);
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
ASSERT_NO_THROW(lq.addRange(range2));
|
ASSERT_NO_THROW(lq.addRange(range2));
|
||||||
ASSERT_NO_THROW(lq.addRange(range3));
|
ASSERT_NO_THROW(lq.addRange(range3));
|
||||||
@@ -540,7 +540,7 @@ TEST(FreeLeaseQueueTest, detectPrefixRange) {
|
|||||||
// This test verifies that false is returned if the specified address to be
|
// This test verifies that false is returned if the specified address to be
|
||||||
// appended does not belong to any of the existing ranges.
|
// appended does not belong to any of the existing ranges.
|
||||||
TEST(FreeLeaseQueueTest, detectRangeFailed) {
|
TEST(FreeLeaseQueueTest, detectRangeFailed) {
|
||||||
FreeLeaseQueue::Range range(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
AddressRange range(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
||||||
|
|
||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
ASSERT_NO_THROW(lq.addRange(range));
|
ASSERT_NO_THROW(lq.addRange(range));
|
||||||
@@ -553,9 +553,9 @@ TEST(FreeLeaseQueueTest, detectRangeFailed) {
|
|||||||
TEST(FreeLeaseQueueTest, appendThroughRangeIndex) {
|
TEST(FreeLeaseQueueTest, appendThroughRangeIndex) {
|
||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
FreeLeaseQueue::Range range1(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
AddressRange range1(IOAddress("192.0.2.1"), IOAddress("192.0.2.255"));
|
||||||
FreeLeaseQueue::Range range2(IOAddress("192.0.3.1"), IOAddress("192.0.3.255"));
|
AddressRange range2(IOAddress("192.0.3.1"), IOAddress("192.0.3.255"));
|
||||||
FreeLeaseQueue::Range range3(IOAddress("10.0.0.1"), IOAddress("10.8.1.45"));
|
AddressRange range3(IOAddress("10.0.0.1"), IOAddress("10.8.1.45"));
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
ASSERT_NO_THROW(lq.addRange(range2));
|
ASSERT_NO_THROW(lq.addRange(range2));
|
||||||
ASSERT_NO_THROW(lq.addRange(range3));
|
ASSERT_NO_THROW(lq.addRange(range3));
|
||||||
@@ -584,9 +584,9 @@ TEST(FreeLeaseQueueTest, appendThroughRangeIndex) {
|
|||||||
TEST(FreeLeaseQueueTest, appendPrefixThroughRangeIndex) {
|
TEST(FreeLeaseQueueTest, appendPrefixThroughRangeIndex) {
|
||||||
FreeLeaseQueue lq;
|
FreeLeaseQueue lq;
|
||||||
|
|
||||||
FreeLeaseQueue::PrefixRange range1(IOAddress("2001:db8:1::"), 64, 96);
|
PrefixRange range1(IOAddress("2001:db8:1::"), 64, 96);
|
||||||
FreeLeaseQueue::PrefixRange range2(IOAddress("2001:db8:2::"), 64, 96);
|
PrefixRange range2(IOAddress("2001:db8:2::"), 64, 96);
|
||||||
FreeLeaseQueue::PrefixRange range3(IOAddress("2001:db8:3::"), 64, 96);
|
PrefixRange range3(IOAddress("2001:db8:3::"), 64, 96);
|
||||||
ASSERT_NO_THROW(lq.addRange(range1));
|
ASSERT_NO_THROW(lq.addRange(range1));
|
||||||
ASSERT_NO_THROW(lq.addRange(range2));
|
ASSERT_NO_THROW(lq.addRange(range2));
|
||||||
ASSERT_NO_THROW(lq.addRange(range3));
|
ASSERT_NO_THROW(lq.addRange(range3));
|
||||||
|
@@ -21,11 +21,11 @@ namespace {
|
|||||||
// both IPv4 and IPv6 address range.
|
// both IPv4 and IPv6 address range.
|
||||||
TEST(IPRangePermutationTest, constructor) {
|
TEST(IPRangePermutationTest, constructor) {
|
||||||
ASSERT_NO_THROW({
|
ASSERT_NO_THROW({
|
||||||
IPRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
|
AddressRange range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
|
||||||
IPRangePermutation perm(range);
|
IPRangePermutation perm(range);
|
||||||
});
|
});
|
||||||
ASSERT_NO_THROW({
|
ASSERT_NO_THROW({
|
||||||
IPRangePermutation::Range range(IOAddress("3000::"), IOAddress("3000::10"));
|
AddressRange range(IOAddress("3000::"), IOAddress("3000::10"));
|
||||||
IPRangePermutation perm(range);
|
IPRangePermutation perm(range);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ TEST(IPRangePermutationTest, constructor) {
|
|||||||
// be generated.
|
// be generated.
|
||||||
TEST(IPRangePermutationTest, ipv4) {
|
TEST(IPRangePermutationTest, ipv4) {
|
||||||
// Create address range with 91 addresses.
|
// Create address range with 91 addresses.
|
||||||
IPRangePermutation::Range range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
|
AddressRange range(IOAddress("192.0.2.10"), IOAddress("192.0.2.100"));
|
||||||
IPRangePermutation perm(range);
|
IPRangePermutation perm(range);
|
||||||
|
|
||||||
// This set will record unique IP addresses generated.
|
// This set will record unique IP addresses generated.
|
||||||
@@ -67,7 +67,7 @@ TEST(IPRangePermutationTest, ipv4) {
|
|||||||
// This test verifies that a permutation of IPv6 address range can
|
// This test verifies that a permutation of IPv6 address range can
|
||||||
// be generated.
|
// be generated.
|
||||||
TEST(IPRangePermutationTest, ipv6) {
|
TEST(IPRangePermutationTest, ipv6) {
|
||||||
IPRangePermutation::Range range(IOAddress("2001:db8:1::1:fea0"),
|
AddressRange range(IOAddress("2001:db8:1::1:fea0"),
|
||||||
IOAddress("2001:db8:1::2:abcd"));
|
IOAddress("2001:db8:1::2:abcd"));
|
||||||
IPRangePermutation perm(range);
|
IPRangePermutation perm(range);
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ TEST(IPRangePermutationTest, ipv6) {
|
|||||||
// This test verifies that a permutation of delegated prefixes can be
|
// This test verifies that a permutation of delegated prefixes can be
|
||||||
// generated.
|
// generated.
|
||||||
TEST(IPRangePermutationTest, pd) {
|
TEST(IPRangePermutationTest, pd) {
|
||||||
IPRangePermutation::PrefixRange range(IOAddress("3000::"), 112, 120);
|
PrefixRange range(IOAddress("3000::"), 112, 120);
|
||||||
IPRangePermutation perm(range);
|
IPRangePermutation perm(range);
|
||||||
|
|
||||||
std::set<IOAddress> addrs;
|
std::set<IOAddress> addrs;
|
||||||
|
Reference in New Issue
Block a user