45 #include <boost/algorithm/string.hpp> 46 #include <boost/foreach.hpp> 47 #include <boost/lexical_cast.hpp> 48 #include <boost/scoped_ptr.hpp> 49 #include <boost/shared_ptr.hpp> 54 #include <netinet/in.h> 89 std::string option_str = source_elem->stringValue();
93 code = boost::lexical_cast<int64_t>(option_str);
97 << option_str <<
"', the option code must be a" 98 " non-negative value");
100 }
else if (code > std::numeric_limits<uint16_t>::max()) {
102 << option_str <<
"', the option code must not be" 103 " greater than '" << std::numeric_limits<uint16_t>::max()
107 }
catch (
const boost::bad_lexical_cast &) {
115 code = def->getCode();
118 " specified option name '" << option_str <<
"'" 119 " while parsing the list of enabled" 120 " relay-supplied-options");
123 cfg->getCfgRSOO()->enable(code);
125 }
catch (
const std::exception& ex) {
160 uint32_t probation_period =
161 getUint32(global,
"decline-probation-period");
162 srv_config->setDeclinePeriod(probation_period);
165 uint16_t dhcp4o6_port = getUint16(global,
"dhcp4o6-port");
166 srv_config->setDhcp4o6Port(dhcp4o6_port);
171 srv_config->setContext(user_context);
175 std::string server_tag = getString(global,
"server-tag");
176 srv_config->setServerTag(server_tag);
188 if (!dest || !from) {
200 for (
auto net = networks->begin(); net != networks->end(); ++net) {
211 for (
auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
231 sharedNetworksSanityChecks(*networks, global->get(
"shared-networks"));
253 std::set<string> names;
256 for (
auto net = networks.begin(); net != networks.end(); ++net) {
261 string iface = (*net)->getIface();
266 bool rapid_commit =
false;
269 for (
auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
273 if (subnet == subnets->begin()) {
275 rapid_commit = (*subnet)->getRapidCommit();
279 if (rapid_commit != (*subnet)->getRapidCommit()) {
281 "must have the same rapid-commit value. Subnet " 282 << (*subnet)->toText()
283 <<
" has specified rapid-commit " 284 << ( (*subnet)->getRapidCommit() ?
"true" :
"false")
285 <<
", but earlier subnet in the same shared-network" 286 <<
" or the shared-network itself used rapid-commit " 287 << (rapid_commit ?
"true" :
"false"));
293 iface = (*subnet)->getIface();
297 if ((*subnet)->getIface().empty()) {
301 if (iface != (*subnet)->getIface()) {
303 <<
" has specified interface " << (*subnet)->getIface()
304 <<
", but earlier subnet in the same shared-network" 305 <<
" or the shared-network itself used " << iface);
310 txt += (*subnet)->toText() +
" ";
315 if ((*net)->getName().empty()) {
317 << txt <<
" is missing mandatory 'name' parameter");
321 if (names.find((*net)->getName()) != names.end()) {
323 "name " << (*net)->getName() <<
" defined twice.");
325 names.insert((*net)->getName());
348 CfgMgr::instance().getStagingCfg()->getControlSocketInfo();
352 CfgMgr::instance().getCurrentCfg()->getControlSocketInfo();
357 bool sock_changed = (sock_cfg && current_sock_cfg &&
358 !sock_cfg->equals(*current_sock_cfg));
365 if (!sock_cfg || !current_sock_cfg || sock_changed) {
385 string(
"Can't parse NULL config"));
390 DHCP6_CONFIG_START).arg(config_set->str());
394 Subnet::resetSubnetID();
398 TimerMgr::instance()->unregisterTimers();
403 LibDHCP::revertRuntimeOptionDefs();
409 HostDataSourceFactory::printRegistered();
414 ElementPtr mutable_cfg = boost::const_pointer_cast<Element>(config_set);
420 bool rollback =
false;
427 SrvConfigPtr srv_config = CfgMgr::instance().getStagingCfg();
430 srv_config->extractConfiguredGlobals(config_set);
433 SimpleParser6::setAllDefaults(mutable_cfg);
436 SimpleParser6::deriveParameters(mutable_cfg);
439 const std::map<std::string, ConstElementPtr>& values_map =
440 mutable_cfg->mapValue();
447 parser.
parse(cfg_option_def, option_defs);
452 Dhcp6ConfigParser global_parser;
454 BOOST_FOREACH(config_pair, values_map) {
461 if (config_pair.first ==
"option-def") {
466 if (config_pair.first ==
"option-data") {
469 parser.
parse(cfg_option, config_pair.second);
473 if (config_pair.first ==
"mac-sources") {
476 parser.
parse(mac_source, config_pair.second);
480 if (config_pair.first ==
"control-socket") {
482 parser.
parse(*srv_config, config_pair.second);
486 if (config_pair.first ==
"dhcp-queue-control") {
488 srv_config->setDHCPQueueControl(parser.
parse(config_pair.second));
492 if (config_pair.first ==
"host-reservation-identifiers") {
494 parser.
parse(config_pair.second);
498 if (config_pair.first ==
"server-id") {
500 const CfgDUIDPtr& cfg = srv_config->getCfgDUID();
501 parser.
parse(cfg, config_pair.second);
505 if (config_pair.first ==
"interfaces-config") {
507 boost::const_pointer_cast<Element>(config_pair.second);
510 ifaces_cfg->set(
"re-detect", Element::create(
false));
514 parser.
parse(cfg_iface, ifaces_cfg);
518 if (config_pair.first ==
"sanity-checks") {
520 parser.
parse(*srv_config, config_pair.second);
524 if (config_pair.first ==
"expired-leases-processing") {
526 parser.
parse(config_pair.second);
530 if (config_pair.first ==
"hooks-libraries") {
532 HooksConfig& libraries = srv_config->getHooksConfig();
533 hooks_parser.
parse(libraries, config_pair.second);
538 if (config_pair.first ==
"dhcp-ddns") {
540 D2ClientConfigParser::setAllDefaults(config_pair.second);
543 srv_config->setD2ClientConfig(cfg);
547 if (config_pair.first ==
"client-classes") {
550 parser.
parse(config_pair.second, AF_INET6);
551 srv_config->setClientClassDictionary(dictionary);
556 if (config_pair.first ==
"lease-database") {
558 std::string access_string;
559 parser.
parse(access_string, config_pair.second);
561 cfg_db_access->setLeaseDbAccessString(access_string);
565 if (config_pair.first ==
"hosts-database") {
567 std::string access_string;
568 parser.
parse(access_string, config_pair.second);
570 cfg_db_access->setHostDbAccessString(access_string);
574 if (config_pair.first ==
"hosts-databases") {
577 auto list = config_pair.second->listValue();
578 for (
auto it : list) {
579 std::string access_string;
580 parser.
parse(access_string, it);
581 cfg_db_access->setHostDbAccessString(access_string);
586 if (config_pair.first ==
"subnet6") {
589 subnets_parser.
parse(srv_config, config_pair.second);
593 if (config_pair.first ==
"shared-networks") {
602 parser.
parse(cfg, config_pair.second);
606 global_parser.copySubnets6(srv_config->getCfgSubnets6(), cfg);
610 if (config_pair.first ==
"reservations") {
613 parser.
parse(SUBNET_ID_GLOBAL, config_pair.second, hosts);
614 for (
auto h = hosts.begin(); h != hosts.end(); ++h) {
615 srv_config->getCfgHosts()->add(*h);
621 if (config_pair.first ==
"config-control") {
624 CfgMgr::instance().getStagingCfg()->setConfigControlInfo(config_ctl_info);
633 if ( (config_pair.first ==
"renew-timer") ||
634 (config_pair.first ==
"rebind-timer") ||
635 (config_pair.first ==
"preferred-lifetime") ||
636 (config_pair.first ==
"valid-lifetime") ||
637 (config_pair.first ==
"decline-probation-period") ||
638 (config_pair.first ==
"dhcp4o6-port") ||
639 (config_pair.first ==
"user-context") ||
640 (config_pair.first ==
"server-tag") ||
641 (config_pair.first ==
"reservation-mode")) {
645 if (config_pair.first ==
"relay-supplied-options") {
646 RSOOListConfigParser parser;
647 parser.parse(srv_config, config_pair.second);
653 "unsupported global configuration parameter: " << config_pair.first
654 <<
" (" << config_pair.second->getPosition() <<
")");
658 global_parser.parse(srv_config, mutable_cfg);
663 global_parser.sanityChecks(srv_config, mutable_cfg);
667 .arg(config_pair.first).arg(ex.
what());
676 " processing error");
685 "Configuration seems sane. Control-socket, hook-libraries, and D2 " 686 "configuration were sanity checked, but not applied.");
705 cfg = CfgMgr::instance().getStagingCfg()->getD2ClientConfig();
706 CfgMgr::instance().setD2ClientConfig(cfg);
712 CfgMgr::instance().getStagingCfg()->getHooksConfig();
734 LibDHCP::revertRuntimeOptionDefs();
739 .arg(CfgMgr::instance().getStagingCfg()->
740 getConfigSummary(SrvConfig::CFGSEL_ALL6));
void parse(isc::data::ConstElementPtr expiration_config)
Parses parameters in the JSON map, pertaining to the processing of the expired leases.
Parser for the configuration of DHCP packet queue controls.
std::pair< std::string, isc::data::ConstElementPtr > ConfigPair
Combination of parameter name and configuration contents.
boost::shared_ptr< CfgSharedNetworks6 > CfgSharedNetworks6Ptr
Pointer to the configuration of IPv6 shared networks.
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
D2ClientConfigPtr parse(isc::data::ConstElementPtr d2_client_cfg)
Parses a given dhcp-ddns element into D2ClientConfig.
Parser for hooks library list.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
this class parses a list of DHCP6 subnets
void parse(const CfgDUIDPtr &cfg, isc::data::ConstElementPtr duid_configuration)
Parses DUID configuration.
Parse Database Parameters.
isc::data::ConstElementPtr configureDhcp6Server(Dhcpv6Srv &server, isc::data::ConstElementPtr config_set, bool check_only)
Configures DHCPv6 server.
ClientClassDictionaryPtr parse(isc::data::ConstElementPtr class_def_list, uint16_t family)
Parse configuration entries.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
boost::multi_index_container< SharedNetwork6Ptr, 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< SharedNetwork6, std::string, &SharedNetwork6::getName > > >> SharedNetwork6Collection
Multi index container holding shared networks.
boost::multi_index_container< Subnet6Ptr, 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 > > >> Subnet6Collection
A collection of Subnet6 objects.
Parser for a list of host identifiers for DHCPv6.
#define DHCP6_OPTION_SPACE
Parser for the configuration parameters pertaining to the processing of expired leases.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
std::vector< HostPtr > HostCollection
Collection of the Host objects.
Wrapper class that holds hooks libraries configuration.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
Parser for D2ClientConfig.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Parser for the configuration of interfaces.
void parse(const SubnetID &subnet_id, isc::data::ConstElementPtr hr_list, HostCollection &hosts_list)
Parses a list of host reservation entries for a subnet.
void parse(isc::data::ConstElementPtr ids_list)
Parses a list of host identifiers.
parser for MAC/hardware acquisition sources
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Parser for server DUID configuration.
Parsers for client class definitions.
Implements parser for config control information, "config-control".
Wrapper class that holds MAC/hardware address sources.
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
const int DBG_DHCP6_COMMAND
Debug level used to log receiving commands.
To be removed. Please use ConfigError instead.
void closeCommandSocket()
Shuts down any open control sockets.
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
Parser for a list of shared networks.
boost::shared_ptr< const Element > ConstElementPtr
void verifyLibraries(const isc::data::Element::Position &position) const
Verifies that libraries stored in libraries_ are valid.
Parser for option data values within a subnet.
boost::shared_ptr< CfgSubnets6 > CfgSubnets6Ptr
Non-const pointer.
Parser for a list of option definitions.
void loadLibraries() const
Commits hooks libraries configuration.
void parse(CfgMACSource &mac_sources, isc::data::ConstElementPtr value)
parses parameters value
void parse(const CfgIfacePtr &config, const isc::data::ConstElementPtr &values)
Parses content of the "interfaces-config".
Simple parser for sanity-checks structure.
void discardPackets()
Discards cached and parked packets Clears the call_handle store and packet parking lots of all packet...
void configureCommandChannel()
Initialize the command channel based on the staging configuration.
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
ConfigControlInfoPtr parse(const data::ConstElementPtr &config_control)
Parses a configuration control Element.
This is a base class for exceptions thrown from the DNS library module.
void openCommandSocket(const isc::data::ConstElementPtr &socket_info)
Opens control socket with parameters specified in socket_info.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void parse(SrvConfig &srv_cfg, isc::data::ConstElementPtr value)
"Parses" control-socket structure
Logging initialization functions.
This file contains several functions and constants that are used for handling commands and responses ...
void parse(CfgSharedNetworksTypePtr &cfg, const data::ConstElementPtr &shared_networks_list_data)
Parses a list of shared networks.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
data::ElementPtr parse(const isc::data::ConstElementPtr &control_elem)
Parses content of the "dhcp-queue-control".
Parser for a list of host reservations for a subnet.
void parse(SrvConfig &srv_cfg, const isc::data::ConstElementPtr &value)
parses JSON structure
OptionSpaceContainer< OptionDefContainer, OptionDefinitionPtr, std::string > OptionDefSpaceContainer
void parse(CfgOptionDefPtr cfg, isc::data::ConstElementPtr def_list)
Parses a list of option definitions, create them and store in cfg.
Parser for the control-socket structure.
boost::shared_ptr< CfgDUID > CfgDUIDPtr
Pointer to the Non-const object.
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< ConfigControlInfo > ConfigControlInfoPtr
Defines a pointer to a ConfigControlInfo.
void parse(std::string &access_string, isc::data::ConstElementPtr database_config)
Parse configuration value.
void parse(HooksConfig &libraries, isc::data::ConstElementPtr value)
Parses parameters value.
Parser for a list of client class definitions.
isc::log::Logger dhcp6_logger(DHCP6_APP_LOGGER_NAME)
Base logger for DHCPv6 server.
static CommandMgr & instance()
CommandMgr is a singleton class.