]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2815] Implement del in CfgHosts
authorSlawek Figiel <slawek@isc.org>
Wed, 5 Apr 2023 11:50:31 +0000 (13:50 +0200)
committerSlawek Figiel <slawek@isc.org>
Thu, 25 May 2023 11:29:28 +0000 (13:29 +0200)
src/lib/dhcpsrv/cfg_hosts.cc

index ac2f7b469007e2c0c91f1b65b000e4d7b52b7df3..340d818009811f3bfe6e6d230d37fba0ef279995 100644 (file)
@@ -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