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