]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5651] Implemented fetching IPv6 leases by address ranges.
authorMarcin Siodelski <marcin@isc.org>
Tue, 26 Jun 2018 11:53:01 +0000 (13:53 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 26 Jun 2018 11:53:01 +0000 (13:53 +0200)
Except Cassandra.

16 files changed:
src/lib/dhcpsrv/cql_lease_mgr.cc
src/lib/dhcpsrv/cql_lease_mgr.h
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/lease_mgr.h
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/memfile_lease_mgr.h
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/mysql_lease_mgr.h
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/pgsql_lease_mgr.h
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h
src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc

index a63e73a7b8a3d25e382d6bd34bf28bfaa0b808a7..50bf89cac9ab96eb32d77a8cd8f2979e3547d163 100644 (file)
@@ -881,7 +881,6 @@ public:
     static constexpr StatementTag GET_LEASE6_DUID_IAID_SUBID = "GET_LEASE6_DUID_IAID_SUBID";
     static constexpr StatementTag GET_LEASE6_LIMIT = "GET_LEASE6_LIMIT";
     static constexpr StatementTag GET_LEASE6_PAGE = "GET_LEASE6_PAGE";
-    static constexpr StatementTag GET_LEASE6_RANGE = "GET_LEASE6_RANGE";
     // @}
 
 private:
@@ -922,7 +921,6 @@ constexpr StatementTag CqlLease6Exchange::GET_LEASE6_DUID_IAID;
 constexpr StatementTag CqlLease6Exchange::GET_LEASE6_DUID_IAID_SUBID;
 constexpr StatementTag CqlLease6Exchange::GET_LEASE6_LIMIT;
 constexpr StatementTag CqlLease6Exchange::GET_LEASE6_PAGE;
-constexpr StatementTag CqlLease6Exchange::GET_LEASE6_RANGE;
 
 StatementMap CqlLease6Exchange::tagged_statements_ = {
 
@@ -1038,19 +1036,7 @@ StatementMap CqlLease6Exchange::tagged_statements_ = {
       "FROM lease6 "
       "WHERE TOKEN(address) > TOKEN(?) "
       "LIMIT ? "
-      "ALLOW FILTERING "}},
-
-    // Get range of IPv6 leases between two addresses
-    {GET_LEASE6_RANGE,
-     {GET_LEASE6_RANGE,
-      "SELECT "
-      "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
-      "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
-      "hwaddr_source, state "
-      "FROM lease6 "
-      "WHERE address >= ? "
-      "AND address <= ? "
-      "ALLOW FILTERING "}},
+      "ALLOW FILTERING "}}
 };
 
 CqlLease6Exchange::CqlLease6Exchange(const CqlConnection &connection)
@@ -2372,6 +2358,13 @@ CqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
     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 {
index ab4ffbaf24c8a1a488db709701b35b86a7cf5cc0..c47708a61dce8788a8452f60d65c7696e5c77a73 100644 (file)
@@ -245,8 +245,6 @@ public:
 
     /// @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.
@@ -352,15 +350,37 @@ public:
     /// - If there are no leases returned it indicates that the previous page
     ///   was the last page.
     ///
-    /// @param lower_bound_address IPv4 address used as lower bound for the
+    /// @param lower_bound_address IPv6 address used as lower bound for the
     /// returned range.
     /// @param page_size maximum size of the page returned.
     ///
+    /// @warning This method is currently not implemented. Cassandra doesn't
+    /// support conversions from text to inet. Therefore, we're unable to
+    /// compare the IPv6 addresses to find the desired range. A solution for
+    /// this might be to store the IPv6 address as INET type rather than
+    /// text, but this is currently low priority.
+    ///
     /// @return Lease collection (may be empty if no IPv6 lease found).
+    ///
+    /// @throw isc::NotImplemented
     virtual Lease6Collection
     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
index 9b26dd713518e5b60e178d291d47ee2d1e6b4986..c3366505e1914b7f270ff6cf8453027a8fdb2aeb 100644 (file)
@@ -279,10 +279,6 @@ A debug message issued when the server is attempting to obtain an IPv6
 lease from the Cassandra database for a client with the specified IAID
 (Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
 
-% DHCPSRV_CQL_GET_ADDR_RANGE4 obtaining all IPv4 leases with addresses in range from %1 to %2
-A debug message issued when the server is attempting to obtain leases
-with addresses in the specified range.
-
 % DHCPSRV_CQL_GET_PAGE4 obtaining at most %1 IPv4 leases starting from address %2
 A debug message issued when the server is attempting to obtain a page
 of leases beginning with the specified address.
@@ -291,6 +287,10 @@ of leases beginning with the specified address.
 A debug message issued when the server is attempting to obtain a page
 of leases beginning with the specified address.
 
+% DHCPSRV_CQL_GET_ADDR_RANGE4 obtaining all IPv4 leases with addresses in range from %1 to %2
+A debug message issued when the server is attempting to obtain leases
+with addresses in the specified range.
+
 % DHCPSRV_CQL_GET_SUBID4 obtaining IPv4 leases for subnet ID %1
 A debug message issued when the server is attempting to obtain all IPv4
 leases for a given subnet identifier from the Cassandra database.
@@ -493,6 +493,10 @@ leases from the memory file database.
 A debug message issued when the server is attempting to obtain leases
 with addresses in the specified range.
 
+% DHCPSRV_MEMFILE_GET_ADDR_RANGE6 obtaining all IPv6 leases with addresses in range from %1 to %2
+A debug message issued when the server is attempting to obtain leases
+with addresses in the specified range.
+
 % DHCPSRV_MEMFILE_GET_PAGE4 obtaining at most %1 IPv4 leases starting from address %2
 A debug message issued when the server is attempting to obtain a page
 of leases beginning with the specified address.
@@ -757,6 +761,10 @@ lease from the MySQL database for the specified address.
 A debug message issued when the server is attempting to obtain leases
 with addresses in the specified range.
 
+% DHCPSRV_MYSQL_GET_ADDR_RANGE6 obtaining all IPv6 leases with addresses in range from %1 to %2
+A debug message issued when the server is attempting to obtain leases
+with addresses in the specified range.
+
 % DHCPSRV_MYSQL_GET_PAGE4 obtaining at most %1 IPv4 leases starting from address %2
 A debug message issued when the server is attempting to obtain a page
 of leases beginning with the specified address.
@@ -945,6 +953,10 @@ lease from the PostgreSQL database for the specified address.
 A debug message issued when the server is attempting to obtain leases
 with addresses in the specified range.
 
+% DHCPSRV_PGSQL_GET_ADDR_RANGE6 obtaining all IPv6 leases with addresses in range from %1 to %2
+A debug message issued when the server is attempting to obtain leases
+with addresses in the specified range.
+
 % DHCPSRV_PGSQL_GET_CLIENTID obtaining IPv4 leases for client ID %1
 A debug message issued when the server is attempting to obtain a set
 of IPv4 leases from the PostgreSQL database for a client with the specified
index 2cb8ec9afc556a6995347d54f77afd768c344ff5..81e2dc93a9fe666657e5f5823c7b3729319186d1 100644 (file)
@@ -394,8 +394,6 @@ public:
 
     /// @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.
@@ -507,7 +505,7 @@ public:
     /// - If there are no leases returned it indicates that the previous page
     ///   was the last page.
     ///
-    /// @param lower_bound_address IPv4 address used as lower bound for the
+    /// @param lower_bound_address IPv6 address used as lower bound for the
     /// returned range.
     /// @param page_size maximum size of the page returned.
     ///
@@ -516,6 +514,20 @@ public:
     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
index d0ada4d15830b40e40a17464a6879a4437aa6bfa..2806f6018446276fae4d408712d16dd62fba223a 100644 (file)
@@ -1061,6 +1061,33 @@ Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
     return (collection);
 }
 
+Lease6Collection
+Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
+                             const asiolink::IOAddress& upper_bound_address) const {
+    // 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 {
index c80aa15b78187c2809ab58f61249375f9b5fdb8d..b9fce8e79938b49f8c72bfea2f44d5836d51d6ea 100644 (file)
@@ -262,8 +262,6 @@ public:
 
     /// @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.
@@ -346,7 +344,7 @@ public:
     /// - If there are no leases returned it indicates that the previous page
     ///   was the last page.
     ///
-    /// @param lower_bound_address IPv4 address used as lower bound for the
+    /// @param lower_bound_address IPv6 address used as lower bound for the
     /// returned range.
     /// @param page_size maximum size of the page returned.
     ///
@@ -355,6 +353,20 @@ public:
     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
index f0a4b5cb86d3af43266199e437bf3e39e6eeecb7..74081eb96f49a4c791af03b65fd2c230cb499631 100644 (file)
@@ -225,7 +225,8 @@ tagged_statements = { {
                         "hwaddr, hwtype, hwaddr_source, "
                         "state "
                             "FROM lease6 "
-                            "WHERE address >= ? AND address <= ?"},
+                            "WHERE INET6_ATON(address) >= INET6_ATON(?) "
+                                "AND INET6_ATON(address) <= INET6_ATON(?)"},
     {MySqlLeaseMgr::GET_LEASE6_SUBID,
                     "SELECT address, duid, valid_lifetime, "
                         "expire, subnet_id, pref_lifetime, "
@@ -2199,6 +2200,45 @@ MySqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
     return (result);
 }
 
+Lease6Collection
+MySqlLeaseMgr::getLeases6(const IOAddress& lower_bound_address,
+                          const IOAddress& upper_bound_address) const {
+    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 {
index 24f70f76308a2917674e3d9192f7a6d04cfd2af7..b8f5555db321a6a9a83ad32814af837feca96edc 100644 (file)
@@ -236,8 +236,6 @@ public:
 
     /// @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.
@@ -344,7 +342,7 @@ public:
     /// - If there are no leases returned it indicates that the previous page
     ///   was the last page.
     ///
-    /// @param lower_bound_address IPv4 address used as lower bound for the
+    /// @param lower_bound_address IPv6 address used as lower bound for the
     /// returned range.
     /// @param page_size maximum size of the page returned.
     ///
@@ -353,6 +351,20 @@ public:
     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
index 02dd997d4bf600cfaa193f9562124cad105f1f1c..5d3d4ba6a060a79752ae7b25f4065b4a5e8d908c 100644 (file)
@@ -222,7 +222,7 @@ PgSqlTaggedStatement tagged_statements[] = {
         "hwaddr, hwtype, hwaddr_source, "
         "state "
       "FROM lease6 "
-      "WHERE address >= $1 AND address <= $2"},
+      "WHERE INET(address) >= INET($1) AND INET(address) <= INET($2)"},
 
     // GET_LEASE6_SUBID
     { 1, { OID_INT8 },
@@ -1547,6 +1547,34 @@ PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
     return (result);
 }
 
+Lease6Collection
+PgSqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
+                          const asiolink::IOAddress& upper_bound_address) const {
+    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 {
index e0287c9ac32f6e7e762cbb2f54dba73545c10d52..84ab7a6382b49e1f1d9c1db84b838ead1f4c408d 100644 (file)
@@ -217,8 +217,6 @@ public:
 
     /// @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.
@@ -316,7 +314,7 @@ public:
     /// - If there are no leases returned it indicates that the previous page
     ///   was the last page.
     ///
-    /// @param lower_bound_address IPv4 address used as lower bound for the
+    /// @param lower_bound_address IPv6 address used as lower bound for the
     /// returned range.
     /// @param page_size maximum size of the page returned.
     ///
@@ -325,6 +323,20 @@ public:
     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
index 8f663516ad9df1d20f93d90800de6e9c8c04eb7d..da5eb4a7d7da879fdfc50aa7faf8d9c7f204263d 100644 (file)
@@ -1420,6 +1420,44 @@ GenericLeaseMgrTest::testGetLeases6Paged() {
     }
 }
 
+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);
+}
+
 void
 GenericLeaseMgrTest::testGetLeases6DuidIaid() {
     // Get the leases to be used for the test.
index 914bf4e5f4e3636cd6bd9ab5d204ea366b523089..34de9f1abd20cb32bb17d0487d80f38ce226865d 100644 (file)
@@ -218,6 +218,9 @@ public:
     /// @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),
index 6a88fdce4791f2ac4533089bde2fa0bde62a13e0..8ded197f5f8de043dc334c74fe12ad4a167f8eb3 100644 (file)
@@ -242,6 +242,22 @@ public:
         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
index 59a6b972f4808ef203c92f89690f27b250598aaf..26f157b866c293c4bb4f1b67473f290e8e795c64 100644 (file)
@@ -960,6 +960,12 @@ TEST_F(MemfileLeaseMgrTest, getLeases6Paged) {
     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
index 3c4e8a2fbd48ada899dbff5706809ef56e9e4e88..5f92bac4f77f907584c1d8b18669a5ad554b142b 100644 (file)
@@ -380,6 +380,11 @@ TEST_F(MySqlLeaseMgrTest, getLeases6Paged) {
     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),
index a444e0a03abe87f68a22b35ea0734dca088d3476..62334514d2273b942b6c71ce9c31a0195d1419be 100644 (file)
@@ -369,6 +369,11 @@ TEST_F(PgSqlLeaseMgrTest, getLeases6Paged) {
     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),