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>
40namespace ph = std::placeholders;
56 for (
auto const& source_elem : value->listValue()) {
57 std::string source_str = source_elem->stringValue();
60 mac_sources.add(source);
64 <<
"' was specified twice (" << value->getPosition() <<
")");
65 }
catch (
const std::exception& ex) {
67 << source_str <<
"' to any recognized MAC source:"
68 << ex.
what() <<
" (" << value->getPosition() <<
")");
82 "Specified control-sockets is expected to be a list");
84 bool seen_unix(
false);
85 bool seen_http(
false);
90 "Specified control-sockets is expected to be a list of maps");
95 "'socket-type' parameter is mandatory in control-sockets items");
100 "'socket-type' parameter is expected to be a string");
102 string type = socket_type->stringValue();
103 if (type ==
"unix") {
106 "control socket of type 'unix' already configured");
109 srv_cfg.setUnixControlSocketInfo(socket);
110 }
else if ((type ==
"http") || (type ==
"https")) {
113 "control socket of type 'http' or 'https'"
114 " already configured");
119 srv_cfg.setHttpControlSocketInfo(http_config);
123 "unsupported 'socket-type': '" << type
124 <<
"' not 'unix', 'http' or 'https'");
132 : address_family_(address_family) {
139 if (address_family_ == AF_INET) {
146 std::string name =
getString(option_def,
"name");
147 int64_t code64 =
getInteger(option_def,
"code");
148 std::string type =
getString(option_def,
"type");
152 bool array_type =
getBoolean(option_def,
"array");
153 std::string record_types =
getString(option_def,
"record-types");
154 std::string space =
getString(option_def,
"space");
155 std::string encapsulates =
getString(option_def,
"encapsulate");
162 }
else if (address_family_ == AF_INET &&
163 code64 > std::numeric_limits<uint8_t>::max()) {
165 <<
"', it must not be greater than '"
166 <<
static_cast<int>(std::numeric_limits<uint8_t>::max())
167 <<
"' (" <<
getPosition(
"code", option_def) <<
")");
168 }
else if (address_family_ == AF_INET6 &&
169 code64 > std::numeric_limits<uint16_t>::max()) {
171 <<
"', it must not be greater than '"
172 << std::numeric_limits<uint16_t>::max()
173 <<
"' (" <<
getPosition(
"code", option_def) <<
")");
175 uint32_t code =
static_cast<uint32_t
>(code64);
189 <<
"reserved for PAD ("
193 <<
"reserved for END ("
202 <<
"reserved value ("
211 if (!encapsulates.empty()) {
215 << name <<
"', comprising an array of data"
216 <<
" fields may not encapsulate any option space ("
217 << option_def->getPosition() <<
")");
219 }
else if (encapsulates == space) {
221 <<
" an option space it belongs to: '"
222 << space <<
"." << name <<
"' is set to"
223 <<
" encapsulate '" << space <<
"' ("
224 << option_def->getPosition() <<
")");
228 encapsulates.c_str()));
237 def->setContext(user_context);
241 std::vector<std::string> record_tokens =
245 for (
auto const& record_type : record_tokens) {
247 auto const trim_rec = boost::trim_copy(record_type);
248 if (!trim_rec.empty()) {
249 def->addRecordField(trim_rec);
253 <<
" specified for the option definition: "
255 <<
getPosition(
"record-types", option_def) <<
")");
262 }
catch (
const std::exception& ex) {
264 <<
" (" << option_def->getPosition() <<
")");
274 : address_family_(address_family) {
279 if (!option_def_list) {
282 <<
" option definitions is NULL ("
283 << option_def_list->getPosition() <<
")");
287 for (
auto const& option_def : option_def_list->listValue()) {
291 }
catch (
const std::exception& ex) {
294 << option_def->getPosition() <<
")");
326 "(" <<
getPosition(
"ip-addresses", relay_elem) <<
")");
329 for (
auto const& address_element : addresses->listValue()) {
330 addAddress(
"ip-addresses", address_element->stringValue(),
331 relay_elem, relay_info);
337 const std::string& address_str,
340 boost::scoped_ptr<isc::asiolink::IOAddress> ip;
343 }
catch (
const std::exception& ex) {
345 <<
" is not a valid: "
362 relay_info->addAddress(*ip);
363 }
catch (
const std::exception& ex) {
365 <<
" to relay info: " << ex.
what()
375 const uint16_t address_family,
376 bool encapsulate_options) {
378 if (address_family == AF_INET) {
388 "definition: (" << pool_structure->getPosition() <<
")");
394 string txt = text_pool->stringValue();
397 boost::erase_all(txt,
" ");
398 boost::erase_all(txt,
"\t");
403 size_t pos = txt.find(
"/");
404 if (pos != string::npos) {
411 string prefix_len = txt.substr(pos + 1);
423 int val_len = boost::lexical_cast<int>(prefix_len);
424 if ((val_len < std::numeric_limits<uint8_t>::min()) ||
425 (val_len > std::numeric_limits<uint8_t>::max())) {
429 len =
static_cast<uint8_t
>(val_len);
432 "definition: " << txt <<
" ("
433 << text_pool->getPosition() <<
")");
438 pools->push_back(pool);
439 }
catch (
const std::exception& ex) {
441 << txt <<
" (" << text_pool->getPosition() <<
")");
450 if (pos != string::npos) {
457 "definition: " << txt <<
" ("
458 << text_pool->getPosition() <<
")");
463 pools->push_back(pool);
464 }
catch (
const std::exception& ex) {
466 << txt <<
" (" << text_pool->getPosition() <<
")");
473 << text_pool->stringValue() <<
474 ". There are two acceptable formats <min address-max address>"
476 << text_pool->getPosition() <<
")");
482 if (pool_id->intValue() <= 0) {
484 <<
" a positive integer greater than 0");
485 }
else if (pool_id->intValue() > numeric_limits<uint32_t>::max()) {
487 <<
" a 32 bit unsigned integer");
490 pool->setID(pool_id->intValue());
499 << user_context->getPosition() <<
")");
501 pool->setContext(user_context);
510 option_parser->parse(cfg, option_data, encapsulate_options);
511 }
catch (
const std::exception& ex) {
513 <<
" (" << option_data->getPosition() <<
")");
520 string cclass = client_class->stringValue();
521 if (!cclass.empty()) {
522 pool->allowClientClass(cclass);
532boost::shared_ptr<OptionDataListParser>
534 return (boost::make_shared<OptionDataListParser>(address_family));
553 bool encapsulate_options) {
554 for (
auto const& pool : pools_list->listValue()) {
556 parser->parse(pools, pool, AF_INET, encapsulate_options);
560boost::shared_ptr<PoolParser>
562 return (boost::make_shared<Pool4Parser>());
569 address_family_(family),
570 check_iface_(check_iface) {
587 }
catch (
const std::exception& ex) {
589 "subnet configuration failed: " << ex.
what());
599 if (options_params) {
601 opt_parser->parse(
subnet_->getCfgOption(), options_params, encapsulate_options);
609 std::string subnet_txt;
611 subnet_txt =
getString(params,
"subnet");
615 "mandatory 'subnet' parameter is missing for a subnet being"
616 " configured (" << params->getPosition() <<
")");
620 boost::erase_all(subnet_txt,
" ");
621 boost::erase_all(subnet_txt,
"\t");
628 size_t pos = subnet_txt.find(
"/");
629 if (pos == string::npos) {
632 "Invalid subnet syntax (prefix/len expected):" << subnet_txt
633 <<
" (" << elem->getPosition() <<
")");
643 len = boost::lexical_cast<unsigned int>(subnet_txt.substr(pos + 1));
644 }
catch (
const boost::bad_lexical_cast&) {
647 subnet_txt.substr(pos+1) <<
"' is not an integer ("
648 << elem->getPosition() <<
")");
652 if ((addr.
isV6() && len > 128) ||
653 (addr.
isV4() && len > 32)) {
656 "Invalid prefix length specified for subnet: " << len
657 <<
" (" << elem->getPosition() <<
")");
664 for (
auto const& pool : *
pools_) {
671 ex.
what() <<
" (" << params->getPosition() <<
")");
680 << user_context->getPosition() <<
")");
682 subnet_->setContext(user_context);
693boost::shared_ptr<OptionDataListParser>
713 parser->parse(
pools_, pools, encapsulate_options);
721 "Failed to create an IPv4 subnet (" <<
722 subnet->getPosition() <<
")");
729 "Invalid Subnet4 cast in Subnet4ConfigParser::parse");
741 HostReservationsListParser<HostReservationParser4> parser;
742 parser.parse(
subnet_->getID(), reservations, hosts);
743 for (
auto const& h : hosts) {
750 auto network4 = boost::dynamic_pointer_cast<Network>(sn4ptr);
754 sn4ptr->createAllocators();
763 int64_t subnet_id_max =
static_cast<int64_t
>(SUBNET_ID_MAX);
768 Triplet<uint32_t>(), Triplet<uint32_t>(),
773 mutable_params = boost::const_pointer_cast<Element>(params);
776 NetworkPtr network = boost::dynamic_pointer_cast<Network>(subnet4);
779 std::ostringstream output;
780 output << addr <<
"/" <<
static_cast<int>(len) <<
" with params: ";
782 bool has_renew = !subnet4->getT1().unspecified();
783 bool has_rebind = !subnet4->getT2().unspecified();
789 renew = subnet4->getT1().get();
790 output <<
"t1=" << renew <<
", ";
793 rebind = subnet4->getT2().get();
794 output <<
"t2=" << rebind <<
", ";
797 if (!subnet4->getValid().unspecified()) {
798 output <<
"valid-lifetime=" << subnet4->getValid().get();
804 if (params->contains(
"match-client-id")) {
805 bool match_client_id =
getBoolean(params,
"match-client-id");
806 subnet4->setMatchClientId(match_client_id);
810 if (params->contains(
"authoritative")) {
811 bool authoritative =
getBoolean(params,
"authoritative");
812 subnet4->setAuthoritative(authoritative);
818 if (params->contains(
"next-server")) {
821 next_server =
getString(params,
"next-server");
822 if (!next_server.empty()) {
823 subnet4->setSiaddr(
IOAddress(next_server));
829 pos = next->getPosition().str();
831 pos = params->getPosition().str();
834 << next_server <<
"(" << pos <<
")");
839 if (params->contains(
"server-hostname")) {
840 std::string sname =
getString(params,
"server-hostname");
841 if (!sname.empty()) {
846 << sname.length() <<
" ("
847 <<
error->getPosition() <<
")");
849 subnet4->setSname(sname);
854 if (params->contains(
"boot-file-name")) {
855 std::string filename =
getString(params,
"boot-file-name");
856 if (!filename.empty()) {
861 << filename.length() <<
" ("
862 <<
error->getPosition() <<
")");
864 subnet4->setFilename(filename);
870 if (params->contains(
"interface")) {
871 std::string iface =
getString(params,
"interface");
872 if (!iface.empty()) {
876 <<
" for subnet " << subnet4->toText()
877 <<
" is not present in the system ("
878 <<
error->getPosition() <<
")");
881 subnet4->setIface(iface);
886 if (params->contains(
"client-class")) {
887 string client_class =
getString(params,
"client-class");
888 if (!client_class.empty()) {
889 subnet4->allowClientClass(client_class);
898 if (params->contains(
"4o6-interface")) {
899 string iface4o6 =
getString(params,
"4o6-interface");
900 if (!iface4o6.empty()) {
901 subnet4->get4o6().setIface4o6(iface4o6);
902 subnet4->get4o6().enabled(
true);
907 if (params->contains(
"4o6-subnet")) {
908 string subnet4o6 =
getString(params,
"4o6-subnet");
909 if (!subnet4o6.empty()) {
910 size_t slash = subnet4o6.find(
"/");
911 if (slash == std::string::npos) {
913 << subnet4o6 <<
", expected format: prefix6/length");
915 string prefix = subnet4o6.substr(0, slash);
916 string lenstr = subnet4o6.substr(slash + 1);
920 len = boost::lexical_cast<unsigned int>(lenstr.c_str());
921 }
catch (
const boost::bad_lexical_cast &) {
923 "4o6-subnet parameter: " << subnet4o6 <<
", expected 0..128 value");
925 subnet4->get4o6().setSubnet4o6(
IOAddress(prefix), len);
926 subnet4->get4o6().enabled(
true);
931 if (params->contains(
"4o6-interface-id")) {
932 std::string ifaceid =
getString(params,
"4o6-interface-id");
933 if (!ifaceid.empty()) {
936 subnet4->get4o6().setInterfaceId(opt);
937 subnet4->get4o6().enabled(
true);
958 if (params->contains(
"offer-lifetime")) {
959 uint32_t offer_lft =
getInteger(params,
"offer-lifetime");
960 subnet4->setOfferLft(offer_lft);
964 Network4Ptr network4 = boost::dynamic_pointer_cast<Network4>(subnet4);
971 const IOAddress& address = host->getIPv4Reservation();
972 if (!address.isV4Zero() && !subnet->inRange(address)) {
974 <<
"' is not within the IPv4 subnet '"
975 << subnet->toText() <<
"'");
979boost::shared_ptr<PoolsListParser>
981 return (boost::make_shared<Pools4ListParser>());
987 : check_iface_(check_iface) {
993 bool encapsulate_options) {
995 for (
auto const& subnet_json : subnets_list->listValue()) {
998 Subnet4Ptr subnet = parser->parse(subnet_json, encapsulate_options);
1005 cfg->getCfgSubnets4()->add(subnet);
1007 }
catch (
const std::exception& ex) {
1009 << subnet_json->getPosition() <<
")");
1019 bool encapsulate_options) {
1021 for (
auto const& subnet_json : subnets_list->listValue()) {
1024 Subnet4Ptr subnet = parser->parse(subnet_json, encapsulate_options);
1027 auto ret = subnets.insert(subnet);
1030 "can't store subnet because of conflict");
1033 }
catch (
const std::exception& ex) {
1035 << subnet_json->getPosition() <<
")");
1042boost::shared_ptr<Subnet4ConfigParser>
1044 return (boost::make_shared<Subnet4ConfigParser>(
check_iface_));
1053 (ptype), addr, len)));
1060 (ptype), min, max)));
1068 bool encapsulate_options) {
1069 for (
auto const& pool : pools_list->listValue()) {
1071 parser->parse(pools, pool, AF_INET6, encapsulate_options);
1075boost::shared_ptr<PoolParser>
1077 return (boost::make_shared<Pool6Parser>());
1087 bool encapsulate_options) {
1090 std::string addr_str =
getString(pd_pool,
"prefix");
1092 uint8_t prefix_len =
getUint8(pd_pool,
"prefix-len");
1094 uint8_t delegated_len =
getUint8(pd_pool,
"delegated-len");
1096 std::string excluded_prefix_str =
"::";
1097 if (pd_pool->contains(
"excluded-prefix")) {
1098 excluded_prefix_str =
getString(pd_pool,
"excluded-prefix");
1101 uint8_t excluded_prefix_len = 0;
1102 if (pd_pool->contains(
"excluded-prefix-len")) {
1103 excluded_prefix_len =
getUint8(pd_pool,
"excluded-prefix-len");
1124 excluded_prefix_len));
1125 }
catch (
const std::exception& ex) {
1130 <<
" (" << pd_pool->getPosition() <<
")");
1136 if (pool_id->intValue() <= 0) {
1138 <<
" a positive integer greater than 0");
1139 }
else if (pool_id->intValue() > numeric_limits<uint32_t>::max()) {
1141 <<
" a 32 bit unsigned integer");
1144 pool_->setID(pool_id->intValue());
1156 opts_parser->parse(
pool_->getCfgOption(), option_data, encapsulate_options);
1165 if (!cclass.empty()) {
1166 pool_->allowClientClass(cclass);
1176 pools->push_back(
pool_);
1179boost::shared_ptr<OptionDataListParser>
1181 return (boost::make_shared<OptionDataListParser>(AF_INET6));
1189 for (
auto const& pd_pool : pd_pool_list->listValue()) {
1191 parser->parse(pools, pd_pool);
1195boost::shared_ptr<PdPoolParser>
1197 return (boost::make_shared<PdPoolParser>());
1215 parser->parse(
pools_, pools, encapsulate_options);
1220 parser->parse(
pools_, pd_pools);
1228 "Failed to create an IPv6 subnet (" <<
1229 subnet->getPosition() <<
")");
1236 "Invalid Subnet6 cast in Subnet6ConfigParser::parse");
1248 HostReservationsListParser<HostReservationParser6> parser;
1249 parser.parse(
subnet_->getID(), reservations, hosts);
1250 for (
auto const& h : hosts) {
1257 auto network = boost::dynamic_pointer_cast<Network>(sn6ptr);
1261 auto network6 = boost::dynamic_pointer_cast<Network6>(sn6ptr);
1265 sn6ptr->createAllocators();
1275 .arg(code).arg(addr.
toText());
1282 int64_t subnet_id_max =
static_cast<int64_t
>(SUBNET_ID_MAX);
1288 Optional<bool> rapid_commit;
1289 if (params->contains(
"rapid-commit")) {
1290 rapid_commit =
getBoolean(params,
"rapid-commit");
1294 Triplet<uint32_t> pref =
parseIntTriplet(params,
"preferred-lifetime");
1298 Triplet<uint32_t>(),
1300 Triplet<uint32_t>(),
1305 mutable_params = boost::const_pointer_cast<Element>(params);
1312 if (!rapid_commit.unspecified()) {
1313 subnet6->setRapidCommit(rapid_commit);
1316 std::ostringstream output;
1317 output << addr <<
"/" <<
static_cast<int>(len) <<
" with params: ";
1320 bool has_renew = !subnet6->getT1().unspecified();
1321 bool has_rebind = !subnet6->getT2().unspecified();
1323 int64_t rebind = -1;
1326 renew = subnet6->getT1().get();
1327 output <<
"t1=" << renew <<
", ";
1330 rebind = subnet6->getT2().get();
1331 output <<
"t2=" << rebind <<
", ";
1334 if (!subnet6->getPreferred().unspecified()) {
1335 output <<
"preferred-lifetime=" << subnet6->getPreferred().get() <<
", ";
1337 if (!subnet6->getValid().unspecified()) {
1338 output <<
"valid-lifetime=" << subnet6->getValid().get();
1340 if (!subnet6->getRapidCommit().unspecified()) {
1341 output <<
", rapid-commit is "
1342 << boolalpha << subnet6->getRapidCommit().get();
1349 Optional<std::string> ifaceid;
1350 if (params->contains(
"interface-id")) {
1351 ifaceid =
getString(params,
"interface-id");
1354 Optional<std::string> iface;
1355 if (params->contains(
"interface")) {
1362 if (!ifaceid.unspecified() && !iface.unspecified() && !ifaceid.empty() &&
1365 "parser error: interface (defined for locally reachable "
1366 "subnets) and interface-id (defined for subnets reachable"
1367 " via relays) cannot be defined at the same time for "
1368 "subnet " << addr <<
"/" << (
int)len <<
"("
1369 << params->getPosition() <<
")");
1373 if (!ifaceid.unspecified() && !ifaceid.empty()) {
1374 std::string ifaceid_value = ifaceid.get();
1375 OptionBuffer tmp(ifaceid_value.begin(), ifaceid_value.end());
1377 subnet6->setInterfaceId(opt);
1382 if (!iface.unspecified() && !iface.empty()) {
1386 <<
" for subnet " << subnet6->toText()
1387 <<
" is not present in the system ("
1388 <<
error->getPosition() <<
")");
1391 subnet6->setIface(iface);
1395 if (params->contains(
"client-class")) {
1396 string client_class =
getString(params,
"client-class");
1397 if (!client_class.empty()) {
1398 subnet6->allowClientClass(client_class);
1422 BOOST_FOREACH(
auto const& it, range) {
1423 const IOAddress& address = it.second.getPrefix();
1424 if (!subnet->inRange(address)) {
1426 <<
"' is not within the IPv6 subnet '"
1427 << subnet->toText() <<
"'");
1432boost::shared_ptr<PoolsListParser>
1434 return (boost::make_shared<Pools6ListParser>());
1437boost::shared_ptr<PdPoolsListParser>
1439 return (boost::make_shared<PdPoolsListParser>());
1445 : check_iface_(check_iface) {
1451 bool encapsulate_options) {
1453 for (
auto const& subnet_json : subnets_list->listValue()) {
1456 Subnet6Ptr subnet = parser->parse(subnet_json, encapsulate_options);
1462 cfg->getCfgSubnets6()->add(subnet);
1464 }
catch (
const std::exception& ex) {
1466 << subnet_json->getPosition() <<
")");
1475 bool encapsulate_options) {
1477 for (
auto const& subnet_json : subnets_list->listValue()) {
1480 Subnet6Ptr subnet = parser->parse(subnet_json, encapsulate_options);
1483 auto ret = subnets.insert(subnet);
1486 "can't store subnet because of conflict");
1489 }
catch (
const std::exception& ex) {
1491 << subnet_json->getPosition() <<
")");
1498boost::shared_ptr<Subnet6ConfigParser>
1500 return (boost::make_shared<Subnet6ConfigParser>(
check_iface_));
1507 const std::string& name) {
1510 (scope, name,
"NameChangeRequest protocol"));
1515 const std::string& name) {
1518 (scope, name,
"NameChangeRequest format"));
1523 const std::string& name) {
1526 (scope, name,
"ReplaceClientName mode"));
1534 bool enable_updates =
getBoolean(client_config,
"enable-updates");
1538 uint32_t server_port =
getUint32(client_config,
"server-port");
1540 std::string sender_ip_str =
getString(client_config,
"sender-ip");
1542 uint32_t sender_port =
getUint32(client_config,
"sender-port");
1544 uint32_t max_queue_size =
getUint32(client_config,
"max-queue-size");
1547 getProtocol(client_config,
"ncr-protocol");
1550 getFormat(client_config,
"ncr-format");
1553 if (sender_ip_str.empty()) {
1560 }
catch (
const std::exception& ex) {
1562 <<
") specified for parameter 'sender-ip' ("
1563 <<
getPosition(
"sender-ip", client_config) <<
")");
1573 <<
" is not supported. ("
1574 <<
getPosition(
"ncr-format", client_config) <<
")");
1580 <<
" is not supported. ("
1581 <<
getPosition(
"ncr-protocol", client_config) <<
")");
1584 if (sender_ip.getFamily() != server_ip.getFamily()) {
1586 "D2ClientConfig error: address family mismatch: "
1587 <<
"server-ip: " << server_ip.toText()
1588 <<
" is: " << (server_ip.isV4() ?
"IPv4" :
"IPv6")
1589 <<
" while sender-ip: " << sender_ip.toText()
1590 <<
" is: " << (sender_ip.isV4() ?
"IPv4" :
"IPv6")
1591 <<
" (" <<
getPosition(
"sender-ip", client_config) <<
")");
1594 if (server_ip == sender_ip && server_port == sender_port) {
1596 "D2ClientConfig error: server and sender cannot"
1597 " share the exact same IP address/port: "
1598 << server_ip.toText() <<
"/" << server_port
1599 <<
" (" <<
getPosition(
"sender-ip", client_config) <<
")");
1612 }
catch (
const std::exception& ex) {
1614 << client_config->getPosition() <<
")");
1620 new_config->setContext(user_context);
1623 return (new_config);
1642 ElementPtr mutable_d2 = boost::const_pointer_cast<Element>(d2_config);
1648 if (compatibility) {
1650 for (
auto const& kv : compatibility->mapValue()) {
1653 "compatibility parameter values must be "
1654 <<
"boolean (" << kv.first <<
" at "
1655 << kv.second->getPosition() <<
")");
1657 if (kv.first ==
"lenient-option-parsing") {
1658 srv_cfg.setLenientOptionParsing(kv.second->boolValue());
1659 }
else if (family == AF_INET) {
1660 if (kv.first ==
"ignore-dhcp-server-identifier") {
1661 srv_cfg.setIgnoreServerIdentifier(kv.second->boolValue());
1662 }
else if (kv.first ==
"ignore-rai-link-selection") {
1663 srv_cfg.setIgnoreRAILinkSelection(kv.second->boolValue());
1664 }
else if (kv.first ==
"exclude-first-last-24") {
1665 srv_cfg.setExcludeFirstLast24(kv.second->boolValue());
1668 "unsupported compatibility parameter: "
1669 << kv.first <<
" (" << kv.second->getPosition()
1674 "unsupported compatibility parameter: "
1675 << kv.first <<
" (" << kv.second->getPosition()
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.
The IOAddress class represents an IP addresses (version agnostic)
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
std::string toText() const
Convert the address to a string.
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
HTTP command config aka HTTP control socket info class.
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 getAdditionalClassesElem(data::ConstElementPtr params, ClassAdderFunc adder_func)
Fetches the element for either 'evaluate-additional-classes' or deprecated 'require-client-classes'.
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.
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
void parse(isc::data::ConstElementPtr cfg, isc::dhcp::SrvConfig &srv_cfg)
Parse compatibility flags.
void parse(SrvConfig &srv_cfg, isc::data::ConstElementPtr value)
"Parses" control-sockets structure
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.
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
ReplaceClientNameMode
Defines the client name replacement modes.
An exception that is thrown if an error occurs while configuring the D2 DHCP DDNS client.
To be removed. Please use ConfigError instead.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
static void setRuntimeOptionDefs(const OptionDefSpaceContainer &defs)
Copies option definitions created at runtime.
void parse(CfgMACSource &mac_sources, isc::data::ConstElementPtr value)
parses parameters value
Holds optional information about relay.
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
void addAdditionalClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to the additional classes list.
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.
OptionDefinitionPtr parse(isc::data::ConstElementPtr option_def)
Parses an entry that describes single option definition.
OptionDefParser(const uint16_t address_family)
Constructor.
Base class representing a DHCP option definition.
static bool validateName(const std::string &name)
Checks that the provided option space name is valid.
Universe
defines option universe DHCPv4 or DHCPv6
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)
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.
isc::data::ConstElementPtr client_class_
Client class (a client has to belong to to use this pd-pool)
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
static const size_t MAX_FILE_LEN
length of the FILE field in DHCPv4 message
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.
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.
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 addAdditionalClass(const ClientClass &class_name)
Adds class class_name to the additional classes list.
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
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.
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.
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.
this class parses a single subnet
SubnetConfigParser(uint16_t family, bool check_iface=true)
constructor
isc::dhcp::SubnetPtr subnet_
Pointer to the created subnet object.
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.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
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.
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.
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
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
#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.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
boost::shared_ptr< HttpCommandConfig > HttpCommandConfigPtr
Pointer to a HttpCommandConfig object.
boost::shared_ptr< const Element > ConstElementPtr
std::vector< SimpleDefault > SimpleDefaults
This specifies all default values in a given scope (e.g. a subnet).
boost::shared_ptr< Element > ElementPtr
NameChangeProtocol stringToNcrProtocol(const std::string &protocol_str)
Function which converts text labels to NameChangeProtocol enums.
NameChangeFormat
Defines the list of data wire formats supported.
NameChangeProtocol
Defines the list of socket protocols supported.
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
NameChangeFormat stringToNcrFormat(const std::string &fmt_str)
Function which converts labels to NameChangeFormat enum values.
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET6
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
boost::shared_ptr< Network4 > Network4Ptr
Pointer to the Network4 object.
std::vector< PoolPtr > PoolStorage
a collection of pools
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
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.
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.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
std::pair< IPv6ResrvIterator, IPv6ResrvIterator > IPv6ResrvRange
std::vector< HostPtr > HostCollection
Collection of the Host objects.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
boost::shared_ptr< PoolStorage > PoolStoragePtr
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
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.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET4
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
boost::shared_ptr< Option > OptionPtr
vector< string > tokens(const string &text, const string &delim, bool escape)
Split string into tokens.
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.