From 1fe31bdca0825e9fe39c3709167a64d20b77f0a3 Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Sat, 30 Jun 2018 12:33:54 +0800 Subject: [PATCH] Add unfiltered getAll to CfgHosts Add getAll() without parameters to class CfgHosts. Useful for, e.g., "dhcp4_srv_configured" hooks that want to iterator over all host reservations. --- src/lib/dhcpsrv/cfg_hosts.cc | 22 ++++++++++++++++++++++ src/lib/dhcpsrv/cfg_hosts.h | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc index d673cdc3b1..9001aeff82 100644 --- a/src/lib/dhcpsrv/cfg_hosts.cc +++ b/src/lib/dhcpsrv/cfg_hosts.cc @@ -23,6 +23,28 @@ using namespace isc::data; namespace isc { namespace dhcp { +ConstHostCollection +CfgHosts::getAll() const { + ConstHostCollection collection; + const HostContainerIndex0& idx = hosts_.get<0>(); + for (HostContainerIndex0::const_iterator host = idx.begin(); + host != idx.end(); ++host) { + collection.push_back(*host); + } + return (collection); +} + +HostCollection +CfgHosts::getAll() { + HostCollection collection; + const HostContainerIndex0& idx = hosts_.get<0>(); + for (HostContainerIndex0::const_iterator host = idx.begin(); + host != idx.end(); ++host) { + collection.push_back(*host); + } + return (collection); +} + ConstHostCollection CfgHosts::getAll(const Host::IdentifierType& identifier_type, const uint8_t* identifier_begin, diff --git a/src/lib/dhcpsrv/cfg_hosts.h b/src/lib/dhcpsrv/cfg_hosts.h index e41ba6a250..62199aa9a2 100644 --- a/src/lib/dhcpsrv/cfg_hosts.h +++ b/src/lib/dhcpsrv/cfg_hosts.h @@ -41,6 +41,24 @@ class CfgHosts : public BaseHostDataSource, public WritableHostDataSource, /// @brief Destructor. virtual ~CfgHosts() { } + /// @brief Return all hosts + /// + /// This method returns all @c Host objects which represent reservations + /// in this configuration. + /// + /// @return Collection of const @c Host objects. + virtual ConstHostCollection + getAll() const; + + /// @brief Non-const version of the @c getAll const method. + /// + /// This method returns all @c Host objects which represent reservations + /// in this configuration. + /// + /// @return Collection of non-const @c Host objects. + virtual HostCollection + getAll(); + /// @brief Return all hosts connected to any subnet for which reservations /// have been made using a specified identifier. ///