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