summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/cfg_hosts.cc
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2020-09-30 15:16:30 +0200
committerMarcin Siodelski <marcin@isc.org>2020-10-05 15:14:57 +0200
commitc7e9763582b72da958d91282c3cd8107ebb34487 (patch)
treefd360e6cedce77db7d8e3c4b1f4d1aa4020b438b /src/lib/dhcpsrv/cfg_hosts.cc
parent[#1428] Allow non-unique IPs in MySQL and PgSQL (diff)
downloadkea-c7e9763582b72da958d91282c3cd8107ebb34487.tar.xz
kea-c7e9763582b72da958d91282c3cd8107ebb34487.zip
[#1428] Calls to fetch many hosts by id/address
The new calls have been added to the host backends to retrieve multiple hosts by subnet_id and address.
Diffstat (limited to 'src/lib/dhcpsrv/cfg_hosts.cc')
-rw-r--r--src/lib/dhcpsrv/cfg_hosts.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc
index fe25c071f8..bba9b39362 100644
--- a/src/lib/dhcpsrv/cfg_hosts.cc
+++ b/src/lib/dhcpsrv/cfg_hosts.cc
@@ -701,6 +701,30 @@ CfgHosts::get4(const SubnetID& subnet_id, const IOAddress& address) const {
return (ConstHostPtr());
}
+ConstHostCollection
+CfgHosts::getAll4(const SubnetID& subnet_id,
+ const asiolink::IOAddress& address) const {
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS4)
+ .arg(subnet_id).arg(address.toText());
+
+ ConstHostCollection hosts;
+ for (auto host : getAll4(address)) {
+ if (host->getIPv4SubnetID() == subnet_id) {
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+ HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS4_HOST)
+ .arg(subnet_id)
+ .arg(address.toText())
+ .arg(host->toText());
+ hosts.push_back(host);
+ }
+ }
+ LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS4_COUNT)
+ .arg(subnet_id)
+ .arg(address.toText())
+ .arg(hosts.size());
+
+ return (hosts);
+}
ConstHostPtr
CfgHosts::get6(const SubnetID& subnet_id,
@@ -744,6 +768,14 @@ CfgHosts::get6(const SubnetID& subnet_id,
return (getHostInternal6<HostPtr, HostCollection>(subnet_id, address));
}
+ConstHostCollection
+CfgHosts::getAll6(const SubnetID& subnet_id,
+ const asiolink::IOAddress& address) const {
+ ConstHostCollection hosts;
+ getAllInternal6(subnet_id, address, hosts);
+ return (hosts);
+}
+
template<typename ReturnType, typename Storage>
ReturnType
CfgHosts::getHostInternal6(const SubnetID& subnet_id,