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>
15 #include <dhcp/option_definition.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 
49 using namespace std;
50 using namespace isc;
51 using namespace isc::dhcp;
52 using namespace isc::data;
53 using namespace isc::asiolink;
54 using namespace isc::hooks;
55 using namespace isc::process;
56 using namespace isc::config;
57 
58 namespace {
59 
68 class Dhcp4ConfigParser : public isc::data::SimpleParser {
69 public:
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 
250 namespace isc {
251 namespace 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.
308  Subnet::resetSubnetID();
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.
317  LibDHCP::revertRuntimeOptionDefs();
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.
320  LibDHCP::setRuntimeOptionDefs(OptionDefSpaceContainer());
321 
322  // Print the list of known backends.
323  HostDataSourceFactory::printRegistered();
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.
349  SimpleParser4::setAllDefaults(mutable_cfg);
350 
351  // And now derive (inherit) global parameters to subnets, if not specified.
352  SimpleParser4::deriveParameters(mutable_cfg);
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") {
394  DHCPQueueControlParser parser;
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") {
425  ExpirationConfigParser parser;
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);
442  D2ClientConfigParser parser;
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
607  D2ClientConfigPtr cfg;
608  cfg = CfgMgr::instance().getStagingCfg()->getD2ClientConfig();
609  CfgMgr::instance().setD2ClientConfig(cfg);
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++.
641  LibDHCP::revertRuntimeOptionDefs();
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 
654 bool databaseConfigConnect(const SrvConfigPtr& srv_cfg) {
655  // We need to get rid of any existing backends. These would be any
656  // opened by previous configuration cycle.
657  ConfigBackendDHCPv4Mgr& mgr = ConfigBackendDHCPv4Mgr::instance();
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 
678 void 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
isc::dhcp::OptionDefListParser::parse
void parse(CfgOptionDefPtr cfg, isc::data::ConstElementPtr def_list)
Parses a list of option definitions, create them and store in cfg.
Definition: dhcp_parsers.cc:199
isc::dhcp::CfgOptionDefPtr
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
Definition: cfg_option_def.h:139
isc::dhcp::ClientClassDictionaryPtr
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
Definition: client_class_def.h:382
isc::dhcp::IfacesConfigParser
Parser for the configuration of interfaces.
Definition: ifaces_config_parser.h:26
isc::dhcp::DhcpConfigError
To be removed. Please use ConfigError instead.
Definition: dhcp_config_error.h:58
option_data_parser.h
isc::hooks::HooksConfig::verifyLibraries
void verifyLibraries(const isc::data::Element::Position &position) const
Verifies that libraries stored in libraries_ are valid.
Definition: hooks_config.cc:20
command_mgr.h
isc::dhcp::IfacesConfigParser::parse
void parse(const CfgIfacePtr &config, const isc::data::ConstElementPtr &values)
Parses content of the "interfaces-config".
Definition: ifaces_config_parser.cc:41
LOG_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition: macros.h:32
isc::dhcp::SharedNetworksListParser::parse
void parse(CfgSharedNetworksTypePtr &cfg, const data::ConstElementPtr &shared_networks_list_data)
Parses a list of shared networks.
Definition: shared_networks_list_parser.h:44
isc::dhcp::OptionDataListParser::parse
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
Definition: option_data_parser.cc:381
isc::config::CONTROL_RESULT_SUCCESS
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
Definition: command_interpreter.h:39
isc::dhcp::configureDhcp4Server
isc::data::ConstElementPtr configureDhcp4Server(Dhcpv4Srv &server, isc::data::ConstElementPtr config_set, bool check_only)
Configure DHCPv4 server (Dhcpv4Srv) with a set of configuration values.
Definition: dhcp4/json_config_parser.cc:295
isc::dhcp::Subnets4ListConfigParser
this class parses list of DHCP4 subnets
Definition: dhcp_parsers.h:561
db_type.h
isc::dhcp::databaseConfigFetch
void databaseConfigFetch(const SrvConfigPtr &srv_cfg, ElementPtr)
Fetch configuration from CB databases and merge it into the given configuration.
Definition: dhcp4/json_config_parser.cc:678
libdhcp++.h
isc::dhcp::SharedNetwork4Collection
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.
Definition: shared_network.h:194
hooks_parser.h
dbaccess_parser.h
isc::config::createAnswer
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
Definition: command_interpreter.cc:33
isc::dhcp::ClientClassDefListParser
Parser for a list of client class definitions.
Definition: client_class_def_parser.h:126
isc::dhcp::CfgSubnets4Ptr
boost::shared_ptr< CfgSubnets4 > CfgSubnets4Ptr
Non-const pointer.
Definition: cfg_subnets4.h:270
isc::config
Definition: command_interpreter.cc:23
isc::cb::BaseConfigBackendMgr::addBackend
void addBackend(const std::string &dbaccess)
Create an instance of a configuration backend.
Definition: base_config_backend_mgr.h:148
dhcp_parsers.h
isc::dhcp::CfgSharedNetworks4Ptr
boost::shared_ptr< CfgSharedNetworks4 > CfgSharedNetworks4Ptr
Pointer to the configuration of IPv4 shared networks.
Definition: cfg_shared_networks.h:131
isc::config::CONTROL_RESULT_ERROR
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
Definition: command_interpreter.h:42
shared_networks_list_parser.h
isc::data
Definition: cfg_to_element.h:25
isc::hooks::HooksLibrariesParser
Parser for hooks library list.
Definition: hooks_parser.h:21
timer_mgr.h
isc::dhcp::SanityChecksParser
Simple parser for sanity-checks structure.
Definition: sanity_checks_parser.h:20
simple_parser4.h
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
isc::dhcp::ExpirationConfigParser::parse
void parse(isc::data::ConstElementPtr expiration_config)
Parses parameters in the JSON map, pertaining to the processing of the expired leases.
Definition: expiration_config_parser.cc:22
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
dhcp4_srv.h
isc::dhcp::SharedNetworksListParser
Parser for a list of shared networks.
Definition: shared_networks_list_parser.h:29
isc::dhcp::D2ClientConfigParser::parse
D2ClientConfigPtr parse(isc::data::ConstElementPtr d2_client_cfg)
Parses a given dhcp-ddns element into D2ClientConfig.
Definition: dhcp_parsers.cc:1291
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition: exceptions/exceptions.cc:32
isc::db::DbAccessParser
Parse Database Parameters.
Definition: dbaccess_parser.h:26
strutil.h
isc::dhcp::OptionDefSpaceContainer
OptionSpaceContainer< OptionDefContainer, OptionDefinitionPtr, std::string > OptionDefSpaceContainer
Definition: option_definition.h:847
hex.h
isc::hooks::HooksConfig
Wrapper class that holds hooks libraries configuration.
Definition: hooks_config.h:36
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition: exceptions/exceptions.h:192
isc::config::CommandMgr::instance
static CommandMgr & instance()
CommandMgr is a singleton class.
Definition: command_mgr.cc:620
LOG_DEBUG
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition: macros.h:14
isc::config::CommandMgr::openCommandSocket
void openCommandSocket(const isc::data::ConstElementPtr &socket_info)
Opens control socket with parameters specified in socket_info.
Definition: command_mgr.cc:594
isc::hooks::HooksConfig::loadLibraries
void loadLibraries() const
Commits hooks libraries configuration.
Definition: hooks_config.cc:55
config_backend_dhcp4_mgr.h
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition: exceptions/exceptions.h:132
isc::dhcp::DHCPQueueControlParser::parse
data::ElementPtr parse(const isc::data::ConstElementPtr &control_elem)
Parses content of the "dhcp-queue-control".
Definition: dhcp_queue_control_parser.cc:22
sanity_checks_parser.h
command_interpreter.h
isc::dhcp::Subnets4ListConfigParser::parse
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
Definition: dhcp_parsers.cc:869
isc::dhcp::configureCommandChannel
void configureCommandChannel()
Initialize the command channel based on the staging configuration.
Definition: dhcp4/json_config_parser.cc:260
host_reservations_list_parser.h
isc::dhcp
Definition: ctrl_dhcp4_srv.cc:75
dhcp4_log.h
isc::data::SimpleParser
A simple parser.
Definition: lib/cc/simple_parser.h:60
isc::process::ConfigControlInfoPtr
boost::shared_ptr< ConfigControlInfo > ConfigControlInfoPtr
Defines a pointer to a ConfigControlInfo.
Definition: config_ctl_info.h:199
cfg_option.h
expiration_config_parser.h
config_ctl_parser.h
isc::dhcp::ClientClassDefListParser::parse
ClientClassDictionaryPtr parse(isc::data::ConstElementPtr class_def_list, uint16_t family)
Parse configuration entries.
Definition: client_class_def_parser.cc:260
isc::hooks::HooksLibrariesParser::parse
void parse(HooksConfig &libraries, isc::data::ConstElementPtr value)
Parses parameters value.
Definition: hooks_parser.cc:28
isc::dhcp::ConfigBackendDHCPv4Mgr
Configuration Backend Manager for DHPCv4 servers.
Definition: config_backend_dhcp4_mgr.h:34
isc::process::ConstConfigControlInfoPtr
boost::shared_ptr< const ConfigControlInfo > ConstConfigControlInfoPtr
Defines a pointer to a const ConfigControlInfo.
Definition: config_ctl_info.h:201
option_definition.h
isc::dhcp::OptionDataListParser
Parser for option data values within a subnet.
Definition: option_data_parser.h:163
isc::dhcp::D2ClientConfigPtr
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
Definition: d2_client_cfg.h:323
ifaces_config_parser.h
json_config_parser.h
dhcp_queue_control_parser.h
isc::dhcp::OptionDefListParser
Parser for a list of option definitions.
Definition: dhcp_parsers.h:246
isc::dhcp::HostReservationsListParser
Parser for a list of host reservations for a subnet.
Definition: host_reservations_list_parser.h:25
isc::process
Definition: config_base.cc:16
isc::dhcp::HostReservationIdsParser::parse
void parse(isc::data::ConstElementPtr ids_list)
Parses a list of host identifiers.
Definition: host_reservation_parser.cc:359
isc::process::ConfigControlParser::parse
ConfigControlInfoPtr parse(const data::ConstElementPtr &config_control)
Parses a configuration control Element.
Definition: config_ctl_parser.cc:21
isc::cb::BaseConfigBackendMgr::delAllBackends
void delAllBackends()
Removes all backends from the pool.
Definition: base_config_backend_mgr.h:181
isc::dhcp::databaseConfigConnect
bool databaseConfigConnect(const SrvConfigPtr &srv_cfg)
Attempts to connect to configured CB databases.
Definition: dhcp4/json_config_parser.cc:654
isc::process::ConfigControlParser
Implements parser for config control information, "config-control".
Definition: config_ctl_parser.h:18
isc::dhcp::ConfigPair
std::pair< std::string, isc::data::ConstElementPtr > ConfigPair
Combination of parameter name and configuration contents.
Definition: dhcp_parsers.h:173
cfgmgr.h
client_class_def_parser.h
Parsers for client class definitions.
host_data_source_factory.h
isc::dhcp::DBG_DHCP4_COMMAND
const int DBG_DHCP4_COMMAND
Debug level used to log receiving commands.
Definition: dhcp4_log.h:30
isc::dhcp::Dhcpv4Srv
DHCPv4 server service.
Definition: dhcp4_srv.h:194
isc::db::DbAccessParser::parse
void parse(std::string &access_string, isc::data::ConstElementPtr database_config)
Parse configuration value.
Definition: dbaccess_parser.cc:34
isc::dhcp::DHCPQueueControlParser
Parser for the configuration of DHCP packet queue controls.
Definition: dhcp_queue_control_parser.h:34
isc::hooks
Definition: callout_handle.cc:21
isc::dhcp::ControlSocketParser::parse
void parse(SrvConfig &srv_cfg, isc::data::ConstElementPtr value)
"Parses" control-socket structure
Definition: dhcp_parsers.cc:69
isc::dhcp::D2ClientConfigParser
Parser for D2ClientConfig.
Definition: dhcp_parsers.h:783
isc::config::CommandMgr::closeCommandSocket
void closeCommandSocket()
Shuts down any open control sockets.
Definition: command_mgr.cc:598
isc::dhcp::CfgOptionPtr
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:497
isc::dhcp::dhcp4_logger
isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME)
Base logger for DHCPv4 server.
Definition: dhcp4_log.h:90
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
isc::dhcp::Dhcpv4Srv::discardPackets
void discardPackets()
Discard all in-progress packets.
Definition: dhcp4_srv.cc:3631
isc::dhcp::ControlSocketParser
Parser for the control-socket structure.
Definition: dhcp_parsers.h:209
isc::dhcp::CfgDbAccessPtr
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
Definition: cfg_db_access.h:101
isc::dhcp::SrvConfigPtr
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Definition: srv_config.h:707
isc::dhcp::ExpirationConfigParser
Parser for the configuration parameters pertaining to the processing of expired leases.
Definition: expiration_config_parser.h:39
isc::dhcp::SanityChecksParser::parse
void parse(SrvConfig &srv_cfg, const isc::data::ConstElementPtr &value)
parses JSON structure
Definition: sanity_checks_parser.cc:18
isc::dhcp::CfgIfacePtr
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
Definition: cfg_iface.h:387
isc::dhcp::HostReservationsListParser::parse
void parse(const SubnetID &subnet_id, isc::data::ConstElementPtr hr_list, HostCollection &hosts_list)
Parses a list of host reservation entries for a subnet.
Definition: host_reservations_list_parser.h:39
isc::dhcp::HostReservationIdsParser4
Parser for a list of host identifiers for DHCPv4.
Definition: host_reservation_parser.h:187
LOG_INFO
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition: macros.h:20
host_reservation_parser.h
isc::dhcp::Subnet4Collection
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
isc::dhcp::HostCollection
std::vector< HostPtr > HostCollection
Collection of the Host objects.
Definition: host.h:734