summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/cfg_subnets6.cc
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2019-03-08 05:12:59 +0100
committerTomek Mrugalski <tomek@isc.org>2019-04-19 12:39:47 +0200
commit47fbbe7bb0d11986621b252293cb4c9d30bfb810 (patch)
tree05cdbc8d08ae66d8c78222007b4c6b64ebbe92ee /src/lib/dhcpsrv/cfg_subnets6.cc
parent[465-add-subnet4-update-and-subnet6-update-commands-to-subnet-cmds-hook] Adde... (diff)
downloadkea-47fbbe7bb0d11986621b252293cb4c9d30bfb810.tar.xz
kea-47fbbe7bb0d11986621b252293cb4c9d30bfb810.zip
[465-add-subnet4-update-and-subnet6-update-commands-to-subnet-cmds-hook] Added cfg_subnet replace -- unit test to do
Diffstat (limited to 'src/lib/dhcpsrv/cfg_subnets6.cc')
-rw-r--r--src/lib/dhcpsrv/cfg_subnets6.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/dhcpsrv/cfg_subnets6.cc b/src/lib/dhcpsrv/cfg_subnets6.cc
index 3167e3b7b4..210ad8a9b6 100644
--- a/src/lib/dhcpsrv/cfg_subnets6.cc
+++ b/src/lib/dhcpsrv/cfg_subnets6.cc
@@ -41,6 +41,27 @@ CfgSubnets6::add(const Subnet6Ptr& subnet) {
subnets_.push_back(subnet);
}
+Subnet6Ptr
+CfgSubnets6::replace(const Subnet6Ptr& subnet) {
+ // Get the subnet with the same ID.
+ const SubnetID& subnet_id = subnet->getID();
+ auto& index = subnets_.template get<SubnetSubnetIdIndexTag>();
+ auto subnet_it = index.find(subnet_id);
+ if (subnet_it == index.end()) {
+ isc_throw(BadValue, "ID of the IPv6 subnet '" << subnet_id
+ << "' is not in use");
+ }
+ bool ret = index.replace(subnet_it, subnet);
+
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_CFGMGR_UPDATE_SUBNET6)
+ .arg(subnet_id).arg(ret);
+ if (ret) {
+ return (*subnet_it);
+ } else {
+ return (Subnet6Ptr());
+ }
+}
+
void
CfgSubnets6::del(const ConstSubnet6Ptr& subnet) {
del(subnet->getID());