From: Slawek Figiel Date: Wed, 5 Apr 2023 11:50:31 +0000 (+0200) Subject: [#2815] Implement del in CfgHosts X-Git-Tag: Kea-2.3.8~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c285eec0baf01feef429861344955327a837bcc0;p=thirdparty%2Fkea.git [#2815] Implement del in CfgHosts --- diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc index ac2f7b4690..340d818009 100644 --- a/src/lib/dhcpsrv/cfg_hosts.cc +++ b/src/lib/dhcpsrv/cfg_hosts.cc @@ -1086,10 +1086,18 @@ CfgHosts::add6(const HostPtr& host) { } bool -CfgHosts::del(const SubnetID& /*subnet_id*/, const asiolink::IOAddress& /*addr*/) { - /// @todo: Implement host removal - isc_throw(NotImplemented, "sorry, not implemented"); - return (false); +CfgHosts::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr) { + bool erased = false; + if (addr.isV4()) { + HostContainerIndex1& idx = hosts_.get<1>(); + erased = idx.erase(addr) != 0; + } else { + HostContainer6Index1& idx = hosts6_.get<1>(); + auto range = idx.equal_range(boost::make_tuple(subnet_id, addr)); + auto eraseIt = idx.erase(range.first, range.second); + erased = eraseIt != idx.end(); + } + return (erased); } size_t