Kea 1.5.0
dhcp4/json_config_parser.cc
Go to the documentation of this file.
1// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
11#include <dhcp4/dhcp4_log.h>
12#include <dhcp4/dhcp4_srv.h>
14#include <dhcp/libdhcp++.h>
16#include <dhcpsrv/cfg_option.h>
17#include <dhcpsrv/cfgmgr.h>
19#include <dhcpsrv/db_type.h>
32#include <dhcpsrv/timer_mgr.h>
34#include <hooks/hooks_parser.h>
35#include <config/command_mgr.h>
36#include <util/encode/hex.h>
37#include <util/strutil.h>
38
39#include <boost/foreach.hpp>
40#include <boost/lexical_cast.hpp>
41#include <boost/algorithm/string.hpp>
42
43#include <limits>
44#include <iostream>
45#include <netinet/in.h>
46#include <vector>
47#include <map>
48
49using namespace std;
50using namespace isc;
51using namespace isc::dhcp;
52using namespace isc::data;
53using namespace isc::asiolink;
54using namespace isc::hooks;
55using namespace isc::process;
56using namespace isc::config;
57
58namespace {
59
68class Dhcp4ConfigParser : public isc::data::SimpleParser {
69public:
70
85 void parse(const SrvConfigPtr& cfg, const ConstElementPtr& global) {
86
87 // Set whether v4 server is supposed to echo back client-id
88 // (yes = RFC6842 compatible, no = backward compatibility)
89 bool echo_client_id = getBoolean(global, "echo-client-id");
90 cfg->setEchoClientId(echo_client_id);
91
92 // Set the probation period for decline handling.
93 uint32_t probation_period =
94 getUint32(global, "decline-probation-period");
95 cfg->setDeclinePeriod(probation_period);
96
97 // Set the DHCPv4-over-DHCPv6 interserver port.
98 uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port");
99 cfg->setDhcp4o6Port(dhcp4o6_port);
100
101 // Set the global user context.
102 ConstElementPtr user_context = global->get("user-context");
103 if (user_context) {
104 cfg->setContext(user_context);
105 }
106
107 // Set the server's logical name
108 std::string server_tag = getString(global, "server-tag");
109 cfg->setServerTag(server_tag);
110 }
111
118 void
119 copySubnets4(const CfgSubnets4Ptr& dest, const CfgSharedNetworks4Ptr& from) {
120
121 if (!dest || !from) {
122 isc_throw(BadValue, "Unable to copy subnets: at least one pointer is null");
123 }
124
125 const SharedNetwork4Collection* networks = from->getAll();
126 if (!networks) {
127 // Nothing to copy. Technically, it should return a pointer to empty
128 // container, but let's handle null pointer as well.
129 return;
130 }
131
132 // Let's go through all the networks one by one
133 for (auto net = networks->begin(); net != networks->end(); ++net) {
134
135 // For each network go through all the subnets in it.
136 const Subnet4Collection* subnets = (*net)->getAllSubnets();
137 if (!subnets) {
138 // Shared network without subnets it weird, but we decided to
139 // accept such configurations.
140 continue;
141 }
142
143 // For each subnet, add it to a list of regular subnets.
144 for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
145 dest->add(*subnet);
146 }
147 }
148 }
149
158 void
159 sanityChecks(const SrvConfigPtr& cfg, const ConstElementPtr& global) {
160
162 const SharedNetwork4Collection* networks = cfg->getCfgSharedNetworks4()->getAll();
163 if (networks) {
164 sharedNetworksSanityChecks(*networks, global->get("shared-networks"));
165 }
166 }
167
174 void
175 sharedNetworksSanityChecks(const SharedNetwork4Collection& networks,
176 ConstElementPtr json) {
177
179 if (!json) {
180 // No json? That means that the shared-networks was never specified
181 // in the config.
182 return;
183 }
184
185 // Used for names uniqueness checks.
186 std::set<string> names;
187
188 // Let's go through all the networks one by one
189 for (auto net = networks.begin(); net != networks.end(); ++net) {
190 string txt;
191
192 // Let's check if all subnets have either the same interface
193 // or don't have the interface specified at all.
194 string iface = (*net)->getIface();
195 bool authoritative = (*net)->getAuthoritative();
196
197 const Subnet4Collection* subnets = (*net)->getAllSubnets();
198 if (subnets) {
199 // For each subnet, add it to a list of regular subnets.
200 for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
201 if (iface.empty()) {
202 iface = (*subnet)->getIface();
203 continue;
204 }
205
206 if ((*subnet)->getIface().empty()) {
207 continue;
208 }
209
210 if (iface != (*subnet)->getIface()) {
211 isc_throw(DhcpConfigError, "Subnet " << (*subnet)->toText()
212 << " has specified interface " << (*subnet)->getIface()
213 << ", but earlier subnet in the same shared-network"
214 << " or the shared-network itself used " << iface);
215 }
216
217 if (authoritative != (*subnet)->getAuthoritative()) {
218 isc_throw(DhcpConfigError, "Subnet " << (*subnet)->toText()
219 << " has different authoritative setting "
220 << (*subnet)->getAuthoritative()
221 << " than the shared-network itself: "
222 << authoritative);
223 }
224
225 // Let's collect the subnets in case we later find out the
226 // subnet doesn't have a mandatory name.
227 txt += (*subnet)->toText() + " ";
228 }
229 }
230
231 // Next, let's check name of the shared network.
232 if ((*net)->getName().empty()) {
233 isc_throw(DhcpConfigError, "Shared-network with subnets "
234 << txt << " is missing mandatory 'name' parameter");
235 }
236
237 // Is it unique?
238 if (names.find((*net)->getName()) != names.end()) {
239 isc_throw(DhcpConfigError, "A shared-network with "
240 "name " << (*net)->getName() << " defined twice.");
241 }
242 names.insert((*net)->getName());
243
244 }
245 }
246};
247
248} // anonymous namespace
249
250namespace isc {
251namespace dhcp {
252
261 // Get new socket configuration.
262 ConstElementPtr sock_cfg =
263 CfgMgr::instance().getStagingCfg()->getControlSocketInfo();
264
265 // Get current socket configuration.
266 ConstElementPtr current_sock_cfg =
267 CfgMgr::instance().getCurrentCfg()->getControlSocketInfo();
268
269 // Determine if the socket configuration has changed. It has if
270 // both old and new configuration is specified but respective
271 // data elements aren't equal.
272 bool sock_changed = (sock_cfg && current_sock_cfg &&
273 !sock_cfg->equals(*current_sock_cfg));
274
275 // If the previous or new socket configuration doesn't exist or
276 // the new configuration differs from the old configuration we
277 // close the existing socket and open a new socket as appropriate.
278 // Note that closing an existing socket means the client will not
279 // receive the configuration result.
280 if (!sock_cfg || !current_sock_cfg || sock_changed) {
281 // Close the existing socket (if any).
283
284 if (sock_cfg) {
285 // This will create a control socket and install the external
286 // socket in IfaceMgr. That socket will be monitored when
287 // Dhcp4Srv::receivePacket() calls IfaceMgr::receive4() and
288 // callback in CommandMgr will be called, if necessary.
290 }
291 }
292}
293
296 bool check_only) {
297 if (!config_set) {
299 string("Can't parse NULL config"));
300 return (answer);
301 }
302
304 DHCP4_CONFIG_START).arg(config_set->str());
305
306 // Before starting any subnet operations, let's reset the subnet-id counter,
307 // so newly recreated configuration starts with first subnet-id equal 1.
309
310 // Remove any existing timers.
311 if (!check_only) {
312 TimerMgr::instance()->unregisterTimers();
313 server.discardPackets();
314 }
315
316 // Revert any runtime option definitions configured so far and not committed.
318 // Let's set empty container in case a user hasn't specified any configuration
319 // for option definitions. This is equivalent to committing empty container.
321
322 // Print the list of known backends.
324
325 // Answer will hold the result.
326 ConstElementPtr answer;
327 // Rollback informs whether error occurred and original data
328 // have to be restored to global storages.
329 bool rollback = false;
330 // config_pair holds the details of the current parser when iterating over
331 // the parsers. It is declared outside the loops so in case of an error,
332 // the name of the failing parser can be retrieved in the "catch" clause.
333 ConfigPair config_pair;
334 ElementPtr mutable_cfg;
335 SrvConfigPtr srv_cfg;
336 try {
337 // Get the staging configuration
338 srv_cfg = CfgMgr::instance().getStagingCfg();
339
340 // Preserve all scalar global parameters
341 srv_cfg->extractConfiguredGlobals(config_set);
342
343 // This is a way to convert ConstElementPtr to ElementPtr.
344 // We need a config that can be edited, because we will insert
345 // default values and will insert derived values as well.
346 mutable_cfg = boost::const_pointer_cast<Element>(config_set);
347
348 // Set all default values if not specified by the user.
350
351 // And now derive (inherit) global parameters to subnets, if not specified.
353
354 // We need definitions first
355 ConstElementPtr option_defs = mutable_cfg->get("option-def");
356 if (option_defs) {
357 OptionDefListParser parser;
358 CfgOptionDefPtr cfg_option_def = srv_cfg->getCfgOptionDef();
359 parser.parse(cfg_option_def, option_defs);
360 }
361
362 // This parser is used in several places, so it should be available
363 // early.
364 Dhcp4ConfigParser global_parser;
365
366 // Make parsers grouping.
367 const std::map<std::string, ConstElementPtr>& values_map =
368 mutable_cfg->mapValue();
369 BOOST_FOREACH(config_pair, values_map) {
370 // In principle we could have the following code structured as a series
371 // of long if else if clauses. That would give a marginal performance
372 // boost, but would make the code less readable. We had serious issues
373 // with the parser code debugability, so I decided to keep it as a
374 // series of independent ifs.
375 if (config_pair.first == "option-def") {
376 // This is converted to SimpleParser and is handled already above.
377 continue;
378 }
379
380 if (config_pair.first == "option-data") {
381 OptionDataListParser parser(AF_INET);
382 CfgOptionPtr cfg_option = srv_cfg->getCfgOption();
383 parser.parse(cfg_option, config_pair.second);
384 continue;
385 }
386
387 if (config_pair.first == "control-socket") {
388 ControlSocketParser parser;
389 parser.parse(*srv_cfg, config_pair.second);
390 continue;
391 }
392
393 if (config_pair.first == "dhcp-queue-control") {
395 srv_cfg->setDHCPQueueControl(parser.parse(config_pair.second));
396 continue;
397 }
398
399 if (config_pair.first == "host-reservation-identifiers") {
401 parser.parse(config_pair.second);
402 continue;
403 }
404
405 if (config_pair.first == "interfaces-config") {
406 ElementPtr ifaces_cfg =
407 boost::const_pointer_cast<Element>(config_pair.second);
408 if (check_only) {
409 // No re-detection in check only mode
410 ifaces_cfg->set("re-detect", Element::create(false));
411 }
412 IfacesConfigParser parser(AF_INET);
413 CfgIfacePtr cfg_iface = srv_cfg->getCfgIface();
414 parser.parse(cfg_iface, ifaces_cfg);
415 continue;
416 }
417
418 if (config_pair.first == "sanity-checks") {
419 SanityChecksParser parser;
420 parser.parse(*srv_cfg, config_pair.second);
421 continue;
422 }
423
424 if (config_pair.first == "expired-leases-processing") {
426 parser.parse(config_pair.second);
427 continue;
428 }
429
430 if (config_pair.first == "hooks-libraries") {
431 HooksLibrariesParser hooks_parser;
432 HooksConfig& libraries = srv_cfg->getHooksConfig();
433 hooks_parser.parse(libraries, config_pair.second);
434 libraries.verifyLibraries(config_pair.second->getPosition());
435 continue;
436 }
437
438 // Legacy DhcpConfigParser stuff below
439 if (config_pair.first == "dhcp-ddns") {
440 // Apply defaults
441 D2ClientConfigParser::setAllDefaults(config_pair.second);
443 D2ClientConfigPtr cfg = parser.parse(config_pair.second);
444 srv_cfg->setD2ClientConfig(cfg);
445 continue;
446 }
447
448 if (config_pair.first == "client-classes") {
450 ClientClassDictionaryPtr dictionary =
451 parser.parse(config_pair.second, AF_INET);
452 srv_cfg->setClientClassDictionary(dictionary);
453 continue;
454 }
455
456 // Please move at the end when migration will be finished.
457 if (config_pair.first == "lease-database") {
458 db::DbAccessParser parser;
459 std::string access_string;
460 parser.parse(access_string, config_pair.second);
461 CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
462 cfg_db_access->setLeaseDbAccessString(access_string);
463 continue;
464 }
465
466 if (config_pair.first == "hosts-database") {
467 db::DbAccessParser parser;
468 std::string access_string;
469 parser.parse(access_string, config_pair.second);
470 CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
471 cfg_db_access->setHostDbAccessString(access_string);
472 continue;
473 }
474
475 if (config_pair.first == "hosts-databases") {
476 CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
477 db::DbAccessParser parser;
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);
483 }
484 continue;
485 }
486
487 if (config_pair.first == "subnet4") {
488 Subnets4ListConfigParser subnets_parser;
489 // parse() returns number of subnets parsed. We may log it one day.
490 subnets_parser.parse(srv_cfg, config_pair.second);
491 continue;
492 }
493
494 if (config_pair.first == "shared-networks") {
495
502 CfgSharedNetworks4Ptr cfg = srv_cfg->getCfgSharedNetworks4();
503 parser.parse(cfg, config_pair.second);
504
505 // We also need to put the subnets it contains into normal
506 // subnets list.
507 global_parser.copySubnets4(srv_cfg->getCfgSubnets4(), cfg);
508 continue;
509 }
510
511 if (config_pair.first == "reservations") {
512 HostCollection hosts;
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);
517 }
518
519 continue;
520 }
521
522 if (config_pair.first == "config-control") {
523 ConfigControlParser parser;
524 ConfigControlInfoPtr config_ctl_info = parser.parse(config_pair.second);
525 CfgMgr::instance().getStagingCfg()->setConfigControlInfo(config_ctl_info);
526 continue;
527 }
528
529 // Timers are not used in the global scope. Their values are derived
530 // to specific subnets (see SimpleParser6::deriveParameters).
531 // decline-probation-period, dhcp4o6-port, echo-client-id,
532 // user-context are handled in global_parser.parse() which
533 // sets global parameters.
534 // match-client-id and authoritative are derived to subnet scope
535 // level.
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")) {
550 continue;
551 }
552
553 // If we got here, no code handled this parameter, so we bail out.
555 "unsupported global configuration parameter: " << config_pair.first
556 << " (" << config_pair.second->getPosition() << ")");
557 }
558
559 // Apply global options in the staging config.
560 global_parser.parse(srv_cfg, mutable_cfg);
561
562 // This method conducts final sanity checks and tweaks. In particular,
563 // it checks that there is no conflict between plain subnets and those
564 // defined as part of shared networks.
565 global_parser.sanityChecks(srv_cfg, mutable_cfg);
566
567 } catch (const isc::Exception& ex) {
568 LOG_ERROR(dhcp4_logger, DHCP4_PARSER_FAIL)
569 .arg(config_pair.first).arg(ex.what());
571
572 // An error occurred, so make sure that we restore original data.
573 rollback = true;
574
575 } catch (...) {
576 // For things like bad_cast in boost::lexical_cast
577 LOG_ERROR(dhcp4_logger, DHCP4_PARSER_EXCEPTION).arg(config_pair.first);
578 answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, "undefined configuration"
579 " processing error");
580
581 // An error occurred, so make sure that we restore original data.
582 rollback = true;
583 }
584
585 if (check_only) {
586 rollback = true;
587 if (!answer) {
589 "Configuration seems sane. Control-socket, hook-libraries, and D2 "
590 "configuration were sanity checked, but not applied.");
591 }
592 }
593
594 // So far so good, there was no parsing error so let's commit the
595 // configuration. This will add created subnets and option values into
596 // the server's configuration.
597 // This operation should be exception safe but let's make sure.
598 if (!rollback) {
599 try {
600 // Setup the command channel.
602
603 // No need to commit interface names as this is handled by the
604 // CfgMgr::commit() function.
605
606 // Apply the staged D2ClientConfig, used to be done by parser commit
608 cfg = CfgMgr::instance().getStagingCfg()->getD2ClientConfig();
610
611 // This occurs last as if it succeeds, there is no easy way
612 // revert it. As a result, the failure to commit a subsequent
613 // change causes problems when trying to roll back.
614 const HooksConfig& libraries =
615 CfgMgr::instance().getStagingCfg()->getHooksConfig();
616 libraries.loadLibraries();
617
618#ifdef CONFIG_BACKEND // Disabled until we restart CB work
619 // If there are config backends, fetch and merge into staging config
620 databaseConfigFetch(srv_cfg, mutable_cfg);
621#endif
622 }
623 catch (const isc::Exception& ex) {
624 LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
626 rollback = true;
627 } catch (...) {
628 // For things like bad_cast in boost::lexical_cast
629 LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_EXCEPTION);
630 answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, "undefined configuration"
631 " parsing error");
632 rollback = true;
633 }
634 }
635
636
637 // Rollback changes as the configuration parsing failed.
638 if (rollback) {
639 // Revert to original configuration of runtime option definitions
640 // in the libdhcp++.
642 return (answer);
643 }
644
645 LOG_INFO(dhcp4_logger, DHCP4_CONFIG_COMPLETE)
646 .arg(CfgMgr::instance().getStagingCfg()->
647 getConfigSummary(SrvConfig::CFGSEL_ALL4));
648
649 // Everything was fine. Configuration is successful.
650 answer = isc::config::createAnswer(CONTROL_RESULT_SUCCESS, "Configuration successful.");
651 return (answer);
652}
653
655 // We need to get rid of any existing backends. These would be any
656 // opened by previous configuration cycle.
658 mgr.delAllBackends();
659
660 // Fetch the config-control info.
661 ConstConfigControlInfoPtr config_ctl = srv_cfg->getConfigControlInfo();
662 if (!config_ctl || config_ctl->getConfigDatabases().empty()) {
663 // No config dbs, nothing to do.
664 return (false);
665 }
666
667 // Iterate over the configured DBs and instantiate them.
668 for (auto db : config_ctl->getConfigDatabases()) {
669 LOG_INFO(dhcp4_logger, DHCP4_OPEN_CONFIG_DB)
670 .arg(db.redactedAccessString());
671 mgr.addBackend(db.getAccessString());
672 }
673
674 // Let the caller know we have opened DBs.
675 return (true);
676}
677
678void databaseConfigFetch(const SrvConfigPtr& srv_cfg, ElementPtr /* mutable_cfg */) {
679
680 // Close any existing CB databasess, then open all in srv_cfg (if any)
681 if (!databaseConfigConnect(srv_cfg)) {
682 // There are no CB databases so we're done
683 return;
684 }
685
686 // @todo Fetching and merging the configuration falls under #99
687 // ConfigBackendDHCPv4Mgr& mgr = ConfigBackendDHCPv4Mgr::instance();
688 // Next we have to fetch the pieces we care about it and merge them
689 // probably in this order?
690 // globals
691 // option defs
692 // options
693 // shared networks
694 // subnets
695}
696
697
698}; // end of isc::dhcp namespace
699}; // end of isc namespace
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
void addBackend(const std::string &dbaccess)
Create an instance of a configuration backend.
void delAllBackends()
Removes all backends from the pool.
void closeCommandSocket()
Shuts down any open control sockets.
Definition: command_mgr.cc:598
static CommandMgr & instance()
CommandMgr is a singleton class.
Definition: command_mgr.cc:620
void openCommandSocket(const isc::data::ConstElementPtr &socket_info)
Opens control socket with parameters specified in socket_info.
Definition: command_mgr.cc:594
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition: data.cc:223
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
uint32_t getUint32(isc::data::ConstElementPtr scope, const std::string &name)
Returns a value converted to uint32_t.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
uint16_t getUint16(isc::data::ConstElementPtr scope, const std::string &name)
Returns a value converted to uint16_t.
Parse Database Parameters.
void parse(std::string &access_string, isc::data::ConstElementPtr database_config)
Parse configuration value.
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
Definition: cfgmgr.cc:40
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition: cfgmgr.cc:160
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition: cfgmgr.cc:154
Parser for a list of client class definitions.
ClientClassDictionaryPtr parse(isc::data::ConstElementPtr class_def_list, uint16_t family)
Parse configuration entries.
Configuration Backend Manager for DHPCv4 servers.
static ConfigBackendDHCPv4Mgr & instance()
Returns a sole instance of the ConfigBackendDHCPv4Mgr.
Parser for the control-socket structure.
Definition: dhcp_parsers.h:209
void parse(SrvConfig &srv_cfg, isc::data::ConstElementPtr value)
"Parses" control-socket structure
Definition: dhcp_parsers.cc:69
Parser for D2ClientConfig.
Definition: dhcp_parsers.h:783
D2ClientConfigPtr parse(isc::data::ConstElementPtr d2_client_cfg)
Parses a given dhcp-ddns element into D2ClientConfig.
static size_t setAllDefaults(isc::data::ConstElementPtr d2_config)
Sets all defaults for D2 client configuration.
Parser for the configuration of DHCP packet queue controls.
data::ElementPtr parse(const isc::data::ConstElementPtr &control_elem)
Parses content of the "dhcp-queue-control".
To be removed. Please use ConfigError instead.
DHCPv4 server service.
Definition: dhcp4_srv.h:194
void discardPackets()
Discard all in-progress packets.
Definition: dhcp4_srv.cc:3631
Parser for the configuration parameters pertaining to the processing of expired leases.
void parse(isc::data::ConstElementPtr expiration_config)
Parses parameters in the JSON map, pertaining to the processing of the expired leases.
static void printRegistered()
Prints out all registered backends.
Parser for a list of host identifiers for DHCPv4.
void parse(isc::data::ConstElementPtr ids_list)
Parses a list of host identifiers.
Parser for a list of host reservations for a subnet.
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 the configuration of interfaces.
void parse(const CfgIfacePtr &config, const isc::data::ConstElementPtr &values)
Parses content of the "interfaces-config".
static void setRuntimeOptionDefs(const OptionDefSpaceContainer &defs)
Copies option definitions created at runtime.
Definition: libdhcp++.cc:234
static void revertRuntimeOptionDefs()
Reverts uncommitted changes to runtime option definitions.
Definition: libdhcp++.cc:255
Parser for option data values within a subnet.
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
Parser for a list of option definitions.
Definition: dhcp_parsers.h:246
void parse(CfgOptionDefPtr cfg, isc::data::ConstElementPtr def_list)
Parses a list of option definitions, create them and store in cfg.
Simple parser for sanity-checks structure.
void parse(SrvConfig &srv_cfg, const isc::data::ConstElementPtr &value)
parses JSON structure
Parser for a list of shared networks.
void parse(CfgSharedNetworksTypePtr &cfg, const data::ConstElementPtr &shared_networks_list_data)
Parses a list of shared networks.
static size_t deriveParameters(isc::data::ElementPtr global)
Derives (inherits) all parameters from global to more specific scopes.
static size_t setAllDefaults(isc::data::ElementPtr global)
Sets all defaults for DHCPv4 configuration.
static const uint32_t CFGSEL_ALL4
IPv4 related config.
Definition: srv_config.h:68
static void resetSubnetID()
Resets subnet-id counter to its initial value (1)
Definition: subnet.h:231
this class parses list of DHCP4 subnets
Definition: dhcp_parsers.h:561
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
Definition: timer_mgr.cc:319
Wrapper class that holds hooks libraries configuration.
Definition: hooks_config.h:36
void verifyLibraries(const isc::data::Element::Position &position) const
Verifies that libraries stored in libraries_ are valid.
Definition: hooks_config.cc:20
void loadLibraries() const
Commits hooks libraries configuration.
Definition: hooks_config.cc:55
Parser for hooks library list.
Definition: hooks_parser.h:21
void parse(HooksConfig &libraries, isc::data::ConstElementPtr value)
Parses parameters value.
Definition: hooks_parser.cc:28
Implements parser for config control information, "config-control".
ConfigControlInfoPtr parse(const data::ConstElementPtr &config_control)
Parses a configuration control Element.
Parsers for client class definitions.
This file contains several functions and constants that are used for handling commands and responses ...
Contains declarations for loggers used by the DHCPv4 server component.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition: macros.h:32
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition: macros.h:20
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition: macros.h:14
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
boost::shared_ptr< Element > ElementPtr
Definition: data.h:22
void configureCommandChannel()
Initialize the command channel based on the staging 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.
OptionSpaceContainer< OptionDefContainer, OptionDefinitionPtr, std::string > OptionDefSpaceContainer
std::pair< std::string, isc::data::ConstElementPtr > ConfigPair
Combination of parameter name and configuration contents.
Definition: dhcp_parsers.h:173
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:497
void databaseConfigFetch(const SrvConfigPtr &srv_cfg, ElementPtr)
Fetch configuration from CB databases and merge it into the given configuration.
bool databaseConfigConnect(const SrvConfigPtr &srv_cfg)
Attempts to connect to configured CB databases.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
isc::data::ConstElementPtr configureDhcp4Server(Dhcpv4Srv &server, isc::data::ConstElementPtr config_set, bool check_only)
Configure DHCPv4 server (Dhcpv4Srv) with a set of configuration values.
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
Definition: cfg_iface.h:387
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Definition: srv_config.h:707
std::vector< HostPtr > HostCollection
Collection of the Host objects.
Definition: host.h:734
const int DBG_DHCP4_COMMAND
Debug level used to log receiving commands.
Definition: dhcp4_log.h:30
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
boost::shared_ptr< CfgSubnets4 > CfgSubnets4Ptr
Non-const pointer.
Definition: cfg_subnets4.h:270
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.
Definition: subnet.h:798
boost::shared_ptr< CfgSharedNetworks4 > CfgSharedNetworks4Ptr
Pointer to the configuration of IPv4 shared networks.
isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME)
Base logger for DHCPv4 server.
Definition: dhcp4_log.h:90
boost::shared_ptr< const ConfigControlInfo > ConstConfigControlInfoPtr
Defines a pointer to a const ConfigControlInfo.
boost::shared_ptr< ConfigControlInfo > ConfigControlInfoPtr
Defines a pointer to a ConfigControlInfo.
Defines the logger used by the top-level component of kea-dhcp-ddns.