Kea 3.2.0-git
srv_config.cc
Go to the documentation of this file.
1// Copyright (C) 2014-2026 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
9#include <cc/simple_parser.h>
12#include <dhcpsrv/cfgmgr.h>
24#include <dhcpsrv/srv_config.h>
26#include <dhcpsrv/dhcpsrv_log.h>
30#include <log/logger_manager.h>
32#include <dhcp/pkt.h>
33#include <stats/stats_mgr.h>
34#include <util/str.h>
35
36#include <boost/make_shared.hpp>
37
38#include <list>
39#include <sstream>
40
41using namespace isc::log;
42using namespace isc::data;
43using namespace isc::process;
44using namespace isc::db;
45
46namespace isc {
47namespace dhcp {
48
50 : sequence_(0), cfg_iface_(new CfgIface()),
51 cfg_option_def_(new CfgOptionDef()), cfg_option_(new CfgOption()),
52 cfg_subnets4_(new CfgSubnets4()), cfg_subnets6_(new CfgSubnets6()),
53 cfg_shared_networks4_(new CfgSharedNetworks4()),
54 cfg_shared_networks6_(new CfgSharedNetworks6()),
55 cfg_hosts_(new CfgHosts()), cfg_rsoo_(new CfgRSOO()),
56 cfg_expiration_(new CfgExpiration()), cfg_duid_(new CfgDUID()),
57 cfg_db_access_(new CfgDbAccess()),
58 cfg_host_operations4_(CfgHostOperations::createConfig4()),
59 cfg_host_operations6_(CfgHostOperations::createConfig6()),
60 class_dictionary_(new ClientClassDictionary()),
61 decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0),
62 d2_client_config_(new D2ClientConfig()),
63 configured_globals_(new CfgGlobals()), cfg_consist_(new CfgConsistency()),
64 lenient_option_parsing_(false), ignore_dhcp_server_identifier_(false),
65 ignore_rai_link_selection_(false), exclude_first_last_24_(false),
66 reservations_lookup_first_(false) {
67}
68
69SrvConfig::SrvConfig(const uint32_t sequence)
70 : sequence_(sequence), cfg_iface_(new CfgIface()),
71 cfg_option_def_(new CfgOptionDef()), cfg_option_(new CfgOption()),
72 cfg_subnets4_(new CfgSubnets4()), cfg_subnets6_(new CfgSubnets6()),
73 cfg_shared_networks4_(new CfgSharedNetworks4()),
74 cfg_shared_networks6_(new CfgSharedNetworks6()),
75 cfg_hosts_(new CfgHosts()), cfg_rsoo_(new CfgRSOO()),
76 cfg_expiration_(new CfgExpiration()), cfg_duid_(new CfgDUID()),
77 cfg_db_access_(new CfgDbAccess()),
78 cfg_host_operations4_(CfgHostOperations::createConfig4()),
79 cfg_host_operations6_(CfgHostOperations::createConfig6()),
80 class_dictionary_(new ClientClassDictionary()),
81 decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0),
82 d2_client_config_(new D2ClientConfig()),
83 configured_globals_(new CfgGlobals()), cfg_consist_(new CfgConsistency()),
84 lenient_option_parsing_(false), ignore_dhcp_server_identifier_(false),
85 ignore_rai_link_selection_(false), exclude_first_last_24_(false),
86 reservations_lookup_first_(false) {
87}
88
89std::string
90SrvConfig::getConfigSummary(const uint32_t selection) const {
91 std::ostringstream s;
92 size_t subnets_num;
93 if ((selection & CFGSEL_SUBNET4) == CFGSEL_SUBNET4) {
94 subnets_num = getCfgSubnets4()->getAll()->size();
95 if (subnets_num > 0) {
96 s << "added IPv4 subnets: " << subnets_num;
97 } else {
98 s << "no IPv4 subnets!";
99 }
100 s << "; ";
101 }
102
103 if ((selection & CFGSEL_SUBNET6) == CFGSEL_SUBNET6) {
104 subnets_num = getCfgSubnets6()->getAll()->size();
105 if (subnets_num > 0) {
106 s << "added IPv6 subnets: " << subnets_num;
107 } else {
108 s << "no IPv6 subnets!";
109 }
110 s << "; ";
111 }
112
113 if ((selection & CFGSEL_DDNS) == CFGSEL_DDNS) {
114 bool ddns_enabled = getD2ClientConfig()->getEnableUpdates();
115 s << "DDNS: " << (ddns_enabled ? "enabled" : "disabled") << "; ";
116 }
117
118 if (s.tellp() == static_cast<std::streampos>(0)) {
119 s << "no config details available";
120 }
121
122 std::string summary = s.str();
123 size_t last_separator_pos = summary.find_last_of(";");
124 if (last_separator_pos == summary.length() - 2) {
125 summary.erase(last_separator_pos);
126 }
127 return (summary);
128}
129
130bool
132 return (getSequence() == other.getSequence());
133}
134
135void
136SrvConfig::copy(SrvConfig& new_config) const {
137 ConfigBase::copy(new_config);
138
139 // Replace interface configuration.
140 new_config.cfg_iface_.reset(new CfgIface(*cfg_iface_));
141 // Replace option definitions.
142 cfg_option_def_->copyTo(*new_config.cfg_option_def_);
143 cfg_option_->copyTo(*new_config.cfg_option_);
144 // Replace the client class dictionary
145 new_config.class_dictionary_.reset(new ClientClassDictionary(*class_dictionary_));
146 // Replace the D2 client configuration
148 // Replace configured hooks libraries.
149 new_config.hooks_config_.clear();
150 using namespace isc::hooks;
151 for (auto const& it : hooks_config_.get()) {
152 new_config.hooks_config_.add(it.libname_, it.parameters_, it.cfgname_);
153 }
154}
155
156bool
157SrvConfig::equals(const SrvConfig& other) const {
158
159 // Checks common elements: logging & config control
160 if (!ConfigBase::equals(other)) {
161 return (false);
162 }
163
164 // Common information is equal between objects, so check other values.
165 if ((*cfg_iface_ != *other.cfg_iface_) ||
166 (*cfg_option_def_ != *other.cfg_option_def_) ||
167 (*cfg_option_ != *other.cfg_option_) ||
168 (*class_dictionary_ != *other.class_dictionary_) ||
169 (*d2_client_config_ != *other.d2_client_config_)) {
170 return (false);
171 }
172 // Now only configured hooks libraries can differ.
173 // If number of configured hooks libraries are different, then
174 // configurations aren't equal.
175 if (hooks_config_.get().size() != other.hooks_config_.get().size()) {
176 return (false);
177 }
178
179 // Pass through all configured hooks libraries.
180 return (hooks_config_.equal(other.hooks_config_));
181}
182
183void
185 ConfigBase::merge(other);
186 try {
187 SrvConfig& other_srv_config = dynamic_cast<SrvConfig&>(other);
188 // We merge objects in order of dependency (real or theoretical).
189 // First we merge the common stuff.
190
191 // Merge globals.
192 mergeGlobals(other_srv_config);
193
194 // Merge global containers.
195 mergeGlobalContainers(other_srv_config);
196
197 // Merge option defs. We need to do this next so we
198 // pass these into subsequent merges so option instances
199 // at each level can be created based on the merged
200 // definitions.
201 cfg_option_def_->merge(*other_srv_config.getCfgOptionDef());
202
203 // Merge options.
204 cfg_option_->merge(cfg_option_def_, *other_srv_config.getCfgOption());
205
206 if (!other_srv_config.getClientClassDictionary()->empty()) {
207 // Client classes are complicated because they are ordered and may
208 // depend on each other. Merging two lists of classes with preserving
209 // the order would be very involved and could result in errors. Thus,
210 // we simply replace the current list of classes with a new list.
211 setClientClassDictionary(boost::make_shared
212 <ClientClassDictionary>(*other_srv_config.getClientClassDictionary()));
213 }
214
215 if (CfgMgr::instance().getFamily() == AF_INET) {
216 merge4(other_srv_config);
217 } else {
218 merge6(other_srv_config);
219 }
220 } catch (const std::bad_cast&) {
221 isc_throw(InvalidOperation, "internal server error: must use derivation"
222 " of the SrvConfig as an argument of the call to"
223 " SrvConfig::merge()");
224 }
225}
226
227void
228SrvConfig::merge4(SrvConfig& other) {
229 // Merge shared networks.
230 cfg_shared_networks4_->merge(cfg_option_def_, *(other.getCfgSharedNetworks4()));
231
232 // Merge subnets.
233 cfg_subnets4_->merge(cfg_option_def_, getCfgSharedNetworks4(),
234 *(other.getCfgSubnets4()));
235
237}
238
239void
240SrvConfig::merge6(SrvConfig& other) {
241 // Merge shared networks.
242 cfg_shared_networks6_->merge(cfg_option_def_, *(other.getCfgSharedNetworks6()));
243
244 // Merge subnets.
245 cfg_subnets6_->merge(cfg_option_def_, getCfgSharedNetworks6(),
246 *(other.getCfgSubnets6()));
247
249}
250
251void
252SrvConfig::mergeGlobals(SrvConfig& other) {
253 auto config_set = getConfiguredGlobals();
254 // Iterate over the "other" globals, adding/overwriting them into
255 // this config's list of globals.
256 for (auto const& other_global : other.getConfiguredGlobals()->valuesMap()) {
257 addConfiguredGlobal(other_global.first, other_global.second);
258 }
259
260 // A handful of values are stored as members in SrvConfig. So we'll
261 // iterate over the merged globals, setting appropriate members.
262 for (auto const& merged_global : getConfiguredGlobals()->valuesMap()) {
263 std::string name = merged_global.first;
264 ConstElementPtr element = merged_global.second;
265 try {
266 if (name == "decline-probation-period") {
267 setDeclinePeriod(element->intValue());
268 } else if (name == "echo-client-id") {
269 // echo-client-id is v4 only, but we'll let upstream
270 // worry about that.
271 setEchoClientId(element->boolValue());
272 } else if (name == "dhcp4o6-port") {
273 setDhcp4o6Port(element->intValue());
274 } else if (name == "server-tag") {
275 setServerTag(element->stringValue());
276 } else if (name == "ip-reservations-unique") {
277 setIPReservationsUnique(element->boolValue());
278 } else if (name == "reservations-lookup-first") {
279 setReservationsLookupFirst(element->boolValue());
280 }
281 } catch(const std::exception& ex) {
282 isc_throw (BadValue, "Invalid value:" << element->str()
283 << " explicit global:" << name);
284 }
285 }
286}
287
288void
289SrvConfig::mergeGlobalContainers(SrvConfig& other) {
291 for (auto const& other_global : other.getConfiguredGlobals()->valuesMap()) {
292 config->set(other_global.first, other_global.second);
293 }
294 std::string parameter_name;
295 try {
296 // Merge list containers.
297 ConstElementPtr host_reservation_identifiers = config->get("host-reservation-identifiers");
298 parameter_name = "host-reservation-identifiers";
299 if (host_reservation_identifiers) {
300 if (CfgMgr::instance().getFamily() == AF_INET) {
301 HostReservationIdsParser4 parser(getCfgHostOperations4());
302 parser.parse(host_reservation_identifiers);
303 } else {
304 HostReservationIdsParser6 parser(getCfgHostOperations6());
305 parser.parse(host_reservation_identifiers);
306 }
307 addConfiguredGlobal("host-reservation-identifiers", host_reservation_identifiers);
308 }
309 // Merge map containers.
310 ConstElementPtr compatibility = config->get("compatibility");
311 parameter_name = "compatibility";
312 if (compatibility) {
313 CompatibilityParser parser;
314 parser.parse(compatibility, *this);
315 addConfiguredGlobal("compatibility", compatibility);
316 }
317 ElementPtr dhcp_ddns = boost::const_pointer_cast<Element>(config->get("dhcp-ddns"));
318 parameter_name = "dhcp-ddns";
319 if (dhcp_ddns) {
320 // Apply defaults
322 D2ClientConfigParser parser;
323 // D2 client configuration.
324 D2ClientConfigPtr d2_client_cfg;
325 d2_client_cfg = parser.parse(dhcp_ddns);
326 if (!d2_client_cfg) {
327 d2_client_cfg.reset(new D2ClientConfig());
328 }
329 d2_client_cfg->validateContents();
330 setD2ClientConfig(d2_client_cfg);
331 addConfiguredGlobal("dhcp-ddns", dhcp_ddns);
332 }
333 ConstElementPtr expiration_cfg = config->get("expired-leases-processing");
334 parameter_name = "expired-leases-processing";
335 if (expiration_cfg) {
336 ExpirationConfigParser parser;
337 parser.parse(expiration_cfg, getCfgExpiration());
338 addConfiguredGlobal("expired-leases-processing", expiration_cfg);
339 }
340 ElementPtr multi_threading = boost::const_pointer_cast<Element>(config->get("multi-threading"));
341 parameter_name = "multi-threading";
342 if (multi_threading) {
343 if (CfgMgr::instance().getFamily() == AF_INET) {
345 } else {
347 }
348 MultiThreadingConfigParser parser;
349 parser.parse(*this, multi_threading);
350 addConfiguredGlobal("multi-threading", multi_threading);
351 }
352 bool multi_threading_enabled = true;
353 uint32_t thread_count = 0;
354 uint32_t queue_size = 0;
356 multi_threading_enabled, thread_count, queue_size);
357 ElementPtr sanity_checks = boost::const_pointer_cast<Element>(config->get("sanity-checks"));
358 parameter_name = "sanity-checks";
359 if (sanity_checks) {
360 if (CfgMgr::instance().getFamily() == AF_INET) {
362 } else {
364 }
365 SanityChecksParser parser;
366 parser.parse(*this, sanity_checks);
367 addConfiguredGlobal("multi-threading", sanity_checks);
368 }
369 ConstElementPtr server_id = config->get("server-id");
370 parameter_name = "server-id";
371 if (server_id) {
372 DUIDConfigParser parser;
373 const CfgDUIDPtr& cfg = getCfgDUID();
374 parser.parse(cfg, server_id);
375 addConfiguredGlobal("server-id", server_id);
376 }
377 ElementPtr queue_control = boost::const_pointer_cast<Element>(config->get("dhcp-queue-control"));
378 parameter_name = "dhcp-queue-control";
379 if (queue_control) {
380 if (CfgMgr::instance().getFamily() == AF_INET) {
382 } else {
384 }
385 DHCPQueueControlParser parser;
386 setDHCPQueueControl(parser.parse(queue_control, multi_threading_enabled));
387 addConfiguredGlobal("dhcp-queue-control", queue_control);
388 }
389 } catch (const isc::Exception& ex) {
390 isc_throw(BadValue, "Invalid parameter " << parameter_name << " error: " << ex.what());
391 } catch (...) {
392 isc_throw(BadValue, "Invalid parameter " << parameter_name);
393 }
394}
395
396void
398 // Removes statistics for v4 and v6 subnets
399 getCfgSubnets4()->removeStatistics();
400 getCfgSubnets6()->removeStatistics();
401}
402
403void
405 // Update default sample limits.
407 ConstElementPtr samples =
408 getConfiguredGlobal("statistic-default-sample-count");
409 uint32_t max_samples = 0;
410 if (samples) {
411 max_samples = samples->intValue();
412 stats_mgr.setMaxSampleCountDefault(max_samples);
413 if (max_samples != 0) {
414 stats_mgr.setMaxSampleCountAll(max_samples);
415 }
416 }
417 ConstElementPtr duration =
418 getConfiguredGlobal("statistic-default-sample-age");
419 if (duration) {
420 int64_t time_duration = duration->intValue();
421 auto max_age = std::chrono::seconds(time_duration);
422 stats_mgr.setMaxSampleAgeDefault(max_age);
423 if (max_samples == 0) {
424 stats_mgr.setMaxSampleAgeAll(max_age);
425 }
426 }
427
428 // Updating subnet statistics involves updating lease statistics, which
429 // is done by the LeaseMgr. Since servers with subnets, must have a
430 // LeaseMgr, we do not bother updating subnet stats for servers without
431 // a lease manager, such as D2. @todo We should probably examine why
432 // "SrvConfig" is being used by D2.
434 // Updates statistics for v4 and v6 subnets.
435 getCfgSubnets4()->updateStatistics();
436 getCfgSubnets6()->updateStatistics();
437 }
438}
439
440void
442 // Code from SimpleParser::setDefaults
443 // This is the position representing a default value. As the values
444 // we're inserting here are not present in whatever the config file
445 // came from, we need to make sure it's clearly labeled as default.
446 const Element::Position pos("<default-value>", 0, 0);
447
448 // Let's go over all parameters we have defaults for.
449 for (auto const& def_value : defaults) {
450
451 // Try if such a parameter is there. If it is, let's
452 // skip it, because user knows best *cough*.
453 ConstElementPtr x = getConfiguredGlobal(def_value.name_);
454 if (x) {
455 // There is such a value already, skip it.
456 continue;
457 }
458
459 // There isn't such a value defined, let's create the default
460 // value...
461 switch (def_value.type_) {
462 case Element::string: {
463 x.reset(new StringElement(def_value.value_, pos));
464 break;
465 }
466 case Element::integer: {
467 try {
468 int int_value = boost::lexical_cast<int>(def_value.value_);
469 x.reset(new IntElement(int_value, pos));
470 }
471 catch (const std::exception& ex) {
473 "Internal error. Integer value expected for: "
474 << def_value.name_ << ", value is: "
475 << def_value.value_ );
476 }
477
478 break;
479 }
480 case Element::boolean: {
481 bool bool_value;
482 if (def_value.value_ == std::string("true")) {
483 bool_value = true;
484 } else if (def_value.value_ == std::string("false")) {
485 bool_value = false;
486 } else {
488 "Internal error. Boolean value for "
489 << def_value.name_ << " specified as "
490 << def_value.value_ << ", expected true or false");
491 }
492 x.reset(new BoolElement(bool_value, pos));
493 break;
494 }
495 case Element::real: {
496 double dbl_value = boost::lexical_cast<double>(def_value.value_);
497 x.reset(new DoubleElement(dbl_value, pos));
498 break;
499 }
500 default:
501 // No default values for null, list or map
503 "Internal error. Incorrect default value type for "
504 << def_value.name_);
505 }
506 addConfiguredGlobal(def_value.name_, x);
507 }
508}
509
510void
512 if (config->getType() != Element::map) {
513 isc_throw(BadValue, "extractConfiguredGlobals must be given a map element");
514 }
515
516 const std::map<std::string, ConstElementPtr>& values = config->mapValue();
517 for (auto const& value : values) {
518 if (value.second->getType() != Element::list &&
519 value.second->getType() != Element::map) {
520 addConfiguredGlobal(value.first, value.second);
521 }
522 }
523}
524
525uint32_t SrvConfig::rangeCheck(data::ConstElementPtr elem, std::string name) {
526 if (!elem) {
527 isc_throw (BadValue, "Element cannot be empty " << name);
528 }
529
530 if (elem->getType() != Element::integer) {
531 isc_throw (BadValue, "Element is not an integer " << name);
532 }
533
534 auto ivalue = elem->intValue();
535 if (ivalue < 0 || ivalue > std::numeric_limits<uint32_t>::max()) {
536 isc_throw (BadValue, "'" << name << "' : " << ivalue << " is out of range,"
537 << " must be >= 0 and <= "
538 << std::numeric_limits<uint32_t>::max());
539 }
540
541 return (static_cast<uint32_t>(ivalue));
542}
543
544void
545SrvConfig::sanityChecksLifetime(const std::string& name) const {
546 // Initialize as some compilers complain otherwise.
547
548 uint32_t value = 0;
549 ConstElementPtr has_value = getConfiguredGlobal(name);
550 if (has_value) {
551 value = rangeCheck(has_value, name);
552 }
553
554 uint32_t min_value = 0;
555 ConstElementPtr has_min = getConfiguredGlobal("min-" + name);
556 if (has_min) {
557 min_value = rangeCheck(has_min, "min-" + name);
558 }
559
560 uint32_t max_value = 0;
561 ConstElementPtr has_max = getConfiguredGlobal("max-" + name);
562 if (has_max) {
563 max_value = rangeCheck(has_max, "max-" + name);
564 }
565
566 if (!has_value && !has_min && !has_max) {
567 return;
568 }
569 if (has_value) {
570 if (!has_min && !has_max) {
571 // default only.
572 return;
573 } else if (!has_min) {
574 // default and max.
575 min_value = value;
576 } else if (!has_max) {
577 // default and min.
578 max_value = value;
579 }
580 } else if (has_min) {
581 if (!has_max) {
582 // min only.
583 return;
584 } else {
585 // min and max.
586 isc_throw(BadValue, "have min-" << name << " and max-"
587 << name << " but no " << name << " (default)");
588 }
589 } else {
590 // max only.
591 return;
592 }
593
594 // Check that min <= max.
595 if (min_value > max_value) {
596 if (has_min && has_max) {
597 isc_throw(BadValue, "the value of min-" << name << " ("
598 << min_value << ") is not less than max-" << name << " ("
599 << max_value << ")");
600 } else if (has_min) {
601 // Only min and default so min > default.
602 isc_throw(BadValue, "the value of min-" << name << " ("
603 << min_value << ") is not less than (default) " << name
604 << " (" << value << ")");
605 } else {
606 // Only default and max so default > max.
607 isc_throw(BadValue, "the value of (default) " << name
608 << " (" << value << ") is not less than max-" << name
609 << " (" << max_value << ")");
610 }
611 }
612
613 // Check that value is between min and max.
614 if ((value < min_value) || (value > max_value)) {
615 isc_throw(BadValue, "the value of (default) " << name << " ("
616 << value << ") is not between min-" << name << " ("
617 << min_value << ") and max-" << name << " ("
618 << max_value << ")");
619 }
620}
621
622void
624 const std::string& name) const {
625 // Three cases:
626 // - the external/source config has the parameter: use it.
627 // - only the target config has the parameter: use this one.
628 // - no config has the parameter.
629 uint32_t value = 0;
630 ConstElementPtr has_value = getConfiguredGlobal(name);
631 bool new_value = true;
632 if (!has_value) {
633 has_value = target_config.getConfiguredGlobal(name);
634 new_value = false;
635 }
636 if (has_value) {
637 value = rangeCheck(has_value, name);
638 }
639
640 uint32_t min_value = 0;
641 ConstElementPtr has_min = getConfiguredGlobal("min-" + name);
642 bool new_min = true;
643 if (!has_min) {
644 has_min = target_config.getConfiguredGlobal("min-" + name);
645 new_min = false;
646 }
647 if (has_min) {
648 min_value = rangeCheck(has_min, "min-" + name);
649 }
650
651 uint32_t max_value = 0;
652 ConstElementPtr has_max = getConfiguredGlobal("max-" + name);
653 bool new_max = true;
654 if (!has_max) {
655 has_max = target_config.getConfiguredGlobal("max-" + name);
656 new_max = false;
657 }
658 if (has_max) {
659 max_value = rangeCheck(has_max, "max-" + name);
660 }
661
662 if (!has_value && !has_min && !has_max) {
663 return;
664 }
665 if (has_value) {
666 if (!has_min && !has_max) {
667 // default only.
668 return;
669 } else if (!has_min) {
670 // default and max.
671 min_value = value;
672 } else if (!has_max) {
673 // default and min.
674 max_value = value;
675 }
676 } else if (has_min) {
677 if (!has_max) {
678 // min only.
679 return;
680 } else {
681 // min and max.
682 isc_throw(BadValue, "have min-" << name << " and max-"
683 << name << " but no " << name << " (default)");
684 }
685 } else {
686 // max only.
687 return;
688 }
689
690 // Check that min <= max.
691 if (min_value > max_value) {
692 if (has_min && has_max) {
693 std::string from_min = (new_min ? "new" : "previous");
694 std::string from_max = (new_max ? "new" : "previous");
695 isc_throw(BadValue, "the value of " << from_min
696 << " min-" << name << " ("
697 << min_value << ") is not less than "
698 << from_max << " max-" << name
699 << " (" << max_value << ")");
700 } else if (has_min) {
701 // Only min and default so min > default.
702 std::string from_min = (new_min ? "new" : "previous");
703 std::string from_value = (new_value ? "new" : "previous");
704 isc_throw(BadValue, "the value of " << from_min
705 << " min-" << name << " ("
706 << min_value << ") is not less than " << from_value
707 << " (default) " << name
708 << " (" << value << ")");
709 } else {
710 // Only default and max so default > max.
711 std::string from_max = (new_max ? "new" : "previous");
712 std::string from_value = (new_value ? "new" : "previous");
713 isc_throw(BadValue, "the value of " << from_value
714 << " (default) " << name
715 << " (" << value << ") is not less than " << from_max
716 << " max-" << name << " (" << max_value << ")");
717 }
718 }
719
720 // Check that value is between min and max.
721 if ((value < min_value) || (value > max_value)) {
722 std::string from_value = (new_value ? "new" : "previous");
723 std::string from_min = (new_min ? "new" : "previous");
724 std::string from_max = (new_max ? "new" : "previous");
725 isc_throw(BadValue, "the value of " << from_value
726 <<" (default) " << name << " ("
727 << value << ") is not between " << from_min
728 << " min-" << name << " (" << min_value
729 << ") and " << from_max << " max-"
730 << name << " (" << max_value << ")");
731 }
732}
733
736 // Top level map
738
739 // Get family for the configuration manager
740 uint16_t family = CfgMgr::instance().getFamily();
741
742 // DhcpX global map initialized from configured globals
743 ElementPtr dhcp = configured_globals_->toElement();
744
745 auto loggers_info = getLoggingInfo();
746 // Was in the Logging global map.
747 if (!loggers_info.empty()) {
748 // Set loggers list
750 for (LoggingInfoStorage::const_iterator logger =
751 loggers_info.cbegin();
752 logger != loggers_info.cend(); ++logger) {
753 loggers->add(logger->toElement());
754 }
755 dhcp->set("loggers", loggers);
756 }
757
758 // Set user-context
760
761 // Set compatibility flags.
762 ElementPtr compatibility = Element::createMap();
764 compatibility->set("lenient-option-parsing", Element::create(true));
765 }
767 compatibility->set("ignore-dhcp-server-identifier", Element::create(true));
768 }
770 compatibility->set("ignore-rai-link-selection", Element::create(true));
771 }
772 if (getExcludeFirstLast24()) {
773 compatibility->set("exclude-first-last-24", Element::create(true));
774 }
775 if (compatibility->size() > 0) {
776 dhcp->set("compatibility", compatibility);
777 }
778
779 // Set decline-probation-period
780 dhcp->set("decline-probation-period",
781 Element::create(static_cast<long long>(decline_timer_)));
782 // Set echo-client-id (DHCPv4)
783 if (family == AF_INET) {
784 dhcp->set("echo-client-id", Element::create(echo_v4_client_id_));
785 }
786 // Set dhcp4o6-port
787 dhcp->set("dhcp4o6-port",
788 Element::create(static_cast<int>(dhcp4o6_port_)));
789 // Set dhcp-ddns
790 dhcp->set("dhcp-ddns", d2_client_config_->toElement());
791 // Set interfaces-config
792 dhcp->set("interfaces-config", cfg_iface_->toElement());
793 // Set option-def
794 dhcp->set("option-def", cfg_option_def_->toElement());
795 // Set option-data
796 dhcp->set("option-data", cfg_option_->toElement());
797
798 // Set subnets and shared networks.
799
800 // We have two problems to solve:
801 // - a subnet is unparsed once:
802 // * if it is a plain subnet in the global subnet list
803 // * if it is a member of a shared network in the shared network
804 // subnet list
805 // - unparsed subnets must be kept to add host reservations in them.
806 // Of course this can be done only when subnets are unparsed.
807
808 // The list of all unparsed subnets
809 std::vector<ElementPtr> sn_list;
810
811 if (family == AF_INET) {
812 // Get plain subnets
813 ElementPtr plain_subnets = Element::createList();
814 const Subnet4Collection* subnets = cfg_subnets4_->getAll();
815 for (auto const& subnet : *subnets) {
816 // Skip subnets which are in a shared-network
817 SharedNetwork4Ptr network;
818 subnet->getSharedNetwork(network);
819 if (network) {
820 continue;
821 }
822 ElementPtr subnet_cfg = subnet->toElement();
823 sn_list.push_back(subnet_cfg);
824 plain_subnets->add(subnet_cfg);
825 }
826 dhcp->set("subnet4", plain_subnets);
827
828 // Get shared networks
829 ElementPtr shared_networks = cfg_shared_networks4_->toElement();
830 dhcp->set("shared-networks", shared_networks);
831
832 // Get subnets in shared network subnet lists
833 const std::vector<ElementPtr> networks = shared_networks->listValue();
834 for (auto const& network : networks) {
835 const std::vector<ElementPtr> sh_list =
836 network->get("subnet4")->listValue();
837 for (auto const& subnet : sh_list) {
838 sn_list.push_back(subnet);
839 }
840 }
841
842 } else {
843 // Get plain subnets
844 ElementPtr plain_subnets = Element::createList();
845 const Subnet6Collection* subnets = cfg_subnets6_->getAll();
846 for (auto const& subnet : *subnets) {
847 // Skip subnets which are in a shared-network
848 SharedNetwork6Ptr network;
849 subnet->getSharedNetwork(network);
850 if (network) {
851 continue;
852 }
853 ElementPtr subnet_cfg = subnet->toElement();
854 sn_list.push_back(subnet_cfg);
855 plain_subnets->add(subnet_cfg);
856 }
857 dhcp->set("subnet6", plain_subnets);
858
859 // Get shared networks
860 ElementPtr shared_networks = cfg_shared_networks6_->toElement();
861 dhcp->set("shared-networks", shared_networks);
862
863 // Get subnets in shared network subnet lists
864 const std::vector<ElementPtr> networks = shared_networks->listValue();
865 for (auto const& network : networks) {
866 const std::vector<ElementPtr> sh_list =
867 network->get("subnet6")->listValue();
868 for (auto const& subnet : sh_list) {
869 sn_list.push_back(subnet);
870 }
871 }
872 }
873
874 // Host reservations
875 CfgHostsList resv_list;
876 resv_list.internalize(cfg_hosts_->toElement());
877
878 // Insert global reservations
879 ConstElementPtr global_resvs = resv_list.get(SUBNET_ID_GLOBAL);
880 if (global_resvs->size() > 0) {
881 dhcp->set("reservations", global_resvs);
882 }
883
884 // Insert subnet reservations
885 for (auto const& subnet : sn_list) {
886 ConstElementPtr id = subnet->get("id");
887 if (isNull(id)) {
888 isc_throw(ToElementError, "subnet has no id");
889 }
890 SubnetID subnet_id = id->intValue();
891 ConstElementPtr resvs = resv_list.get(subnet_id);
892 subnet->set("reservations", resvs);
893 }
894
895 // Set expired-leases-processing
896 ConstElementPtr expired = cfg_expiration_->toElement();
897 dhcp->set("expired-leases-processing", expired);
898 if (family == AF_INET6) {
899 // Set server-id (DHCPv6)
900 dhcp->set("server-id", cfg_duid_->toElement());
901
902 // Set relay-supplied-options (DHCPv6)
903 dhcp->set("relay-supplied-options", cfg_rsoo_->toElement());
904 }
905 // Set lease-database
906 CfgLeaseDbAccess lease_db(*cfg_db_access_);
907 dhcp->set("lease-database", lease_db.toElement());
908 // Set hosts-databases
909 CfgHostDbAccess host_db(*cfg_db_access_);
910 ConstElementPtr hosts_databases = host_db.toElement();
911 if (hosts_databases->size() > 0) {
912 dhcp->set("hosts-databases", hosts_databases);
913 }
914 // Set host-reservation-identifiers
915 ConstElementPtr host_ids;
916 if (family == AF_INET) {
917 host_ids = cfg_host_operations4_->toElement();
918 } else {
919 host_ids = cfg_host_operations6_->toElement();
920 }
921 dhcp->set("host-reservation-identifiers", host_ids);
922 // Set mac-sources (DHCPv6)
923 if (family == AF_INET6) {
924 dhcp->set("mac-sources", cfg_mac_source_.toElement());
925 }
926 // Set control-sockets.
927 ElementPtr control_sockets = Element::createList();
928 if (!isNull(unix_control_socket_)) {
929 for (auto const& socket : unix_control_socket_->listValue()) {
930 control_sockets->add(UserContext::toElement(socket));
931 }
932 }
933 if (!isNull(http_control_socket_)) {
934 for (auto const& socket : http_control_socket_->listValue()) {
935 control_sockets->add(UserContext::toElement(socket));
936 }
937 }
938 if (!control_sockets->empty()) {
939 dhcp->set("control-sockets", control_sockets);
940 }
941 // Set client-classes
942 ConstElementPtr client_classes = class_dictionary_->toElement();
944 if (!client_classes->empty()) {
945 dhcp->set("client-classes", client_classes);
946 }
947 // Set hooks-libraries
948 ConstElementPtr hooks_libs = hooks_config_.toElement();
949 dhcp->set("hooks-libraries", hooks_libs);
950 // Set DhcpX
951 result->set(family == AF_INET ? "Dhcp4" : "Dhcp6", dhcp);
952
953 ConstElementPtr cfg_consist = cfg_consist_->toElement();
954 dhcp->set("sanity-checks", cfg_consist);
955
956 // Set config-control (if it exists)
958 if (info) {
959 ConstElementPtr info_elem = info->toElement();
960 dhcp->set("config-control", info_elem);
961 }
962
963 // Set dhcp-packet-control (if it exists)
964 data::ConstElementPtr dhcp_queue_control = getDHCPQueueControl();
965 if (dhcp_queue_control) {
966 dhcp->set("dhcp-queue-control", dhcp_queue_control);
967 }
968
969 // Set multi-threading (if it exists)
970 data::ConstElementPtr dhcp_multi_threading = getDHCPMultiThreading();
971 if (dhcp_multi_threading) {
972 dhcp->set("multi-threading", dhcp_multi_threading);
973 }
974
975 return (result);
976}
977
980 return (DdnsParamsPtr(new DdnsParams(subnet,
981 getD2ClientConfig()->getEnableUpdates())));
982}
983
986 return (DdnsParamsPtr(new DdnsParams(subnet,
987 getD2ClientConfig()->getEnableUpdates())));
988}
989
990void
992 if (!getCfgDbAccess()->getIPReservationsUnique() && unique) {
994 }
995 getCfgHosts()->setIPReservationsUnique(unique);
996 getCfgDbAccess()->setIPReservationsUnique(unique);
997}
998
999void
1001 Option::lenient_parsing_ = lenient_option_parsing_;
1002}
1003
1004bool
1006 if (!subnet_) {
1007 return (false);
1008 }
1009
1010 if (pool_) {
1011 auto optional = pool_->getDdnsSendUpdates();
1012 if (!optional.unspecified()) {
1013 return (optional.get());
1014 }
1015 }
1016
1017 return (d2_client_enabled_ && subnet_->getDdnsSendUpdates().get());
1018}
1019
1020bool
1022 if (!subnet_) {
1023 return (false);
1024 }
1025
1026 if (pool_) {
1027 auto optional = pool_->getDdnsOverrideNoUpdate();
1028 if (!optional.unspecified()) {
1029 return (optional.get());
1030 }
1031 }
1032
1033 return (subnet_->getDdnsOverrideNoUpdate().get());
1034}
1035
1037 if (!subnet_) {
1038 return (false);
1039 }
1040
1041 if (pool_) {
1042 auto optional = pool_->getDdnsOverrideClientUpdate();
1043 if (!optional.unspecified()) {
1044 return (optional.get());
1045 }
1046 }
1047
1048 return (subnet_->getDdnsOverrideClientUpdate().get());
1049}
1050
1053 if (!subnet_) {
1055 }
1056
1057 if (pool_) {
1058 auto optional = pool_->getDdnsReplaceClientNameMode();
1059 if (!optional.unspecified()) {
1060 return (optional.get());
1061 }
1062 }
1063
1064 return (subnet_->getDdnsReplaceClientNameMode().get());
1065}
1066
1067std::string
1069 if (!subnet_) {
1070 return ("");
1071 }
1072
1073 if (pool_) {
1074 auto optional = pool_->getDdnsGeneratedPrefix();
1075 if (!optional.unspecified()) {
1076 return (optional.get());
1077 }
1078 }
1079
1080 return (subnet_->getDdnsGeneratedPrefix().get());
1081}
1082
1083std::string
1085 if (!subnet_) {
1086 return ("");
1087 }
1088
1089 if (pool_) {
1090 auto optional = pool_->getDdnsQualifyingSuffix();
1091 if (!optional.unspecified()) {
1092 return (optional.get());
1093 }
1094 }
1095
1096 return (subnet_->getDdnsQualifyingSuffix().get());
1097}
1098
1099std::string
1101 if (!subnet_) {
1102 return ("");
1103 }
1104
1105 return (subnet_->getHostnameCharSet().get());
1106}
1107
1108std::string
1110 if (!subnet_) {
1111 return ("");
1112 }
1113
1114 return (subnet_->getHostnameCharReplacement().get());
1115}
1116
1120 if (subnet_) {
1121 std::string char_set = getHostnameCharSet();
1122 if (!char_set.empty()) {
1123 try {
1124 sanitizer.reset(new util::str::StringSanitizer(char_set,
1126 } catch (const std::exception& ex) {
1127 isc_throw(BadValue, "hostname_char_set_: '" << char_set <<
1128 "' is not a valid regular expression");
1129 }
1130 }
1131 }
1132
1133 return (sanitizer);
1134}
1135
1136void
1138 // Need to check that global DDNS TTL values make sense
1139
1140 // Get ddns-ttl first. If ddns-ttl is specified none of the others should be.
1141 ConstElementPtr has_ddns_ttl = getConfiguredGlobal("ddns-ttl");
1142
1143 if (getConfiguredGlobal("ddns-ttl-percent")) {
1144 if (has_ddns_ttl) {
1145 isc_throw(BadValue, "cannot specify both ddns-ttl-percent and ddns-ttl");
1146 }
1147 }
1148
1149 ConstElementPtr has_ddns_ttl_min = getConfiguredGlobal("ddns-ttl-min");
1150 if (has_ddns_ttl_min && has_ddns_ttl) {
1151 isc_throw(BadValue, "cannot specify both ddns-ttl-min and ddns-ttl");
1152 }
1153
1154 ConstElementPtr has_ddns_ttl_max = getConfiguredGlobal("ddns-ttl-max");
1155 if (has_ddns_ttl_max) {
1156 if (has_ddns_ttl) {
1157 isc_throw(BadValue, "cannot specify both ddns-ttl-max and ddns-ttl");
1158 }
1159
1160 if (has_ddns_ttl_min) {
1161 // Have min and max, make sure the range is sane.
1162 uint32_t ddns_ttl_min = has_ddns_ttl_min->intValue();
1163 uint32_t ddns_ttl_max = has_ddns_ttl_max->intValue();
1164 if (ddns_ttl_max < ddns_ttl_min) {
1165 isc_throw(BadValue, "ddns-ttl-max: " << ddns_ttl_max
1166 << " must be greater than ddns-ttl-min: " << ddns_ttl_min);
1167 }
1168 }
1169 }
1170}
1171
1172void
1174 const std::string type = "type";
1175
1176 // Parse the access string and create a redacted string for logging.
1177 auto parameters = DatabaseConnection::parse(cfg_db_access_->getLeaseDbAccessString());
1178 std::string redacted = DatabaseConnection::redactedAccessString(parameters);
1179
1180 // Get the database type and open the corresponding database.
1181 DatabaseConnection::ParameterMap::iterator it = parameters.find(type);
1182 if (it == parameters.end()) {
1183 isc_throw(InvalidParameter, "Database configuration parameters do not "
1184 "contain the 'type' keyword" << redacted);
1185 }
1186
1187 std::string db_type = it->second;
1188 bool allowed = (db_type == "mysql" || db_type == "postgresql");
1189 if (CfgMgr::instance().getFamily() == AF_INET) {
1190 for (auto subnet : *(getCfgSubnets4()->getAll()) ) {
1191 if (subnet->getAllocatorType() == "shared-flq") {
1192 if (!allowed) {
1193 isc_throw(BadValue, "shared-flq allocator is only supported by MySQL and PosgreSQL backends");
1194 }
1195
1197 }
1198 }
1199 } else {
1200 for (auto subnet : *(getCfgSubnets6()->getAll()) ) {
1201 if (subnet->getAllocatorType() == "shared-flq") {
1202 if (!allowed) {
1203 isc_throw(BadValue, "shared-flq allocator is only supported by MySQL and PosgreSQL backends");
1204 }
1205
1207 }
1208 }
1209 }
1210}
1211
1212} // namespace dhcp
1213} // namespace isc
@ integer
Definition data.h:153
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
Cannot unparse error.
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
Definition data.cc:299
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:354
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:349
Notes: IntElement type is changed to int64_t.
Definition data.h:776
static size_t setDefaults(isc::data::ElementPtr scope, const SimpleDefaults &default_values)
Sets the default values.
static std::string redactedAccessString(const ParameterMap &parameters)
Redact database access string.
static ParameterMap parse(const std::string &dbaccess)
Parse database access string.
Parameters for various consistency checks.
Holds manual configuration of the server identifier (DUID).
Definition cfg_duid.h:30
Holds access parameters and the configuration of the lease and hosts database connection.
Holds configuration parameters pertaining to lease expiration and lease affinity.
Class to store configured global parameters.
Definition cfg_globals.h:25
Represents global configuration for host reservations.
Utility class to represent host reservation configurations internally as a map keyed by subnet IDs,...
isc::data::ConstElementPtr get(SubnetID id) const
Return the host reservations for a subnet ID.
void internalize(isc::data::ConstElementPtr list)
Internalize a list Element.
Represents the host reservations specified in the configuration file.
Definition cfg_hosts.h:41
Represents selection of interfaces for DHCP server.
Definition cfg_iface.h:131
uint16_t getFamily() const
Returns address family.
Definition cfgmgr.h:246
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:29
static void extract(data::ConstElementPtr value, bool &enabled, uint32_t &thread_count, uint32_t &queue_size)
Extract multi-threading parameters from a given configuration.
Represents option definitions used by the DHCP server.
Represents option data configuration for the DHCP server.
Definition cfg_option.h:404
Represents configuration of the RSOO options for the DHCP server.
Definition cfg_rsoo.h:25
Represents configuration of IPv4 shared networks.
Represents configuration of IPv6 shared networks.
Holds subnets configured for the DHCPv4 server.
Holds subnets configured for the DHCPv6 server.
Maintains a list of ClientClassDef's.
static size_t setAllDefaults(isc::data::ConstElementPtr d2_config)
Sets all defaults for D2 client configuration.
Acts as a storage vault for D2 client configuration.
ReplaceClientNameMode
Defines the client name replacement modes.
Convenience container for conveying DDNS behavioral parameters It is intended to be created per Packe...
Definition ddns_params.h:23
std::string getHostnameCharReplacement() const
Returns the string to replace invalid characters when scrubbing hostnames.
D2ClientConfig::ReplaceClientNameMode getReplaceClientNameMode() const
Returns how Kea should handle the domain-name supplied by the client.
std::string getGeneratedPrefix() const
Returns the Prefix Kea should use when generating domain-names.
isc::util::str::StringSanitizerPtr getHostnameSanitizer() const
Returns a regular expression string sanitizer.
std::string getHostnameCharSet() const
Returns the regular expression describing invalid characters for client hostnames.
std::string getQualifyingSuffix() const
Returns the suffix Kea should use when to qualify partial domain-names.
bool getOverrideNoUpdate() const
Returns whether or not Kea should perform updates, even if client requested no updates.
bool getEnableUpdates() const
Returns whether or not DHCP DDNS updating is enabled.
bool getOverrideClientUpdate() const
Returns whether or not Kea should perform updates, even if client requested delegation.
static bool haveInstance()
Indicates if the lease manager has been instantiated.
static bool lenient_parsing_
Governs whether options should be parsed less strictly.
Definition option.h:490
static void sanityChecksSflqAllocator6(Subnet6Ptr subnet)
Sanity checks the subnet and pool configuration for use with SFLQ.
static void sanityChecksSflqAllocator4(Subnet4Ptr subnet)
Sanity checks the subnet and pool configuration for use with SFLQ.
static const isc::data::SimpleDefaults DHCP_MULTI_THREADING4_DEFAULTS
This table defines default values for multi-threading in DHCPv4.
static const isc::data::SimpleDefaults SANITY_CHECKS4_DEFAULTS
This defines default values for sanity checking for DHCPv4.
static const isc::data::SimpleDefaults DHCP_QUEUE_CONTROL4_DEFAULTS
This table defines default values for dhcp-queue-control in DHCPv4.
static const isc::data::SimpleDefaults DHCP_QUEUE_CONTROL6_DEFAULTS
This table defines default values for dhcp-queue-control in DHCPv6.
static const isc::data::SimpleDefaults DHCP_MULTI_THREADING6_DEFAULTS
This table defines default values for multi-threading in DHCPv6.
static const isc::data::SimpleDefaults SANITY_CHECKS6_DEFAULTS
This defines default values for sanity checking for DHCPv6.
Specifies current DHCP configuration.
Definition srv_config.h:50
ClientClassDictionaryPtr getClientClassDictionary()
Returns pointer to the dictionary of global client class definitions.
Definition srv_config.h:459
static const uint32_t CFGSEL_SUBNET4
Number of IPv4 subnets.
Definition srv_config.h:58
void setDhcp4o6Port(uint16_t port)
Sets DHCP4o6 IPC port.
Definition srv_config.h:696
void addConfiguredGlobal(const std::string &name, isc::data::ConstElementPtr value)
Adds a parameter to the collection configured globals.
Definition srv_config.h:802
CfgGlobalsPtr getConfiguredGlobals()
Returns non-const pointer to configured global parameters.
Definition srv_config.h:736
void sanityChecksDdnsTtlParameters() const
Conducts sanity checks on global DDNS ttl parameters: ddns-ttl, ddns-ttl-percent, ddns-ttl-min,...
void setClientClassDictionary(const ClientClassDictionaryPtr &dictionary)
Sets the client class dictionary.
Definition srv_config.h:474
virtual void merge(ConfigBase &other)
Merges the configuration specified as a parameter into this configuration.
void extractConfiguredGlobals(isc::data::ConstElementPtr config)
Saves scalar elements from the global scope of a configuration.
isc::data::ConstElementPtr getConfiguredGlobal(std::string name) const
Returns pointer to a given configured global parameter.
Definition srv_config.h:755
CfgSharedNetworks6Ptr getCfgSharedNetworks6() const
Returns pointer to non-const object holding configuration of shared networks in DHCPv6.
Definition srv_config.h:216
bool getIgnoreRAILinkSelection() const
Get ignore RAI Link Selection compatibility flag.
Definition srv_config.h:910
void setD2ClientConfig(const D2ClientConfigPtr &d2_client_config)
Sets the D2 client configuration.
Definition srv_config.h:726
void applyDefaultsConfiguredGlobals(const isc::data::SimpleDefaults &defaults)
Applies defaults to global parameters.
void setIPReservationsUnique(const bool unique)
Configures the server to allow or disallow specifying multiple hosts with the same IP address/subnet.
void configureLowerLevelLibraries() const
Convenience method to propagate configuration parameters through inversion of control.
CfgDUIDPtr getCfgDUID()
Returns pointer to the object holding configuration of the server identifier.
Definition srv_config.h:300
void sanityChecksSflqAllocator() const
Conducts sanity check in use of SFLQ allocator.
bool sequenceEquals(const SrvConfig &other)
Compares configuration sequence with other sequence.
CfgSubnets4Ptr getCfgSubnets4()
Returns pointer to non-const object holding subnets configuration for DHCPv4.
Definition srv_config.h:198
CfgSubnets6Ptr getCfgSubnets6()
Returns pointer to non-const object holding subnets configuration for DHCPv6.
Definition srv_config.h:232
CfgOptionDefPtr getCfgOptionDef()
Return pointer to non-const object representing user-defined option definitions.
Definition srv_config.h:159
D2ClientConfigPtr getD2ClientConfig()
Returns pointer to the D2 client configuration.
Definition srv_config.h:712
CfgHostOperationsPtr getCfgHostOperations6()
Returns pointer to the object holding general configuration for host reservations in DHCPv6.
Definition srv_config.h:354
void setReservationsLookupFirst(const bool first)
Sets whether the server does host reservations lookup before lease lookup.
Definition srv_config.h:851
const isc::data::ConstElementPtr getDHCPMultiThreading() const
Returns DHCP multi threading information.
Definition srv_config.h:444
void setDHCPQueueControl(const isc::data::ConstElementPtr dhcp_queue_control)
Sets information about the dhcp queue control.
Definition srv_config.h:437
DdnsParamsPtr getDdnsParams(const ConstSubnet4Ptr &subnet) const
Fetches the DDNS parameters for a given DHCPv4 subnet.
void sanityChecksLifetime(const std::string &name) const
Conducts sanity checks on global lifetime parameters.
std::string getConfigSummary(const uint32_t selection) const
Returns summary of the configuration in the textual format.
Definition srv_config.cc:90
const isc::data::ConstElementPtr getDHCPQueueControl() const
Returns DHCP queue control information.
Definition srv_config.h:430
bool equals(const SrvConfig &other) const
Compares two objects for equality.
uint32_t getSequence() const
Returns configuration sequence number.
Definition srv_config.h:116
static const uint32_t CFGSEL_DDNS
DDNS enabled/disabled.
Definition srv_config.h:66
void setDeclinePeriod(const uint32_t decline_timer)
Sets decline probation-period.
Definition srv_config.h:660
void removeStatistics()
Removes statistics.
CfgExpirationPtr getCfgExpiration()
Returns pointer to the object holding configuration pertaining to processing expired leases.
Definition srv_config.h:282
CfgOptionPtr getCfgOption()
Returns pointer to the non-const object holding options.
Definition srv_config.h:180
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
bool getLenientOptionParsing() const
Get lenient option parsing compatibility flag.
Definition srv_config.h:880
static const uint32_t CFGSEL_SUBNET6
Number of IPv6 subnets.
Definition srv_config.h:60
bool getExcludeFirstLast24() const
Get exclude .0 and .255 addresses in subnets bigger than /24 flag.
Definition srv_config.h:925
void updateStatistics()
Updates statistics.
CfgDbAccessPtr getCfgDbAccess()
Returns pointer to the object holding configuration of the lease and host database connection paramet...
Definition srv_config.h:318
void setEchoClientId(const bool echo)
Sets whether server should send back client-id in DHCPv4.
Definition srv_config.h:679
void copy(SrvConfig &new_config) const
Copies the current configuration to a new configuration.
CfgSharedNetworks4Ptr getCfgSharedNetworks4() const
Returns pointer to non-const object holding configuration of shared networks in DHCPv4;.
Definition srv_config.h:207
CfgHostsPtr getCfgHosts()
Returns pointer to the non-const objects representing host reservations for different IPv4 and IPv6 s...
Definition srv_config.h:248
bool getIgnoreServerIdentifier() const
Get ignore DHCP Server Identifier compatibility flag.
Definition srv_config.h:895
SrvConfig()
Default constructor.
Definition srv_config.cc:49
CfgHostOperationsPtr getCfgHostOperations4()
Returns pointer to the object holding general configuration for host reservations in DHCPv4.
Definition srv_config.h:336
void clear()
Removes all configured hooks libraries.
void add(const std::string &libname, isc::data::ConstElementPtr parameters, const std::string &cfgname="")
Adds additional hooks libraries.
const isc::hooks::HookLibsCollection & get() const
Provides access to the configured hooks libraries.
Base class for all configurations.
Definition config_base.h:33
process::ConstConfigControlInfoPtr getConfigControlInfo() const
Fetches a read-only copy of the configuration control information.
const process::LoggingInfoStorage & getLoggingInfo() const
Returns logging specific configuration.
Definition config_base.h:43
void setServerTag(const util::Optional< std::string > &server_tag)
Sets the server's logical name.
void copy(ConfigBase &new_config) const
Copies the current configuration to a new configuration.
virtual void merge(ConfigBase &other)
Merges specified configuration into this configuration.
bool equals(const ConfigBase &other) const
Compares two configuration.
Statistics Manager class.
static StatsMgr & instance()
Statistics Manager accessor method.
Implements a regular expression based string scrubber.
Definition str.h:222
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void setMaxSampleCountDefault(uint32_t max_samples)
Set default count limit.
void setMaxSampleAgeAll(const StatsDuration &duration)
Set duration limit for all collected statistics.
void setMaxSampleCountAll(uint32_t max_samples)
Set count limit for all collected statistics.
void setMaxSampleAgeDefault(const StatsDuration &duration)
Set default duration limit.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Definition macros.h:26
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
bool isNull(ConstElementPtr p)
Checks whether the given ElementPtr is a null pointer.
Definition data.cc:1230
std::vector< SimpleDefault > SimpleDefaults
This specifies all default values in a given scope (e.g. a subnet).
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
@ info
Definition db_log.h:126
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
Definition dhcpsrv_log.h:56
boost::shared_ptr< CfgDUID > CfgDUIDPtr
Pointer to the Non-const object.
Definition cfg_duid.h:161
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
Definition subnet.h:620
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
Definition subnet.h:455
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< 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< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet6Collection
A collection of Subnet6 objects.
Definition subnet.h:934
boost::shared_ptr< DdnsParams > DdnsParamsPtr
Defines a pointer for DdnsParams instances.
boost::shared_ptr< SharedNetwork6 > SharedNetwork6Ptr
Pointer to SharedNetwork6 object.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< 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 > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet4Collection
A collection of Subnet4 objects.
Definition subnet.h:863
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
const isc::log::MessageID DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_POSSIBLE
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
boost::shared_ptr< const ConfigControlInfo > ConstConfigControlInfoPtr
Defines a pointer to a const ConfigControlInfo.
std::unique_ptr< StringSanitizer > StringSanitizerPtr
Type representing the pointer to the StringSanitizer.
Definition str.h:263
Defines the logger used by the top-level component of kea-lfc.
Represents the position of the data element within a configuration string.
Definition data.h:107
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
static data::ElementPtr toElement(data::ConstElementPtr map)
Copy an Element map.
virtual isc::data::ElementPtr toElement() const
Unparse.
utility class for unparsing
virtual isc::data::ElementPtr toElement() const
Unparse.