diff options
author | Piotrek Zadroga <piotrek@isc.org> | 2023-06-20 10:49:11 +0200 |
---|---|---|
committer | Piotrek Zadroga <piotrek@isc.org> | 2023-06-26 17:30:59 +0200 |
commit | 71929865c3c98f86d0b1b4489eac59562eb2b04f (patch) | |
tree | 50acdb64281c38096eecf1362bb59520ae80dbce /src/lib/dhcpsrv/testutils | |
parent | [#2795] extend impl of MemHostDataSource::getAll4 (diff) | |
download | kea-71929865c3c98f86d0b1b4489eac59562eb2b04f.tar.xz kea-71929865c3c98f86d0b1b4489eac59562eb2b04f.zip |
[#2795] extend impl of BaseHostDataSource::getAll6
Diffstat (limited to 'src/lib/dhcpsrv/testutils')
-rw-r--r-- | src/lib/dhcpsrv/testutils/memory_host_data_source.cc | 30 | ||||
-rw-r--r-- | src/lib/dhcpsrv/testutils/memory_host_data_source.h | 10 |
2 files changed, 37 insertions, 3 deletions
diff --git a/src/lib/dhcpsrv/testutils/memory_host_data_source.cc b/src/lib/dhcpsrv/testutils/memory_host_data_source.cc index 2ba8a3737d..7b6bd22c03 100644 --- a/src/lib/dhcpsrv/testutils/memory_host_data_source.cc +++ b/src/lib/dhcpsrv/testutils/memory_host_data_source.cc @@ -296,10 +296,34 @@ ConstHostCollection MemHostDataSource::getAll6(const SubnetID& subnet_id, const asiolink::IOAddress& address) const { ConstHostCollection hosts; - auto host = get6(subnet_id, address); - if (host) { - hosts.push_back(host); + for (const auto & h : store_) { + if (h->getIPv6SubnetID() != subnet_id) { + continue; + } + + auto resrvs = h->getIPv6Reservations(); + for (auto r = resrvs.first; r != resrvs.second; ++r) { + if ((*r).second.getPrefix() == address) { + hosts.push_back(h); + } + } } + + return (hosts); +} + +ConstHostCollection +MemHostDataSource::getAll6(const asiolink::IOAddress& address) const { + ConstHostCollection hosts; + for (const auto & h : store_) { + auto resrvs = h->getIPv6Reservations(); + for (auto r = resrvs.first; r != resrvs.second; ++r) { + if ((*r).second.getPrefix() == address) { + hosts.push_back(h); + } + } + } + return (hosts); } diff --git a/src/lib/dhcpsrv/testutils/memory_host_data_source.h b/src/lib/dhcpsrv/testutils/memory_host_data_source.h index 8ba8405a72..6bca9f27d1 100644 --- a/src/lib/dhcpsrv/testutils/memory_host_data_source.h +++ b/src/lib/dhcpsrv/testutils/memory_host_data_source.h @@ -218,6 +218,16 @@ public: getAll6(const SubnetID& subnet_id, const asiolink::IOAddress& address) const; + // @brief Returns all hosts having a reservation for a specified + // address or delegated prefix (lease). + /// + /// @param address reserved IPv6 address/prefix. + /// + /// @return Collection of const @c Host objects. + virtual ConstHostCollection + getAll6(const asiolink::IOAddress& address) const; + + /// @brief Adds a new host to the collection. /// /// @param host Pointer to the new @c Host object being added. |