summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/network.h
diff options
context:
space:
mode:
authorRazvan Becheriu <razvan@isc.org>2020-10-09 13:48:31 +0200
committerRazvan Becheriu <razvan@isc.org>2020-11-18 14:55:22 +0100
commit2832b1e91d776ffebe238d8935c1482e830b286d (patch)
tree2e20fb0fc412e0747ae7d89f34251ca150b024fa /src/lib/dhcpsrv/network.h
parent[#1405] added parser class (diff)
downloadkea-2832b1e91d776ffebe238d8935c1482e830b286d.tar.xz
kea-2832b1e91d776ffebe238d8935c1482e830b286d.zip
[#1405] inherit reservation modes from global level
Diffstat (limited to 'src/lib/dhcpsrv/network.h')
-rw-r--r--src/lib/dhcpsrv/network.h34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/lib/dhcpsrv/network.h b/src/lib/dhcpsrv/network.h
index 2408ad2b73..95cb0465a1 100644
--- a/src/lib/dhcpsrv/network.h
+++ b/src/lib/dhcpsrv/network.h
@@ -406,10 +406,11 @@ public:
/// @brief Specifies what type of Host Reservations are supported.
///
- /// Host reservations may be either in-pool (they reserve an address that
- /// is in the dynamic pool) or out-of-pool (they reserve an address that is
- /// not in the dynamic pool). HR may also be completely disabled for
- /// performance reasons.
+ /// Host reservations may be any of the combinations of in-subnet (they
+ /// reserve an address that is in the subnet either in-pool or out-of-pool),
+ /// out-of-pool (they reserve an address that is not in the dynamic pool) or
+ /// global (they are defined at global level). HR may also be completely
+ /// disabled for performance reasons.
///
/// @param inheritance inheritance mode to be used.
/// @return Host reservation mode enabled.
@@ -443,6 +444,31 @@ public:
// method doesn't throw. Let's just return unspecified.
return (hr_mode);
}
+ } else {
+ // Get global reservation modes and merge the values.
+ bool found = false;
+ uint8_t flags = 0;
+ util::Optional<bool> hr_mode_global;
+ getGlobalProperty(hr_mode_global, "reservation-modes.global");
+ if (!hr_mode_global.unspecified()) {
+ flags |= Network::HR_GLOBAL;
+ found = true;
+ }
+ util::Optional<bool> hr_mode_in_subnet;
+ getGlobalProperty(hr_mode_in_subnet, "reservation-modes.in-subnet");
+ if (!hr_mode_in_subnet.unspecified()) {
+ flags |= Network::HR_IN_SUBNET;
+ found = true;
+ }
+ util::Optional<bool> hr_mode_out_of_pool;
+ getGlobalProperty(hr_mode_out_of_pool, "reservation-modes.out-of-pool");
+ if (!hr_mode_out_of_pool.unspecified()) {
+ flags |= Network::HR_OUT_OF_POOL;
+ found = true;
+ }
+ if (found) {
+ return (static_cast<Network::HRMode>(flags));
+ }
}
}
return (hr_mode);