diff options
author | Francis Dupont <fdupont@isc.org> | 2018-03-31 16:49:15 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2018-03-31 16:49:15 +0200 |
commit | a0bb7188df47a0f8020ff57739c5a6ab5f7e9828 (patch) | |
tree | b48c3702fcbb03d4d728b24a6bdd38b0d00885f0 /src/lib/dhcpsrv | |
parent | [master] Added ChangeLog entry for #5470. (diff) | |
parent | [5469] Corrections in doxygen for lease_cmds. (diff) | |
download | kea-a0bb7188df47a0f8020ff57739c5a6ab5f7e9828.tar.xz kea-a0bb7188df47a0f8020ff57739c5a6ab5f7e9828.zip |
[master] Finishing merge of trac5469 (lease6-get-all)
Diffstat (limited to 'src/lib/dhcpsrv')
-rw-r--r-- | src/lib/dhcpsrv/cql_lease_mgr.cc | 10 | ||||
-rw-r--r-- | src/lib/dhcpsrv/cql_lease_mgr.h | 22 | ||||
-rw-r--r-- | src/lib/dhcpsrv/dhcpsrv_messages.mes | 24 | ||||
-rw-r--r-- | src/lib/dhcpsrv/lease_mgr.h | 12 | ||||
-rw-r--r-- | src/lib/dhcpsrv/memfile_lease_mgr.cc | 30 | ||||
-rw-r--r-- | src/lib/dhcpsrv/memfile_lease_mgr.h | 12 | ||||
-rw-r--r-- | src/lib/dhcpsrv/mysql_lease_mgr.cc | 48 | ||||
-rw-r--r-- | src/lib/dhcpsrv/mysql_lease_mgr.h | 14 | ||||
-rw-r--r-- | src/lib/dhcpsrv/pgsql_lease_mgr.cc | 51 | ||||
-rw-r--r-- | src/lib/dhcpsrv/pgsql_lease_mgr.h | 14 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc | 27 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h | 6 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/lease_mgr_unittest.cc | 16 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc | 12 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc | 10 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc | 10 |
16 files changed, 317 insertions, 1 deletions
diff --git a/src/lib/dhcpsrv/cql_lease_mgr.cc b/src/lib/dhcpsrv/cql_lease_mgr.cc index cca6696250..8adef1019d 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.cc +++ b/src/lib/dhcpsrv/cql_lease_mgr.cc @@ -2046,6 +2046,16 @@ CqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID &duid, uint32_t iaid, return (result); } +Lease6Collection +CqlLeaseMgr::getLeases6(SubnetID) const { + isc_throw(NotImplemented, "getLeases6(subnet_id) is not implemented"); +} + +Lease6Collection +CqlLeaseMgr::getLeases6() const { + isc_throw(NotImplemented, "getLeases6() is not implemented"); +} + void CqlLeaseMgr::getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const { diff --git a/src/lib/dhcpsrv/cql_lease_mgr.h b/src/lib/dhcpsrv/cql_lease_mgr.h index 15c59f11be..92f933a88f 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.h +++ b/src/lib/dhcpsrv/cql_lease_mgr.h @@ -203,11 +203,15 @@ public: /// @param subnet_id subnet identifier. /// /// @return Lease collection (may be empty if no IPv4 lease found). + /// @throw NotImplemented because this method is currently not implemented for + /// this backend. virtual Lease4Collection getLeases4(SubnetID subnet_id) const override; /// @brief Returns all IPv4 leases. /// /// @return Lease collection (may be empty if no IPv4 lease found). + /// @throw NotImplemented because this method is currently not implemented for + /// this backend. virtual Lease4Collection getLeases4() const override; /// @brief Returns existing IPv6 lease for a given IPv6 address. @@ -268,6 +272,22 @@ public: uint32_t iaid, SubnetID subnet_id) const override; + /// @brief Returns all IPv6 leases for the particular subnet identifier. + /// + /// @param subnet_id subnet identifier. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + /// @throw NotImplemented because this method is currently not implemented for + /// this backend. + virtual Lease6Collection getLeases6(SubnetID subnet_id) const override; + + /// @brief Returns all IPv6 leases. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + /// @throw NotImplemented because this method is currently not implemented for + /// this backend. + virtual Lease6Collection getLeases6() const override; + /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases @@ -316,7 +336,7 @@ public: /// @param lease6 The lease to be updated. /// /// @throw isc::dhcp::NoSuchLease Attempt to update a lease that did not - /// exist. + /// @throw isc::dhcp::DbOperationError An operation on the open database has /// failed. virtual void updateLease6(const Lease6Ptr& lease6) override; diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index 3e279513c9..245c497f67 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -471,6 +471,10 @@ in the message. A debug message issued when the server is attempting to obtain all IPv4 leases from the memory file database. +% DHCPSRV_MEMFILE_GET6 obtaining all IPv6 leases +A debug message issued when the server is attempting to obtain all IPv6 +leases from the memory file database. + % DHCPSRV_MEMFILE_GET_ADDR4 obtaining IPv4 lease for address %1 A debug message issued when the server is attempting to obtain an IPv4 lease from the memory file database for the specified address. @@ -518,6 +522,10 @@ lease from the memory file database for a client with the specified IAID A debug message issued when the server is attempting to obtain all IPv4 leases for a given subnet identifier from the memory file database. +% DHCPSRV_MEMFILE_GET_SUBID6 obtaining IPv6 leases for subnet ID %1 +A debug message issued when the server is attempting to obtain all IPv6 +leases for a given subnet identifier from the memory file database. + % DHCPSRV_MEMFILE_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2 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 @@ -705,6 +713,10 @@ exit code. This is most likely due to a network issue. A debug message issued when the server is attempting to obtain all IPv4 leases from the MySQL database. +% DHCPSRV_MYSQL_GET6 obtaining all IPv6 leases +A debug message issued when the server is attempting to obtain all IPv6 +leases from the MySQL database. + % DHCPSRV_MYSQL_GET_ADDR4 obtaining IPv4 lease for address %1 A debug message issued when the server is attempting to obtain an IPv4 lease from the MySQL database for the specified address. @@ -747,6 +759,10 @@ lease from the MySQL database for a client with the specified IAID A debug message issued when the server is attempting to obtain all IPv4 leases for a given subnet identifier from the MySQL database. +% DHCPSRV_MYSQL_GET_SUBID6 obtaining IPv6 leases for subnet ID %1 +A debug message issued when the server is attempting to obtain all IPv6 +leases for a given subnet identifier from the MySQL database. + % DHCPSRV_MYSQL_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2 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 @@ -867,6 +883,10 @@ exit code. This is most likely due to a network issue. A debug message issued when the server is attempting to obtain all IPv4 leases from the PostgreSQL database. +% DHCPSRV_PGSQL_GET6 obtaining all IPv6 leases +A debug message issued when the server is attempting to obtain all IPv6 +leases from the PostgreSQL database. + % DHCPSRV_PGSQL_GET_ADDR4 obtaining IPv4 lease for address %1 A debug message issued when the server is attempting to obtain an IPv4 lease from the PostgreSQL database for the specified address. @@ -909,6 +929,10 @@ lease from the PostgreSQL database for a client with the specified IAID A debug message issued when the server is attempting to obtain all IPv4 leases for a given subnet identifier from the PostgreSQL database. +% DHCPSRV_PGSQL_GET_SUBID6 obtaining IPv6 leases for subnet ID %1 +A debug message issued when the server is attempting to obtain all IPv6 +leases for a given subnet identifier from the PostgreSQL database. + % DHCPSRV_PGSQL_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2 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 diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h index 56507195f7..f0fd431cc4 100644 --- a/src/lib/dhcpsrv/lease_mgr.h +++ b/src/lib/dhcpsrv/lease_mgr.h @@ -364,6 +364,18 @@ public: Lease6Ptr getLease6(Lease::Type type, const DUID& duid, uint32_t iaid, SubnetID subnet_id) const; + /// @brief Returns all IPv6 leases for the particular subnet identifier. + /// + /// @param subnet_id subnet identifier. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6(SubnetID subnet_id) const = 0; + + /// @brief Returns all IPv6 leases. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6() const = 0; + /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc index e2186868b4..336fe8be1c 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.cc +++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc @@ -831,6 +831,36 @@ Memfile_LeaseMgr::getLeases6(Lease::Type type, return (collection); } +Lease6Collection +Memfile_LeaseMgr::getLeases6(SubnetID subnet_id) const { + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET_SUBID6) + .arg(subnet_id); + + Lease6Collection collection; + const Lease6StorageSubnetIdIndex& idx = storage6_.get<SubnetIdIndexTag>(); + std::pair<Lease6StorageSubnetIdIndex::const_iterator, + Lease6StorageSubnetIdIndex::const_iterator> l = + idx.equal_range(subnet_id); + + for (auto lease = l.first; lease != l.second; ++lease) { + collection.push_back(Lease6Ptr(new Lease6(**lease))); + } + + return (collection); +} + +Lease6Collection +Memfile_LeaseMgr::getLeases6() const { + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET6); + + Lease6Collection collection; + for (auto lease = storage6_.begin(); lease != storage6_.end(); ++lease ) { + collection.push_back(Lease6Ptr(new Lease6(**lease))); + } + + return (collection); +} + void Memfile_LeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases, const size_t max_leases) const { diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h index dea6d92085..81586566a8 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.h +++ b/src/lib/dhcpsrv/memfile_lease_mgr.h @@ -271,6 +271,18 @@ public: uint32_t iaid, SubnetID subnet_id) const; + /// @brief Returns all IPv6 leases for the particular subnet identifier. + /// + /// @param subnet_id subnet identifier. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6(SubnetID subnet_id) const; + + /// @brief Returns all IPv6 leases. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6() const; + /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index e12302b962..b4e489b144 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -153,6 +153,14 @@ tagged_statements = { { "WHERE state != ? AND expire < ? " "ORDER BY expire ASC " "LIMIT ?"}, + {MySqlLeaseMgr::GET_LEASE6, + "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 " + "FROM lease6"}, {MySqlLeaseMgr::GET_LEASE6_ADDR, "SELECT address, duid, valid_lifetime, " "expire, subnet_id, pref_lifetime, " @@ -181,6 +189,15 @@ tagged_statements = { { "FROM lease6 " "WHERE duid = ? AND iaid = ? AND subnet_id = ? " "AND lease_type = ?"}, + {MySqlLeaseMgr::GET_LEASE6_SUBID, + "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 " + "FROM lease6 " + "WHERE subnet_id = ?"}, {MySqlLeaseMgr::GET_LEASE6_EXPIRE, "SELECT address, duid, valid_lifetime, " "expire, subnet_id, pref_lifetime, " @@ -1900,6 +1917,37 @@ MySqlLeaseMgr::getLeases6(Lease::Type lease_type, return (result); } +Lease6Collection +MySqlLeaseMgr::getLeases6(SubnetID subnet_id) const { + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID6) + .arg(subnet_id); + + // Set up the WHERE clause value + MYSQL_BIND inbind[1]; + memset(inbind, 0, sizeof(inbind)); + + // Subnet ID + inbind[0].buffer_type = MYSQL_TYPE_LONG; + inbind[0].buffer = reinterpret_cast<char*>(&subnet_id); + inbind[0].is_unsigned = MLM_TRUE; + + // ... and get the data + Lease6Collection result; + getLeaseCollection(GET_LEASE6_SUBID, inbind, result); + + return (result); +} + +Lease6Collection +MySqlLeaseMgr::getLeases6() const { + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET6); + + Lease6Collection result; + getLeaseCollection(GET_LEASE6, 0, result); + + return (result); +} + void MySqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases, const size_t max_leases) const { diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h index ac7fc7bcf8..db87cf812b 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.h +++ b/src/lib/dhcpsrv/mysql_lease_mgr.h @@ -268,6 +268,18 @@ public: virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid, uint32_t iaid, SubnetID subnet_id) const; + /// @brief Returns all IPv6 leases for the particular subnet identifier. + /// + /// @param subnet_id subnet identifier. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6(SubnetID subnet_id) const; + + /// @brief Returns all IPv6 leases. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6() const; + /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases @@ -455,9 +467,11 @@ public: GET_LEASE4_HWADDR_SUBID, // Get lease4 by HW address & subnet ID GET_LEASE4_SUBID, // Get IPv4 leases by subnet ID GET_LEASE4_EXPIRE, // Get lease4 by expiration. + GET_LEASE6, // Get all IPv6 leases GET_LEASE6_ADDR, // Get lease6 by address GET_LEASE6_DUID_IAID, // Get lease6 by DUID and IAID GET_LEASE6_DUID_IAID_SUBID, // Get lease6 by DUID, IAID and subnet ID + GET_LEASE6_SUBID, // Get IPv6 leases by subnet ID GET_LEASE6_EXPIRE, // Get lease6 by expiration. GET_VERSION, // Obtain version number INSERT_LEASE4, // Add entry to lease4 table diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index 4d35339268..34572f73f6 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -133,6 +133,15 @@ PgSqlTaggedStatement tagged_statements[] = { "ORDER BY expire " "LIMIT $3"}, + // GET_LEASE6 + { 0, { OID_NONE }, + "get_lease6", + "SELECT address, duid, valid_lifetime, " + "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, " + "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, " + "state " + "FROM lease6"}, + // GET_LEASE6_ADDR { 2, { OID_VARCHAR, OID_INT2 }, "get_lease6_addr", @@ -167,6 +176,16 @@ PgSqlTaggedStatement tagged_statements[] = { "WHERE lease_type = $1 " "AND duid = $2 AND iaid = $3 AND subnet_id = $4"}, + // GET_LEASE6_SUBID + { 1, { OID_INT8 }, + "get_lease6_subid", + "SELECT address, duid, valid_lifetime, " + "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, " + "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, " + "state " + "FROM lease6 " + "WHERE subnet_id = $1"}, + // GET_LEASE6_EXPIRE { 3, { OID_INT8, OID_TIMESTAMP, OID_INT8 }, "get_lease6_expire", @@ -1270,6 +1289,38 @@ PgSqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, return (result); } +Lease6Collection +PgSqlLeaseMgr::getLeases6(SubnetID subnet_id) const { + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_SUBID6) + .arg(subnet_id); + + // Set up the WHERE clause value + PsqlBindArray bind_array; + + // SUBNET_ID + std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id); + bind_array.add(subnet_id_str); + + // ... and get the data + Lease6Collection result; + getLeaseCollection(GET_LEASE6_SUBID, bind_array, result); + + return (result); +} + +Lease6Collection +PgSqlLeaseMgr::getLeases6() const { + LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET6); + + // Provide empty binding array because our query has no parameters in + // WHERE clause. + PsqlBindArray bind_array; + Lease6Collection result; + getLeaseCollection(GET_LEASE6, bind_array, result); + + return (result); +} + void PgSqlLeaseMgr::getExpiredLeases4(Lease4Collection& expired_leases, const size_t max_leases) const { diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h index 105f4a4666..badc4efb39 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.h +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h @@ -241,6 +241,18 @@ public: virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid, uint32_t iaid, SubnetID subnet_id) const; + /// @brief Returns all IPv6 leases for the particular subnet identifier. + /// + /// @param subnet_id subnet identifier. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6(SubnetID subnet_id) const; + + /// @brief Returns all IPv6 leases. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6() const; + /// @brief Returns a collection of expired DHCPv4 leases. /// /// This method returns at most @c max_leases expired leases. The leases @@ -425,9 +437,11 @@ public: GET_LEASE4_HWADDR_SUBID, // Get lease4 by HW address & subnet ID GET_LEASE4_SUBID, // Get IPv4 leases by subnet ID GET_LEASE4_EXPIRE, // Get expired lease4 + GET_LEASE6, // Get all IPv6 leases GET_LEASE6_ADDR, // Get lease6 by address GET_LEASE6_DUID_IAID, // Get lease6 by DUID and IAID GET_LEASE6_DUID_IAID_SUBID, // Get lease6 by DUID, IAID and subnet ID + GET_LEASE6_SUBID, // Get IPv6 leases by subnet ID GET_LEASE6_EXPIRE, // Get expired lease6 GET_VERSION, // Obtain version number INSERT_LEASE4, // Add entry to lease4 table diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc index 0dcece26e0..242c8152b1 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc @@ -1245,6 +1245,33 @@ GenericLeaseMgrTest::testGetLeases4() { } void +GenericLeaseMgrTest::testGetLeases6SubnetId() { + // 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])); + } + + // There should be exactly two leases for the subnet id that the second + // lease belongs to. + Lease6Collection returned = lmptr_->getLeases6(leases[1]->subnet_id_); + EXPECT_EQ(2, returned.size()); +} + +void +GenericLeaseMgrTest::testGetLeases6() { + // 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 leases should be returned. + Lease6Collection returned = lmptr_->getLeases6(); + ASSERT_EQ(leases.size(), returned.size()); +} + +void GenericLeaseMgrTest::testGetLeases6DuidIaid() { // Get the leases to be used for the test. vector<Lease6Ptr> leases = createLeases6(); diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h index 5f4eaea952..aeee7067cd 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h @@ -201,6 +201,12 @@ public: /// @brief Test method which returns all IPv4 leases. void testGetLeases4(); + /// @brief Test method which returns all IPv6 leases for Subnet ID. + void testGetLeases6SubnetId(); + + /// @brief Test method which returns all IPv6 leases. + void testGetLeases6(); + /// @brief Basic Lease4 Checks /// /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id), diff --git a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc index 373eb1a0b9..88ea5a064a 100644 --- a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc @@ -178,6 +178,22 @@ public: return (leases6_); } + /// @brief Returns all IPv6 leases for the particular subnet identifier. + /// + /// @param subnet_id subnet identifier. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6(SubnetID) const { + return (Lease6Collection()); + } + + /// @brief Returns all IPv6 leases. + /// + /// @return Lease collection (may be empty if no IPv6 lease found). + virtual Lease6Collection getLeases6() const { + return (Lease6Collection()); + } + /// @brief Returns expired DHCPv6 leases. /// diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc index a59706b492..cdcf55eef7 100644 --- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc @@ -930,6 +930,18 @@ TEST_F(MemfileLeaseMgrTest, getLeases4) { testGetLeases4(); } +// This test checks that all IPv6 leases for a specified subnet id are returned. +TEST_F(MemfileLeaseMgrTest, getLeases6SubnetId) { + startBackend(V6); + testGetLeases6SubnetId(); +} + +// This test checks that all IPv6 leases are returned. +TEST_F(MemfileLeaseMgrTest, getLeases6) { + startBackend(V6); + testGetLeases6(); +} + /// @brief Basic Lease6 Checks /// /// Checks that the addLease, getLease6 (by address) and deleteLease (with an diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc index 64fae4c95d..c6c12381cc 100644 --- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc @@ -350,6 +350,16 @@ TEST_F(MySqlLeaseMgrTest, getLeases4) { testGetLeases4(); } +// This test checks that all IPv6 leases for a specified subnet id are returned. +TEST_F(MySqlLeaseMgrTest, getLeases6SubnetId) { + testGetLeases6SubnetId(); +} + +// This test checks that all IPv6 leases are returned. +TEST_F(MySqlLeaseMgrTest, getLeases6) { + testGetLeases6(); +} + /// @brief Basic Lease4 Checks /// /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id), diff --git a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc index f8fd0a8e45..49586587bf 100644 --- a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc @@ -343,6 +343,16 @@ TEST_F(PgSqlLeaseMgrTest, getLeases4) { testGetLeases4(); } +// This test checks that all IPv6 leases for a specified subnet id are returned. +TEST_F(PgSqlLeaseMgrTest, getLeases6SubnetId) { + testGetLeases6SubnetId(); +} + +// This test checks that all IPv6 leases are returned. +TEST_F(PgSqlLeaseMgrTest, getLeases6) { + testGetLeases6(); +} + /// @brief Basic Lease4 Checks /// /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id), |