2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-10-19 14:36:24 +00:00

[5357] Addressed comments after review:

- many more parameters are now inherited from shared-network to subnet4
 - parameters now passed as const reference
 - it is no longer possible to specify echo-client-id on shared-network
   level (because it's a global parameter)
 - example config commented properly
This commit is contained in:
Tomek Mrugalski
2017-09-13 21:04:25 +02:00
parent de94f82ba0
commit 3e1e56f151
10 changed files with 359 additions and 54 deletions

View File

@@ -7,6 +7,7 @@
#include <dhcpsrv/parsers/simple_parser4.h>
#include <cc/data.h>
#include <boost/foreach.hpp>
#include <iostream>
using namespace isc::data;
@@ -66,6 +67,12 @@ const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = {
};
/// @brief This table defines default values for each IPv4 subnet.
///
/// Note: When updating this array, please also update SHARED_SUBNET4_DEFAULTS
/// below. In most cases, those two should be kept in sync, except cases
/// where a parameter can be derived from shared-networks, but is not
/// defined on global level. Currently there are two such parameters:
/// interface and reservation-mode
const SimpleDefaults SimpleParser4::SUBNET4_DEFAULTS = {
{ "id", Element::integer, "0" }, // 0 means autogenerate
{ "interface", Element::string, "" },
@@ -76,24 +83,51 @@ const SimpleDefaults SimpleParser4::SUBNET4_DEFAULTS = {
{ "4o6-subnet", Element::string, "" },
};
/// @brief This table defines default values for each IPv4 subnet that is
/// part of a shared network
///
/// This is mostly the same as @ref SUBNET4_DEFAULTS, except two parameters
/// that can be derived from shared-network, but cannot from global scope.
/// Those are: interface and reservation-mode.
const SimpleDefaults SimpleParser4::SHARED_SUBNET4_DEFAULTS = {
{ "id", Element::integer, "0" }, // 0 means autogenerate
{ "client-class", Element::string, "" },
{ "4o6-interface", Element::string, "" },
{ "4o6-interface-id", Element::string, "" },
{ "4o6-subnet", Element::string, "" },
};
/// @brief This table defines default values for each IPv4 shared network.
const SimpleDefaults SimpleParser4::SHARED_NETWORK4_DEFAULTS = {
{ "interface", Element::string, "" },
{ "reservation-mode", Element::string, "all" }
};
/// @brief This table defines default values for interfaces for DHCPv4.
const SimpleDefaults SimpleParser4::IFACE4_DEFAULTS = {
{ "re-detect", Element::boolean, "true" }
};
/// @brief List of parameters that can be inherited from the global to subnet4 scope.
/// @brief List of parameters that can be inherited to subnet4 scope.
///
/// Some parameters may be defined on both global (directly in Dhcp4) and
/// subnet (Dhcp4/subnet4/...) scope. If not defined in the subnet scope,
/// the value is being inherited (derived) from the global scope. This
/// array lists all of such parameters.
const ParamsList SimpleParser4::INHERIT_GLOBAL_TO_SUBNET4 = {
"renew-timer",
"rebind-timer",
"valid-lifetime",
///
/// This list is also used for inheriting from global to shared networks
/// and from shared networks to subnets within it.
const ParamsList SimpleParser4::INHERIT_TO_SUBNET4 = {
"interface",
"match-client-id",
"next-server"
"next-server",
"rebind-timer",
"relay",
"renew-timer",
"reservation-mode",
"valid-lifetime"
};
/// @}
/// ---------------------------------------------------------------------------
@@ -137,9 +171,12 @@ size_t SimpleParser4::setAllDefaults(isc::data::ElementPtr global) {
ConstElementPtr shared = global->get("shared-networks");
if (shared) {
BOOST_FOREACH(ElementPtr net, shared->listValue()) {
cnt += setDefaults(net, SHARED_NETWORK4_DEFAULTS);
ConstElementPtr subs = net->get("subnet4");
if (subs) {
cnt += setListDefaults(subs, SUBNET4_DEFAULTS);
cnt += setListDefaults(subs, SHARED_SUBNET4_DEFAULTS);
}
}
}
@@ -155,7 +192,7 @@ size_t SimpleParser4::deriveParameters(isc::data::ElementPtr global) {
if (subnets) {
BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
cnt += SimpleParser::deriveParams(global, single_subnet,
INHERIT_GLOBAL_TO_SUBNET4);
INHERIT_TO_SUBNET4);
}
}
@@ -169,16 +206,17 @@ size_t SimpleParser4::deriveParameters(isc::data::ElementPtr global) {
// if defined there.
// Then try to inherit them from global.
cnt += SimpleParser::deriveParams(global, net,
INHERIT_GLOBAL_TO_SUBNET4);
INHERIT_TO_SUBNET4);
// Now we need to go thrugh all the subnets in this net.
subnets = net->get("subnet4");
if (subnets) {
BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
cnt += SimpleParser::deriveParams(net, single_subnet,
INHERIT_GLOBAL_TO_SUBNET4);
INHERIT_TO_SUBNET4);
}
}
}
}