diff options
author | Francis Dupont <fdupont@isc.org> | 2020-09-01 13:41:04 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2020-09-22 10:13:23 +0200 |
commit | f3e8356a417eb82b8af57c5b7d146c47d5e97742 (patch) | |
tree | e5c433465c28d096d57ed47d9602d44252e50cee /src/lib/dhcpsrv/cfg_hosts.cc | |
parent | [#1025] Changed mention by far better specify (diff) | |
download | kea-f3e8356a417eb82b8af57c5b7d146c47d5e97742.tar.xz kea-f3e8356a417eb82b8af57c5b7d146c47d5e97742.zip |
[#1163] Checkpoint: updated API
Diffstat (limited to 'src/lib/dhcpsrv/cfg_hosts.cc')
-rw-r--r-- | src/lib/dhcpsrv/cfg_hosts.cc | 88 |
1 files changed, 87 insertions, 1 deletions
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc index 5ec8407f67..544cdf74a4 100644 --- a/src/lib/dhcpsrv/cfg_hosts.cc +++ b/src/lib/dhcpsrv/cfg_hosts.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -201,6 +201,58 @@ CfgHosts::getPage6(const SubnetID& subnet_id, } ConstHostCollection +CfgHosts::getPage4(size_t& /*source_index*/, + uint64_t lower_host_id, + const HostPageSize& page_size) const { + // Do not issue logging message here because it will be logged by + // the getPageInternal method. + ConstHostCollection collection; + getPageInternal<ConstHostCollection>(lower_host_id, + page_size, + collection); + return (collection); +} + +HostCollection +CfgHosts::getPage4(size_t& /*source_index*/, + uint64_t lower_host_id, + const HostPageSize& page_size) { + // Do not issue logging message here because it will be logged by + // the getPageInternal method. + HostCollection collection; + getPageInternal<HostCollection>(lower_host_id, + page_size, + collection); + return (collection); +} + +ConstHostCollection +CfgHosts::getPage6(size_t& /*source_index*/, + uint64_t lower_host_id, + const HostPageSize& page_size) const { + // Do not issue logging message here because it will be logged by + // the getPageInternal method. + ConstHostCollection collection; + getPageInternal<ConstHostCollection>(lower_host_id, + page_size, + collection); + return (collection); +} + +HostCollection +CfgHosts::getPage6(size_t& /*source_index*/, + uint64_t lower_host_id, + const HostPageSize& page_size) { + // Do not issue logging message here because it will be logged by + // the getPageInternal method. + HostCollection collection; + getPageInternal<HostCollection>(lower_host_id, + page_size, + collection); + return (collection); +} + +ConstHostCollection CfgHosts::getAll4(const IOAddress& address) const { // Do not issue logging message here because it will be logged by // the getAllInternal4 method. @@ -435,6 +487,40 @@ CfgHosts::getAllbyHostnameInternal6(const std::string& hostname, template<typename Storage> void +CfgHosts::getPageInternal(uint64_t lower_host_id, + const HostPageSize& page_size, + Storage& storage) const { + + LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_CFG_GET_ALL); + + // Use the host id last index. + const HostContainerIndex4& idx = hosts_.get<4>(); + HostContainerIndex4::const_iterator host = idx.lower_bound(lower_host_id); + + // Exclude the lower bound id when it is not zero. + if (lower_host_id && + (host != idx.end()) && ((*host)->getHostId() == lower_host_id)) { + ++host; + } + + // Return hosts within the page size. + for (; host != idx.end(); ++host) { + LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA, + HOSTS_CFG_GET_ALL_HOST) + .arg((*host)->toText()); + storage.push_back(*host); + if (storage.size() >= page_size.page_size_) { + break; + } + } + + // Log how many hosts have been found. + LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_COUNT) + .arg(storage.size()); +} + +template<typename Storage> +void CfgHosts::getPageInternal4(const SubnetID& subnet_id, uint64_t lower_host_id, const HostPageSize& page_size, |