Kea 3.1.9
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
525void
526SrvConfig::sanityChecksLifetime(const std::string& name) const {
527 // Initialize as some compilers complain otherwise.
528 uint32_t value = 0;
529 ConstElementPtr has_value = getConfiguredGlobal(name);
530 if (has_value) {
531 value = has_value->intValue();
532 }
533
534 uint32_t min_value = 0;
535 ConstElementPtr has_min = getConfiguredGlobal("min-" + name);
536 if (has_min) {
537 min_value = has_min->intValue();
538 }
539
540 uint32_t max_value = 0;
541 ConstElementPtr has_max = getConfiguredGlobal("max-" + name);
542 if (has_max) {
543 max_value = has_max->intValue();
544 }
545
546 if (!has_value && !has_min && !has_max) {
547 return;
548 }
549 if (has_value) {
550 if (!has_min && !has_max) {
551 // default only.
552 return;
553 } else if (!has_min) {
554 // default and max.
555 min_value = value;
556 } else if (!has_max) {
557 // default and min.
558 max_value = value;
559 }
560 } else if (has_min) {
561 if (!has_max) {
562 // min only.
563 return;
564 } else {
565 // min and max.
566 isc_throw(BadValue, "have min-" << name << " and max-"
567 << name << " but no " << name << " (default)");
568 }
569 } else {
570 // max only.
571 return;
572 }
573
574 // Check that min <= max.
575 if (min_value > max_value) {
576 if (has_min && has_max) {
577 isc_throw(BadValue, "the value of min-" << name << " ("
578 << min_value << ") is not less than max-" << name << " ("
579 << max_value << ")");
580 } else if (has_min) {
581 // Only min and default so min > default.
582 isc_throw(BadValue, "the value of min-" << name << " ("
583 << min_value << ") is not less than (default) " << name
584 << " (" << value << ")");
585 } else {
586 // Only default and max so default > max.
587 isc_throw(BadValue, "the value of (default) " << name
588 << " (" << value << ") is not less than max-" << name
589 << " (" << max_value << ")");
590 }
591 }
592
593 // Check that value is between min and max.
594 if ((value < min_value) || (value > max_value)) {
595 isc_throw(BadValue, "the value of (default) " << name << " ("
596 << value << ") is not between min-" << name << " ("
597 << min_value << ") and max-" << name << " ("
598 << max_value << ")");
599 }
600}
601
602void
604 const std::string& name) const {
605 // Three cases:
606 // - the external/source config has the parameter: use it.
607 // - only the target config has the parameter: use this one.
608 // - no config has the parameter.
609 uint32_t value = 0;
610 ConstElementPtr has_value = getConfiguredGlobal(name);
611 bool new_value = true;
612 if (!has_value) {
613 has_value = target_config.getConfiguredGlobal(name);
614 new_value = false;
615 }
616 if (has_value) {
617 value = has_value->intValue();
618 }
619
620 uint32_t min_value = 0;
621 ConstElementPtr has_min = getConfiguredGlobal("min-" + name);
622 bool new_min = true;
623 if (!has_min) {
624 has_min = target_config.getConfiguredGlobal("min-" + name);
625 new_min = false;
626 }
627 if (has_min) {
628 min_value = has_min->intValue();
629 }
630
631 uint32_t max_value = 0;
632 ConstElementPtr has_max = getConfiguredGlobal("max-" + name);
633 bool new_max = true;
634 if (!has_max) {
635 has_max = target_config.getConfiguredGlobal("max-" + name);
636 new_max = false;
637 }
638 if (has_max) {
639 max_value = has_max->intValue();
640 }
641
642 if (!has_value && !has_min && !has_max) {
643 return;
644 }
645 if (has_value) {
646 if (!has_min && !has_max) {
647 // default only.
648 return;
649 } else if (!has_min) {
650 // default and max.
651 min_value = value;
652 } else if (!has_max) {
653 // default and min.
654 max_value = value;
655 }
656 } else if (has_min) {
657 if (!has_max) {
658 // min only.
659 return;
660 } else {
661 // min and max.
662 isc_throw(BadValue, "have min-" << name << " and max-"
663 << name << " but no " << name << " (default)");
664 }
665 } else {
666 // max only.
667 return;
668 }
669
670 // Check that min <= max.
671 if (min_value > max_value) {
672 if (has_min && has_max) {
673 std::string from_min = (new_min ? "new" : "previous");
674 std::string from_max = (new_max ? "new" : "previous");
675 isc_throw(BadValue, "the value of " << from_min
676 << " min-" << name << " ("
677 << min_value << ") is not less than "
678 << from_max << " max-" << name
679 << " (" << max_value << ")");
680 } else if (has_min) {
681 // Only min and default so min > default.
682 std::string from_min = (new_min ? "new" : "previous");
683 std::string from_value = (new_value ? "new" : "previous");
684 isc_throw(BadValue, "the value of " << from_min
685 << " min-" << name << " ("
686 << min_value << ") is not less than " << from_value
687 << " (default) " << name
688 << " (" << value << ")");
689 } else {
690 // Only default and max so default > max.
691 std::string from_max = (new_max ? "new" : "previous");
692 std::string from_value = (new_value ? "new" : "previous");
693 isc_throw(BadValue, "the value of " << from_value
694 << " (default) " << name
695 << " (" << value << ") is not less than " << from_max
696 << " max-" << name << " (" << max_value << ")");
697 }
698 }
699
700 // Check that value is between min and max.
701 if ((value < min_value) || (value > max_value)) {
702 std::string from_value = (new_value ? "new" : "previous");
703 std::string from_min = (new_min ? "new" : "previous");
704 std::string from_max = (new_max ? "new" : "previous");
705 isc_throw(BadValue, "the value of " << from_value
706 <<" (default) " << name << " ("
707 << value << ") is not between " << from_min
708 << " min-" << name << " (" << min_value
709 << ") and " << from_max << " max-"
710 << name << " (" << max_value << ")");
711 }
712}
713
716 // Top level map
718
719 // Get family for the configuration manager
720 uint16_t family = CfgMgr::instance().getFamily();
721
722 // DhcpX global map initialized from configured globals
723 ElementPtr dhcp = configured_globals_->toElement();
724
725 auto loggers_info = getLoggingInfo();
726 // Was in the Logging global map.
727 if (!loggers_info.empty()) {
728 // Set loggers list
730 for (LoggingInfoStorage::const_iterator logger =
731 loggers_info.cbegin();
732 logger != loggers_info.cend(); ++logger) {
733 loggers->add(logger->toElement());
734 }
735 dhcp->set("loggers", loggers);
736 }
737
738 // Set user-context
740
741 // Set compatibility flags.
742 ElementPtr compatibility = Element::createMap();
744 compatibility->set("lenient-option-parsing", Element::create(true));
745 }
747 compatibility->set("ignore-dhcp-server-identifier", Element::create(true));
748 }
750 compatibility->set("ignore-rai-link-selection", Element::create(true));
751 }
752 if (getExcludeFirstLast24()) {
753 compatibility->set("exclude-first-last-24", Element::create(true));
754 }
755 if (compatibility->size() > 0) {
756 dhcp->set("compatibility", compatibility);
757 }
758
759 // Set decline-probation-period
760 dhcp->set("decline-probation-period",
761 Element::create(static_cast<long long>(decline_timer_)));
762 // Set echo-client-id (DHCPv4)
763 if (family == AF_INET) {
764 dhcp->set("echo-client-id", Element::create(echo_v4_client_id_));
765 }
766 // Set dhcp4o6-port
767 dhcp->set("dhcp4o6-port",
768 Element::create(static_cast<int>(dhcp4o6_port_)));
769 // Set dhcp-ddns
770 dhcp->set("dhcp-ddns", d2_client_config_->toElement());
771 // Set interfaces-config
772 dhcp->set("interfaces-config", cfg_iface_->toElement());
773 // Set option-def
774 dhcp->set("option-def", cfg_option_def_->toElement());
775 // Set option-data
776 dhcp->set("option-data", cfg_option_->toElement());
777
778 // Set subnets and shared networks.
779
780 // We have two problems to solve:
781 // - a subnet is unparsed once:
782 // * if it is a plain subnet in the global subnet list
783 // * if it is a member of a shared network in the shared network
784 // subnet list
785 // - unparsed subnets must be kept to add host reservations in them.
786 // Of course this can be done only when subnets are unparsed.
787
788 // The list of all unparsed subnets
789 std::vector<ElementPtr> sn_list;
790
791 if (family == AF_INET) {
792 // Get plain subnets
793 ElementPtr plain_subnets = Element::createList();
794 const Subnet4Collection* subnets = cfg_subnets4_->getAll();
795 for (auto const& subnet : *subnets) {
796 // Skip subnets which are in a shared-network
797 SharedNetwork4Ptr network;
798 subnet->getSharedNetwork(network);
799 if (network) {
800 continue;
801 }
802 ElementPtr subnet_cfg = subnet->toElement();
803 sn_list.push_back(subnet_cfg);
804 plain_subnets->add(subnet_cfg);
805 }
806 dhcp->set("subnet4", plain_subnets);
807
808 // Get shared networks
809 ElementPtr shared_networks = cfg_shared_networks4_->toElement();
810 dhcp->set("shared-networks", shared_networks);
811
812 // Get subnets in shared network subnet lists
813 const std::vector<ElementPtr> networks = shared_networks->listValue();
814 for (auto const& network : networks) {
815 const std::vector<ElementPtr> sh_list =
816 network->get("subnet4")->listValue();
817 for (auto const& subnet : sh_list) {
818 sn_list.push_back(subnet);
819 }
820 }
821
822 } else {
823 // Get plain subnets
824 ElementPtr plain_subnets = Element::createList();
825 const Subnet6Collection* subnets = cfg_subnets6_->getAll();
826 for (auto const& subnet : *subnets) {
827 // Skip subnets which are in a shared-network
828 SharedNetwork6Ptr network;
829 subnet->getSharedNetwork(network);
830 if (network) {
831 continue;
832 }
833 ElementPtr subnet_cfg = subnet->toElement();
834 sn_list.push_back(subnet_cfg);
835 plain_subnets->add(subnet_cfg);
836 }
837 dhcp->set("subnet6", plain_subnets);
838
839 // Get shared networks
840 ElementPtr shared_networks = cfg_shared_networks6_->toElement();
841 dhcp->set("shared-networks", shared_networks);
842
843 // Get subnets in shared network subnet lists
844 const std::vector<ElementPtr> networks = shared_networks->listValue();
845 for (auto const& network : networks) {
846 const std::vector<ElementPtr> sh_list =
847 network->get("subnet6")->listValue();
848 for (auto const& subnet : sh_list) {
849 sn_list.push_back(subnet);
850 }
851 }
852 }
853
854 // Host reservations
855 CfgHostsList resv_list;
856 resv_list.internalize(cfg_hosts_->toElement());
857
858 // Insert global reservations
859 ConstElementPtr global_resvs = resv_list.get(SUBNET_ID_GLOBAL);
860 if (global_resvs->size() > 0) {
861 dhcp->set("reservations", global_resvs);
862 }
863
864 // Insert subnet reservations
865 for (auto const& subnet : sn_list) {
866 ConstElementPtr id = subnet->get("id");
867 if (isNull(id)) {
868 isc_throw(ToElementError, "subnet has no id");
869 }
870 SubnetID subnet_id = id->intValue();
871 ConstElementPtr resvs = resv_list.get(subnet_id);
872 subnet->set("reservations", resvs);
873 }
874
875 // Set expired-leases-processing
876 ConstElementPtr expired = cfg_expiration_->toElement();
877 dhcp->set("expired-leases-processing", expired);
878 if (family == AF_INET6) {
879 // Set server-id (DHCPv6)
880 dhcp->set("server-id", cfg_duid_->toElement());
881
882 // Set relay-supplied-options (DHCPv6)
883 dhcp->set("relay-supplied-options", cfg_rsoo_->toElement());
884 }
885 // Set lease-database
886 CfgLeaseDbAccess lease_db(*cfg_db_access_);
887 dhcp->set("lease-database", lease_db.toElement());
888 // Set hosts-databases
889 CfgHostDbAccess host_db(*cfg_db_access_);
890 ConstElementPtr hosts_databases = host_db.toElement();
891 if (hosts_databases->size() > 0) {
892 dhcp->set("hosts-databases", hosts_databases);
893 }
894 // Set host-reservation-identifiers
895 ConstElementPtr host_ids;
896 if (family == AF_INET) {
897 host_ids = cfg_host_operations4_->toElement();
898 } else {
899 host_ids = cfg_host_operations6_->toElement();
900 }
901 dhcp->set("host-reservation-identifiers", host_ids);
902 // Set mac-sources (DHCPv6)
903 if (family == AF_INET6) {
904 dhcp->set("mac-sources", cfg_mac_source_.toElement());
905 }
906 // Set control-sockets.
907 ElementPtr control_sockets = Element::createList();
908 if (!isNull(unix_control_socket_)) {
909 for (auto const& socket : unix_control_socket_->listValue()) {
910 control_sockets->add(UserContext::toElement(socket));
911 }
912 }
913 if (!isNull(http_control_socket_)) {
914 for (auto const& socket : http_control_socket_->listValue()) {
915 control_sockets->add(UserContext::toElement(socket));
916 }
917 }
918 if (!control_sockets->empty()) {
919 dhcp->set("control-sockets", control_sockets);
920 }
921 // Set client-classes
922 ConstElementPtr client_classes = class_dictionary_->toElement();
924 if (!client_classes->empty()) {
925 dhcp->set("client-classes", client_classes);
926 }
927 // Set hooks-libraries
928 ConstElementPtr hooks_libs = hooks_config_.toElement();
929 dhcp->set("hooks-libraries", hooks_libs);
930 // Set DhcpX
931 result->set(family == AF_INET ? "Dhcp4" : "Dhcp6", dhcp);
932
933 ConstElementPtr cfg_consist = cfg_consist_->toElement();
934 dhcp->set("sanity-checks", cfg_consist);
935
936 // Set config-control (if it exists)
938 if (info) {
939 ConstElementPtr info_elem = info->toElement();
940 dhcp->set("config-control", info_elem);
941 }
942
943 // Set dhcp-packet-control (if it exists)
944 data::ConstElementPtr dhcp_queue_control = getDHCPQueueControl();
945 if (dhcp_queue_control) {
946 dhcp->set("dhcp-queue-control", dhcp_queue_control);
947 }
948
949 // Set multi-threading (if it exists)
950 data::ConstElementPtr dhcp_multi_threading = getDHCPMultiThreading();
951 if (dhcp_multi_threading) {
952 dhcp->set("multi-threading", dhcp_multi_threading);
953 }
954
955 return (result);
956}
957
960 return (DdnsParamsPtr(new DdnsParams(subnet,
961 getD2ClientConfig()->getEnableUpdates())));
962}
963
966 return (DdnsParamsPtr(new DdnsParams(subnet,
967 getD2ClientConfig()->getEnableUpdates())));
968}
969
970void
972 if (!getCfgDbAccess()->getIPReservationsUnique() && unique) {
974 }
975 getCfgHosts()->setIPReservationsUnique(unique);
976 getCfgDbAccess()->setIPReservationsUnique(unique);
977}
978
979void
981 Option::lenient_parsing_ = lenient_option_parsing_;
982}
983
984bool
986 if (!subnet_) {
987 return (false);
988 }
989
990 if (pool_) {
991 auto optional = pool_->getDdnsSendUpdates();
992 if (!optional.unspecified()) {
993 return (optional.get());
994 }
995 }
996
997 return (d2_client_enabled_ && subnet_->getDdnsSendUpdates().get());
998}
999
1000bool
1002 if (!subnet_) {
1003 return (false);
1004 }
1005
1006 if (pool_) {
1007 auto optional = pool_->getDdnsOverrideNoUpdate();
1008 if (!optional.unspecified()) {
1009 return (optional.get());
1010 }
1011 }
1012
1013 return (subnet_->getDdnsOverrideNoUpdate().get());
1014}
1015
1017 if (!subnet_) {
1018 return (false);
1019 }
1020
1021 if (pool_) {
1022 auto optional = pool_->getDdnsOverrideClientUpdate();
1023 if (!optional.unspecified()) {
1024 return (optional.get());
1025 }
1026 }
1027
1028 return (subnet_->getDdnsOverrideClientUpdate().get());
1029}
1030
1033 if (!subnet_) {
1035 }
1036
1037 if (pool_) {
1038 auto optional = pool_->getDdnsReplaceClientNameMode();
1039 if (!optional.unspecified()) {
1040 return (optional.get());
1041 }
1042 }
1043
1044 return (subnet_->getDdnsReplaceClientNameMode().get());
1045}
1046
1047std::string
1049 if (!subnet_) {
1050 return ("");
1051 }
1052
1053 if (pool_) {
1054 auto optional = pool_->getDdnsGeneratedPrefix();
1055 if (!optional.unspecified()) {
1056 return (optional.get());
1057 }
1058 }
1059
1060 return (subnet_->getDdnsGeneratedPrefix().get());
1061}
1062
1063std::string
1065 if (!subnet_) {
1066 return ("");
1067 }
1068
1069 if (pool_) {
1070 auto optional = pool_->getDdnsQualifyingSuffix();
1071 if (!optional.unspecified()) {
1072 return (optional.get());
1073 }
1074 }
1075
1076 return (subnet_->getDdnsQualifyingSuffix().get());
1077}
1078
1079std::string
1081 if (!subnet_) {
1082 return ("");
1083 }
1084
1085 return (subnet_->getHostnameCharSet().get());
1086}
1087
1088std::string
1090 if (!subnet_) {
1091 return ("");
1092 }
1093
1094 return (subnet_->getHostnameCharReplacement().get());
1095}
1096
1100 if (subnet_) {
1101 std::string char_set = getHostnameCharSet();
1102 if (!char_set.empty()) {
1103 try {
1104 sanitizer.reset(new util::str::StringSanitizer(char_set,
1106 } catch (const std::exception& ex) {
1107 isc_throw(BadValue, "hostname_char_set_: '" << char_set <<
1108 "' is not a valid regular expression");
1109 }
1110 }
1111 }
1112
1113 return (sanitizer);
1114}
1115
1116void
1118 // Need to check that global DDNS TTL values make sense
1119
1120 // Get ddns-ttl first. If ddns-ttl is specified none of the others should be.
1121 ConstElementPtr has_ddns_ttl = getConfiguredGlobal("ddns-ttl");
1122
1123 if (getConfiguredGlobal("ddns-ttl-percent")) {
1124 if (has_ddns_ttl) {
1125 isc_throw(BadValue, "cannot specify both ddns-ttl-percent and ddns-ttl");
1126 }
1127 }
1128
1129 ConstElementPtr has_ddns_ttl_min = getConfiguredGlobal("ddns-ttl-min");
1130 if (has_ddns_ttl_min && has_ddns_ttl) {
1131 isc_throw(BadValue, "cannot specify both ddns-ttl-min and ddns-ttl");
1132 }
1133
1134 ConstElementPtr has_ddns_ttl_max = getConfiguredGlobal("ddns-ttl-max");
1135 if (has_ddns_ttl_max) {
1136 if (has_ddns_ttl) {
1137 isc_throw(BadValue, "cannot specify both ddns-ttl-max and ddns-ttl");
1138 }
1139
1140 if (has_ddns_ttl_min) {
1141 // Have min and max, make sure the range is sane.
1142 uint32_t ddns_ttl_min = has_ddns_ttl_min->intValue();
1143 uint32_t ddns_ttl_max = has_ddns_ttl_max->intValue();
1144 if (ddns_ttl_max < ddns_ttl_min) {
1145 isc_throw(BadValue, "ddns-ttl-max: " << ddns_ttl_max
1146 << " must be greater than ddns-ttl-min: " << ddns_ttl_min);
1147 }
1148 }
1149 }
1150}
1151
1152void
1154 const std::string type = "type";
1155
1156 // Parse the access string and create a redacted string for logging.
1157 auto parameters = DatabaseConnection::parse(cfg_db_access_->getLeaseDbAccessString());
1158 std::string redacted = DatabaseConnection::redactedAccessString(parameters);
1159
1160 // Get the database type and open the corresponding database.
1161 DatabaseConnection::ParameterMap::iterator it = parameters.find(type);
1162 if (it == parameters.end()) {
1163 isc_throw(InvalidParameter, "Database configuration parameters do not "
1164 "contain the 'type' keyword" << redacted);
1165 }
1166
1167 std::string db_type = it->second;
1168 bool allowed = (db_type == "mysql" || db_type == "postgresql");
1169 if (CfgMgr::instance().getFamily() == AF_INET) {
1170 for (auto subnet : *(getCfgSubnets4()->getAll()) ) {
1171 if (subnet->getAllocatorType() == "shared-flq") {
1172 if (!allowed) {
1173 isc_throw(BadValue, "shared-flq allocator is only supported by MySQL and PosgreSQL backends");
1174 }
1175
1177 }
1178 }
1179 } else {
1180 for (auto subnet : *(getCfgSubnets6()->getAll()) ) {
1181 if (subnet->getAllocatorType() == "shared-flq") {
1182 if (!allowed) {
1183 isc_throw(BadValue, "shared-flq allocator is only supported by MySQL and PosgreSQL backends");
1184 }
1185
1187 }
1188 }
1189 }
1190}
1191
1192} // namespace dhcp
1193} // namespace isc
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:1235
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:120
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.