 |
Kea
1.5.0
|
Go to the documentation of this file.
39 #include <boost/foreach.hpp>
40 #include <boost/lexical_cast.hpp>
41 #include <boost/algorithm/string.hpp>
45 #include <netinet/in.h>
89 bool echo_client_id = getBoolean(global,
"echo-client-id");
90 cfg->setEchoClientId(echo_client_id);
93 uint32_t probation_period =
94 getUint32(global,
"decline-probation-period");
95 cfg->setDeclinePeriod(probation_period);
98 uint16_t dhcp4o6_port = getUint16(global,
"dhcp4o6-port");
99 cfg->setDhcp4o6Port(dhcp4o6_port);
104 cfg->setContext(user_context);
108 std::string server_tag = getString(global,
"server-tag");
109 cfg->setServerTag(server_tag);
121 if (!dest || !from) {
133 for (
auto net = networks->begin(); net != networks->end(); ++net) {
144 for (
auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
164 sharedNetworksSanityChecks(*networks, global->get(
"shared-networks"));
186 std::set<string> names;
189 for (
auto net = networks.begin(); net != networks.end(); ++net) {
194 string iface = (*net)->getIface();
195 bool authoritative = (*net)->getAuthoritative();
200 for (
auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
202 iface = (*subnet)->getIface();
206 if ((*subnet)->getIface().empty()) {
210 if (iface != (*subnet)->getIface()) {
212 <<
" has specified interface " << (*subnet)->getIface()
213 <<
", but earlier subnet in the same shared-network"
214 <<
" or the shared-network itself used " << iface);
217 if (authoritative != (*subnet)->getAuthoritative()) {
219 <<
" has different authoritative setting "
220 << (*subnet)->getAuthoritative()
221 <<
" than the shared-network itself: "
227 txt += (*subnet)->toText() +
" ";
232 if ((*net)->getName().empty()) {
234 << txt <<
" is missing mandatory 'name' parameter");
238 if (names.find((*net)->getName()) != names.end()) {
240 "name " << (*net)->getName() <<
" defined twice.");
242 names.insert((*net)->getName());
263 CfgMgr::instance().getStagingCfg()->getControlSocketInfo();
267 CfgMgr::instance().getCurrentCfg()->getControlSocketInfo();
272 bool sock_changed = (sock_cfg && current_sock_cfg &&
273 !sock_cfg->equals(*current_sock_cfg));
280 if (!sock_cfg || !current_sock_cfg || sock_changed) {
299 string(
"Can't parse NULL config"));
304 DHCP4_CONFIG_START).arg(config_set->str());
308 Subnet::resetSubnetID();
312 TimerMgr::instance()->unregisterTimers();
317 LibDHCP::revertRuntimeOptionDefs();
323 HostDataSourceFactory::printRegistered();
329 bool rollback =
false;
338 srv_cfg = CfgMgr::instance().getStagingCfg();
341 srv_cfg->extractConfiguredGlobals(config_set);
346 mutable_cfg = boost::const_pointer_cast<Element>(config_set);
349 SimpleParser4::setAllDefaults(mutable_cfg);
352 SimpleParser4::deriveParameters(mutable_cfg);
359 parser.
parse(cfg_option_def, option_defs);
364 Dhcp4ConfigParser global_parser;
367 const std::map<std::string, ConstElementPtr>& values_map =
368 mutable_cfg->mapValue();
369 BOOST_FOREACH(config_pair, values_map) {
375 if (config_pair.first ==
"option-def") {
380 if (config_pair.first ==
"option-data") {
383 parser.
parse(cfg_option, config_pair.second);
387 if (config_pair.first ==
"control-socket") {
389 parser.
parse(*srv_cfg, config_pair.second);
393 if (config_pair.first ==
"dhcp-queue-control") {
395 srv_cfg->setDHCPQueueControl(parser.
parse(config_pair.second));
399 if (config_pair.first ==
"host-reservation-identifiers") {
401 parser.
parse(config_pair.second);
405 if (config_pair.first ==
"interfaces-config") {
407 boost::const_pointer_cast<Element>(config_pair.second);
410 ifaces_cfg->set(
"re-detect", Element::create(
false));
414 parser.
parse(cfg_iface, ifaces_cfg);
418 if (config_pair.first ==
"sanity-checks") {
420 parser.
parse(*srv_cfg, config_pair.second);
424 if (config_pair.first ==
"expired-leases-processing") {
426 parser.
parse(config_pair.second);
430 if (config_pair.first ==
"hooks-libraries") {
432 HooksConfig& libraries = srv_cfg->getHooksConfig();
433 hooks_parser.
parse(libraries, config_pair.second);
439 if (config_pair.first ==
"dhcp-ddns") {
441 D2ClientConfigParser::setAllDefaults(config_pair.second);
444 srv_cfg->setD2ClientConfig(cfg);
448 if (config_pair.first ==
"client-classes") {
451 parser.
parse(config_pair.second, AF_INET);
452 srv_cfg->setClientClassDictionary(dictionary);
457 if (config_pair.first ==
"lease-database") {
459 std::string access_string;
460 parser.
parse(access_string, config_pair.second);
462 cfg_db_access->setLeaseDbAccessString(access_string);
466 if (config_pair.first ==
"hosts-database") {
468 std::string access_string;
469 parser.
parse(access_string, config_pair.second);
471 cfg_db_access->setHostDbAccessString(access_string);
475 if (config_pair.first ==
"hosts-databases") {
478 auto list = config_pair.second->listValue();
479 for (
auto it : list) {
480 std::string access_string;
481 parser.
parse(access_string, it);
482 cfg_db_access->setHostDbAccessString(access_string);
487 if (config_pair.first ==
"subnet4") {
490 subnets_parser.
parse(srv_cfg, config_pair.second);
494 if (config_pair.first ==
"shared-networks") {
503 parser.
parse(cfg, config_pair.second);
507 global_parser.copySubnets4(srv_cfg->getCfgSubnets4(), cfg);
511 if (config_pair.first ==
"reservations") {
514 parser.
parse(SUBNET_ID_GLOBAL, config_pair.second, hosts);
515 for (
auto h = hosts.begin(); h != hosts.end(); ++h) {
516 srv_cfg->getCfgHosts()->add(*h);
522 if (config_pair.first ==
"config-control") {
525 CfgMgr::instance().getStagingCfg()->setConfigControlInfo(config_ctl_info);
536 if ( (config_pair.first ==
"renew-timer") ||
537 (config_pair.first ==
"rebind-timer") ||
538 (config_pair.first ==
"valid-lifetime") ||
539 (config_pair.first ==
"decline-probation-period") ||
540 (config_pair.first ==
"dhcp4o6-port") ||
541 (config_pair.first ==
"echo-client-id") ||
542 (config_pair.first ==
"user-context") ||
543 (config_pair.first ==
"match-client-id") ||
544 (config_pair.first ==
"authoritative") ||
545 (config_pair.first ==
"next-server") ||
546 (config_pair.first ==
"server-hostname") ||
547 (config_pair.first ==
"boot-file-name") ||
548 (config_pair.first ==
"server-tag") ||
549 (config_pair.first ==
"reservation-mode")) {
555 "unsupported global configuration parameter: " << config_pair.first
556 <<
" (" << config_pair.second->getPosition() <<
")");
560 global_parser.parse(srv_cfg, mutable_cfg);
565 global_parser.sanityChecks(srv_cfg, mutable_cfg);
569 .arg(config_pair.first).arg(ex.
what());
579 " processing error");
589 "Configuration seems sane. Control-socket, hook-libraries, and D2 "
590 "configuration were sanity checked, but not applied.");
608 cfg = CfgMgr::instance().getStagingCfg()->getD2ClientConfig();
609 CfgMgr::instance().setD2ClientConfig(cfg);
615 CfgMgr::instance().getStagingCfg()->getHooksConfig();
618 #ifdef CONFIG_BACKEND // Disabled until we restart CB work
641 LibDHCP::revertRuntimeOptionDefs();
646 .arg(CfgMgr::instance().getStagingCfg()->
647 getConfigSummary(SrvConfig::CFGSEL_ALL4));
662 if (!config_ctl || config_ctl->getConfigDatabases().empty()) {
668 for (
auto db : config_ctl->getConfigDatabases()) {
670 .arg(db.redactedAccessString());
void parse(CfgOptionDefPtr cfg, isc::data::ConstElementPtr def_list)
Parses a list of option definitions, create them and store in cfg.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
Parser for the configuration of interfaces.
To be removed. Please use ConfigError instead.
void verifyLibraries(const isc::data::Element::Position &position) const
Verifies that libraries stored in libraries_ are valid.
void parse(const CfgIfacePtr &config, const isc::data::ConstElementPtr &values)
Parses content of the "interfaces-config".
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
void parse(CfgSharedNetworksTypePtr &cfg, const data::ConstElementPtr &shared_networks_list_data)
Parses a list of shared networks.
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
isc::data::ConstElementPtr configureDhcp4Server(Dhcpv4Srv &server, isc::data::ConstElementPtr config_set, bool check_only)
Configure DHCPv4 server (Dhcpv4Srv) with a set of configuration values.
this class parses list of DHCP4 subnets
void databaseConfigFetch(const SrvConfigPtr &srv_cfg, ElementPtr)
Fetch configuration from CB databases and merge it into the given configuration.
boost::multi_index_container< SharedNetwork4Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SharedNetworkRandomAccessIndexTag > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SharedNetworkNameIndexTag >, boost::multi_index::const_mem_fun< SharedNetwork4, std::string, &SharedNetwork4::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SharedNetworkServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > > >> SharedNetwork4Collection
Multi index container holding shared networks.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
Parser for a list of client class definitions.
boost::shared_ptr< CfgSubnets4 > CfgSubnets4Ptr
Non-const pointer.
void addBackend(const std::string &dbaccess)
Create an instance of a configuration backend.
boost::shared_ptr< CfgSharedNetworks4 > CfgSharedNetworks4Ptr
Pointer to the configuration of IPv4 shared networks.
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
Parser for hooks library list.
Simple parser for sanity-checks structure.
This is a base class for exceptions thrown from the DNS library module.
void parse(isc::data::ConstElementPtr expiration_config)
Parses parameters in the JSON map, pertaining to the processing of the expired leases.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Parser for a list of shared networks.
D2ClientConfigPtr parse(isc::data::ConstElementPtr d2_client_cfg)
Parses a given dhcp-ddns element into D2ClientConfig.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Parse Database Parameters.
OptionSpaceContainer< OptionDefContainer, OptionDefinitionPtr, std::string > OptionDefSpaceContainer
Wrapper class that holds hooks libraries configuration.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
static CommandMgr & instance()
CommandMgr is a singleton class.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
void openCommandSocket(const isc::data::ConstElementPtr &socket_info)
Opens control socket with parameters specified in socket_info.
void loadLibraries() const
Commits hooks libraries configuration.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
data::ElementPtr parse(const isc::data::ConstElementPtr &control_elem)
Parses content of the "dhcp-queue-control".
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
void configureCommandChannel()
Initialize the command channel based on the staging configuration.
boost::shared_ptr< ConfigControlInfo > ConfigControlInfoPtr
Defines a pointer to a ConfigControlInfo.
ClientClassDictionaryPtr parse(isc::data::ConstElementPtr class_def_list, uint16_t family)
Parse configuration entries.
void parse(HooksConfig &libraries, isc::data::ConstElementPtr value)
Parses parameters value.
Configuration Backend Manager for DHPCv4 servers.
boost::shared_ptr< const ConfigControlInfo > ConstConfigControlInfoPtr
Defines a pointer to a const ConfigControlInfo.
Parser for option data values within a subnet.
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
Parser for a list of option definitions.
Parser for a list of host reservations for a subnet.
void parse(isc::data::ConstElementPtr ids_list)
Parses a list of host identifiers.
ConfigControlInfoPtr parse(const data::ConstElementPtr &config_control)
Parses a configuration control Element.
void delAllBackends()
Removes all backends from the pool.
bool databaseConfigConnect(const SrvConfigPtr &srv_cfg)
Attempts to connect to configured CB databases.
Implements parser for config control information, "config-control".
std::pair< std::string, isc::data::ConstElementPtr > ConfigPair
Combination of parameter name and configuration contents.
Parsers for client class definitions.
const int DBG_DHCP4_COMMAND
Debug level used to log receiving commands.
void parse(std::string &access_string, isc::data::ConstElementPtr database_config)
Parse configuration value.
Parser for the configuration of DHCP packet queue controls.
void parse(SrvConfig &srv_cfg, isc::data::ConstElementPtr value)
"Parses" control-socket structure
Parser for D2ClientConfig.
void closeCommandSocket()
Shuts down any open control sockets.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME)
Base logger for DHCPv4 server.
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< const Element > ConstElementPtr
void discardPackets()
Discard all in-progress packets.
Parser for the control-socket structure.
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Parser for the configuration parameters pertaining to the processing of expired leases.
void parse(SrvConfig &srv_cfg, const isc::data::ConstElementPtr &value)
parses JSON structure
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
void parse(const SubnetID &subnet_id, isc::data::ConstElementPtr hr_list, HostCollection &hosts_list)
Parses a list of host reservation entries for a subnet.
Parser for a list of host identifiers for DHCPv4.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SubnetRandomAccessIndexTag > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > > >> Subnet4Collection
A collection of Subnet4 objects.
std::vector< HostPtr > HostCollection
Collection of the Host objects.