Kea 2.5.5
dhcp_parsers.cc
Go to the documentation of this file.
1// Copyright (C) 2013-2023 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#include <dhcp/iface_mgr.h>
9#include <dhcp/dhcp4.h>
10#include <dhcp/libdhcp++.h>
11#include <dhcpsrv/cfgmgr.h>
12#include <dhcpsrv/cfg_option.h>
13#include <dhcpsrv/dhcpsrv_log.h>
21#include <util/encode/hex.h>
22#include <util/strutil.h>
23
24#include <boost/algorithm/string.hpp>
25#include <boost/foreach.hpp>
26#include <boost/lexical_cast.hpp>
27#include <boost/make_shared.hpp>
28#include <boost/scoped_ptr.hpp>
29
30#include <limits>
31#include <map>
32#include <string>
33#include <vector>
34#include <iomanip>
35
36using namespace std;
37using namespace isc::asiolink;
38using namespace isc::data;
39using namespace isc::util;
40
41namespace isc {
42namespace dhcp {
43
44// ******************** MACSourcesListConfigParser *************************
45
46void
48 uint32_t source = 0;
49 size_t cnt = 0;
50
51 // By default, there's only one source defined: ANY.
52 // If user specified anything, we need to get rid of that default.
53 mac_sources.clear();
54
55 BOOST_FOREACH(ConstElementPtr source_elem, value->listValue()) {
56 std::string source_str = source_elem->stringValue();
57 try {
58 source = CfgMACSource::MACSourceFromText(source_str);
59 mac_sources.add(source);
60 ++cnt;
61 } catch (const InvalidParameter& ex) {
62 isc_throw(DhcpConfigError, "The mac-sources value '" << source_str
63 << "' was specified twice (" << value->getPosition() << ")");
64 } catch (const std::exception& ex) {
65 isc_throw(DhcpConfigError, "Failed to convert '"
66 << source_str << "' to any recognized MAC source:"
67 << ex.what() << " (" << value->getPosition() << ")");
68 }
69 }
70
71 if (!cnt) {
72 isc_throw(DhcpConfigError, "If specified, MAC Sources cannot be empty");
73 }
74}
75
76// ******************** ControlSocketParser *************************
78 if (!value) {
79 // Sanity check: not supposed to fail.
80 isc_throw(DhcpConfigError, "Logic error: specified control-socket is null");
81 }
82
83 if (value->getType() != Element::map) {
84 // Sanity check: not supposed to fail.
85 isc_throw(DhcpConfigError, "Specified control-socket is expected to be a map"
86 ", i.e. a structure defined within { }");
87 }
88 srv_cfg.setControlSocketInfo(value);
89}
90
91// ******************************** OptionDefParser ****************************
92
93OptionDefParser::OptionDefParser(const uint16_t address_family)
94 : address_family_(address_family) {
95}
96
99
100 // Check parameters.
101 if (address_family_ == AF_INET) {
103 } else {
105 }
106
107 // Get mandatory parameters.
108 std::string name = getString(option_def, "name");
109 int64_t code64 = getInteger(option_def, "code");
110 std::string type = getString(option_def, "type");
111
112 // Get optional parameters. Whoever called this parser, should have
113 // called SimpleParser::setDefaults first.
114 bool array_type = getBoolean(option_def, "array");
115 std::string record_types = getString(option_def, "record-types");
116 std::string space = getString(option_def, "space");
117 std::string encapsulates = getString(option_def, "encapsulate");
118 ConstElementPtr user_context = option_def->get("user-context");
119
120 // Check code value.
121 if (code64 < 0) {
122 isc_throw(DhcpConfigError, "option code must not be negative "
123 "(" << getPosition("code", option_def) << ")");
124 } else if (address_family_ == AF_INET &&
125 code64 > std::numeric_limits<uint8_t>::max()) {
126 isc_throw(DhcpConfigError, "invalid option code '" << code64
127 << "', it must not be greater than '"
128 << static_cast<int>(std::numeric_limits<uint8_t>::max())
129 << "' (" << getPosition("code", option_def) << ")");
130 } else if (address_family_ == AF_INET6 &&
131 code64 > std::numeric_limits<uint16_t>::max()) {
132 isc_throw(DhcpConfigError, "invalid option code '" << code64
133 << "', it must not be greater than '"
134 << std::numeric_limits<uint16_t>::max()
135 << "' (" << getPosition("code", option_def) << ")");
136 }
137 uint32_t code = static_cast<uint32_t>(code64);
138
139 // Validate space name.
140 if (!OptionSpace::validateName(space)) {
141 isc_throw(DhcpConfigError, "invalid option space name '"
142 << space << "' ("
143 << getPosition("space", option_def) << ")");
144 }
145
146 // Protect against definition of options 0 (PAD) or 255 (END)
147 // in (and only in) the dhcp4 space.
148 if (space == DHCP4_OPTION_SPACE) {
149 if (code == DHO_PAD) {
150 isc_throw(DhcpConfigError, "invalid option code '0': "
151 << "reserved for PAD ("
152 << getPosition("code", option_def) << ")");
153 } else if (code == DHO_END) {
154 isc_throw(DhcpConfigError, "invalid option code '255': "
155 << "reserved for END ("
156 << getPosition("code", option_def) << ")");
157 }
158 }
159
160 // For dhcp6 space the value 0 is reserved.
161 if (space == DHCP6_OPTION_SPACE) {
162 if (code == 0) {
163 isc_throw(DhcpConfigError, "invalid option code '0': "
164 << "reserved value ("
165 << getPosition("code", option_def) << ")");
166 }
167 }
168
169 // Create option definition.
171 // We need to check if user has set encapsulated option space
172 // name. If so, different constructor will be used.
173 if (!encapsulates.empty()) {
174 // Arrays can't be used together with sub-options.
175 if (array_type) {
176 isc_throw(DhcpConfigError, "option '" << space << "."
177 << name << "', comprising an array of data"
178 << " fields may not encapsulate any option space ("
179 << option_def->getPosition() << ")");
180
181 } else if (encapsulates == space) {
182 isc_throw(DhcpConfigError, "option must not encapsulate"
183 << " an option space it belongs to: '"
184 << space << "." << name << "' is set to"
185 << " encapsulate '" << space << "' ("
186 << option_def->getPosition() << ")");
187
188 } else {
189 def.reset(new OptionDefinition(name, code, space, type,
190 encapsulates.c_str()));
191 }
192
193 } else {
194 def.reset(new OptionDefinition(name, code, space, type, array_type));
195
196 }
197
198 if (user_context) {
199 def->setContext(user_context);
200 }
201
202 // Split the list of record types into tokens.
203 std::vector<std::string> record_tokens =
204 isc::util::str::tokens(record_types, ",");
205 // Iterate over each token and add a record type into
206 // option definition.
207 BOOST_FOREACH(std::string record_type, record_tokens) {
208 try {
209 boost::trim(record_type);
210 if (!record_type.empty()) {
211 def->addRecordField(record_type);
212 }
213 } catch (const Exception& ex) {
214 isc_throw(DhcpConfigError, "invalid record type values"
215 << " specified for the option definition: "
216 << ex.what() << " ("
217 << getPosition("record-types", option_def) << ")");
218 }
219 }
220
221 // Validate the definition.
222 try {
223 def->validate();
224 } catch (const std::exception& ex) {
226 << " (" << option_def->getPosition() << ")");
227 }
228
229 // Option definition has been created successfully.
230 return (def);
231}
232
233// ******************************** OptionDefListParser ************************
234
235OptionDefListParser::OptionDefListParser(const uint16_t address_family)
236 : address_family_(address_family) {
237}
238
239void
241 if (!option_def_list) {
242 // Sanity check: not supposed to fail.
243 isc_throw(DhcpConfigError, "parser error: a pointer to a list of"
244 << " option definitions is NULL ("
245 << option_def_list->getPosition() << ")");
246 }
247
248 OptionDefParser parser(address_family_);
249 BOOST_FOREACH(ConstElementPtr option_def, option_def_list->listValue()) {
250 OptionDefinitionPtr def = parser.parse(option_def);
251 try {
252 storage->add(def);
253 } catch (const std::exception& ex) {
254 // Append position if there is a failure.
255 isc_throw(DhcpConfigError, ex.what() << " ("
256 << option_def->getPosition() << ")");
257 }
258 }
259
260 // All definitions have been prepared. Put them as runtime options into
261 // the libdhcp++.
262 LibDHCP::setRuntimeOptionDefs(storage->getContainer());
263}
264
265//****************************** RelayInfoParser ********************************
267 : family_(family) {
268};
269
270void
272 ConstElementPtr relay_elem) {
273
274 if (relay_elem->getType() != Element::map) {
275 isc_throw(DhcpConfigError, "relay must be a map");
276 }
277
278 ConstElementPtr address = relay_elem->get("ip-address");
279 ConstElementPtr addresses = relay_elem->get("ip-addresses");
280
281 if (address && addresses) {
283 "specify either ip-address or ip-addresses, not both");
284 }
285
286 if (!address && !addresses) {
287 isc_throw(DhcpConfigError, "ip-addresses is required");
288 }
289
290 // Create our resultant RelayInfo structure
291 *relay_info = isc::dhcp::Network::RelayInfo();
292
293 if (address) {
294 addAddress("ip-address", getString(relay_elem, "ip-address"),
295 relay_elem, relay_info);
298 .arg(getPosition("ip-address", relay_elem));
299 return;
300 }
301
302 if (addresses->getType() != Element::list) {
303 isc_throw(DhcpConfigError, "ip-addresses must be a list "
304 "(" << getPosition("ip-addresses", relay_elem) << ")");
305 }
306
307 BOOST_FOREACH(ConstElementPtr address_element, addresses->listValue()) {
308 addAddress("ip-addresses", address_element->stringValue(),
309 relay_elem, relay_info);
310 }
311}
312
313void
314RelayInfoParser::addAddress(const std::string& name,
315 const std::string& address_str,
316 ConstElementPtr relay_elem,
317 const isc::dhcp::Network::RelayInfoPtr& relay_info) {
318 boost::scoped_ptr<isc::asiolink::IOAddress> ip;
319 try {
320 ip.reset(new isc::asiolink::IOAddress(address_str));
321 } catch (const std::exception& ex) {
322 isc_throw(DhcpConfigError, "address " << address_str
323 << " is not a valid: "
324 << (family_ == Option::V4 ? "IPv4" : "IPv6")
325 << "address"
326 << " (" << getPosition(name, relay_elem) << ")");
327 }
328
329 // Check if the address family matches.
330 if ((ip->isV4() && family_ != Option::V4) ||
331 (ip->isV6() && family_ != Option::V6) ) {
332 isc_throw(DhcpConfigError, "address " << address_str
333 << " is not a: "
334 << (family_ == Option::V4 ? "IPv4" : "IPv6")
335 << "address"
336 << " (" << getPosition(name, relay_elem) << ")");
337 }
338
339 try {
340 relay_info->addAddress(*ip);
341 } catch (const std::exception& ex) {
342 isc_throw(DhcpConfigError, "cannot add address: " << address_str
343 << " to relay info: " << ex.what()
344 << " (" << getPosition(name, relay_elem) << ")");
345 }
346}
347
348//****************************** PoolParser ********************************
349
350void
352 ConstElementPtr pool_structure,
353 const uint16_t address_family,
354 bool encapsulate_options) {
355
356 if (address_family == AF_INET) {
358 } else {
360 }
361
362 ConstElementPtr text_pool = pool_structure->get("pool");
363
364 if (!text_pool) {
365 isc_throw(DhcpConfigError, "Mandatory 'pool' entry missing in "
366 "definition: (" << pool_structure->getPosition() << ")");
367 }
368
369 // That should be a single pool representation. It should contain
370 // text is form prefix/len or first - last. Note that spaces
371 // are allowed
372 string txt = text_pool->stringValue();
373
374 // first let's remove any whitespaces
375 boost::erase_all(txt, " "); // space
376 boost::erase_all(txt, "\t"); // tabulation
377
378 PoolPtr pool;
379
380 // Is this prefix/len notation?
381 size_t pos = txt.find("/");
382 if (pos != string::npos) {
383 isc::asiolink::IOAddress addr("::");
384 uint8_t len = 0;
385 try {
386 addr = isc::asiolink::IOAddress(txt.substr(0, pos));
387
388 // start with the first character after /
389 string prefix_len = txt.substr(pos + 1);
390
391 // It is lexical cast to int and then downcast to uint8_t.
392 // Direct cast to uint8_t (which is really an unsigned char)
393 // will result in interpreting the first digit as output
394 // value and throwing exception if length is written on two
395 // digits (because there are extra characters left over).
396
397 // No checks for values over 128. Range correctness will
398 // be checked in Pool4 constructor, here we only check
399 // the representation fits in an uint8_t as this can't
400 // be done by a direct lexical cast as explained...
401 int val_len = boost::lexical_cast<int>(prefix_len);
402 if ((val_len < std::numeric_limits<uint8_t>::min()) ||
403 (val_len > std::numeric_limits<uint8_t>::max())) {
404 // This exception will be handled 4 line later!
406 }
407 len = static_cast<uint8_t>(val_len);
408 } catch (...) {
409 isc_throw(DhcpConfigError, "Failed to parse pool "
410 "definition: " << txt << " ("
411 << text_pool->getPosition() << ")");
412 }
413
414 try {
415 pool = poolMaker(addr, len);
416 pools->push_back(pool);
417 } catch (const std::exception& ex) {
418 isc_throw(DhcpConfigError, "Failed to create pool defined by: "
419 << txt << " (" << text_pool->getPosition() << ")");
420 }
421
422 } else {
423 isc::asiolink::IOAddress min("::");
424 isc::asiolink::IOAddress max("::");
425
426 // Is this min-max notation?
427 pos = txt.find("-");
428 if (pos != string::npos) {
429 // using min-max notation
430 try {
431 min = isc::asiolink::IOAddress(txt.substr(0, pos));
432 max = isc::asiolink::IOAddress(txt.substr(pos + 1));
433 } catch (...) {
434 isc_throw(DhcpConfigError, "Failed to parse pool "
435 "definition: " << txt << " ("
436 << text_pool->getPosition() << ")");
437 }
438
439 try {
440 pool = poolMaker(min, max);
441 pools->push_back(pool);
442 } catch (const std::exception& ex) {
443 isc_throw(DhcpConfigError, "Failed to create pool defined by: "
444 << txt << " (" << text_pool->getPosition() << ")");
445 }
446 }
447 }
448
449 if (!pool) {
450 isc_throw(DhcpConfigError, "invalid pool definition: "
451 << text_pool->stringValue() <<
452 ". There are two acceptable formats <min address-max address>"
453 " or <prefix/len> ("
454 << text_pool->getPosition() << ")");
455 }
456
457 // If there is a pool-id, store it.
458 ConstElementPtr pool_id = pool_structure->get("pool-id");
459 if (pool_id) {
460 if (pool_id->intValue() <= 0) {
461 isc_throw(BadValue, "pool-id " << pool_id->intValue() << " is not"
462 << " a positive integer greater than 0");
463 } else if (pool_id->intValue() > numeric_limits<uint32_t>::max()) {
464 isc_throw(BadValue, "pool-id " << pool_id->intValue() << " is not"
465 << " a 32 bit unsigned integer");
466 }
467
468 pool->setID(pool_id->intValue());
469 }
470
471 // If there's user-context specified, store it.
472 ConstElementPtr user_context = pool_structure->get("user-context");
473 if (user_context) {
474 // The grammar accepts only maps but still check it.
475 if (user_context->getType() != Element::map) {
476 isc_throw(isc::dhcp::DhcpConfigError, "User context has to be a map ("
477 << user_context->getPosition() << ")");
478 }
479 pool->setContext(user_context);
480 }
481
482 // Parser pool specific options.
483 ConstElementPtr option_data = pool_structure->get("option-data");
484 if (option_data) {
485 try {
486 CfgOptionPtr cfg = pool->getCfgOption();
487 auto option_parser = createOptionDataListParser(address_family);
488 option_parser->parse(cfg, option_data, encapsulate_options);
489 } catch (const std::exception& ex) {
491 << " (" << option_data->getPosition() << ")");
492 }
493 }
494
495 // Client-class.
496 ConstElementPtr client_class = pool_structure->get("client-class");
497 if (client_class) {
498 string cclass = client_class->stringValue();
499 if (!cclass.empty()) {
500 pool->allowClientClass(cclass);
501 }
502 }
503
504 // Try setting up required client classes.
505 ConstElementPtr class_list = pool_structure->get("require-client-classes");
506 if (class_list) {
507 const std::vector<data::ElementPtr>& classes = class_list->listValue();
508 for (auto cclass = classes.cbegin();
509 cclass != classes.cend(); ++cclass) {
510 if (((*cclass)->getType() != Element::string) ||
511 (*cclass)->stringValue().empty()) {
512 isc_throw(DhcpConfigError, "invalid class name ("
513 << (*cclass)->getPosition() << ")");
514 }
515 pool->requireClientClass((*cclass)->stringValue());
516 }
517 }
518}
519
520boost::shared_ptr<OptionDataListParser>
521PoolParser::createOptionDataListParser(const uint16_t address_family) const {
522 auto parser = boost::make_shared<OptionDataListParser>(address_family);
523 return (parser);
524}
525
526//****************************** Pool4Parser *************************
527
529Pool4Parser::poolMaker (IOAddress &addr, uint32_t len, int32_t) {
530 return (PoolPtr(new Pool4(addr, len)));
531}
532
535 return (PoolPtr(new Pool4(min, max)));
536}
537
538//****************************** Pools4ListParser *************************
539
540void
542 bool encapsulate_options) {
543 BOOST_FOREACH(ConstElementPtr pool, pools_list->listValue()) {
544 auto parser = createPoolConfigParser();
545 parser->parse(pools, pool, AF_INET, encapsulate_options);
546 }
547}
548
549boost::shared_ptr<PoolParser>
551 auto parser = boost::make_shared<Pool4Parser>();
552 return (parser);
553}
554
555//****************************** SubnetConfigParser *************************
556
557SubnetConfigParser::SubnetConfigParser(uint16_t family, bool check_iface)
558 : pools_(new PoolStorage()),
559 address_family_(family),
560 check_iface_(check_iface) {
562}
563
565SubnetConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
566
567 ConstElementPtr relay_params = subnet->get("relay");
568 if (relay_params) {
570 RelayInfoParser parser(u);
571 parser.parse(relay_info_, relay_params);
572 }
573
574 // Create a subnet.
575 try {
576 createSubnet(subnet);
577 } catch (const std::exception& ex) {
579 "subnet configuration failed: " << ex.what());
580 }
581
582 // We create subnet first and then parse the options straight into the subnet's
583 // CfgOption structure. Previously, we first parsed the options and then copied
584 // them into the CfgOption after creating the subnet but it had two issues. First,
585 // it cost performance. Second, copying options reset the isEncapsulated() flag.
586 // If the options have been encapsulated we want to preserve the flag to ensure
587 // they are not encapsulated several times.
588 ConstElementPtr options_params = subnet->get("option-data");
589 if (options_params) {
590 auto opt_parser = createOptionDataListParser();
591 opt_parser->parse(subnet_->getCfgOption(), options_params, encapsulate_options);
592 }
593
594 return (subnet_);
595}
596
597void
599 std::string subnet_txt;
600 try {
601 subnet_txt = getString(params, "subnet");
602 } catch (const DhcpConfigError &) {
603 // rethrow with precise error
605 "mandatory 'subnet' parameter is missing for a subnet being"
606 " configured (" << params->getPosition() << ")");
607 }
608
609 // Remove any spaces or tabs.
610 boost::erase_all(subnet_txt, " ");
611 boost::erase_all(subnet_txt, "\t");
612
613 // The subnet format is prefix/len. We are going to extract
614 // the prefix portion of a subnet string to create IOAddress
615 // object from it. IOAddress will be passed to the Subnet's
616 // constructor later on. In order to extract the prefix we
617 // need to get all characters preceding "/".
618 size_t pos = subnet_txt.find("/");
619 if (pos == string::npos) {
620 ConstElementPtr elem = params->get("subnet");
622 "Invalid subnet syntax (prefix/len expected):" << subnet_txt
623 << " (" << elem->getPosition() << ")");
624 }
625
626 // Try to create the address object. It also validates that
627 // the address syntax is ok.
628 isc::asiolink::IOAddress addr(subnet_txt.substr(0, pos));
629
630 // Now parse out the prefix length.
631 unsigned int len;
632 try {
633 len = boost::lexical_cast<unsigned int>(subnet_txt.substr(pos + 1));
634 } catch (const boost::bad_lexical_cast&) {
635 ConstElementPtr elem = params->get("subnet");
636 isc_throw(DhcpConfigError, "prefix length: '" <<
637 subnet_txt.substr(pos+1) << "' is not an integer ("
638 << elem->getPosition() << ")");
639 }
640
641 // Sanity check the prefix length
642 if ((addr.isV6() && len > 128) ||
643 (addr.isV4() && len > 32)) {
644 ConstElementPtr elem = params->get("subnet");
646 "Invalid prefix length specified for subnet: " << len
647 << " (" << elem->getPosition() << ")");
648 }
649
650 // Call the subclass's method to instantiate the subnet
651 initSubnet(params, addr, len);
652
653 // Add pools to it.
654 for (const auto& pool : *pools_) {
655 try {
656 subnet_->addPool(pool);
657 } catch (const BadValue& ex) {
658 // addPool() can throw BadValue if the pool is overlapping or
659 // is out of bounds for the subnet.
661 ex.what() << " (" << params->getPosition() << ")");
662 }
663 }
664 // If there's user-context specified, store it.
665 ConstElementPtr user_context = params->get("user-context");
666 if (user_context) {
667 // The grammar accepts only maps but still check it.
668 if (user_context->getType() != Element::map) {
669 isc_throw(isc::dhcp::DhcpConfigError, "User context has to be a map ("
670 << user_context->getPosition() << ")");
671 }
672 subnet_->setContext(user_context);
673 }
674
675 // In order to take advantage of the dynamic inheritance of global
676 // parameters to a subnet we need to set a callback function for each
677 // subnet to allow for fetching global parameters.
678 subnet_->setFetchGlobalsFn([]() -> ConstCfgGlobalsPtr {
679 return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
680 });
681}
682
683boost::shared_ptr<OptionDataListParser>
685 auto parser = boost::make_shared<OptionDataListParser>(address_family_);
686 return (parser);
687}
688
689//****************************** Subnet4ConfigParser *************************
690
692 : SubnetConfigParser(AF_INET, check_iface) {
693}
694
696Subnet4ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
697 // Check parameters.
699
701 ConstElementPtr pools = subnet->get("pools");
702 if (pools) {
703 auto parser = createPoolsListParser();
704 parser->parse(pools_, pools, encapsulate_options);
705 }
706
707 SubnetPtr generic = SubnetConfigParser::parse(subnet, encapsulate_options);
708
709 if (!generic) {
710 // Sanity check: not supposed to fail.
712 "Failed to create an IPv4 subnet (" <<
713 subnet->getPosition() << ")");
714 }
715
716 Subnet4Ptr sn4ptr = boost::dynamic_pointer_cast<Subnet4>(subnet_);
717 if (!sn4ptr) {
718 // If we hit this, it is a programming error.
720 "Invalid Subnet4 cast in Subnet4ConfigParser::parse");
721 }
722
723 // Set relay information if it was parsed
724 if (relay_info_) {
725 sn4ptr->setRelayInfo(*relay_info_);
726 }
727
728 // Parse Host Reservations for this subnet if any.
729 ConstElementPtr reservations = subnet->get("reservations");
730 if (reservations) {
731 HostCollection hosts;
733 parser.parse(subnet_->getID(), reservations, hosts);
734 for (auto h = hosts.begin(); h != hosts.end(); ++h) {
735 validateResv(sn4ptr, *h);
736 CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
737 }
738 }
739
740 // Parse allocator specification.
741 auto network4 = boost::dynamic_pointer_cast<Network>(sn4ptr);
742 parseAllocatorParams(subnet, network4);
743
744 // Instantiate the allocator.
745 sn4ptr->createAllocators();
746
747 return (sn4ptr);
748}
749
750void
752 asiolink::IOAddress addr, uint8_t len) {
753 // Subnet ID is optional. If it is not supplied the value of 0 is used,
754 // which means autogenerate. The value was inserted earlier by calling
755 // SimpleParser4::setAllDefaults.
756 int64_t subnet_id_max = static_cast<int64_t>(SUBNET_ID_MAX);
757 SubnetID subnet_id = static_cast<SubnetID>(getInteger(params, "id", 0,
758 subnet_id_max));
759
760 auto subnet4 = Subnet4::create(addr, len, Triplet<uint32_t>(),
762 subnet_id);
763 subnet_ = subnet4;
764
765 // Move from reservation mode to new reservations flags.
766 ElementPtr mutable_params;
767 mutable_params = boost::const_pointer_cast<Element>(params);
768 // @todo add warning
770
771 // Parse parameters common to all Network derivations.
772 NetworkPtr network = boost::dynamic_pointer_cast<Network>(subnet4);
773 parseCommon(mutable_params, network);
774
775 std::ostringstream output;
776 output << addr << "/" << static_cast<int>(len) << " with params: ";
777
778 bool has_renew = !subnet4->getT1().unspecified();
779 bool has_rebind = !subnet4->getT2().unspecified();
780 int64_t renew = -1;
781 int64_t rebind = -1;
782
783 // t1 and t2 are optional may be not specified.
784 if (has_renew) {
785 renew = subnet4->getT1().get();
786 output << "t1=" << renew << ", ";
787 }
788 if (has_rebind) {
789 rebind = subnet4->getT2().get();
790 output << "t2=" << rebind << ", ";
791 }
792
793 if (!subnet4->getValid().unspecified()) {
794 output << "valid-lifetime=" << subnet4->getValid().get();
795 }
796
798
799 // Set the match-client-id value for the subnet.
800 if (params->contains("match-client-id")) {
801 bool match_client_id = getBoolean(params, "match-client-id");
802 subnet4->setMatchClientId(match_client_id);
803 }
804
805 // Set the authoritative value for the subnet.
806 if (params->contains("authoritative")) {
807 bool authoritative = getBoolean(params, "authoritative");
808 subnet4->setAuthoritative(authoritative);
809 }
810
811 // Set next-server. The default value is 0.0.0.0. Nevertheless, the
812 // user could have messed that up by specifying incorrect value.
813 // To avoid using 0.0.0.0, user can specify "".
814 if (params->contains("next-server")) {
815 string next_server;
816 try {
817 next_server = getString(params, "next-server");
818 if (!next_server.empty()) {
819 subnet4->setSiaddr(IOAddress(next_server));
820 }
821 } catch (...) {
822 ConstElementPtr next = params->get("next-server");
823 string pos;
824 if (next) {
825 pos = next->getPosition().str();
826 } else {
827 pos = params->getPosition().str();
828 }
829 isc_throw(DhcpConfigError, "invalid parameter next-server : "
830 << next_server << "(" << pos << ")");
831 }
832 }
833
834 // Set server-hostname.
835 if (params->contains("server-hostname")) {
836 std::string sname = getString(params, "server-hostname");
837 if (!sname.empty()) {
838 if (sname.length() >= Pkt4::MAX_SNAME_LEN) {
839 ConstElementPtr error = params->get("server-hostname");
840 isc_throw(DhcpConfigError, "server-hostname must be at most "
841 << Pkt4::MAX_SNAME_LEN - 1 << " bytes long, it is "
842 << sname.length() << " ("
843 << error->getPosition() << ")");
844 }
845 subnet4->setSname(sname);
846 }
847 }
848
849 // Set boot-file-name.
850 if (params->contains("boot-file-name")) {
851 std::string filename =getString(params, "boot-file-name");
852 if (!filename.empty()) {
853 if (filename.length() > Pkt4::MAX_FILE_LEN) {
854 ConstElementPtr error = params->get("boot-file-name");
855 isc_throw(DhcpConfigError, "boot-file-name must be at most "
856 << Pkt4::MAX_FILE_LEN - 1 << " bytes long, it is "
857 << filename.length() << " ("
858 << error->getPosition() << ")");
859 }
860 subnet4->setFilename(filename);
861 }
862 }
863
864 // Get interface name. If it is defined, then the subnet is available
865 // directly over specified network interface.
866 if (params->contains("interface")) {
867 std::string iface = getString(params, "interface");
868 if (!iface.empty()) {
869 if (check_iface_ && !IfaceMgr::instance().getIface(iface)) {
870 ConstElementPtr error = params->get("interface");
871 isc_throw(DhcpConfigError, "Specified network interface name " << iface
872 << " for subnet " << subnet4->toText()
873 << " is not present in the system ("
874 << error->getPosition() << ")");
875 }
876
877 subnet4->setIface(iface);
878 }
879 }
880
881 // Try setting up client class.
882 if (params->contains("client-class")) {
883 string client_class = getString(params, "client-class");
884 if (!client_class.empty()) {
885 subnet4->allowClientClass(client_class);
886 }
887 }
888
889 // Try setting up required client classes.
890 ConstElementPtr class_list = params->get("require-client-classes");
891 if (class_list) {
892 const std::vector<data::ElementPtr>& classes = class_list->listValue();
893 for (auto cclass = classes.cbegin();
894 cclass != classes.cend(); ++cclass) {
895 if (((*cclass)->getType() != Element::string) ||
896 (*cclass)->stringValue().empty()) {
897 isc_throw(DhcpConfigError, "invalid class name ("
898 << (*cclass)->getPosition() << ")");
899 }
900 subnet4->requireClientClass((*cclass)->stringValue());
901 }
902 }
903
904 // 4o6 specific parameter: 4o6-interface.
905 if (params->contains("4o6-interface")) {
906 string iface4o6 = getString(params, "4o6-interface");
907 if (!iface4o6.empty()) {
908 subnet4->get4o6().setIface4o6(iface4o6);
909 subnet4->get4o6().enabled(true);
910 }
911 }
912
913 // 4o6 specific parameter: 4o6-subnet.
914 if (params->contains("4o6-subnet")) {
915 string subnet4o6 = getString(params, "4o6-subnet");
916 if (!subnet4o6.empty()) {
917 size_t slash = subnet4o6.find("/");
918 if (slash == std::string::npos) {
919 isc_throw(DhcpConfigError, "Missing / in the 4o6-subnet parameter:"
920 << subnet4o6 << ", expected format: prefix6/length");
921 }
922 string prefix = subnet4o6.substr(0, slash);
923 string lenstr = subnet4o6.substr(slash + 1);
924
925 uint8_t len = 128;
926 try {
927 len = boost::lexical_cast<unsigned int>(lenstr.c_str());
928 } catch (const boost::bad_lexical_cast &) {
929 isc_throw(DhcpConfigError, "Invalid prefix length specified in "
930 "4o6-subnet parameter: " << subnet4o6 << ", expected 0..128 value");
931 }
932 subnet4->get4o6().setSubnet4o6(IOAddress(prefix), len);
933 subnet4->get4o6().enabled(true);
934 }
935 }
936
937 // Try 4o6 specific parameter: 4o6-interface-id
938 if (params->contains("4o6-interface-id")) {
939 std::string ifaceid = getString(params, "4o6-interface-id");
940 if (!ifaceid.empty()) {
941 OptionBuffer tmp(ifaceid.begin(), ifaceid.end());
943 subnet4->get4o6().setInterfaceId(opt);
944 subnet4->get4o6().enabled(true);
945 }
946 }
947
950
951 // Here globally defined options were merged to the subnet specific
952 // options but this is no longer the case (they have a different
953 // and not consecutive priority).
954
955 // Parse t1-percent and t2-percent
956 parseTeePercents(params, network);
957
958 // Parse DDNS parameters
959 parseDdnsParams(params, network);
960
961 // Parse lease cache parameters
962 parseCacheParams(params, network);
963
964 // Set the offer_lft value for the subnet.
965 if (params->contains("offer-lifetime")) {
966 uint32_t offer_lft = getInteger(params, "offer-lifetime");
967 subnet4->setOfferLft(offer_lft);
968 }
969
970 // Parse offer-lifetime parameter.
971 Network4Ptr network4 = boost::dynamic_pointer_cast<Network4>(subnet4);
972 parseOfferLft(params, network4);
973
974}
975
976void
978 const IOAddress& address = host->getIPv4Reservation();
979 if (!address.isV4Zero() && !subnet->inRange(address)) {
980 isc_throw(DhcpConfigError, "specified reservation '" << address
981 << "' is not within the IPv4 subnet '"
982 << subnet->toText() << "'");
983 }
984}
985
986boost::shared_ptr<PoolsListParser>
988 auto parser = boost::make_shared<Pools4ListParser>();
989 return (parser);
990}
991
992//**************************** Subnets4ListConfigParser **********************
993
995 : check_iface_(check_iface) {
996}
997
998size_t
1000 ConstElementPtr subnets_list,
1001 bool encapsulate_options) {
1002 size_t cnt = 0;
1003 BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
1004
1005 auto parser = createSubnetConfigParser();
1006 Subnet4Ptr subnet = parser->parse(subnet_json, encapsulate_options);
1007 if (subnet) {
1008
1009 // Adding a subnet to the Configuration Manager may fail if the
1010 // subnet id is invalid (duplicate). Thus, we catch exceptions
1011 // here to append a position in the configuration string.
1012 try {
1013 cfg->getCfgSubnets4()->add(subnet);
1014 cnt++;
1015 } catch (const std::exception& ex) {
1016 isc_throw(DhcpConfigError, ex.what() << " ("
1017 << subnet_json->getPosition() << ")");
1018 }
1019 }
1020 }
1021 return (cnt);
1022}
1023
1024size_t
1026 data::ConstElementPtr subnets_list,
1027 bool encapsulate_options) {
1028 size_t cnt = 0;
1029 BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
1030
1031 auto parser = createSubnetConfigParser();
1032 Subnet4Ptr subnet = parser->parse(subnet_json, encapsulate_options);
1033 if (subnet) {
1034 try {
1035 auto ret = subnets.insert(subnet);
1036 if (!ret.second) {
1038 "can't store subnet because of conflict");
1039 }
1040 ++cnt;
1041 } catch (const std::exception& ex) {
1042 isc_throw(DhcpConfigError, ex.what() << " ("
1043 << subnet_json->getPosition() << ")");
1044 }
1045 }
1046 }
1047 return (cnt);
1048}
1049
1050boost::shared_ptr<Subnet4ConfigParser>
1052 auto parser = boost::make_shared<Subnet4ConfigParser>(check_iface_);
1053 return (parser);
1054}
1055
1056//**************************** Pool6Parser *********************************
1057
1058PoolPtr
1059Pool6Parser::poolMaker(IOAddress &addr, uint32_t len, int32_t ptype)
1060{
1061 return (PoolPtr(new Pool6(static_cast<isc::dhcp::Lease::Type>
1062 (ptype), addr, len)));
1063}
1064
1065PoolPtr
1067{
1068 return (PoolPtr(new Pool6(static_cast<isc::dhcp::Lease::Type>
1069 (ptype), min, max)));
1070}
1071
1072
1073//**************************** Pool6ListParser ***************************
1074
1075void
1077 bool encapsulate_options) {
1078 BOOST_FOREACH(ConstElementPtr pool, pools_list->listValue()) {
1079 auto parser = createPoolConfigParser();
1080 parser->parse(pools, pool, AF_INET6, encapsulate_options);
1081 }
1082}
1083
1084boost::shared_ptr<PoolParser>
1086 auto parser = boost::make_shared<Pool6Parser>();
1087 return (parser);
1088}
1089
1090//**************************** PdPoolParser ******************************
1091
1093}
1094
1095void
1097 bool encapsulate_options) {
1099
1100 std::string addr_str = getString(pd_pool_, "prefix");
1101
1102 uint8_t prefix_len = getUint8(pd_pool_, "prefix-len");
1103
1104 uint8_t delegated_len = getUint8(pd_pool_, "delegated-len");
1105
1106 std::string excluded_prefix_str = "::";
1107 if (pd_pool_->contains("excluded-prefix")) {
1108 excluded_prefix_str = getString(pd_pool_, "excluded-prefix");
1109 }
1110
1111 uint8_t excluded_prefix_len = 0;
1112 if (pd_pool_->contains("excluded-prefix-len")) {
1113 excluded_prefix_len = getUint8(pd_pool_, "excluded-prefix-len");
1114 }
1115
1116 ConstElementPtr user_context = pd_pool_->get("user-context");
1117 if (user_context) {
1118 user_context_ = user_context;
1119 }
1120
1121 ConstElementPtr client_class = pd_pool_->get("client-class");
1122 if (client_class) {
1123 client_class_ = client_class;
1124 }
1125
1126 ConstElementPtr class_list = pd_pool_->get("require-client-classes");
1127
1128 // Check the pool parameters. It will throw an exception if any
1129 // of the required parameters are invalid.
1130 try {
1131 // Attempt to construct the local pool.
1132 pool_.reset(new Pool6(IOAddress(addr_str),
1133 prefix_len,
1134 delegated_len,
1135 IOAddress(excluded_prefix_str),
1136 excluded_prefix_len));
1137 } catch (const std::exception& ex) {
1138 // Some parameters don't exist or are invalid. Since we are not
1139 // aware whether they don't exist or are invalid, let's append
1140 // the position of the pool map element.
1142 << " (" << pd_pool_->getPosition() << ")");
1143 }
1144
1145 // We create subnet first and then parse the options straight into the subnet's
1146 // CfgOption structure. Previously, we first parsed the options and then copied
1147 // them into the CfgOption after creating the subnet but it had two issues. First,
1148 // it cost performance. Second, copying options reset the isEncapsulated() flag.
1149 // If the options have been encapsulated we want to preserve the flag to ensure
1150 // they are not encapsulated several times.
1151 ConstElementPtr option_data = pd_pool_->get("option-data");
1152 if (option_data) {
1153 auto opts_parser = createOptionDataListParser();
1154 opts_parser->parse(pool_->getCfgOption(), option_data, encapsulate_options);
1155 }
1156
1157 if (user_context_) {
1158 pool_->setContext(user_context_);
1159 }
1160
1161 if (client_class_) {
1162 string cclass = client_class_->stringValue();
1163 if (!cclass.empty()) {
1164 pool_->allowClientClass(cclass);
1165 }
1166 }
1167
1168 if (class_list) {
1169 const std::vector<data::ElementPtr>& classes = class_list->listValue();
1170 for (auto cclass = classes.cbegin();
1171 cclass != classes.cend(); ++cclass) {
1172 if (((*cclass)->getType() != Element::string) ||
1173 (*cclass)->stringValue().empty()) {
1174 isc_throw(DhcpConfigError, "invalid class name ("
1175 << (*cclass)->getPosition() << ")");
1176 }
1177 pool_->requireClientClass((*cclass)->stringValue());
1178 }
1179 }
1180
1181 // Add the local pool to the external storage ptr.
1182 pools->push_back(pool_);
1183}
1184
1185boost::shared_ptr<OptionDataListParser>
1187 auto parser = boost::make_shared<OptionDataListParser>(AF_INET6);
1188 return (parser);
1189}
1190
1191//**************************** PdPoolsListParser ************************
1192
1193void
1195 // Loop through the list of pd pools.
1196 BOOST_FOREACH(ConstElementPtr pd_pool, pd_pool_list->listValue()) {
1197 auto parser = createPdPoolConfigParser();
1198 parser->parse(pools, pd_pool);
1199 }
1200}
1201
1202boost::shared_ptr<PdPoolParser>
1204 auto parser = boost::make_shared<PdPoolParser>();
1205 return (parser);
1206}
1207
1208//**************************** Subnet6ConfigParser ***********************
1209
1211 : SubnetConfigParser(AF_INET6, check_iface) {
1212}
1213
1215Subnet6ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
1216 // Check parameters.
1218
1220 ConstElementPtr pools = subnet->get("pools");
1221 if (pools) {
1222 auto parser = createPoolsListParser();
1223 parser->parse(pools_, pools, encapsulate_options);
1224 }
1225 ConstElementPtr pd_pools = subnet->get("pd-pools");
1226 if (pd_pools) {
1227 auto parser = createPdPoolsListParser();
1228 parser->parse(pools_, pd_pools);
1229 }
1230
1231 SubnetPtr generic = SubnetConfigParser::parse(subnet, encapsulate_options);
1232
1233 if (!generic) {
1234 // Sanity check: not supposed to fail.
1236 "Failed to create an IPv6 subnet (" <<
1237 subnet->getPosition() << ")");
1238 }
1239
1240 Subnet6Ptr sn6ptr = boost::dynamic_pointer_cast<Subnet6>(subnet_);
1241 if (!sn6ptr) {
1242 // If we hit this, it is a programming error.
1244 "Invalid Subnet6 cast in Subnet6ConfigParser::parse");
1245 }
1246
1247 // Set relay information if it was provided
1248 if (relay_info_) {
1249 sn6ptr->setRelayInfo(*relay_info_);
1250 }
1251
1252 // Parse Host Reservations for this subnet if any.
1253 ConstElementPtr reservations = subnet->get("reservations");
1254 if (reservations) {
1255 HostCollection hosts;
1257 parser.parse(subnet_->getID(), reservations, hosts);
1258 for (auto h = hosts.begin(); h != hosts.end(); ++h) {
1259 validateResvs(sn6ptr, *h);
1260 CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
1261 }
1262 }
1263
1264 // Parse allocator specification.
1265 auto network = boost::dynamic_pointer_cast<Network>(sn6ptr);
1266 parseAllocatorParams(subnet, network);
1267
1268 // Parse pd-allocator specification.
1269 auto network6 = boost::dynamic_pointer_cast<Network6>(sn6ptr);
1270 parsePdAllocatorParams(subnet, network6);
1271
1272 // Instantiate the allocators.
1273 sn6ptr->createAllocators();
1274
1275 return (sn6ptr);
1276}
1277
1278// Unused?
1279void
1281 asiolink::IOAddress& addr) {
1283 .arg(code).arg(addr.toText());
1284}
1285
1286void
1288 asiolink::IOAddress addr, uint8_t len) {
1289 // Subnet ID is optional. If it is not supplied the value of 0 is used,
1290 // which means autogenerate. The value was inserted earlier by calling
1291 // SimpleParser6::setAllDefaults.
1292 int64_t subnet_id_max = static_cast<int64_t>(SUBNET_ID_MAX);
1293 SubnetID subnet_id = static_cast<SubnetID>(getInteger(params, "id", 0,
1294 subnet_id_max));
1295
1296 // We want to log whether rapid-commit is enabled, so we get this
1297 // before the actual subnet creation.
1298 Optional<bool> rapid_commit;
1299 if (params->contains("rapid-commit")) {
1300 rapid_commit = getBoolean(params, "rapid-commit");
1301 }
1302
1303 // Parse preferred lifetime as it is not parsed by the common function.
1304 Triplet<uint32_t> pref = parseIntTriplet(params, "preferred-lifetime");
1305
1306 // Create a new subnet.
1307 auto subnet6 = Subnet6::create(addr, len, Triplet<uint32_t>(),
1309 pref,
1311 subnet_id);
1312 subnet_ = subnet6;
1313
1314 // Move from reservation mode to new reservations flags.
1315 ElementPtr mutable_params;
1316 mutable_params = boost::const_pointer_cast<Element>(params);
1317 // @todo add warning
1319
1320 // Parse parameters common to all Network derivations.
1321 NetworkPtr network = boost::dynamic_pointer_cast<Network>(subnet_);
1322 parseCommon(mutable_params, network);
1323
1324 // Enable or disable Rapid Commit option support for the subnet.
1325 if (!rapid_commit.unspecified()) {
1326 subnet6->setRapidCommit(rapid_commit);
1327 }
1328
1329 std::ostringstream output;
1330 output << addr << "/" << static_cast<int>(len) << " with params: ";
1331 // t1 and t2 are optional may be not specified.
1332
1333 bool has_renew = !subnet6->getT1().unspecified();
1334 bool has_rebind = !subnet6->getT2().unspecified();
1335 int64_t renew = -1;
1336 int64_t rebind = -1;
1337
1338 if (has_renew) {
1339 renew = subnet6->getT1().get();
1340 output << "t1=" << renew << ", ";
1341 }
1342 if (has_rebind) {
1343 rebind = subnet6->getT2().get();
1344 output << "t2=" << rebind << ", ";
1345 }
1346
1347 if (!subnet6->getPreferred().unspecified()) {
1348 output << "preferred-lifetime=" << subnet6->getPreferred().get() << ", ";
1349 }
1350 if (!subnet6->getValid().unspecified()) {
1351 output << "valid-lifetime=" << subnet6->getValid().get();
1352 }
1353 if (!subnet6->getRapidCommit().unspecified()) {
1354 output << ", rapid-commit is "
1355 << boolalpha << subnet6->getRapidCommit().get();
1356 }
1357
1359
1360 // Get interface-id option content. For now we support string
1361 // representation only
1362 Optional<std::string> ifaceid;
1363 if (params->contains("interface-id")) {
1364 ifaceid = getString(params, "interface-id");
1365 }
1366
1368 if (params->contains("interface")) {
1369 iface = getString(params, "interface");
1370 }
1371
1372 // Specifying both interface for locally reachable subnets and
1373 // interface id for relays is mutually exclusive. Need to test for
1374 // this condition.
1375 if (!ifaceid.unspecified() && !iface.unspecified() && !ifaceid.empty() &&
1376 !iface.empty()) {
1378 "parser error: interface (defined for locally reachable "
1379 "subnets) and interface-id (defined for subnets reachable"
1380 " via relays) cannot be defined at the same time for "
1381 "subnet " << addr << "/" << (int)len << "("
1382 << params->getPosition() << ")");
1383 }
1384
1385 // Configure interface-id for remote interfaces, if defined
1386 if (!ifaceid.unspecified() && !ifaceid.empty()) {
1387 std::string ifaceid_value = ifaceid.get();
1388 OptionBuffer tmp(ifaceid_value.begin(), ifaceid_value.end());
1390 subnet6->setInterfaceId(opt);
1391 }
1392
1393 // Get interface name. If it is defined, then the subnet is available
1394 // directly over specified network interface.
1395 if (!iface.unspecified() && !iface.empty()) {
1396 if (check_iface_ && !IfaceMgr::instance().getIface(iface)) {
1397 ConstElementPtr error = params->get("interface");
1398 isc_throw(DhcpConfigError, "Specified network interface name " << iface
1399 << " for subnet " << subnet6->toText()
1400 << " is not present in the system ("
1401 << error->getPosition() << ")");
1402 }
1403
1404 subnet6->setIface(iface);
1405 }
1406
1407 // Try setting up client class.
1408 if (params->contains("client-class")) {
1409 string client_class = getString(params, "client-class");
1410 if (!client_class.empty()) {
1411 subnet6->allowClientClass(client_class);
1412 }
1413 }
1414
1415 if (params->contains("require-client-classes")) {
1416 // Try setting up required client classes.
1417 ConstElementPtr class_list = params->get("require-client-classes");
1418 if (class_list) {
1419 const std::vector<data::ElementPtr>& classes = class_list->listValue();
1420 for (auto cclass = classes.cbegin();
1421 cclass != classes.cend(); ++cclass) {
1422 if (((*cclass)->getType() != Element::string) ||
1423 (*cclass)->stringValue().empty()) {
1424 isc_throw(DhcpConfigError, "invalid class name ("
1425 << (*cclass)->getPosition() << ")");
1426 }
1427 subnet6->requireClientClass((*cclass)->stringValue());
1428 }
1429 }
1430 }
1431
1434
1435 // Parse t1-percent and t2-percent
1436 parseTeePercents(params, network);
1437
1438 // Parse DDNS parameters
1439 parseDdnsParams(params, network);
1440
1441 // Parse lease cache parameters
1442 parseCacheParams(params, network);
1443}
1444
1445void
1447 IPv6ResrvRange range = host->getIPv6Reservations(IPv6Resrv::TYPE_NA);
1448 for (auto it = range.first; it != range.second; ++it) {
1449 const IOAddress& address = it->second.getPrefix();
1450 if (!subnet->inRange(address)) {
1451 isc_throw(DhcpConfigError, "specified reservation '" << address
1452 << "' is not within the IPv6 subnet '"
1453 << subnet->toText() << "'");
1454 }
1455 }
1456}
1457
1458boost::shared_ptr<PoolsListParser>
1460 auto parser = boost::make_shared<Pools6ListParser>();
1461 return (parser);
1462}
1463
1464boost::shared_ptr<PdPoolsListParser>
1466 auto parser = boost::make_shared<PdPoolsListParser>();
1467 return (parser);
1468}
1469
1470//**************************** Subnet6ListConfigParser ********************
1471
1473 : check_iface_(check_iface) {
1474}
1475
1476size_t
1478 ConstElementPtr subnets_list,
1479 bool encapsulate_options) {
1480 size_t cnt = 0;
1481 BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
1482
1483 auto parser = createSubnetConfigParser();
1484 Subnet6Ptr subnet = parser->parse(subnet_json, encapsulate_options);
1485
1486 // Adding a subnet to the Configuration Manager may fail if the
1487 // subnet id is invalid (duplicate). Thus, we catch exceptions
1488 // here to append a position in the configuration string.
1489 try {
1490 cfg->getCfgSubnets6()->add(subnet);
1491 cnt++;
1492 } catch (const std::exception& ex) {
1493 isc_throw(DhcpConfigError, ex.what() << " ("
1494 << subnet_json->getPosition() << ")");
1495 }
1496 }
1497 return (cnt);
1498}
1499
1500size_t
1502 ConstElementPtr subnets_list,
1503 bool encapsulate_options) {
1504 size_t cnt = 0;
1505 BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
1506
1507 auto parser = createSubnetConfigParser();
1508 Subnet6Ptr subnet = parser->parse(subnet_json, encapsulate_options);
1509 if (subnet) {
1510 try {
1511 auto ret = subnets.insert(subnet);
1512 if (!ret.second) {
1514 "can't store subnet because of conflict");
1515 }
1516 ++cnt;
1517 } catch (const std::exception& ex) {
1518 isc_throw(DhcpConfigError, ex.what() << " ("
1519 << subnet_json->getPosition() << ")");
1520 }
1521 }
1522 }
1523 return (cnt);
1524}
1525
1526boost::shared_ptr<Subnet6ConfigParser>
1528 auto parser = boost::make_shared<Subnet6ConfigParser>(check_iface_);
1529 return (parser);
1530}
1531
1532//**************************** D2ClientConfigParser **********************
1533
1535D2ClientConfigParser::getProtocol(ConstElementPtr scope,
1536 const std::string& name) {
1539 (scope, name, "NameChangeRequest protocol"));
1540}
1541
1543D2ClientConfigParser::getFormat(ConstElementPtr scope,
1544 const std::string& name) {
1547 (scope, name, "NameChangeRequest format"));
1548}
1549
1551D2ClientConfigParser::getMode(ConstElementPtr scope,
1552 const std::string& name) {
1555 (scope, name, "ReplaceClientName mode"));
1556}
1557
1560 D2ClientConfigPtr new_config;
1561
1562 // Get all parameters that are needed to create the D2ClientConfig.
1563 bool enable_updates = getBoolean(client_config, "enable-updates");
1564
1565 IOAddress server_ip = getAddress(client_config, "server-ip");
1566
1567 uint32_t server_port = getUint32(client_config, "server-port");
1568
1569 std::string sender_ip_str = getString(client_config, "sender-ip");
1570
1571 uint32_t sender_port = getUint32(client_config, "sender-port");
1572
1573 uint32_t max_queue_size = getUint32(client_config, "max-queue-size");
1574
1575 dhcp_ddns::NameChangeProtocol ncr_protocol =
1576 getProtocol(client_config, "ncr-protocol");
1577
1578 dhcp_ddns::NameChangeFormat ncr_format =
1579 getFormat(client_config, "ncr-format");
1580
1581 IOAddress sender_ip(0);
1582 if (sender_ip_str.empty()) {
1583 // The default sender IP depends on the server IP family
1584 sender_ip = (server_ip.isV4() ? IOAddress::IPV4_ZERO_ADDRESS() :
1586 } else {
1587 try {
1588 sender_ip = IOAddress(sender_ip_str);
1589 } catch (const std::exception& ex) {
1590 isc_throw(DhcpConfigError, "invalid address (" << sender_ip_str
1591 << ") specified for parameter 'sender-ip' ("
1592 << getPosition("sender-ip", client_config) << ")");
1593 }
1594 }
1595
1596 // Now we check for logical errors. This repeats what is done in
1597 // D2ClientConfig::validate(), but doing it here permits us to
1598 // emit meaningful parameter position info in the error.
1599 if (ncr_format != dhcp_ddns::FMT_JSON) {
1600 isc_throw(D2ClientError, "D2ClientConfig error: NCR Format: "
1601 << dhcp_ddns::ncrFormatToString(ncr_format)
1602 << " is not supported. ("
1603 << getPosition("ncr-format", client_config) << ")");
1604 }
1605
1606 if (ncr_protocol != dhcp_ddns::NCR_UDP) {
1607 isc_throw(D2ClientError, "D2ClientConfig error: NCR Protocol: "
1608 << dhcp_ddns::ncrProtocolToString(ncr_protocol)
1609 << " is not supported. ("
1610 << getPosition("ncr-protocol", client_config) << ")");
1611 }
1612
1613 if (sender_ip.getFamily() != server_ip.getFamily()) {
1615 "D2ClientConfig error: address family mismatch: "
1616 << "server-ip: " << server_ip.toText()
1617 << " is: " << (server_ip.isV4() ? "IPv4" : "IPv6")
1618 << " while sender-ip: " << sender_ip.toText()
1619 << " is: " << (sender_ip.isV4() ? "IPv4" : "IPv6")
1620 << " (" << getPosition("sender-ip", client_config) << ")");
1621 }
1622
1623 if (server_ip == sender_ip && server_port == sender_port) {
1625 "D2ClientConfig error: server and sender cannot"
1626 " share the exact same IP address/port: "
1627 << server_ip.toText() << "/" << server_port
1628 << " (" << getPosition("sender-ip", client_config) << ")");
1629 }
1630
1631 try {
1632 // Attempt to create the new client config.
1633 new_config.reset(new D2ClientConfig(enable_updates,
1634 server_ip,
1635 server_port,
1636 sender_ip,
1637 sender_port,
1638 max_queue_size,
1639 ncr_protocol,
1640 ncr_format));
1641 } catch (const std::exception& ex) {
1642 isc_throw(DhcpConfigError, ex.what() << " ("
1643 << client_config->getPosition() << ")");
1644 }
1645
1646 // Add user context
1647 ConstElementPtr user_context = client_config->get("user-context");
1648 if (user_context) {
1649 new_config->setContext(user_context);
1650 }
1651
1652 return (new_config);
1653}
1654
1657 // enable-updates is unconditionally required
1658 { "server-ip", Element::string, "127.0.0.1" },
1659 { "server-port", Element::integer, "53001" },
1660 // default sender-ip depends on server-ip family, so we leave default blank
1661 // parser knows to use the appropriate ZERO address based on server-ip
1662 { "sender-ip", Element::string, "" },
1663 { "sender-port", Element::integer, "0" },
1664 { "max-queue-size", Element::integer, "1024" },
1665 { "ncr-protocol", Element::string, "UDP" },
1666 { "ncr-format", Element::string, "JSON" }
1667};
1668
1669size_t
1671 ElementPtr mutable_d2 = boost::const_pointer_cast<Element>(d2_config);
1673}
1674
1675} // namespace dhcp
1676} // 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 parameter given to a method or function is considered invalid...
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
A generic exception that is thrown when an unexpected error condition occurs.
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
target_type getAndConvert(isc::data::ConstElementPtr scope, const std::string &name, const std::string &type_name)
Returns a converted value from a scope.
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
uint8_t getUint8(ConstElementPtr scope, const std::string &name)
Get an uint8_t value.
static isc::asiolink::IOAddress getAddress(const ConstElementPtr &scope, const std::string &name)
Returns a IOAddress parameter from a scope.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
uint32_t getUint32(isc::data::ConstElementPtr scope, const std::string &name)
Returns a value converted to uint32_t.
const isc::util::Triplet< uint32_t > parseIntTriplet(const data::ConstElementPtr &scope, const std::string &name)
Parses an integer triplet.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
static size_t setDefaults(isc::data::ElementPtr scope, const SimpleDefaults &default_values)
Sets the default values.
void parseCacheParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to lease cache settings.
void parseAllocatorParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to allocator selection.
void parseDdnsParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to DDNS behavior.
void parseCommon(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses common parameters.
static void moveReservationMode(isc::data::ElementPtr config)
Moves deprecated reservation-mode parameter to new reservations flags.
void parseTeePercents(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to "percent" timers settings.
void parsePdAllocatorParams(const data::ConstElementPtr &network_data, Network6Ptr &network)
Parses parameters pertaining to prefix delegation allocator selection.
void parseOfferLft(const data::ConstElementPtr &network_data, Network4Ptr &network)
Parses offer-lifetime parameter (v4 only)
Wrapper class that holds MAC/hardware address sources.
void add(uint32_t source)
Adds additional MAC/hardware address acquisition.
void clear()
Removes any configured MAC/Hardware address sources.
static uint32_t MACSourceFromText(const std::string &name)
Attempts to convert known hardware address sources to uint32_t.
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition: cfgmgr.cc:167
void parse(SrvConfig &srv_cfg, isc::data::ConstElementPtr value)
"Parses" control-socket structure
Definition: dhcp_parsers.cc:77
D2ClientConfigPtr parse(isc::data::ConstElementPtr d2_client_cfg)
Parses a given dhcp-ddns element into D2ClientConfig.
static const isc::data::SimpleDefaults D2_CLIENT_CONFIG_DEFAULTS
Defaults for the D2 client configuration.
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
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
ReplaceClientNameMode
Defines the client name replacement modes.
Definition: d2_client_cfg.h:76
An exception that is thrown if an error occurs while configuring the D2 DHCP DDNS client.
Definition: d2_client_cfg.h:34
To be removed. Please use ConfigError instead.
Parser for a list of host reservations for a subnet.
void parse(const SubnetID &subnet_id, isc::data::ConstElementPtr hr_list, HostCollection &hosts_list)
Parses a list of host reservation entries for a subnet.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
Definition: iface_mgr.cc:54
static void setRuntimeOptionDefs(const OptionDefSpaceContainer &defs)
Copies option definitions created at runtime.
Definition: libdhcp++.cc:216
void parse(CfgMACSource &mac_sources, isc::data::ConstElementPtr value)
parses parameters value
Definition: dhcp_parsers.cc:47
Holds optional information about relay.
Definition: network.h:162
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
Definition: network.h:210
OptionDefListParser(const uint16_t address_family)
Constructor.
void parse(CfgOptionDefPtr cfg, isc::data::ConstElementPtr def_list)
Parses a list of option definitions, create them and store in cfg.
Parser for a single option definition.
Definition: dhcp_parsers.h:228
OptionDefinitionPtr parse(isc::data::ConstElementPtr option_def)
Parses an entry that describes single option definition.
Definition: dhcp_parsers.cc:98
OptionDefParser(const uint16_t address_family)
Constructor.
Definition: dhcp_parsers.cc:93
Base class representing a DHCP option definition.
static bool validateName(const std::string &name)
Checks that the provided option space name is valid.
Definition: option_space.cc:26
Universe
defines option universe DHCPv4 or DHCPv6
Definition: option.h:83
PdPoolParser()
Constructor.
virtual boost::shared_ptr< OptionDataListParser > createOptionDataListParser() const
Returns an instance of the OptionDataListParser to be used in parsing the option-data structure.
isc::data::ConstElementPtr user_context_
User context (optional, may be null)
Definition: dhcp_parsers.h:827
void parse(PoolStoragePtr pools, data::ConstElementPtr pd_pool_, bool encapsulate_options=true)
Builds a prefix delegation pool from the given configuration.
isc::dhcp::Pool6Ptr pool_
Pointer to the created pool object.
Definition: dhcp_parsers.h:822
isc::data::ConstElementPtr client_class_
Client class (a client has to belong to to use this pd-pool)
Definition: dhcp_parsers.h:832
virtual boost::shared_ptr< PdPoolParser > createPdPoolConfigParser() const
Returns an instance of the PdPoolParser to be used in parsing the prefix delegation pools.
void parse(PoolStoragePtr pools, data::ConstElementPtr pd_pool_list)
Parse configuration entries.
static const size_t MAX_SNAME_LEN
length of the SNAME field in DHCPv4 message
Definition: pkt4.h:44
static const size_t MAX_FILE_LEN
length of the FILE field in DHCPv4 message
Definition: pkt4.h:47
PoolPtr poolMaker(asiolink::IOAddress &addr, uint32_t len, int32_t ignored)
Creates a Pool4 object given a IPv4 prefix and the prefix length.
Pool information for IPv4 addresses.
Definition: pool.h:240
PoolPtr poolMaker(asiolink::IOAddress &addr, uint32_t len, int32_t ptype)
Creates a Pool6 object given a IPv6 prefix and the prefix length.
Pool information for IPv6 addresses and prefixes.
Definition: pool.h:299
virtual PoolPtr poolMaker(isc::asiolink::IOAddress &addr, uint32_t len, int32_t ptype=0)=0
Creates a Pool object given a IPv4 prefix and the prefix length.
virtual void parse(PoolStoragePtr pools, isc::data::ConstElementPtr pool_structure, const uint16_t address_family, bool encapsulate_options=true)
parses the actual structure
virtual boost::shared_ptr< OptionDataListParser > createOptionDataListParser(const uint16_t address_family) const
Returns an instance of the OptionDataListParser to be used in parsing the option-data structure.
void parse(PoolStoragePtr pools, data::ConstElementPtr pools_list, bool encapsulate_options=true)
parses the actual structure
virtual boost::shared_ptr< PoolParser > createPoolConfigParser() const
Returns an instance of the Pool4Parser to be used in parsing the address pools.
void parse(PoolStoragePtr pools, data::ConstElementPtr pools_list, bool encapsulate_options=true)
parses the actual structure
virtual boost::shared_ptr< PoolParser > createPoolConfigParser() const
Returns an instance of the Pool6Parser to be used in parsing the address pools.
parser for additional relay information
Definition: dhcp_parsers.h:449
RelayInfoParser(const isc::dhcp::Option::Universe &family)
constructor
void addAddress(const std::string &name, const std::string &address_str, isc::data::ConstElementPtr relay_elem, const isc::dhcp::Network::RelayInfoPtr &relay_info)
Attempts to add an IP address to list of relay addresses.
void parse(const isc::dhcp::Network::RelayInfoPtr &relay_info, isc::data::ConstElementPtr relay_elem)
parses the actual relay parameters
static const isc::data::SimpleKeywords SUBNET4_PARAMETERS
This table defines all subnet parameters for DHCPv4.
static const isc::data::SimpleKeywords OPTION4_DEF_PARAMETERS
This table defines all option definition parameters.
static const isc::data::SimpleKeywords POOL4_PARAMETERS
This table defines all pool parameters.
static const isc::data::SimpleKeywords POOL6_PARAMETERS
This table defines all pool parameters.
static const isc::data::SimpleKeywords SUBNET6_PARAMETERS
This table defines all subnet parameters for DHCPv6.
static const isc::data::SimpleKeywords OPTION6_DEF_PARAMETERS
This table defines all option definition parameters.
static const isc::data::SimpleKeywords PD_POOL6_PARAMETERS
This table defines all prefix delegation pool parameters.
Specifies current DHCP configuration.
Definition: srv_config.h:184
void setControlSocketInfo(const isc::data::ConstElementPtr &control_socket)
Sets information about the control socket.
Definition: srv_config.h:543
Subnet4ConfigParser(bool check_iface=true)
Constructor.
virtual boost::shared_ptr< PoolsListParser > createPoolsListParser() const
Returns an instance of the Pools4ListParser to be used in parsing the address pools.
void validateResv(const Subnet4Ptr &subnet, ConstHostPtr host)
Verifies the host reservation address is in the subnet range.
void initSubnet(data::ConstElementPtr params, asiolink::IOAddress addr, uint8_t len)
Instantiates the IPv4 Subnet based on a given IPv4 address and prefix length.
Subnet4Ptr parse(data::ConstElementPtr subnet, bool encapsulate_options=true)
Parses a single IPv4 subnet configuration and adds to the Configuration Manager.
static Subnet4Ptr create(const isc::asiolink::IOAddress &prefix, uint8_t length, const util::Triplet< uint32_t > &t1, const util::Triplet< uint32_t > &t2, const util::Triplet< uint32_t > &valid_lifetime, const SubnetID id)
Factory function creating an instance of the Subnet4.
Definition: subnet.cc:270
virtual boost::shared_ptr< PoolsListParser > createPoolsListParser() const
Returns an instance of the Pools6ListParser to be used in parsing the address pools.
virtual boost::shared_ptr< PdPoolsListParser > createPdPoolsListParser() const
Returns an instance of the PdPools6ListParser to be used in parsing the prefix delegation pools.
Subnet6Ptr parse(data::ConstElementPtr subnet, bool encapsulate_options=true)
Parses a single IPv6 subnet configuration and adds to the Configuration Manager.
void initSubnet(isc::data::ConstElementPtr params, isc::asiolink::IOAddress addr, uint8_t len)
Instantiates the IPv6 Subnet based on a given IPv6 address and prefix length.
virtual void duplicateOptionWarning(uint32_t code, asiolink::IOAddress &addr)
Issues a DHCP6 server specific warning regarding duplicate subnet options.
void validateResvs(const Subnet6Ptr &subnet, ConstHostPtr host)
Verifies host reservation addresses are in the subnet range.
Subnet6ConfigParser(bool check_iface=true)
Constructor.
static Subnet6Ptr create(const isc::asiolink::IOAddress &prefix, uint8_t length, const util::Triplet< uint32_t > &t1, const util::Triplet< uint32_t > &t2, const util::Triplet< uint32_t > &preferred_lifetime, const util::Triplet< uint32_t > &valid_lifetime, const SubnetID id)
Factory function creating an instance of the Subnet4.
Definition: subnet.cc:658
this class parses a single subnet
Definition: dhcp_parsers.h:512
SubnetConfigParser(uint16_t family, bool check_iface=true)
constructor
isc::dhcp::SubnetPtr subnet_
Pointer to the created subnet object.
Definition: dhcp_parsers.h:581
void createSubnet(isc::data::ConstElementPtr data)
Create a new subnet using a data from child parsers.
virtual void initSubnet(isc::data::ConstElementPtr params, isc::asiolink::IOAddress addr, uint8_t len)=0
Instantiates the subnet based on a given IP prefix and prefix length.
isc::dhcp::Network::RelayInfoPtr relay_info_
Pointer to relay information.
Definition: dhcp_parsers.h:587
uint16_t address_family_
Address family: AF_INET or AF_INET6.
Definition: dhcp_parsers.h:584
SubnetPtr parse(isc::data::ConstElementPtr subnet, bool encapsulate_options)
parses a subnet description and returns Subnet{4,6} structure
bool check_iface_
Check if the specified interface exists in the system.
Definition: dhcp_parsers.h:590
virtual boost::shared_ptr< OptionDataListParser > createOptionDataListParser() const
Returns an instance of the OptionDataListParser to be used in parsing the option-data structure.
PoolStoragePtr pools_
Storage for pools belonging to this subnet.
Definition: dhcp_parsers.h:578
bool check_iface_
Check if the specified interface exists in the system.
Definition: dhcp_parsers.h:703
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list, bool encapsulate_options=true)
parses contents of the list
Subnets4ListConfigParser(bool check_iface=true)
constructor
virtual boost::shared_ptr< Subnet4ConfigParser > createSubnetConfigParser() const
Returns an instance of the Subnet4ConfigParser to be used in parsing the subnets.
virtual boost::shared_ptr< Subnet6ConfigParser > createSubnetConfigParser() const
Returns an instance of the Subnet6ConfigParser to be used in parsing the subnets.
Subnets6ListConfigParser(bool check_iface=true)
constructor
bool check_iface_
Check if the specified interface exists in the system.
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list, bool encapsulate_options=true)
parses contents of the list
T get() const
Retrieves the encapsulated value.
Definition: optional.h:114
bool empty() const
Checks if the encapsulated value is empty.
Definition: optional.h:153
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
Definition: optional.h:136
@ D6O_INTERFACE_ID
Definition: dhcp6.h:38
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#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
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition: macros.h:14
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:29
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
@ error
Definition: db_log.h:116
NameChangeProtocol stringToNcrProtocol(const std::string &protocol_str)
Function which converts text labels to NameChangeProtocol enums.
Definition: ncr_io.cc:23
NameChangeFormat
Defines the list of data wire formats supported.
Definition: ncr_msg.h:60
NameChangeProtocol
Defines the list of socket protocols supported.
Definition: ncr_io.h:68
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
Definition: ncr_io.cc:36
NameChangeFormat stringToNcrFormat(const std::string &fmt_str)
Function which converts labels to NameChangeFormat enum values.
Definition: ncr_msg.cc:26
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
Definition: ncr_msg.cc:35
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
Definition: dhcpsrv_log.h:56
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
Definition: cfg_globals.h:163
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
Definition: subnet.h:489
const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET6
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
Definition: subnet.h:498
boost::shared_ptr< Network4 > Network4Ptr
Pointer to the Network4 object.
Definition: network.h:1413
std::vector< PoolPtr > PoolStorage
a collection of pools
Definition: dhcp_parsers.h:280
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:803
@ DHO_END
Definition: dhcp4.h:230
@ DHO_PAD
Definition: dhcp4.h:69
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
const isc::log::MessageID DHCPSRV_CFGMGR_OPTION_DUPLICATE
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
const isc::log::MessageID DHCPSRV_CFGMGR_RELAY_IP_ADDRESS_DEPRECATED
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Definition: srv_config.h:1232
std::pair< IPv6ResrvIterator, IPv6ResrvIterator > IPv6ResrvRange
Definition: host.h:243
std::vector< HostPtr > HostCollection
Collection of the Host objects.
Definition: host.h:816
const int DHCPSRV_DBG_TRACE_DETAIL
Additional information.
Definition: dhcpsrv_log.h:38
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
boost::shared_ptr< PoolStorage > PoolStoragePtr
Definition: dhcp_parsers.h:281
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition: pool.h:483
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_NEW_SUBNET4
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:810
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
Definition: network.h:73
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Definition: option.h:24
boost::shared_ptr< Option > OptionPtr
Definition: option.h:37
string trim(const string &instring)
Trim Leading and Trailing Spaces.
Definition: strutil.cc:53
vector< string > tokens(const std::string &text, const std::string &delim, bool escape)
Split String into Tokens.
Definition: strutil.cc:77
Definition: edns.h:19
Defines the logger used by the top-level component of kea-lfc.
#define DHCP4_OPTION_SPACE
global std option spaces
#define DHCP6_OPTION_SPACE
Type
Type of lease or pool.
Definition: lease.h:46