]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3149] Moved to getLeases6 overload
authorFrancis Dupont <fdupont@isc.org>
Fri, 12 Jan 2024 13:11:37 +0000 (14:11 +0100)
committerFrancis Dupont <fdupont@isc.org>
Wed, 17 Jan 2024 10:06:16 +0000 (11:06 +0100)
14 files changed:
src/lib/dhcpsrv/dhcpsrv_messages.cc
src/lib/dhcpsrv/dhcpsrv_messages.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/memfile_lease_extended_info_unittest.cc
src/lib/dhcpsrv/testutils/concrete_lease_mgr.cc
src/lib/dhcpsrv/testutils/concrete_lease_mgr.h
src/lib/dhcpsrv/testutils/generic_lease_extended_info_unittest.h

index 7ec251da82d4e74f3acac09e5eb2c69ad8be6f70..b3b3b3b5f45472e55fcf529d6286f05204c93eb4 100644 (file)
@@ -113,7 +113,6 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME6 = "DHCPSRV_MEMFIL
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HWADDR = "DHCPSRV_MEMFILE_GET_HWADDR";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_DUID = "DHCPSRV_MEMFILE_GET_IAID_DUID";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID = "DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID";
-extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_LINKADDR6 = "DHCPSRV_MEMFILE_GET_LINKADDR6";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE4 = "DHCPSRV_MEMFILE_GET_PAGE4";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE6 = "DHCPSRV_MEMFILE_GET_PAGE6";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_RELAYID4 = "DHCPSRV_MEMFILE_GET_RELAYID4";
@@ -124,6 +123,7 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID4 = "DHCPSRV_MEMFILE_G
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID6 = "DHCPSRV_MEMFILE_GET_SUBID6";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_CLIENTID = "DHCPSRV_MEMFILE_GET_SUBID_CLIENTID";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_HWADDR = "DHCPSRV_MEMFILE_GET_SUBID_HWADDR";
+extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_PAGE6 = "DHCPSRV_MEMFILE_GET_SUBID_PAGE6";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_VERSION = "DHCPSRV_MEMFILE_GET_VERSION";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_FILE_LOAD = "DHCPSRV_MEMFILE_LEASE_FILE_LOAD";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_LOAD = "DHCPSRV_MEMFILE_LEASE_LOAD";
@@ -171,7 +171,6 @@ extern const isc::log::MessageID DHCPSRV_MYSQL_GET_HOSTNAME6 = "DHCPSRV_MYSQL_GE
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_HWADDR = "DHCPSRV_MYSQL_GET_HWADDR";
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_IAID_DUID = "DHCPSRV_MYSQL_GET_IAID_DUID";
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_IAID_SUBID_DUID = "DHCPSRV_MYSQL_GET_IAID_SUBID_DUID";
-extern const isc::log::MessageID DHCPSRV_MYSQL_GET_LINKADDR6 = "DHCPSRV_MYSQL_GET_LINKADDR6";
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_PAGE4 = "DHCPSRV_MYSQL_GET_PAGE4";
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_PAGE6 = "DHCPSRV_MYSQL_GET_PAGE6";
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_RELAYID4 = "DHCPSRV_MYSQL_GET_RELAYID4";
@@ -182,6 +181,7 @@ extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID4 = "DHCPSRV_MYSQL_GET_S
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID6 = "DHCPSRV_MYSQL_GET_SUBID6";
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_CLIENTID = "DHCPSRV_MYSQL_GET_SUBID_CLIENTID";
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_HWADDR = "DHCPSRV_MYSQL_GET_SUBID_HWADDR";
+extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_PAGE6 = "DHCPSRV_MYSQL_GET_SUBID_PAGE6";
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_VERSION = "DHCPSRV_MYSQL_GET_VERSION";
 extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB = "DHCPSRV_MYSQL_HOST_DB";
 extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_GET_VERSION = "DHCPSRV_MYSQL_HOST_DB_GET_VERSION";
@@ -231,7 +231,6 @@ extern const isc::log::MessageID DHCPSRV_PGSQL_GET_HOSTNAME6 = "DHCPSRV_PGSQL_GE
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_HWADDR = "DHCPSRV_PGSQL_GET_HWADDR";
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_DUID = "DHCPSRV_PGSQL_GET_IAID_DUID";
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_SUBID_DUID = "DHCPSRV_PGSQL_GET_IAID_SUBID_DUID";
-extern const isc::log::MessageID DHCPSRV_PGSQL_GET_LINKADDR6 = "DHCPSRV_PGSQL_GET_LINKADDR6";
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE4 = "DHCPSRV_PGSQL_GET_PAGE4";
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE6 = "DHCPSRV_PGSQL_GET_PAGE6";
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_RELAYID4 = "DHCPSRV_PGSQL_GET_RELAYID4";
@@ -242,6 +241,7 @@ extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID4 = "DHCPSRV_PGSQL_GET_S
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID6 = "DHCPSRV_PGSQL_GET_SUBID6";
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_CLIENTID = "DHCPSRV_PGSQL_GET_SUBID_CLIENTID";
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_HWADDR = "DHCPSRV_PGSQL_GET_SUBID_HWADDR";
+extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_PAGE6 = "DHCPSRV_PGSQL_GET_SUBID_PAGE6";
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_VERSION = "DHCPSRV_PGSQL_GET_VERSION";
 extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB = "DHCPSRV_PGSQL_HOST_DB";
 extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_GET_VERSION = "DHCPSRV_PGSQL_HOST_DB_GET_VERSION";
@@ -400,7 +400,6 @@ const char* values[] = {
     "DHCPSRV_MEMFILE_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
     "DHCPSRV_MEMFILE_GET_IAID_DUID", "obtaining IPv6 leases for IAID %1 and DUID %2 and lease type %3",
     "DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID", "obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3 and lease type %4",
-    "DHCPSRV_MEMFILE_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
     "DHCPSRV_MEMFILE_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
     "DHCPSRV_MEMFILE_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
     "DHCPSRV_MEMFILE_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
@@ -411,6 +410,7 @@ const char* values[] = {
     "DHCPSRV_MEMFILE_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
     "DHCPSRV_MEMFILE_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
     "DHCPSRV_MEMFILE_GET_SUBID_HWADDR", "obtaining IPv4 lease for subnet ID %1 and hardware address %2",
+    "DHCPSRV_MEMFILE_GET_SUBID_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3",
     "DHCPSRV_MEMFILE_GET_VERSION", "obtaining schema version information",
     "DHCPSRV_MEMFILE_LEASE_FILE_LOAD", "loading leases from file %1",
     "DHCPSRV_MEMFILE_LEASE_LOAD", "loading lease %1",
@@ -458,7 +458,6 @@ const char* values[] = {
     "DHCPSRV_MYSQL_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
     "DHCPSRV_MYSQL_GET_IAID_DUID", "obtaining IPv6 leases for IAID %1, DUID %2, lease type %3",
     "DHCPSRV_MYSQL_GET_IAID_SUBID_DUID", "obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3, lease type %4",
-    "DHCPSRV_MYSQL_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
     "DHCPSRV_MYSQL_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
     "DHCPSRV_MYSQL_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
     "DHCPSRV_MYSQL_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
@@ -469,6 +468,7 @@ const char* values[] = {
     "DHCPSRV_MYSQL_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
     "DHCPSRV_MYSQL_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
     "DHCPSRV_MYSQL_GET_SUBID_HWADDR", "obtaining IPv4 lease for subnet ID %1 and hardware address %2",
+    "DHCPSRV_MYSQL_GET_SUBID_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3",
     "DHCPSRV_MYSQL_GET_VERSION", "obtaining schema version information",
     "DHCPSRV_MYSQL_HOST_DB", "opening MySQL hosts database: %1",
     "DHCPSRV_MYSQL_HOST_DB_GET_VERSION", "obtaining schema version information for the MySQL hosts database",
@@ -518,7 +518,6 @@ const char* values[] = {
     "DHCPSRV_PGSQL_GET_HWADDR", "obtaining IPv4 leases for hardware address %1",
     "DHCPSRV_PGSQL_GET_IAID_DUID", "obtaining IPv4 leases for IAID %1 and DUID %2, lease type %3",
     "DHCPSRV_PGSQL_GET_IAID_SUBID_DUID", "obtaining IPv4 leases for IAID %1, Subnet ID %2, DUID %3, and lease type %4",
-    "DHCPSRV_PGSQL_GET_LINKADDR6", "obtaining at most %1 IPv6 leases starting from address %2 with link %3",
     "DHCPSRV_PGSQL_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
     "DHCPSRV_PGSQL_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
     "DHCPSRV_PGSQL_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
@@ -529,6 +528,7 @@ const char* values[] = {
     "DHCPSRV_PGSQL_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
     "DHCPSRV_PGSQL_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
     "DHCPSRV_PGSQL_GET_SUBID_HWADDR", "obtaining IPv4 lease for subnet ID %1 and hardware address %2",
+    "DHCPSRV_PGSQL_GET_SUBID_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3",
     "DHCPSRV_PGSQL_GET_VERSION", "obtaining schema version information",
     "DHCPSRV_PGSQL_HOST_DB", "opening PostgreSQL hosts database: %1",
     "DHCPSRV_PGSQL_HOST_DB_GET_VERSION", "obtaining schema version information for the PostgreSQL hosts database",
index be10d79340c159d71b657dc167c4c7a09f00127d..28f9e452336604758f94b4f42d462c720276d408 100644 (file)
@@ -114,7 +114,6 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME6;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HWADDR;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_DUID;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID;
-extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_LINKADDR6;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE4;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE6;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_RELAYID4;
@@ -125,6 +124,7 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID4;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID6;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_CLIENTID;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_HWADDR;
+extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_PAGE6;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_VERSION;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_FILE_LOAD;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_LEASE_LOAD;
@@ -172,7 +172,6 @@ extern const isc::log::MessageID DHCPSRV_MYSQL_GET_HOSTNAME6;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_HWADDR;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_IAID_DUID;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_IAID_SUBID_DUID;
-extern const isc::log::MessageID DHCPSRV_MYSQL_GET_LINKADDR6;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_PAGE4;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_PAGE6;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_RELAYID4;
@@ -183,6 +182,7 @@ extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID4;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID6;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_CLIENTID;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_HWADDR;
+extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_PAGE6;
 extern const isc::log::MessageID DHCPSRV_MYSQL_GET_VERSION;
 extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB;
 extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_GET_VERSION;
@@ -232,7 +232,6 @@ extern const isc::log::MessageID DHCPSRV_PGSQL_GET_HOSTNAME6;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_HWADDR;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_DUID;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_SUBID_DUID;
-extern const isc::log::MessageID DHCPSRV_PGSQL_GET_LINKADDR6;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE4;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE6;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_RELAYID4;
@@ -243,6 +242,7 @@ extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID4;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID6;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_CLIENTID;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_HWADDR;
+extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_PAGE6;
 extern const isc::log::MessageID DHCPSRV_PGSQL_GET_VERSION;
 extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB;
 extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_GET_VERSION;
index 8ccce896994ca7805c028a1874b9cc7afd84a01a..e2b13b5fc07382aa8e989ecac1bc31cb947bfc22 100644 (file)
@@ -599,10 +599,6 @@ A debug message issued when the server is attempting to obtain an IPv6
 lease from the memory file database for a client with the specified IAID
 (Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
 
-% DHCPSRV_MEMFILE_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
-A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address within a link.
-
 % 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.
@@ -647,6 +643,11 @@ A debug message issued when the server is attempting to obtain an IPv4
 lease from the memory file database for a client with the specified
 subnet ID and hardware address.
 
+% DHCPSRV_MEMFILE_GET_SUBID_PAGE6 obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3
+A debug message issued when the server is attempting to obtain a page of
+IPv6 leases from the memory file database beginning with the specified
+address for a given subnet identifier.
+
 % DHCPSRV_MEMFILE_GET_VERSION obtaining schema version information
 A debug message issued when the server is about to obtain schema version
 information from the memory file database.
@@ -887,10 +888,6 @@ A debug message issued when the server is attempting to obtain an IPv6
 lease from the MySQL database for a client with the specified IAID
 (Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
 
-% DHCPSRV_MYSQL_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
-A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address within a link.
-
 % 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.
@@ -935,6 +932,11 @@ A debug message issued when the server is attempting to obtain an IPv4
 lease from the MySQL database for a client with the specified subnet ID
 and hardware address.
 
+% DHCPSRV_MYSQL_GET_SUBID_PAGE6 obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3
+A debug message issued when the server is attempting to obtain a page of
+IPv6 leases from the MySQL database beginning with the specified address
+for the specified subnet identifier.
+
 % DHCPSRV_MYSQL_GET_VERSION obtaining schema version information
 A debug message issued when the server is about to obtain schema version
 information from the MySQL database.
@@ -1167,10 +1169,6 @@ A debug message issued when the server is attempting to obtain an IPv6
 lease from the PostgreSQL database for a client with the specified IAID
 (Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
 
-% DHCPSRV_PGSQL_GET_LINKADDR6 obtaining at most %1 IPv6 leases starting from address %2 with link %3
-A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address within a link.
-
 % DHCPSRV_PGSQL_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.
@@ -1215,6 +1213,11 @@ A debug message issued when the server is attempting to obtain an IPv4
 lease from the PostgreSQL database for a client with the specified subnet ID
 and hardware address.
 
+% DHCPSRV_PGSQL_GET_SUBID_PAGE6 obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3
+A debug message issued when the server is attempting to obtain a page of
+IPv6 leases from the PostgreSQL database beginning with the specified address
+for the specified subnet identifier.
+
 % DHCPSRV_PGSQL_GET_VERSION obtaining schema version information
 A debug message issued when the server is about to obtain schema version
 information from the PostgreSQL database.
index d61155ce655cd9272e4a7d8912055217bf507256..8e4f16883285709c30d7a88b452e129fcda7559c 100644 (file)
@@ -517,6 +517,19 @@ public:
     getLeases6(const asiolink::IOAddress& lower_bound_address,
                const LeasePageSize& page_size) const = 0;
 
+    /// @brief Returns a page of IPv6 leases for a  subnet identifier.
+    ///
+    /// @param subnet_id subnet identifier.
+    /// @param lower_bound_address IPv6 address used as lower bound for the
+    /// returned range.
+    /// @param page_size maximum size of the page returned.
+    ///
+    /// @return collection of IPv6 leases
+    virtual Lease6Collection
+    getLeases6(SubnetID subnet_id,
+               const asiolink::IOAddress& lower_bound_address,
+               const LeasePageSize& page_size) const = 0;
+
     /// @brief Returns a collection of expired DHCPv4 leases.
     ///
     /// This method returns at most @c max_leases expired leases. The leases
@@ -965,19 +978,6 @@ public:
                          const asiolink::IOAddress& lower_bound_address,
                          const LeasePageSize& page_size) = 0;
 
-    /// @brief Returns existing IPv6 leases with on a given link.
-    ///
-    /// @param subnet_id subnet identifier.
-    /// @param lower_bound_address IPv6 address used as lower bound for the
-    /// returned range.
-    /// @param page_size maximum size of the page returned.
-    ///
-    /// @return collection of IPv6 leases
-    virtual Lease6Collection
-    getLeases6ByLink(SubnetID subnet_id,
-                     const asiolink::IOAddress& lower_bound_address,
-                     const LeasePageSize& page_size) = 0;
-
     /// @brief Write V4 leases to a file.
     ///
     /// @param filename File name to write leases.
index eb4ab394084a6c35f1c8c2af0ce5aa95339c33b3..bac19f49b9879888e6b395830311e9edc1870a5c 100644 (file)
@@ -1686,6 +1686,64 @@ Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
     return (collection);
 }
 
+Lease6Collection
+Memfile_LeaseMgr::getLeases6Internal(SubnetID subnet_id,
+                                     const IOAddress& lower_bound_address,
+                                     const LeasePageSize& page_size) const {
+    Lease6Collection collection;
+    const Lease6StorageSubnetIdIndex& idx = storage6_.get<SubnetIdIndexTag>();
+    Lease6StorageSubnetIdIndex::const_iterator lb =
+        idx.lower_bound(boost::make_tuple(subnet_id, lower_bound_address));
+
+    // Return all leases being within the page size.
+    IOAddress last_addr = lower_bound_address;
+    for (auto it = lb; it != idx.end(); ++it) {
+        if ((*it)->addr_ == last_addr) {
+            // Already seen: skip it.
+            continue;
+        }
+        if ((*it)->subnet_id_ != subnet_id) {
+            // Gone after the subnet id index.
+            break;
+        }
+        last_addr = (*it)->addr_;
+        collection.push_back(Lease6Ptr(new Lease6(**it)));
+        if (collection.size() >= page_size.page_size_) {
+            break;
+        }
+    }
+    return (collection);
+}
+
+Lease6Collection
+Memfile_LeaseMgr::getLeases6(SubnetID subnet_id,
+                             const IOAddress& lower_bound_address,
+                             const LeasePageSize& page_size) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
+              DHCPSRV_MEMFILE_GET_SUBID_PAGE6)
+        .arg(page_size.page_size_)
+        .arg(lower_bound_address.toText())
+        .arg(subnet_id);
+
+    // Expecting IPv6 valid address.
+    if (!lower_bound_address.isV6()) {
+        isc_throw(InvalidAddressFamily, "expected IPv6 address while "
+                  "retrieving leases from the lease database, got "
+                  << lower_bound_address);
+    }
+
+    if (MultiThreadingMgr::instance().getMode()) {
+        std::lock_guard<std::mutex> lock(*mutex_);
+        return (getLeases6Internal(subnet_id,
+                                   lower_bound_address,
+                                   page_size));
+    } else {
+        return (getLeases6Internal(subnet_id,
+                                   lower_bound_address,
+                                    page_size));
+    }
+}
+
 void
 Memfile_LeaseMgr::getExpiredLeases4Internal(Lease4Collection& expired_leases,
                                             const size_t max_leases) const {
@@ -3171,64 +3229,6 @@ Memfile_LeaseMgr::getLeases6ByRemoteIdInternal(const OptionBuffer& remote_id,
     return (collection);
 }
 
-Lease6Collection
-Memfile_LeaseMgr::getLeases6ByLink(SubnetID subnet_id,
-                                   const IOAddress& lower_bound_address,
-                                   const LeasePageSize& page_size) {
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
-              DHCPSRV_MEMFILE_GET_LINKADDR6)
-        .arg(page_size.page_size_)
-        .arg(lower_bound_address.toText())
-        .arg(subnet_id);
-
-    // Expecting IPv6 valid address.
-    if (!lower_bound_address.isV6()) {
-        isc_throw(InvalidAddressFamily, "expected IPv6 address while "
-                  "retrieving leases from the lease database, got "
-                  << lower_bound_address);
-    }
-
-    if (MultiThreadingMgr::instance().getMode()) {
-        std::lock_guard<std::mutex> lock(*mutex_);
-        return (getLeases6ByLinkInternal(subnet_id,
-                                         lower_bound_address,
-                                         page_size));
-    } else {
-        return (getLeases6ByLinkInternal(subnet_id,
-                                         lower_bound_address,
-                                         page_size));
-    }
-}
-
-Lease6Collection
-Memfile_LeaseMgr::getLeases6ByLinkInternal(SubnetID subnet_id,
-                                           const IOAddress& lower_bound_address,
-                                           const LeasePageSize& page_size) {
-    Lease6Collection collection;
-    const Lease6StorageSubnetIdIndex& idx = storage6_.get<SubnetIdIndexTag>();
-    Lease6StorageSubnetIdIndex::const_iterator lb =
-        idx.lower_bound(boost::make_tuple(subnet_id, lower_bound_address));
-
-    // Return all leases being within the page size.
-    IOAddress last_addr = lower_bound_address;
-    for (auto it = lb; it != idx.end(); ++it) {
-        if ((*it)->addr_ == last_addr) {
-            // Already seen: skip it.
-            continue;
-        }
-        if ((*it)->subnet_id_ != subnet_id) {
-            // Gone after the subnet id index.
-            break;
-        }
-        last_addr = (*it)->addr_;
-        collection.push_back(Lease6Ptr(new Lease6(**it)));
-        if (collection.size() >= page_size.page_size_) {
-            break;
-        }
-    }
-    return (collection);
-}
-
 size_t
 Memfile_LeaseMgr::extractExtendedInfo4(bool update, bool current) {
     CfgConsistencyPtr cfg;
index 1d1f3412c720909aafc5c49d8c5f7bda3645c266..54072dffc8ee48f50b28e6e0de4205acbaf3be3a 100644 (file)
@@ -373,6 +373,19 @@ public:
     getLeases6(const asiolink::IOAddress& lower_bound_address,
                const LeasePageSize& page_size) const override;
 
+    /// @brief Returns a page of IPv6 leases for a  subnet identifier.
+    ///
+    /// @param subnet_id subnet identifier.
+    /// @param lower_bound_address IPv6 address used as lower bound for the
+    /// returned range.
+    /// @param page_size maximum size of the page returned.
+    ///
+    /// @return collection of IPv6 leases
+    virtual Lease6Collection
+    getLeases6(SubnetID subnet_id,
+               const asiolink::IOAddress& lower_bound_address,
+               const LeasePageSize& page_size) const override;
+
     /// @brief Returns a collection of expired DHCPv4 leases.
     ///
     /// This method returns at most @c max_leases expired leases. The leases
@@ -719,6 +732,19 @@ private:
                             const LeasePageSize& page_size,
                             Lease6Collection& collection) const;
 
+    /// @brief Returns a page of IPv6 leases for a  subnet identifier.
+    ///
+    /// @param subnet_id subnet identifier.
+    /// @param lower_bound_address IPv6 address used as lower bound for the
+    /// returned range.
+    /// @param page_size maximum size of the page returned.
+    ///
+    /// @return collection of IPv6 leases
+    virtual Lease6Collection
+    getLeases6Internal(SubnetID subnet_id,
+                       const asiolink::IOAddress& lower_bound_address,
+                       const LeasePageSize& page_size) const;
+
     /// @brief Returns a collection of expired DHCPv4 leases.
     ///
     /// @param [out] expired_leases A container to which expired leases returned
@@ -1383,19 +1409,6 @@ public:
                          const asiolink::IOAddress& lower_bound_address,
                          const LeasePageSize& page_size) override;
 
-    /// @brief Returns existing IPv6 leases with on a given link.
-    ///
-    /// @param subnet_id subnet identifier.
-    /// @param lower_bound_address IPv4 address used as lower bound for the
-    /// returned range.
-    /// @param page_size maximum size of the page returned.
-    ///
-    /// @return collection of IPv6 leases
-    virtual Lease6Collection
-    getLeases6ByLink(SubnetID subnet_id,
-                     const asiolink::IOAddress& lower_bound_address,
-                     const LeasePageSize& page_size) override;
-
     /// @brief Extract extended info for v4 leases.
     ///
     /// For v4 relay and remote identifiers are stored inside leases vs.
@@ -1492,18 +1505,6 @@ private:
                                  const asiolink::IOAddress& lower_bound_address,
                                  const LeasePageSize& page_size);
 
-    /// @brief Returns existing IPv6 leases with on a given link.
-    ///
-    /// @param subnet_id subnet identifier.
-    /// @param lower_bound_address IPv4 address used as lower bound for the
-    /// returned range.
-    /// @param page_size maximum size of the page returned.
-    ///
-    /// @return collection of IPv6 leases
-    Lease6Collection
-    getLeases6ByLinkInternal(SubnetID subnet_id,
-                             const asiolink::IOAddress& lower_bound_address,
-                             const LeasePageSize& page_size);
 public:
 
     /// @brief Write V4 leases to a file.
index c4c4197509df57a132dcbd36b47862697344c84a..e6b4d443ece48435208ee1c59ed019226b0bff05 100644 (file)
@@ -359,6 +359,17 @@ tagged_statements = { {
                         "state, user_context, pool_id "
                             "FROM lease6 "
                             "WHERE subnet_id = ?"},
+    {MySqlLeaseMgr::GET_LEASE6_SUBID_PAGE,
+                    "SELECT address, duid, valid_lifetime, "
+                        "expire, subnet_id, pref_lifetime, "
+                        "lease_type, iaid, prefix_len, "
+                        "fqdn_fwd, fqdn_rev, hostname, "
+                        "hwaddr, hwtype, hwaddr_source, "
+                        "state, user_context, pool_id "
+                            "FROM lease6 "
+                            "WHERE subnet_id = ? AND address > ? "
+                            "ORDER BY address "
+                            "LIMIT ?"},
     {MySqlLeaseMgr::GET_LEASE6_DUID,
                     "SELECT address, duid, valid_lifetime, "
                         "expire, subnet_id, pref_lifetime, "
@@ -390,17 +401,6 @@ tagged_statements = { {
                             "AND expire < ? "
                             "ORDER BY expire ASC "
                             "LIMIT ?"},
-    {MySqlLeaseMgr::GET_LEASE6_LINK,
-                    "SELECT address, duid, valid_lifetime, "
-                        "expire, subnet_id, pref_lifetime, "
-                        "lease_type, iaid, prefix_len, "
-                        "fqdn_fwd, fqdn_rev, hostname, "
-                        "hwaddr, hwtype, hwaddr_source, "
-                        "state, user_context, pool_id "
-                            "FROM lease6 "
-                            "WHERE subnet_id = ? AND address > ? "
-                            "ORDER BY address "
-                            "LIMIT ?"},
     {MySqlLeaseMgr::INSERT_LEASE4,
                     "INSERT INTO lease4(address, hwaddr, client_id, "
                         "valid_lifetime, expire, subnet_id, "
@@ -3041,6 +3041,60 @@ MySqlLeaseMgr::getLeases6(SubnetID subnet_id) const {
     return (result);
 }
 
+Lease6Collection
+MySqlLeaseMgr::getLeases6(SubnetID subnet_id,
+                          const IOAddress& lower_bound_address,
+                          const LeasePageSize& page_size) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
+              DHCPSRV_MYSQL_GET_SUBID_PAGE6)
+        .arg(page_size.page_size_)
+        .arg(lower_bound_address.toText())
+        .arg(subnet_id);
+
+    // Expecting IPv6 valid address.
+    if (!lower_bound_address.isV6()) {
+        isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
+                  "retrieving leases from the lease database, got "
+                  << lower_bound_address);
+    }
+
+    Lease6Collection result;
+    // Prepare WHERE clause
+    MYSQL_BIND inbind[3];
+    memset(inbind, 0, sizeof(inbind));
+
+    // Bind the subnet id.
+    inbind[0].buffer_type = MYSQL_TYPE_LONG;
+    inbind[0].buffer = reinterpret_cast<char*>(&subnet_id);
+    inbind[0].is_unsigned = MLM_TRUE;
+
+    // Bind the lower bound address.
+    std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
+    unsigned long lb_addr_size = lb_addr_data.size();
+    if (lb_addr_size != 16) {
+        isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
+    }
+    inbind[1].buffer_type = MYSQL_TYPE_BLOB;
+    inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
+    inbind[1].buffer_length = lb_addr_size;
+    inbind[1].length = &lb_addr_size;
+
+    // Bind page size value
+    uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
+    inbind[2].buffer_type = MYSQL_TYPE_LONG;
+    inbind[2].buffer = reinterpret_cast<char*>(&ps);
+    inbind[2].is_unsigned = MLM_TRUE;
+
+    // Get a context
+    MySqlLeaseContextAlloc get_context(*this);
+    MySqlLeaseContextPtr ctx = get_context.ctx_;
+
+    // Get the leases
+    getLeaseCollection(ctx, GET_LEASE6_SUBID_PAGE, inbind, result);
+
+    return (result);
+}
+
 Lease6Collection
 MySqlLeaseMgr::getLeases6() const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET6);
@@ -4467,60 +4521,6 @@ MySqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
     return (result);
 }
 
-Lease6Collection
-MySqlLeaseMgr::getLeases6ByLink(SubnetID subnet_id,
-                                const IOAddress& lower_bound_address,
-                                const LeasePageSize& page_size) {
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
-              DHCPSRV_MYSQL_GET_LINKADDR6)
-        .arg(page_size.page_size_)
-        .arg(lower_bound_address.toText())
-        .arg(subnet_id);
-
-    // Expecting IPv6 valid address.
-    if (!lower_bound_address.isV6()) {
-        isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
-                  "retrieving leases from the lease database, got "
-                  << lower_bound_address);
-    }
-
-    Lease6Collection result;
-    // Prepare WHERE clause
-    MYSQL_BIND inbind[3];
-    memset(inbind, 0, sizeof(inbind));
-
-    // Bind the subnet id.
-    inbind[0].buffer_type = MYSQL_TYPE_LONG;
-    inbind[0].buffer = reinterpret_cast<char*>(&subnet_id);
-    inbind[0].is_unsigned = MLM_TRUE;
-
-    // Bind the lower bound address.
-    std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
-    unsigned long lb_addr_size = lb_addr_data.size();
-    if (lb_addr_size != 16) {
-        isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
-    }
-    inbind[1].buffer_type = MYSQL_TYPE_BLOB;
-    inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
-    inbind[1].buffer_length = lb_addr_size;
-    inbind[1].length = &lb_addr_size;
-
-    // Bind page size value
-    uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
-    inbind[2].buffer_type = MYSQL_TYPE_LONG;
-    inbind[2].buffer = reinterpret_cast<char*>(&ps);
-    inbind[2].is_unsigned = MLM_TRUE;
-
-    // Get a context
-    MySqlLeaseContextAlloc get_context(*this);
-    MySqlLeaseContextPtr ctx = get_context.ctx_;
-
-    // Get the leases
-    getLeaseCollection(ctx, GET_LEASE6_LINK, inbind, result);
-
-    return (result);
-}
-
 size_t
 MySqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
     auto check = CfgMgr::instance().getCurrentCfg()->
index 4fe8a185a9e8ea28bdc30565e4255d113e283b90..6f32d0053d96c358d5c281ef8adbdb61c336ce68 100644 (file)
@@ -432,6 +432,19 @@ public:
     getLeases6(const asiolink::IOAddress& lower_bound_address,
                const LeasePageSize& page_size) const override;
 
+    /// @brief Returns a page of IPv6 leases for a  subnet identifier.
+    ///
+    /// @param subnet_id subnet identifier.
+    /// @param lower_bound_address IPv6 address used as lower bound for the
+    /// returned range.
+    /// @param page_size maximum size of the page returned.
+    ///
+    /// @return collection of IPv6 leases
+    virtual Lease6Collection
+    getLeases6(SubnetID subnet_id,
+               const asiolink::IOAddress& lower_bound_address,
+               const LeasePageSize& page_size) const override;
+
     /// @brief Returns a collection of expired DHCPv4 leases.
     ///
     /// This method returns at most @c max_leases expired leases. The leases
@@ -748,10 +761,10 @@ public:
         GET_LEASE6_PAGE,             // Get page of leases beginning with an address
         GET_LEASE6_UCTX_PAGE,        // Get page of leases with user context
         GET_LEASE6_SUBID,            // Get IPv6 leases by subnet ID
+        GET_LEASE6_SUBID_PAGE,       // Get page of IPv6 leases by subnet ID
         GET_LEASE6_DUID,             // Get IPv6 leases by DUID
         GET_LEASE6_HOSTNAME,         // Get IPv6 leases by hostname
         GET_LEASE6_EXPIRE,           // Get lease6 by expiration.
-        GET_LEASE6_LINK,             // Get page of lease6 by link
         INSERT_LEASE4,               // Add entry to lease4 table
         INSERT_LEASE6,               // Add entry to lease6 table
         UPDATE_LEASE4,               // Update a Lease4 entry
@@ -1139,19 +1152,6 @@ public:
                          const asiolink::IOAddress& lower_bound_address,
                          const LeasePageSize& page_size) override;
 
-    /// @brief Returns existing IPv6 leases with on a given link.
-    ///
-    /// @param subnet_id subnet identifier.
-    /// @param lower_bound_address IPv4 address used as lower bound for the
-    /// returned range.
-    /// @param page_size maximum size of the page returned.
-    ///
-    /// @return collection of IPv6 leases
-    virtual Lease6Collection
-    getLeases6ByLink(SubnetID subnet_id,
-                     const asiolink::IOAddress& lower_bound_address,
-                     const LeasePageSize& page_size) override;
-
     /// @brief Upgrade extended info (v4).
     ///
     /// For all leases with a not null user context.
index d9e80283a321ec44dfdd0155c2dea05544ae4550..5f223953af1af91e69c98dea649caf99c94d484a 100644 (file)
@@ -372,6 +372,19 @@ PgSqlTaggedStatement tagged_statements[] = {
       "FROM lease6 "
       "WHERE subnet_id = $1" },
 
+    // GET_LEASE6_SUBID_PAGE
+    { 3, { OID_INT8, OID_VARCHAR, OID_INT8 },
+      "get_lease6_subid_page",
+      "SELECT host(address), duid, valid_lifetime, "
+        "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
+        "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
+        "hwaddr, hwtype, hwaddr_source, "
+        "state, user_context, pool_id "
+      "FROM lease6 "
+      "WHERE subnet_id = $1 AND address > cast($2 as inet) "
+      "ORDER BY address "
+      "LIMIT $3" },
+
     // GET_LEASE6_DUID
     { 1, { OID_BYTEA },
       "get_lease6_duid",
@@ -408,19 +421,6 @@ PgSqlTaggedStatement tagged_statements[] = {
       "ORDER BY expire "
       "LIMIT $3" },
 
-    // GET_LEASE6_LINK
-    { 3, { OID_INT8, OID_VARCHAR, OID_INT8 },
-      "get_lease6_link",
-      "SELECT host(address), duid, valid_lifetime, "
-        "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
-        "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
-        "hwaddr, hwtype, hwaddr_source, "
-        "state, user_context, pool_id "
-      "FROM lease6 "
-      "WHERE subnet_id = $1 AND address > cast($2 as inet) "
-      "ORDER BY address "
-      "LIMIT $3" },
-
     // INSERT_LEASE4
     { 14, { OID_INT8, OID_BYTEA, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
             OID_BOOL, OID_BOOL, OID_VARCHAR, OID_INT8, OID_TEXT, OID_BYTEA,
@@ -2303,6 +2303,50 @@ PgSqlLeaseMgr::getLeases6(SubnetID subnet_id) const {
     return (result);
 }
 
+Lease6Collection
+PgSqlLeaseMgr::getLeases6(SubnetID subnet_id,
+                          const IOAddress& lower_bound_address,
+                          const LeasePageSize& page_size) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
+              DHCPSRV_PGSQL_GET_SUBID_PAGE6)
+        .arg(page_size.page_size_)
+        .arg(lower_bound_address.toText())
+        .arg(subnet_id);
+
+    // Expecting IPv6 valid address.
+    if (!lower_bound_address.isV6()) {
+        isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
+                  "retrieving leases from the lease database, got "
+                  << lower_bound_address);
+    }
+
+    Lease6Collection result;
+    // Prepare WHERE clause
+    PsqlBindArray bind_array;
+
+    // Bind subnet id.
+    std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
+    bind_array.add(subnet_id_str);
+
+    // Bind lower bound address
+    std::string lb_address_str = lower_bound_address.toText();
+    bind_array.add(lb_address_str);
+
+    // Bind page size value
+    std::string page_size_data =
+    boost::lexical_cast<std::string>(page_size.page_size_);
+    bind_array.add(page_size_data);
+
+    // Get a context
+    PgSqlLeaseContextAlloc get_context(*this);
+    PgSqlLeaseContextPtr ctx = get_context.ctx_;
+
+    // Get the leases
+    getLeaseCollection(ctx, GET_LEASE6_SUBID_PAGE, bind_array, result);
+
+    return (result);
+}
+
 Lease6Collection
 PgSqlLeaseMgr::getLeases6(const DUID& duid) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_DUID)
@@ -3529,50 +3573,6 @@ PgSqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
     return (result);
 }
 
-Lease6Collection
-PgSqlLeaseMgr::getLeases6ByLink(SubnetID subnet_id,
-                                const IOAddress& lower_bound_address,
-                                const LeasePageSize& page_size) {
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
-              DHCPSRV_PGSQL_GET_LINKADDR6)
-        .arg(page_size.page_size_)
-        .arg(lower_bound_address.toText())
-        .arg(subnet_id);
-
-    // Expecting IPv6 valid address.
-    if (!lower_bound_address.isV6()) {
-        isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
-                  "retrieving leases from the lease database, got "
-                  << lower_bound_address);
-    }
-
-    Lease6Collection result;
-    // Prepare WHERE clause
-    PsqlBindArray bind_array;
-
-    // Bind subnet id.
-    std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
-    bind_array.add(subnet_id_str);
-
-    // Bind lower bound address
-    std::string lb_address_str = lower_bound_address.toText();
-    bind_array.add(lb_address_str);
-
-    // Bind page size value
-    std::string page_size_data =
-    boost::lexical_cast<std::string>(page_size.page_size_);
-    bind_array.add(page_size_data);
-
-    // Get a context
-    PgSqlLeaseContextAlloc get_context(*this);
-    PgSqlLeaseContextPtr ctx = get_context.ctx_;
-
-    // Get the leases
-    getLeaseCollection(ctx, GET_LEASE6_LINK, bind_array, result);
-
-    return (result);
-}
-
 size_t
 PgSqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
     auto check = CfgMgr::instance().getCurrentCfg()->
index 5617f058c73d17b6b16056ac61d17753a3146f92..4f4332826da4d4eaa9d2d68166c1b97239b1dec2 100644 (file)
@@ -408,6 +408,19 @@ public:
     getLeases6(const asiolink::IOAddress& lower_bound_address,
                const LeasePageSize& page_size) const override;
 
+    /// @brief Returns a page of IPv6 leases for a  subnet identifier.
+    ///
+    /// @param subnet_id subnet identifier.
+    /// @param lower_bound_address IPv6 address used as lower bound for the
+    /// returned range.
+    /// @param page_size maximum size of the page returned.
+    ///
+    /// @return collection of IPv6 leases
+    virtual Lease6Collection
+    getLeases6(SubnetID subnet_id,
+               const asiolink::IOAddress& lower_bound_address,
+               const LeasePageSize& page_size) const override;
+
     /// @brief Returns a collection of expired DHCPv4 leases.
     ///
     /// This method returns at most @c max_leases expired leases. The leases
@@ -724,10 +737,10 @@ public:
         GET_LEASE6_PAGE,             // Get page of leases beginning with an address
         GET_LEASE6_UCTX_PAGE,        // Get page of leases with user context
         GET_LEASE6_SUBID,            // Get IPv6 leases by subnet ID
+        GET_LEASE6_SUBID_PAGE,       // Get page of IPv6 lease by subnet ID
         GET_LEASE6_DUID,             // Get IPv6 leases by DUID
         GET_LEASE6_HOSTNAME,         // Get IPv6 leases by hostname
         GET_LEASE6_EXPIRE,           // Get lease6 by expiration.
-        GET_LEASE6_LINK,             // Get page of lease6 by link
         INSERT_LEASE4,               // Add entry to lease4 table
         INSERT_LEASE6,               // Add entry to lease6 table
         UPDATE_LEASE4,               // Update a Lease4 entry
@@ -1093,19 +1106,6 @@ public:
                          const asiolink::IOAddress& lower_bound_address,
                          const LeasePageSize& page_size) override;
 
-    /// @brief Returns existing IPv6 leases with on a given link.
-    ///
-    /// @param subnet_id subnet identifier.
-    /// @param lower_bound_address IPv4 address used as lower bound for the
-    /// returned range.
-    /// @param page_size maximum size of the page returned.
-    ///
-    /// @return collection of IPv6 leases
-    virtual Lease6Collection
-    getLeases6ByLink(SubnetID subnet_id,
-                     const asiolink::IOAddress& lower_bound_address,
-                     const LeasePageSize& page_size) override;
-
     /// @brief Upgrade extended info (v4).
     ///
     /// For all leases with a not null user context.
index 27813a89a7011a690ac2c48023cffc527ec8f95d..9aee4fc31b91612853add13074f66a404a3c0e9d 100644 (file)
@@ -987,7 +987,7 @@ TEST_F(MemfileExtendedInfoTest, getLeases6ByRemoteIdMultiThreading) {
     testGetLeases6ByRemoteId();
 }
 
-/// @brief Verifies that getLeases6ByLink works as expected.
+/// @brief Verifies that paged getLeases6 by subnet id works as expected.
 void
 MemfileExtendedInfoTest::testGetLeases6ByLink() {
     // Lease manager is created with empty tables.
@@ -1007,13 +1007,13 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
 
     Lease6Collection got;
     // Other link: nothing.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(10, zero,
-                                                       LeasePageSize(10)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(10, zero,
+                                                 LeasePageSize(10)));
     EXPECT_EQ(0, got.size());
 
     // Link: 8 entries.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
-                                                       LeasePageSize(10)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, zero,
+                                                 LeasePageSize(10)));
 
     ASSERT_EQ(8, got.size());
     Lease6Ptr lease;
@@ -1024,8 +1024,8 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
     }
 
     // Link: initial partial: 4 entries.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
-                                                       LeasePageSize(4)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, zero,
+                                                 LeasePageSize(4)));
     ASSERT_EQ(4, got.size());
     for (size_t i = 0; i < 4; ++i) {
         lease = got[i];
@@ -1034,8 +1034,8 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
     }
 
     // Link: next partial: 4 entries.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
-                                                       LeasePageSize(4)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, lease->addr_,
+                                                 LeasePageSize(4)));
     ASSERT_EQ(4, got.size());
     for (size_t i = 0; i < 4; ++i) {
         lease = got[i];
@@ -1044,8 +1044,8 @@ MemfileExtendedInfoTest::testGetLeases6ByLink() {
     }
 
     // Link: further partial: nothing.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
-                                                       LeasePageSize(4)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, lease->addr_,
+                                                 LeasePageSize(4)));
     EXPECT_EQ(0, got.size());
 }
 
index 0c162c7b78d86d82d5754432bd3a8a847d330b23..45ba6af02c1e3a328d11204a81ed122a8e6f3900 100644 (file)
@@ -125,6 +125,13 @@ ConcreteLeaseMgr::getLeases6(const IOAddress& /* lower_bound_address */,
     return (Lease6Collection());
 };
 
+Lease6Collection
+ConcreteLeaseMgr::getLeases6(SubnetID /* subnet_id */,
+                             const IOAddress& /* lower_bound_address */,
+                             const LeasePageSize& /* page_size */) const {
+    return (Lease6Collection());
+}
+
 void
 ConcreteLeaseMgr::getExpiredLeases6(Lease6Collection&, const size_t) const {
     isc_throw(NotImplemented, "ConcreteLeaseMgr::getExpiredLeases6 is not"
@@ -279,13 +286,6 @@ ConcreteLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& /* remote_id */,
     isc_throw(NotImplemented, "ConcreteLeaseMgr::getLeases6ByRemoteId not implemented");
 }
 
-Lease6Collection
-ConcreteLeaseMgr::getLeases6ByLink(SubnetID /* subnet_id */,
-                                   const IOAddress& /* lower_bound_address */,
-                                   const LeasePageSize& /* page_size */) {
-    isc_throw(NotImplemented, "ConcreteLeaseMgr::getLeases6ByLink not implemented");
-}
-
 size_t
 ConcreteLeaseMgr::upgradeExtendedInfo4(const LeasePageSize& /* page_size */) {
     return (0);
index caab063290bc701bd665164cce615ab86b6b3129..c51a79bcde5d6f4519ffa564f420d3ac71fcb428 100644 (file)
@@ -220,6 +220,19 @@ public:
     getLeases6(const asiolink::IOAddress& /* lower_bound_address */,
                const LeasePageSize& /* page_size */) const override;
 
+    /// @brief Returns a page of IPv6 leases for a  subnet identifier.
+    ///
+    /// @param subnet_id subnet identifier.
+    /// @param lower_bound_address IPv6 address used as lower bound for the
+    /// returned range.
+    /// @param page_size maximum size of the page returned.
+    ///
+    /// @return collection of IPv6 leases
+    virtual Lease6Collection
+    getLeases6(SubnetID /* subnet_id */,
+               const asiolink::IOAddress& /* lower_bound_address */,
+               const LeasePageSize& /* page_size */) const override;
+
     /// @brief Returns expired DHCPv6 leases.
     ///
     /// This method is not implemented.
@@ -366,12 +379,6 @@ public:
                          const asiolink::IOAddress& /* lower_bound_address */,
                          const LeasePageSize& /* page_size*/) override;
 
-    /// @brief Stub implementation.
-    Lease6Collection
-    getLeases6ByLink(SubnetID /* subnet_id */,
-                     const asiolink::IOAddress& /* lower_bound_address */,
-                     const LeasePageSize& /* page_size */) override;
-
     /// @brief Stub implementation.
     virtual size_t
     upgradeExtendedInfo4(const LeasePageSize& /* page_size */) override;
index 45f41ca64e3f553cd0f547ebec72ff2bb4ae5855..8595884704df898f8049cbe760aa959fa46e0fa9 100644 (file)
@@ -189,7 +189,7 @@ public:
     /// @brief Test getLeases6ByRemoteId.
     void testGetLeases6ByRemoteId();
 
-    /// @brief Test getLeases6ByLink.
+    /// @brief Test paged getLeases6 by subnet id.
     void testGetLeases6ByLink();
 
     /// @brief Test upgradeExtendedInfo6.
@@ -1208,7 +1208,7 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByRemoteId() {
     EXPECT_EQ(lease_addr2, lease->addr_);
 }
 
-/// @brief Verifies that getLeases6ByLink works as expected.
+/// @brief Verifies that paged getLeases6 by subnet id works as expected.
 template<typename NakedLeaseMgrType> void
 GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
     // Lease manager is created with empty tables.
@@ -1228,13 +1228,13 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
 
     Lease6Collection got;
     // Other link: nothing.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(100, zero,
-                                                       LeasePageSize(10)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(100, zero,
+                                                 LeasePageSize(10)));
     EXPECT_EQ(0, got.size());
 
     // Link: 8 entries.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
-                                                       LeasePageSize(10)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, zero,
+                                                 LeasePageSize(10)));
 
     ASSERT_EQ(8, got.size());
     Lease6Ptr lease;
@@ -1245,8 +1245,8 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
     }
 
     // Link: initial partial: 4 entries.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, zero,
-                                                       LeasePageSize(4)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, zero,
+                                                 LeasePageSize(4)));
     ASSERT_EQ(4, got.size());
     for (size_t i = 0; i < 4; ++i) {
         lease = got[i];
@@ -1255,8 +1255,8 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
     }
 
     // Link: next partial: 4 entries.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
-                                                       LeasePageSize(4)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, lease->addr_,
+                                                 LeasePageSize(4)));
     ASSERT_EQ(4, got.size());
     for (size_t i = 0; i < 4; ++i) {
         lease = got[i];
@@ -1265,8 +1265,8 @@ GenericExtendedInfoTest<NakedLeaseMgrType>::testGetLeases6ByLink() {
     }
 
     // Link: further partial: nothing.
-    EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByLink(1, lease->addr_,
-                                                       LeasePageSize(4)));
+    EXPECT_NO_THROW(got = lease_mgr_->getLeases6(1, lease->addr_,
+                                                 LeasePageSize(4)));
     EXPECT_EQ(0, got.size());
 }