// Put gathered data into arguments map.
args->set("leases", leases_json);
args->set("count", Element::create(static_cast<int64_t>(leases_json->size())));
- args->set("total-count", Element::create(total_leases));
// Create the response.
ConstElementPtr response =
ASSERT_TRUE(args);
ASSERT_EQ(Element::map, args->getType());
- // Each response must include total number of leases to allow the
- // controlling client to track progress (e.g. percentage of leases
- // already viewed).
- ConstElementPtr total_count = args->get("total-count");
- ASSERT_TRUE(total_count);
- ASSERT_EQ(Element::integer, total_count->getType());
- EXPECT_EQ(4, total_count->intValue());
-
- // For convenience, we also return the number of returned leases,
+ // For convenience, we return the number of returned leases,
// so as the client can check whether there was anything returned
// before parsing the leases structure.
ConstElementPtr page_count = args->get("count");
ASSERT_TRUE(args);
ASSERT_EQ(Element::map, args->getType());
- // Each response must include total number of leases to allow the
- // controlling client to track progress (e.g. percentage of leases
- // already viewed).
- ConstElementPtr total_count = args->get("total-count");
- ASSERT_TRUE(total_count);
- ASSERT_EQ(Element::integer, total_count->getType());
- EXPECT_EQ(4, total_count->intValue());
-
- // For convenience, we also return the number of returned leases,
+ // For convenience, we return the number of returned leases,
// so as the client can check whether there was anything returned
// before parsing the leases structure.
ConstElementPtr page_count = args->get("count");
return (result);
}
-Lease4Collection
-CqlLeaseMgr::getLeases4(const IOAddress& lower_bound_address,
- const IOAddress& upper_bound_address) const {
- // Expecting two IPv4 addresses.
- if (!lower_bound_address.isV4() || !upper_bound_address.isV4()) {
- isc_throw(InvalidAddressFamily, "expected two IPv4 addresses for "
- "retrieving a range of leases, got "
- << lower_bound_address << " and " << upper_bound_address);
- }
-
- if (upper_bound_address < lower_bound_address) {
- isc_throw(InvalidRange, "upper bound address " << upper_bound_address
- << " is lower than lower bound address " << lower_bound_address);
- }
-
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_ADDR_RANGE4)
- .arg(lower_bound_address.toText())
- .arg(upper_bound_address.toText());
-
- // Set up the WHERE clause value
- AnyArray data;
-
- cass_int32_t lb_address_data = static_cast<cass_int32_t>(lower_bound_address.toUint32());
- data.add(&lb_address_data);
-
- cass_int32_t ub_address_data = static_cast<cass_int32_t>(upper_bound_address.toUint32());
- data.add(&ub_address_data);
-
- // Get the data.
- Lease4Collection result;
- std::unique_ptr<CqlLease4Exchange> exchange4(new CqlLease4Exchange(dbconn_));
- exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_RANGE, data, result);
-
- return (result);
-}
-
Lease6Ptr
CqlLeaseMgr::getLease6(Lease::Type lease_type, const IOAddress &addr) const {
std::string addr_data = addr.toText();
return (result);
}
-Lease6Collection
-CqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const {
- isc_throw(NotImplemented, "getLeases6(lower_bound_address, upper_bound_address) "
- "is not implemented");
-}
-
void
CqlLeaseMgr::getExpiredLeases4(Lease4Collection &expired_leases,
const size_t max_leases) const {
getLeases4(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const override;
- /// @brief Returns a range of IPv4 leases.
- ///
- /// @param lower_bound_address IPv4 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv4 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv4 lease found).
- virtual Lease4Collection
- getLeases4(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const override;
-
/// @brief Returns existing IPv6 lease for a given IPv6 address.
///
/// For a given address, we assume that there will be only one lease.
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const override;
- /// @brief Returns a range of IPv6 leases.
- ///
- /// @param lower_bound_address IPv6 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv6 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv6 lease found).
- virtual Lease6Collection
- getLeases6(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const override;
-
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
getLeases4(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const = 0;
- /// @brief Returns a range of IPv4 leases.
- ///
- /// @param lower_bound_address IPv4 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv4 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv4 lease found).
- virtual Lease4Collection
- getLeases4(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const = 0;
-
/// @brief Returns existing IPv6 lease for a given IPv6 address.
///
/// For a given address, we assume that there will be only one lease.
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const = 0;
- /// @brief Returns a range of IPv6 leases.
- ///
- /// @param lower_bound_address IPv6 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv6 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv6 lease found).
- virtual Lease6Collection
- getLeases6(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const = 0;
-
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
return (collection);
}
-Lease4Collection
-Memfile_LeaseMgr::getLeases4(const IOAddress& lower_bound_address,
- const IOAddress& upper_bound_address) const {
- // Expecting two IPv4 addresses.
- if (!lower_bound_address.isV4() || !upper_bound_address.isV4()) {
- isc_throw(InvalidAddressFamily, "expected two IPv4 addresses for "
- "retrieving a range of leases, got "
- << lower_bound_address << " and " << upper_bound_address);
- }
-
- // Check if the range boundaries aren't swapped.
- if (upper_bound_address < lower_bound_address) {
- isc_throw(InvalidRange, "upper bound address " << upper_bound_address
- << " is lower than lower bound address " << lower_bound_address);
- }
-
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET_ADDR_RANGE4)
- .arg(lower_bound_address.toText())
- .arg(upper_bound_address.toText());
-
- Lease4Collection collection;
- const Lease4StorageAddressIndex& idx = storage4_.get<AddressIndexTag>();
- std::pair<Lease4StorageAddressIndex::const_iterator,
- Lease4StorageAddressIndex::const_iterator> l =
- std::make_pair(idx.lower_bound(lower_bound_address),
- idx.upper_bound(upper_bound_address));
-
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease4Ptr(new Lease4(**lease)));
- }
-
- return (collection);
-}
-
Lease6Ptr
Memfile_LeaseMgr::getLease6(Lease::Type type,
const isc::asiolink::IOAddress& addr) const {
return (collection);
}
-Lease6Collection
-Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const {
- // Expecting two IPv6 addresses.
- if (!lower_bound_address.isV6() || !upper_bound_address.isV6()) {
- isc_throw(InvalidAddressFamily, "expected two IPv6 addresses for "
- "retrieving a range of leases, got "
- << lower_bound_address << " and " << upper_bound_address);
- }
-
- // Check if the range boundaries aren't swapped.
- if (upper_bound_address < lower_bound_address) {
- isc_throw(InvalidRange, "upper bound address " << upper_bound_address
- << " is lower than lower bound address " << lower_bound_address);
- }
-
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET_ADDR_RANGE6)
- .arg(lower_bound_address.toText())
- .arg(upper_bound_address.toText());
-
- Lease6Collection collection;
- const Lease6StorageAddressIndex& idx = storage6_.get<AddressIndexTag>();
- std::pair<Lease6StorageAddressIndex::const_iterator,
- Lease6StorageAddressIndex::const_iterator> l =
- std::make_pair(idx.lower_bound(lower_bound_address),
- idx.upper_bound(upper_bound_address));
-
- for (auto lease = l.first; lease != l.second; ++lease) {
- collection.push_back(Lease6Ptr(new Lease6(**lease)));
- }
-
- return (collection);
-}
-
void
Memfile_LeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases,
const size_t max_leases) const {
getLeases4(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const;
- /// @brief Returns a range of IPv4 leases.
- ///
- /// @param lower_bound_address IPv4 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv4 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv4 lease found).
- virtual Lease4Collection
- getLeases4(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const;
-
/// @brief Returns existing IPv6 lease for a given IPv6 address.
///
/// This function returns a copy of the lease. The modification in the
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const;
- /// @brief Returns a range of IPv6 leases.
- ///
- /// @param lower_bound_address IPv6 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv6 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv6 lease found).
- virtual Lease6Collection
- getLeases6(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const;
-
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
return (result);
}
-Lease4Collection
-MySqlLeaseMgr::getLeases4(const IOAddress& lower_bound_address,
- const IOAddress& upper_bound_address) const {
- // Expecting two IPv4 addresses.
- if (!lower_bound_address.isV4() || !upper_bound_address.isV4()) {
- isc_throw(InvalidAddressFamily, "expected two IPv4 addresses for "
- "retrieving a range of leases, got "
- << lower_bound_address << " and " << upper_bound_address);
- }
-
- if (upper_bound_address < lower_bound_address) {
- isc_throw(InvalidRange, "upper bound address " << upper_bound_address
- << " is lower than lower bound address " << lower_bound_address);
- }
-
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_ADDR_RANGE4)
- .arg(lower_bound_address.toText())
- .arg(upper_bound_address.toText());
-
- // Prepare WHERE clause
- MYSQL_BIND inbind[2];
- memset(inbind, 0, sizeof(inbind));
-
- // Bind lower bound address as uint32 value
- uint32_t lb_address_data = lower_bound_address.toUint32();
- inbind[0].buffer_type = MYSQL_TYPE_LONG;
- inbind[0].buffer = reinterpret_cast<char*>(&lb_address_data);
- inbind[0].is_unsigned = MLM_TRUE;
-
- // Bind upper bound address as uint32 value
- uint32_t ub_address_data = upper_bound_address.toUint32();
- inbind[1].buffer_type = MYSQL_TYPE_LONG;
- inbind[1].buffer = reinterpret_cast<char*>(&ub_address_data);
- inbind[1].is_unsigned = MLM_TRUE;
-
- // Get the leases
- Lease4Collection result;
- getLeaseCollection(GET_LEASE4_RANGE, inbind, result);
-
- return (result);
-}
-
Lease6Ptr
MySqlLeaseMgr::getLease6(Lease::Type lease_type,
const isc::asiolink::IOAddress& addr) const {
return (result);
}
-Lease6Collection
-MySqlLeaseMgr::getLeases6(const IOAddress& lower_bound_address,
- const IOAddress& upper_bound_address) const {
- // Expecting two IPv6 addresses.
- if (!lower_bound_address.isV6() || !upper_bound_address.isV6()) {
- isc_throw(InvalidAddressFamily, "expected two IPv6 addresses for "
- "retrieving a range of leases, got "
- << lower_bound_address << " and " << upper_bound_address);
- }
-
- if (upper_bound_address < lower_bound_address) {
- isc_throw(InvalidRange, "upper bound address " << upper_bound_address
- << " is lower than lower bound address " << lower_bound_address);
- }
-
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_ADDR_RANGE6)
- .arg(lower_bound_address.toText())
- .arg(upper_bound_address.toText());
-
- // Prepare WHERE clause
- MYSQL_BIND inbind[2];
- memset(inbind, 0, sizeof(inbind));
-
- // Bind lower bound address
- std::string lb_address_data = lower_bound_address.toText();
- unsigned long lb_address_data_size = lb_address_data.size();
- inbind[0].buffer_type = MYSQL_TYPE_STRING;
- inbind[0].buffer = const_cast<char*>(lb_address_data.c_str());
- inbind[0].buffer_length = lb_address_data_size;
- inbind[0].length = &lb_address_data_size;
-
- // Bind upper bound address
- std::string ub_address_data = upper_bound_address.toText();
- unsigned long ub_address_data_size = ub_address_data.size();
- inbind[1].buffer_type = MYSQL_TYPE_STRING;
- inbind[1].buffer = const_cast<char*>(ub_address_data.c_str());
- inbind[1].buffer_length = ub_address_data_size;
- inbind[1].length = &ub_address_data_size;
-
- // Get the leases
- Lease6Collection result;
- getLeaseCollection(GET_LEASE6_RANGE, inbind, result);
-
- return (result);
-}
-
void
MySqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases,
const size_t max_leases) const {
getLeases4(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const;
- /// @brief Returns a range of IPv4 leases.
- ///
- /// @param lower_bound_address IPv4 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv4 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv4 lease found).
- virtual Lease4Collection
- getLeases4(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const;
-
/// @brief Returns existing IPv6 lease for a given IPv6 address.
///
/// For a given address, we assume that there will be only one lease.
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const;
- /// @brief Returns a range of IPv6 leases.
- ///
- /// @param lower_bound_address IPv6 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv6 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv6 lease found).
- virtual Lease6Collection
- getLeases6(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const;
-
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
return (result);
}
-Lease4Collection
-PgSqlLeaseMgr::getLeases4(const IOAddress& lower_bound_address,
- const IOAddress& upper_bound_address) const {
- // Expecting two IPv4 addresses.
- if (!lower_bound_address.isV4() || !upper_bound_address.isV4()) {
- isc_throw(InvalidAddressFamily, "expected two IPv4 addresses for "
- "retrieving a range of leases, got "
- << lower_bound_address << " and " << upper_bound_address);
- }
-
- if (upper_bound_address < lower_bound_address) {
- isc_throw(InvalidRange, "upper bound address " << upper_bound_address
- << " is lower than lower bound address " << lower_bound_address);
- }
-
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_ADDR_RANGE4)
- .arg(lower_bound_address.toText())
- .arg(upper_bound_address.toText());
-
- // Prepare WHERE clause
- PsqlBindArray bind_array;
-
- // Bind lower bound address
- std::string lb_address_data = boost::lexical_cast<std::string>
- (lower_bound_address.toUint32());
- bind_array.add(lb_address_data);
-
- // Bind upper bound address
- std::string ub_address_data = boost::lexical_cast<std::string>
- (upper_bound_address.toUint32());
- bind_array.add(ub_address_data);
-
- // Get the leases
- Lease4Collection result;
- getLeaseCollection(GET_LEASE4_RANGE, bind_array, result);
-
- return (result);
-}
-
Lease6Ptr
PgSqlLeaseMgr::getLease6(Lease::Type lease_type,
const isc::asiolink::IOAddress& addr) const {
Lease6Collection
PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
- const LeasePageSize& page_size) const {
+ const LeasePageSize& page_size) const {
// Expecting IPv6 address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 address while "
return (result);
}
-Lease6Collection
-PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const {
- // Expecting two IPv6 addresses.
- if (!lower_bound_address.isV6() || !upper_bound_address.isV6()) {
- isc_throw(InvalidAddressFamily, "expected two IPv6 addresses for "
- "retrieving a range of leases, got "
- << lower_bound_address << " and " << upper_bound_address);
- }
-
- if (upper_bound_address < lower_bound_address) {
- isc_throw(InvalidRange, "upper bound address " << upper_bound_address
- << " is lower than lower bound address " << lower_bound_address);
- }
-
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_ADDR_RANGE6)
- .arg(lower_bound_address.toText())
- .arg(upper_bound_address.toText());
-
- // Prepare WHERE clause
- PsqlBindArray bind_array;
-
- std::string lb_address_data = lower_bound_address.toText();
- bind_array.add(lb_address_data);
-
- std::string ub_address_data = upper_bound_address.toText();
- bind_array.add(ub_address_data);
-
- // Get the leases
- Lease6Collection result;
- getLeaseCollection(GET_LEASE6_RANGE, bind_array, result);
-
- return (result);
-}
-
void
PgSqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases,
const size_t max_leases) const {
getLeases4(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const;
- /// @brief Returns a range of IPv4 leases.
- ///
- /// @param lower_bound_address IPv4 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv4 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv4 lease found).
- virtual Lease4Collection
- getLeases4(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const;
-
/// @brief Returns existing IPv6 lease for a given IPv6 address.
///
/// For a given address, we assume that there will be only one lease.
getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const;
- /// @brief Returns a range of IPv6 leases.
- ///
- /// @param lower_bound_address IPv6 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv6 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv6 lease found).
- virtual Lease6Collection
- getLeases6(const asiolink::IOAddress& lower_bound_address,
- const asiolink::IOAddress& upper_bound_address) const;
-
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
testGetLeases4Paged();
}
-// Test that a range of IPv4 leases is returmed.
-TEST_F(CqlLeaseMgrTest, getLeases4Range) {
- testGetLeases4Range();
-}
-
/// @brief Basic Lease4 Checks
///
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
InvalidAddressFamily);
}
-void
-GenericLeaseMgrTest::testGetLeases4Range() {
- // Get the leases to be used for the test and add to the database.
- vector<Lease4Ptr> leases = createLeases4();
- for (size_t i = 0; i < leases.size(); ++i) {
- EXPECT_TRUE(lmptr_->addLease(leases[i]));
- }
-
- // All addresses in the specified range should be returned.
- Lease4Collection returned = lmptr_->getLeases4(IOAddress("192.0.2.2"),
- IOAddress("192.0.2.6"));
- EXPECT_EQ(5, returned.size());
-
- // The lower bound address is below the range, so the first two addresses
- // in the database should be returned.
- returned = lmptr_->getLeases4(IOAddress("192.0.1.0"), IOAddress("192.0.2.1"));
- EXPECT_EQ(2, returned.size());
-
- // The lower bound address is the last address in the database, so only this
- // address should be returned.
- returned = lmptr_->getLeases4(IOAddress("192.0.2.7"), IOAddress("192.0.2.15"));
- EXPECT_EQ(1, returned.size());
-
- // The lower bound is below the range and the upper bound is above the range,
- // so the whole range should be returned.
- returned = lmptr_->getLeases4(IOAddress("192.0.1.7"), IOAddress("192.0.2.15"));
- EXPECT_EQ(8, returned.size());
-
- // No addresses should be returned because our desired range does not
- // overlap with leases in the database.
- returned = lmptr_->getLeases4(IOAddress("192.0.2.8"), IOAddress("192.0.2.15"));
- EXPECT_TRUE(returned.empty());
-
- // Swapping the lower bound and upper bound should cause an error.
- EXPECT_THROW(lmptr_->getLeases4(IOAddress("192.0.2.8"), IOAddress("192.0.2.1")),
- InvalidRange);
-
- // Both must be IPv4 addresses.
- EXPECT_THROW(lmptr_->getLeases4(IOAddress("192.0.2.3"), IOAddress("2001:db8::8")),
- InvalidAddressFamily);
-
- EXPECT_THROW(lmptr_->getLeases4(IOAddress("2001:db8::2"), IOAddress("192.0.2.7")),
- InvalidAddressFamily);
-}
-
void
GenericLeaseMgrTest::testGetLeases6SubnetId() {
// Get the leases to be used for the test and add to the database.
}
-void
-GenericLeaseMgrTest::testGetLeases6Range() {
- // Get the leases to be used for the test and add to the database.
- vector<Lease6Ptr> leases = createLeases6();
- for (size_t i = 0; i < leases.size(); ++i) {
- EXPECT_TRUE(lmptr_->addLease(leases[i]));
- }
-
- // All addresses in the specified range should be returned.
- Lease6Collection returned = lmptr_->getLeases6(IOAddress("2001:db8::2"),
- IOAddress("2001:db8::6"));
- EXPECT_EQ(5, returned.size());
-
- // The lower bound address is below the range, so the first two addresses
- // in the database should be returned.
- returned = lmptr_->getLeases6(IOAddress("2001::"), IOAddress("2001:db8::1"));
- EXPECT_EQ(2, returned.size());
-
- // The lower bound address is the last address in the database, so only this
- // address should be returned.
- returned = lmptr_->getLeases6(IOAddress("2001:db8::7"), IOAddress("2001:db8::15"));
- EXPECT_EQ(1, returned.size());
-
- // The lower bound is below the range and the upper bound is above the range,
- // so the whole range should be returned.
- returned = lmptr_->getLeases6(IOAddress("2001::"), IOAddress("2001:db8::15"));
- EXPECT_EQ(8, returned.size());
-
- // No addresses should be returned because our desired range does not
- // overlap with leases in the database.
- returned = lmptr_->getLeases6(IOAddress("2001:db8::8"), IOAddress("2001:db8::15"));
- EXPECT_TRUE(returned.empty());
-
- // Swapping the lower bound and upper bound should cause an error.
- EXPECT_THROW(lmptr_->getLeases6(IOAddress("2001:db8::8"), IOAddress("2001:db8::1")),
- InvalidRange);
-
- // Both must be IPv6 addresses.
- EXPECT_THROW(lmptr_->getLeases6(IOAddress("192.0.2.3"), IOAddress("2001:db8::8")),
- InvalidAddressFamily);
-
- EXPECT_THROW(lmptr_->getLeases6(IOAddress("2001:db8::2"), IOAddress("192.0.2.7")),
- InvalidAddressFamily);
-}
-
void
GenericLeaseMgrTest::testGetLeases6DuidIaid() {
// Get the leases to be used for the test.
/// @brief Test method which returns range of IPv4 leases with paging.
void testGetLeases4Paged();
- /// @brief Test method which returns range of IPv4 leases.
- void testGetLeases4Range();
-
/// @brief Test method which returns all IPv6 leases for Subnet ID.
void testGetLeases6SubnetId();
/// @brief Test method which returns range of IPv6 leases with paging.
void testGetLeases6Paged();
- /// @brief Test method which returns range of IPv6 leases.
- void testGetLeases6Range();
-
/// @brief Basic Lease4 Checks
///
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
return (Lease4Collection());
}
- /// @brief Returns a range of IPv4 leases.
- ///
- /// Returned leases are ordered by IPv4 addresses.
- ///
- /// @param lower_bound_address IPv4 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv4 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv4 lease found).
- virtual Lease4Collection
- getLeases4(const asiolink::IOAddress& /* lower_bound_address */,
- const asiolink::IOAddress& /* upper_bound_address */) const {
- return (Lease4Collection());
- }
-
/// @brief Returns existing IPv6 lease for a given IPv6 address.
///
/// @param addr address of the searched lease
return (Lease6Collection());
}
- /// @brief Returns a range of IPv6 leases.
- ///
- /// @param lower_bound_address IPv6 address used as a lower bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- /// @param upper_bound_address IPv6 address used as an upper bound for the
- /// returned range. The lease for this address is included in the returned
- /// range if the lease exists.
- ///
- /// @return Lease collection (may be empty if no IPv6 lease found).
- virtual Lease6Collection
- getLeases6(const asiolink::IOAddress& /* lower_bound_address */,
- const asiolink::IOAddress& /* upper_bound_address */) const {
- return (Lease6Collection());
- }
-
/// @brief Returns range of IPv6 leases using paging.
///
/// This method implements paged browsing of the lease database. The first
testGetLeases4Paged();
}
-// Test that a range of IPv4 leases is returmed.
-TEST_F(MemfileLeaseMgrTest, getLeases4Range) {
- startBackend(V4);
- testGetLeases4Range();
-}
-
// This test checks that all IPv6 leases for a specified subnet id are returned.
TEST_F(MemfileLeaseMgrTest, getLeases6SubnetId) {
startBackend(V6);
testGetLeases6Paged();
}
-// Test that a range of IPv6 leases is returmed.
-TEST_F(MemfileLeaseMgrTest, getLeases6Range) {
- startBackend(V6);
- testGetLeases6Range();
-}
-
/// @brief Basic Lease6 Checks
///
/// Checks that the addLease, getLease6 (by address) and deleteLease (with an
testGetLeases4Paged();
}
-// Test that a range of IPv4 leases is returmed.
-TEST_F(MySqlLeaseMgrTest, getLeases4Range) {
- testGetLeases4Range();
-}
-
// This test checks that all IPv6 leases for a specified subnet id are returned.
TEST_F(MySqlLeaseMgrTest, getLeases6SubnetId) {
testGetLeases6SubnetId();
testGetLeases6Paged();
}
-// Test that a range of IPv6 leases is returmed.
-TEST_F(MySqlLeaseMgrTest, getLeases6Range) {
- testGetLeases6Range();
-}
-
/// @brief Basic Lease4 Checks
///
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
testGetLeases4Paged();
}
-// Test that a range of IPv4 leases is returmed.
-TEST_F(PgSqlLeaseMgrTest, getLeases4Range) {
- testGetLeases4Range();
-}
-
// This test checks that all IPv6 leases for a specified subnet id are returned.
TEST_F(PgSqlLeaseMgrTest, getLeases6SubnetId) {
testGetLeases6SubnetId();
testGetLeases6Paged();
}
-// Test that a range of IPv6 leases is returmed.
-TEST_F(PgSqlLeaseMgrTest, getLeases6Range) {
- testGetLeases6Range();
-}
-
/// @brief Basic Lease4 Checks
///
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),