From: Razvan Becheriu Date: Fri, 9 Oct 2020 11:48:31 +0000 (+0300) Subject: [#1405] inherit reservation modes from global level X-Git-Tag: Kea-1.9.2~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2832b1e91d776ffebe238d8935c1482e830b286d;p=thirdparty%2Fkea.git [#1405] inherit reservation modes from global level --- 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 hr_mode_global; + getGlobalProperty(hr_mode_global, "reservation-modes.global"); + if (!hr_mode_global.unspecified()) { + flags |= Network::HR_GLOBAL; + found = true; + } + util::Optional 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 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(flags)); + } } } return (hr_mode);