continue;
}
- // Timers are not used in the global scope. Their values are derived
- // to specific subnets (see SimpleParser6::deriveParameters).
- // decline-probation-period, dhcp4o6-port, echo-client-id,
- // user-context are handled in global_parser.parse() which
- // sets global parameters.
- // match-client-id and authoritative are derived to subnet scope
- // level.
+ // As of Kea 1.6.0 we have two ways of inheriting the global parameters.
+ // The old method is used in JSON configuration parsers when the global
+ // parameters are derived into the subnets and shared networks and are
+ // being treated as explicitly specified. The new way used by the config
+ // backend is the dynamic inheritance whereby each subnet and shared
+ // network uses a callback function to return global parameter if it
+ // is not specified at lower level. This callback uses configured globals.
+ // Let's store all globals there so as they can be accessed.
if ( (config_pair.first == "renew-timer") ||
(config_pair.first == "rebind-timer") ||
(config_pair.first == "valid-lifetime") ||
(config_pair.first == "calculate-tee-times") ||
(config_pair.first == "t1-percent") ||
(config_pair.first == "t2-percent")) {
+
+ CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first,
+ config_pair.second);
continue;
}
continue;
}
- // Timers are not used in the global scope. Their values are derived
- // to specific subnets (see SimpleParser6::deriveParameters).
- // decline-probation-period, dhcp4o6-port and user-context
- // are handled in the global_parser.parse() which sets
- // global parameters.
+ // As of Kea 1.6.0 we have two ways of inheriting the global parameters.
+ // The old method is used in JSON configuration parsers when the global
+ // parameters are derived into the subnets and shared networks and are
+ // being treated as explicitly specified. The new way used by the config
+ // backend is the dynamic inheritance whereby each subnet and shared
+ // network uses a callback function to return global parameter if it
+ // is not specified at lower level. This callback uses configured globals.
+ // Let's store all globals there so as they can be accessed.
if ( (config_pair.first == "renew-timer") ||
(config_pair.first == "rebind-timer") ||
(config_pair.first == "preferred-lifetime") ||
(config_pair.first == "user-context") ||
(config_pair.first == "server-tag") ||
(config_pair.first == "reservation-mode")) {
+ CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first,
+ config_pair.second);
continue;
}
for (auto network = networks.begin(); network != networks.end(); ++network) {
// In order to take advantage of the dynamic inheritance of global
// parameters to a shared network we need to set a callback function
- // for each network which can be used to fetch global parameters.
+ // for each network to allow for fetching global parameters.
(*network)->setFetchGlobalsFn([] () -> ConstElementPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
// In order to take advantage of the dynamic inheritance of global
// parameters to a subnet we need to set a callback function for each
- // subnet which can be used to fetch global parameters.
+ // subnet to allow for fetching global parameters.
(*subnet)->setFetchGlobalsFn([] () -> ConstElementPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
subnet_->setContext(user_context);
}
+ // In order to take advantage of the dynamic inheritance of global
+ // parameters to a subnet we need to set a callback function for each
+ // subnet to allow for fetching global parameters.
+ subnet_->setFetchGlobalsFn([]() -> ConstElementPtr {
+ return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
+ });
+
}
//****************************** Subnet4ConfigParser *************************
#include <asiolink/io_address.h>
#include <cc/data.h>
+#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <dhcpsrv/parsers/option_data_parser.h>
<< shared_network_data->getPosition() << ")");
}
+ // In order to take advantage of the dynamic inheritance of global
+ // parameters to a shared network we need to set a callback function
+ // for each shared network to allow for fetching global parameters.
+ shared_network->setFetchGlobalsFn([]() -> ConstElementPtr {
+ return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
+ });
+
return (shared_network);
}
<< shared_network_data->getPosition() << ")");
}
+ // In order to take advantage of the dynamic inheritance of global
+ // parameters to a shared network we need to set a callback function
+ // for each shared network which can be used to fetch global parameters.
+ shared_network->setFetchGlobalsFn([]() -> ConstElementPtr {
+ return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
+ });
+
return (shared_network);
}
auto subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets4()->getSubnet(123);
ASSERT_TRUE(subnet);
+ EXPECT_TRUE(subnet->hasFetchGlobalsFn());
+
EXPECT_TRUE(subnet->getIface().unspecified());
EXPECT_TRUE(subnet->getIface().empty());
auto subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->getSubnet(123);
ASSERT_TRUE(subnet);
+ EXPECT_TRUE(subnet->hasFetchGlobalsFn());
+
EXPECT_TRUE(subnet->getIface().unspecified());
EXPECT_TRUE(subnet->getIface().empty());
CfgMgr::instance().getStagingCfg()->getCfgSharedNetworks4()->getByName("frog");
ASSERT_TRUE(network);
+ EXPECT_TRUE(network->hasFetchGlobalsFn());
+
EXPECT_TRUE(network->getIface().unspecified());
EXPECT_TRUE(network->getIface().empty());
CfgMgr::instance().getStagingCfg()->getCfgSharedNetworks6()->getByName("frog");
ASSERT_TRUE(network);
+ EXPECT_TRUE(network->hasFetchGlobalsFn());
+
EXPECT_TRUE(network->getIface().unspecified());
EXPECT_TRUE(network->getIface().empty());