28 #include <boost/algorithm/string.hpp> 29 #include <boost/foreach.hpp> 30 #include <boost/lexical_cast.hpp> 31 #include <boost/make_shared.hpp> 32 #include <boost/scoped_ptr.hpp> 59 std::string source_str = source_elem->stringValue();
61 source = CfgMACSource::MACSourceFromText(source_str);
62 mac_sources.
add(source);
66 <<
"' was specified twice (" << value->getPosition() <<
")");
67 }
catch (
const std::exception& ex) {
69 << source_str <<
"' to any recognized MAC source:" 70 << ex.
what() <<
" (" << value->getPosition() <<
")");
86 if (value->getType() != Element::map) {
89 ", i.e. a structure defined within { }");
96 OptionDefParser::OptionDefParser(
const uint16_t address_family)
97 : address_family_(address_family) {
104 if (address_family_ == AF_INET) {
111 std::string name =
getString(option_def,
"name");
112 int64_t code64 =
getInteger(option_def,
"code");
113 std::string type =
getString(option_def,
"type");
117 bool array_type =
getBoolean(option_def,
"array");
118 std::string record_types =
getString(option_def,
"record-types");
119 std::string space =
getString(option_def,
"space");
120 std::string encapsulates =
getString(option_def,
"encapsulate");
127 }
else if (address_family_ == AF_INET &&
128 code64 > std::numeric_limits<uint8_t>::max()) {
130 <<
"', it must not be greater than '" 131 << static_cast<int>(std::numeric_limits<uint8_t>::max())
132 <<
"' (" <<
getPosition(
"code", option_def) <<
")");
133 }
else if (address_family_ == AF_INET6 &&
134 code64 > std::numeric_limits<uint16_t>::max()) {
136 <<
"', it must not be greater than '" 137 << std::numeric_limits<uint16_t>::max()
138 <<
"' (" <<
getPosition(
"code", option_def) <<
")");
140 uint32_t code =
static_cast<uint32_t
>(code64);
154 <<
"reserved for PAD (" 158 <<
"reserved for END (" 167 <<
"reserved value (" 176 if (!encapsulates.empty()) {
180 << name <<
"', comprising an array of data" 181 <<
" fields may not encapsulate any option space (" 182 << option_def->getPosition() <<
")");
184 }
else if (encapsulates == space) {
186 <<
" an option space it belongs to: '" 187 << space <<
"." << name <<
"' is set to" 188 <<
" encapsulate '" << space <<
"' (" 189 << option_def->getPosition() <<
")");
193 encapsulates.c_str()));
202 def->setContext(user_context);
206 std::vector<std::string> record_tokens =
210 BOOST_FOREACH(std::string record_type, record_tokens) {
213 if (!record_type.empty()) {
214 def->addRecordField(record_type);
218 <<
" specified for the option definition: " 220 <<
getPosition(
"record-types", option_def) <<
")");
227 }
catch (
const std::exception& ex) {
229 <<
" (" << option_def->getPosition() <<
")");
239 : address_family_(address_family) {
244 if (!option_def_list) {
247 <<
" option definitions is NULL (" 248 << option_def_list->getPosition() <<
")");
252 BOOST_FOREACH(
ConstElementPtr option_def, option_def_list->listValue()) {
256 }
catch (
const std::exception& ex) {
259 << option_def->getPosition() <<
")");
284 if (address && addresses) {
286 "specify either ip-address or ip-addresses, not both");
289 if (!address && !addresses) {
298 relay_elem, relay_info);
307 "(" <<
getPosition(
"ip-addresses", relay_elem) <<
")");
310 BOOST_FOREACH(
ConstElementPtr address_element, addresses->listValue()) {
311 addAddress(
"ip-addresses", address_element->stringValue(),
312 relay_elem, relay_info);
318 const std::string& address_str,
321 boost::scoped_ptr<isc::asiolink::IOAddress> ip;
324 }
catch (
const std::exception& ex) {
326 <<
" is not a valid: " 343 relay_info->addAddress(*ip);
344 }
catch (
const std::exception& ex) {
346 <<
" to relay info: " << ex.
what()
356 const uint16_t address_family) {
358 if (address_family == AF_INET) {
368 "definition: (" << pool_structure->getPosition() <<
")");
374 string txt = text_pool->stringValue();
377 boost::erase_all(txt,
" ");
378 boost::erase_all(txt,
"\t");
383 size_t pos = txt.find(
"/");
384 if (pos != string::npos) {
391 string prefix_len = txt.substr(pos + 1);
403 int val_len = boost::lexical_cast<
int>(prefix_len);
404 if ((val_len < std::numeric_limits<uint8_t>::min()) ||
405 (val_len > std::numeric_limits<uint8_t>::max())) {
409 len =
static_cast<uint8_t
>(val_len);
412 "definition: " << txt <<
" (" 413 << text_pool->getPosition() <<
")");
417 pool = poolMaker(addr, len);
418 pools->push_back(pool);
419 }
catch (
const std::exception& ex) {
421 << txt <<
" (" << text_pool->getPosition() <<
")");
430 if (pos != string::npos) {
437 "definition: " << txt <<
" (" 438 << text_pool->getPosition() <<
")");
442 pool = poolMaker(min, max);
443 pools->push_back(pool);
444 }
catch (
const std::exception& ex) {
446 << txt <<
" (" << text_pool->getPosition() <<
")");
453 << text_pool->stringValue() <<
454 ". There are two acceptable formats <min address-max address>" 456 << text_pool->getPosition() <<
")");
465 << user_context->getPosition() <<
")");
467 pool->setContext(user_context);
475 auto option_parser = createOptionDataListParser(address_family);
476 option_parser->parse(cfg, option_data);
477 }
catch (
const std::exception& ex) {
479 <<
" (" << option_data->getPosition() <<
")");
486 string cclass = client_class->stringValue();
487 if (!cclass.empty()) {
488 pool->allowClientClass(cclass);
493 ConstElementPtr class_list = pool_structure->get(
"require-client-classes");
495 const std::vector<data::ElementPtr>& classes = class_list->listValue();
496 for (
auto cclass = classes.cbegin();
497 cclass != classes.cend(); ++cclass) {
499 (*cclass)->stringValue().empty()) {
501 << (*cclass)->getPosition() <<
")");
503 pool->requireClientClass((*cclass)->stringValue());
508 boost::shared_ptr<OptionDataListParser>
510 auto parser = boost::make_shared<OptionDataListParser>(address_family);
531 auto parser = createPoolConfigParser();
532 parser->parse(pools, pool, AF_INET);
536 boost::shared_ptr<PoolParser>
538 auto parser = boost::make_shared<Pool4Parser>();
546 address_family_(family),
548 check_iface_(check_iface) {
556 if (options_params) {
558 opt_parser->parse(
options_, options_params);
571 }
catch (
const std::exception& ex) {
573 "subnet configuration failed: " << ex.
what());
581 std::string subnet_txt;
583 subnet_txt =
getString(params,
"subnet");
587 "mandatory 'subnet' parameter is missing for a subnet being" 588 " configured (" << params->getPosition() <<
")");
592 boost::erase_all(subnet_txt,
" ");
593 boost::erase_all(subnet_txt,
"\t");
600 size_t pos = subnet_txt.find(
"/");
601 if (pos == string::npos) {
604 "Invalid subnet syntax (prefix/len expected):" << subnet_txt
605 <<
" (" << elem->getPosition() <<
")");
615 len = boost::lexical_cast<
unsigned int>(subnet_txt.substr(pos + 1));
616 }
catch (
const boost::bad_lexical_cast&) {
619 subnet_txt.substr(pos+1) <<
"' is not an integer (" 620 << elem->getPosition() <<
")");
624 if ((addr.isV6() && len > 128) ||
625 (addr.isV4() && len > 32)) {
628 "Invalid prefix length specified for subnet: " << len
629 <<
" (" << elem->getPosition() <<
")");
636 for (PoolStorage::iterator it =
pools_->begin(); it !=
pools_->end();
644 ex.
what() <<
" (" << params->getPosition() <<
")");
653 << user_context->getPosition() <<
")");
655 subnet_->setContext(user_context);
666 boost::shared_ptr<OptionDataListParser>
668 auto parser = boost::make_shared<OptionDataListParser>(
address_family_);
687 parser->parse(
pools_, pools);
695 "Failed to create an IPv4 subnet (" <<
696 subnet->getPosition() <<
")");
703 "Invalid Subnet4 cast in Subnet4ConfigParser::parse");
717 for (
auto h = hosts.begin(); h != hosts.end(); ++h) {
724 auto network4 = boost::dynamic_pointer_cast<
Network>(sn4ptr);
727 if (sn4ptr->getAllocatorType() ==
"random") {
729 boost::make_shared<RandomAllocator>
733 for (
auto pool : *
pools_) {
738 for (
auto pool : *
pools_) {
752 int64_t subnet_id_max =
static_cast<int64_t
>(SUBNET_ID_MAX);
763 mutable_params = boost::const_pointer_cast<
Element>(params);
771 std::ostringstream output;
772 output << addr <<
"/" <<
static_cast<int>(len) <<
" with params: ";
774 bool has_renew = !subnet4->getT1().unspecified();
775 bool has_rebind = !subnet4->getT2().unspecified();
781 renew = subnet4->getT1().get();
782 output <<
"t1=" << renew <<
", ";
785 rebind = subnet4->getT2().get();
786 output <<
"t2=" << rebind <<
", ";
789 if (has_renew && has_rebind && (renew > rebind)) {
791 <<
") is greater than the value of rebind-timer (" 795 if (!subnet4->getValid().unspecified()) {
796 output <<
"valid-lifetime=" << subnet4->getValid().get();
802 if (params->contains(
"match-client-id")) {
803 bool match_client_id =
getBoolean(params,
"match-client-id");
804 subnet4->setMatchClientId(match_client_id);
808 if (params->contains(
"authoritative")) {
809 bool authoritative =
getBoolean(params,
"authoritative");
810 subnet4->setAuthoritative(authoritative);
816 if (params->contains(
"next-server")) {
819 next_server =
getString(params,
"next-server");
820 if (!next_server.empty()) {
821 subnet4->setSiaddr(
IOAddress(next_server));
827 pos = next->getPosition().str();
829 pos = params->getPosition().str();
832 << next_server <<
"(" << pos <<
")");
837 if (params->contains(
"server-hostname")) {
838 std::string sname =
getString(params,
"server-hostname");
839 if (!sname.empty()) {
844 << sname.length() <<
" (" 845 << error->getPosition() <<
")");
847 subnet4->setSname(sname);
852 if (params->contains(
"boot-file-name")) {
853 std::string filename =
getString(params,
"boot-file-name");
854 if (!filename.empty()) {
859 << filename.length() <<
" (" 860 << error->getPosition() <<
")");
862 subnet4->setFilename(filename);
868 if (params->contains(
"interface")) {
869 std::string iface =
getString(params,
"interface");
870 if (!iface.empty()) {
874 <<
" for subnet " << subnet4->toText()
875 <<
" is not present in the system (" 876 << error->getPosition() <<
")");
879 subnet4->setIface(iface);
884 if (params->contains(
"client-class")) {
885 string client_class =
getString(params,
"client-class");
886 if (!client_class.empty()) {
887 subnet4->allowClientClass(client_class);
894 const std::vector<data::ElementPtr>& classes = class_list->listValue();
895 for (
auto cclass = classes.cbegin();
896 cclass != classes.cend(); ++cclass) {
898 (*cclass)->stringValue().empty()) {
900 << (*cclass)->getPosition() <<
")");
902 subnet4->requireClientClass((*cclass)->stringValue());
907 if (params->contains(
"4o6-interface")) {
908 string iface4o6 =
getString(params,
"4o6-interface");
909 if (!iface4o6.empty()) {
910 subnet4->get4o6().setIface4o6(iface4o6);
911 subnet4->get4o6().enabled(
true);
916 if (params->contains(
"4o6-subnet")) {
917 string subnet4o6 =
getString(params,
"4o6-subnet");
918 if (!subnet4o6.empty()) {
919 size_t slash = subnet4o6.find(
"/");
920 if (slash == std::string::npos) {
922 << subnet4o6 <<
", expected format: prefix6/length");
924 string prefix = subnet4o6.substr(0, slash);
925 string lenstr = subnet4o6.substr(slash + 1);
929 len = boost::lexical_cast<
unsigned int>(lenstr.c_str());
930 }
catch (
const boost::bad_lexical_cast &) {
932 "4o6-subnet parameter: " << subnet4o6 <<
", expected 0..128 value");
934 subnet4->get4o6().setSubnet4o6(
IOAddress(prefix), len);
935 subnet4->get4o6().enabled(
true);
940 if (params->contains(
"4o6-interface-id")) {
941 std::string ifaceid =
getString(params,
"4o6-interface-id");
942 if (!ifaceid.empty()) {
945 subnet4->get4o6().setInterfaceId(opt);
946 subnet4->get4o6().enabled(
true);
958 options_->copyTo(*subnet4->getCfgOption());
972 const IOAddress& address = host->getIPv4Reservation();
973 if (!address.
isV4Zero() && !subnet->inRange(address)) {
975 <<
"' is not within the IPv4 subnet '" 976 << subnet->
toText() <<
"'");
980 boost::shared_ptr<PoolsListParser>
982 auto parser = boost::make_shared<Pools4ListParser>();
996 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
999 Subnet4Ptr subnet = parser->parse(subnet_json);
1006 cfg->getCfgSubnets4()->add(subnet);
1008 }
catch (
const std::exception& ex) {
1010 << subnet_json->getPosition() <<
")");
1021 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
1024 Subnet4Ptr subnet = parser->parse(subnet_json);
1027 auto ret = subnets.insert(subnet);
1030 "can't store subnet because of conflict");
1033 }
catch (
const std::exception& ex) {
1035 << subnet_json->getPosition() <<
")");
1042 boost::shared_ptr<Subnet4ConfigParser>
1044 auto parser = boost::make_shared<Subnet4ConfigParser>(
check_iface_);
1053 return (
PoolPtr(
new Pool6(static_cast<isc::dhcp::Lease::Type>
1054 (ptype), addr, len)));
1060 return (
PoolPtr(
new Pool6(static_cast<isc::dhcp::Lease::Type>
1061 (ptype), min, max)));
1070 auto parser = createPoolConfigParser();
1071 parser->parse(pools, pool, AF_INET6);
1075 boost::shared_ptr<PoolParser>
1077 auto parser = boost::make_shared<Pool6Parser>();
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");
1109 opts_parser->parse(
options_, option_data);
1132 excluded_prefix_len));
1135 }
catch (
const std::exception& ex) {
1140 <<
" (" << pd_pool_->getPosition() <<
")");
1149 if (!cclass.empty()) {
1150 pool_->allowClientClass(cclass);
1155 const std::vector<data::ElementPtr>& classes = class_list->listValue();
1156 for (
auto cclass = classes.cbegin();
1157 cclass != classes.cend(); ++cclass) {
1159 (*cclass)->stringValue().empty()) {
1161 << (*cclass)->getPosition() <<
")");
1163 pool_->requireClientClass((*cclass)->stringValue());
1168 pools->push_back(
pool_);
1171 boost::shared_ptr<OptionDataListParser>
1173 auto parser = boost::make_shared<OptionDataListParser>(AF_INET6);
1183 auto parser = createPdPoolConfigParser();
1184 parser->parse(pools, pd_pool);
1188 boost::shared_ptr<PdPoolParser>
1190 auto parser = boost::make_shared<PdPoolParser>();
1209 parser->parse(
pools_, pools);
1214 parser->parse(
pools_, pd_pools);
1222 "Failed to create an IPv6 subnet (" <<
1223 subnet->getPosition() <<
")");
1230 "Invalid Subnet6 cast in Subnet6ConfigParser::parse");
1244 for (
auto h = hosts.begin(); h != hosts.end(); ++h) {
1251 auto network = boost::dynamic_pointer_cast<
Network>(sn6ptr);
1255 auto network6 = boost::dynamic_pointer_cast<
Network6>(sn6ptr);
1261 if (sn6ptr->getAllocatorType() ==
"random") {
1263 boost::make_shared<RandomAllocator>
1266 boost::make_shared<RandomAllocator>
1274 if (sn6ptr->getPdAllocatorType() ==
"random") {
1276 boost::make_shared<RandomAllocator>
1283 for (
auto pool : *
pools_) {
1284 switch (pool->getType()) {
1288 if (sn6ptr->getAllocatorType() ==
"random") {
1295 if (sn6ptr->getPdAllocatorType() ==
"random") {
1312 .arg(code).arg(addr.
toText());
1321 int64_t subnet_id_max =
static_cast<int64_t
>(SUBNET_ID_MAX);
1328 if (params->contains(
"rapid-commit")) {
1329 rapid_commit =
getBoolean(params,
"rapid-commit");
1345 mutable_params = boost::const_pointer_cast<
Element>(params);
1355 subnet6->setRapidCommit(rapid_commit);
1358 std::ostringstream output;
1359 output << addr <<
"/" <<
static_cast<int>(len) <<
" with params: ";
1362 bool has_renew = !subnet6->getT1().unspecified();
1363 bool has_rebind = !subnet6->getT2().unspecified();
1365 int64_t rebind = -1;
1368 renew = subnet6->getT1().get();
1369 output <<
"t1=" << renew <<
", ";
1372 rebind = subnet6->getT2().get();
1373 output <<
"t2=" << rebind <<
", ";
1376 if (has_renew && has_rebind && (renew > rebind)) {
1378 <<
") is greater than the value of rebind-timer (" 1382 if (!subnet6->getPreferred().unspecified()) {
1383 output <<
"preferred-lifetime=" << subnet6->getPreferred().get() <<
", ";
1385 if (!subnet6->getValid().unspecified()) {
1386 output <<
"valid-lifetime=" << subnet6->getValid().get();
1388 if (!subnet6->getRapidCommit().unspecified()) {
1389 output <<
", rapid-commit is " 1390 << boolalpha << subnet6->getRapidCommit().get();
1398 if (params->contains(
"interface-id")) {
1399 ifaceid =
getString(params,
"interface-id");
1403 if (params->contains(
"interface")) {
1413 "parser error: interface (defined for locally reachable " 1414 "subnets) and interface-id (defined for subnets reachable" 1415 " via relays) cannot be defined at the same time for " 1416 "subnet " << addr <<
"/" << (
int)len <<
"(" 1417 << params->getPosition() <<
")");
1422 std::string ifaceid_value = ifaceid.
get();
1423 OptionBuffer tmp(ifaceid_value.begin(), ifaceid_value.end());
1425 subnet6->setInterfaceId(opt);
1434 <<
" for subnet " << subnet6->toText()
1435 <<
" is not present in the system (" 1436 << error->getPosition() <<
")");
1439 subnet6->setIface(iface);
1443 if (params->contains(
"client-class")) {
1444 string client_class =
getString(params,
"client-class");
1445 if (!client_class.empty()) {
1446 subnet6->allowClientClass(client_class);
1450 if (params->contains(
"require-client-classes")) {
1454 const std::vector<data::ElementPtr>& classes = class_list->listValue();
1455 for (
auto cclass = classes.cbegin();
1456 cclass != classes.cend(); ++cclass) {
1458 (*cclass)->stringValue().empty()) {
1460 << (*cclass)->getPosition() <<
")");
1462 subnet6->requireClientClass((*cclass)->stringValue());
1471 options_->copyTo(*subnet6->getCfgOption());
1486 for (
auto it = range.first; it != range.second; ++it) {
1487 const IOAddress& address = it->second.getPrefix();
1488 if (!subnet->inRange(address)) {
1490 <<
"' is not within the IPv6 subnet '" 1491 << subnet->
toText() <<
"'");
1496 boost::shared_ptr<PoolsListParser>
1498 auto parser = boost::make_shared<Pools6ListParser>();
1502 boost::shared_ptr<PdPoolsListParser>
1504 auto parser = boost::make_shared<PdPoolsListParser>();
1518 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
1521 Subnet6Ptr subnet = parser->parse(subnet_json);
1527 cfg->getCfgSubnets6()->add(subnet);
1529 }
catch (
const std::exception& ex) {
1531 << subnet_json->getPosition() <<
")");
1541 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
1544 Subnet6Ptr subnet = parser->parse(subnet_json);
1547 auto ret = subnets.insert(subnet);
1550 "can't store subnet because of conflict");
1553 }
catch (
const std::exception& ex) {
1555 << subnet_json->getPosition() <<
")");
1562 boost::shared_ptr<Subnet6ConfigParser>
1564 auto parser = boost::make_shared<Subnet6ConfigParser>(
check_iface_);
1572 const std::string& name) {
1575 (scope, name,
"NameChangeRequest protocol"));
1580 const std::string& name) {
1583 (scope, name,
"NameChangeRequest format"));
1588 const std::string& name) {
1591 (scope, name,
"ReplaceClientName mode"));
1599 bool enable_updates =
getBoolean(client_config,
"enable-updates");
1603 uint32_t server_port =
getUint32(client_config,
"server-port");
1605 std::string sender_ip_str =
getString(client_config,
"sender-ip");
1607 uint32_t sender_port =
getUint32(client_config,
"sender-port");
1609 uint32_t max_queue_size =
getUint32(client_config,
"max-queue-size");
1612 getProtocol(client_config,
"ncr-protocol");
1615 getFormat(client_config,
"ncr-format");
1618 if (sender_ip_str.empty()) {
1625 }
catch (
const std::exception& ex) {
1627 <<
") specified for parameter 'sender-ip' (" 1628 <<
getPosition(
"sender-ip", client_config) <<
")");
1638 <<
" is not supported. (" 1639 <<
getPosition(
"ncr-format", client_config) <<
")");
1645 <<
" is not supported. (" 1646 <<
getPosition(
"ncr-protocol", client_config) <<
")");
1651 "D2ClientConfig error: address family mismatch: " 1652 <<
"server-ip: " << server_ip.
toText()
1653 <<
" is: " << (server_ip.
isV4() ?
"IPv4" :
"IPv6")
1654 <<
" while sender-ip: " << sender_ip.
toText()
1655 <<
" is: " << (sender_ip.
isV4() ?
"IPv4" :
"IPv6")
1656 <<
" (" <<
getPosition(
"sender-ip", client_config) <<
")");
1659 if (server_ip == sender_ip && server_port == sender_port) {
1661 "D2ClientConfig error: server and sender cannot" 1662 " share the exact same IP address/port: " 1663 << server_ip.
toText() <<
"/" << server_port
1664 <<
" (" <<
getPosition(
"sender-ip", client_config) <<
")");
1677 }
catch (
const std::exception& ex) {
1679 << client_config->getPosition() <<
")");
1685 new_config->setContext(user_context);
1688 return (new_config);
void parseDdnsParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to DDNS behavior.
static const size_t MAX_SNAME_LEN
length of the SNAME field in DHCPv4 message
IfacePtr getIface(int ifindex)
Returns interface specified interface index.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
virtual boost::shared_ptr< PoolsListParser > createPoolsListParser() const
Returns an instance of the Pools4ListParser 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...
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
D2ClientConfigPtr parse(isc::data::ConstElementPtr d2_client_cfg)
Parses a given dhcp-ddns element into D2ClientConfig.
void validateResvs(const Subnet6Ptr &subnet, ConstHostPtr host)
Verifies host reservation addresses are in the subnet range.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
isc::dhcp::Pool6Ptr pool_
Pointer to the created pool object.
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
Base class representing a DHCP option definition.
NameChangeProtocol stringToNcrProtocol(const std::string &protocol_str)
Function which converts text labels to NameChangeProtocol enums.
static const isc::data::SimpleKeywords OPTION4_DEF_PARAMETERS
This table defines all option definition parameters.
this class parses a single subnet
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
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=0)
Factory function creating an instance of the Subnet4.
static const isc::data::SimpleDefaults D2_CLIENT_CONFIG_DEFAULTS
Defaults for the D2 client configuration.
std::vector< SimpleDefault > SimpleDefaults
This specifies all default values in a given scope (e.g. a subnet).
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
void parseCommon(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses common parameters.
static const size_t MAX_FILE_LEN
length of the FILE field in DHCPv4 message
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...
static bool validateName(const std::string &name)
Checks that the provided option space name is valid.
static CfgMgr & instance()
returns a single instance of Configuration Manager
Subnets6ListConfigParser(bool check_iface=true)
constructor
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
virtual boost::shared_ptr< OptionDataListParser > createOptionDataListParser() const
Returns an instance of the OptionDataListParser to be used in parsing the option-data structure...
boost::shared_ptr< Option > OptionPtr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
virtual boost::shared_ptr< PoolsListParser > createPoolsListParser() const
Returns an instance of the Pools6ListParser to be used in parsing the address pools.
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
void setControlSocketInfo(const isc::data::ConstElementPtr &control_socket)
Sets information about the control socket.
const isc::log::MessageID DHCPSRV_CFGMGR_RELAY_IP_ADDRESS_DEPRECATED
void clear()
Removes any configured MAC/Hardware address sources.
Universe
defines option universe DHCPv4 or DHCPv6
T get() const
Retrieves the encapsulated value.
void add(uint32_t source)
Adds additional MAC/hardware address acquisition.
the lease contains IPv6 prefix (for prefix delegation)
void parseCacheParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to lease cache settings.
boost::shared_ptr< Element > ElementPtr
virtual boost::shared_ptr< Subnet4ConfigParser > createSubnetConfigParser() const
Returns an instance of the Subnet4ConfigParser to be used in parsing the subnets. ...
std::vector< HostPtr > HostCollection
Collection of the Host objects.
CfgOptionPtr options_
Pointer to the options configuration.
static void setRuntimeOptionDefs(const OptionDefSpaceContainer &defs)
Copies option definitions created at runtime.
Subnet4Ptr parse(data::ConstElementPtr subnet)
Parses a single IPv4 subnet configuration and adds to the Configuration Manager.
NameChangeFormat
Defines the list of data wire formats supported.
A configuration holder for IPv4 subnet.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
OptionDefinitionPtr parse(isc::data::ConstElementPtr option_def)
Parses an entry that describes single option definition.
virtual boost::shared_ptr< OptionDataListParser > createOptionDataListParser() const
Returns an instance of the OptionDataListParser to be used in parsing the option-data structure...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
PdPoolParser()
Constructor.
const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET6
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Specialization of the Network object for DHCPv6 case.
PoolStoragePtr pools_
Storage for pools belonging to this subnet.
static const isc::data::SimpleKeywords SUBNET4_PARAMETERS
This table defines all subnet parameters for DHCPv4.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
void parsePdAllocatorParams(const data::ConstElementPtr &network_data, Network6Ptr &network)
Parses parameters pertaining to prefix delegation allocator selection.
void parse(const SubnetID &subnet_id, isc::data::ConstElementPtr hr_list, HostCollection &hosts_list)
Parses a list of host reservation entries for a subnet.
Holds optional information about relay.
OptionDefListParser(const uint16_t address_family)
Constructor.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
static const isc::data::SimpleKeywords PD_POOL6_PARAMETERS
This table defines all prefix delegation pool parameters.
static const isc::data::SimpleKeywords SUBNET6_PARAMETERS
This table defines all subnet parameters for DHCPv6.
Subnets4ListConfigParser(bool check_iface=true)
constructor
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.
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 createSubnet(isc::data::ConstElementPtr data)
Create a new subnet using a data from child parsers.
std::pair< IPv6ResrvIterator, IPv6ResrvIterator > IPv6ResrvRange
Pool information for IPv6 addresses and prefixes.
Represents option data configuration for the DHCP server.
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.
vector< string > tokens(const std::string &text, const std::string &delim, bool escape)
Split String into Tokens.
An exception that is thrown if an error occurs while configuring the D2 DHCP DDNS client...
Wrapper class that holds MAC/hardware address sources.
const int DHCPSRV_DBG_TRACE_DETAIL
Additional information.
parser for additional relay information
To be removed. Please use ConfigError instead.
Acts as a storage vault for D2 client configuration.
uint8_t getUint8(ConstElementPtr scope, const std::string &name)
Get an uint8_t value.
void parseTeePercents(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to "percent" timers settings.
Parser for a single option definition.
A generic exception that is thrown when an unexpected error condition occurs.
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.
Common interface representing a network to which the DHCP clients are connected.
static size_t setDefaults(isc::data::ElementPtr scope, const SimpleDefaults &default_values)
Sets the default values.
bool isV4Zero() const
Convenience function to check if it is an IPv4 zero address.
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
boost::shared_ptr< SubnetAllocationState > SubnetAllocationStatePtr
static PoolRandomAllocationStatePtr create(const PoolPtr &pool)
Factory function creating the state instance from pool.
static void moveReservationMode(isc::data::ElementPtr config)
Moves deprecated reservation-mode parameter to new reservations flags.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
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=0)
Factory function creating an instance of the Subnet4.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
const isc::log::MessageID DHCPSRV_CFGMGR_NEW_SUBNET4
static const isc::data::SimpleKeywords POOL6_PARAMETERS
This table defines all pool parameters.
void parseAllocatorParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to allocator selection.
the lease contains temporary IPv6 address
void initSubnet(data::ConstElementPtr params, asiolink::IOAddress addr, uint8_t len)
Instantiates the IPv4 Subnet based on a given IPv4 address and prefix length.
bool isV4() const
Convenience function to check for an IPv4 address.
uint32_t getUint32(isc::data::ConstElementPtr scope, const std::string &name)
Returns a value converted to uint32_t.
the lease contains non-temporary IPv6 address
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
isc::data::ConstElementPtr client_class_
Client class (a client has to belong to to use this pd-pool)
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.
Specifies current DHCP configuration.
SubnetConfigParser(uint16_t family, bool check_iface=true)
constructor
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
CfgOptionPtr options_
A storage for pool specific option values.
This is a base class for exceptions thrown from the DNS library module.
static isc::asiolink::IOAddress getAddress(const ConstElementPtr &scope, const std::string &name)
Returns a IOAddress parameter from a scope.
Defines the logger used by the top-level component of kea-lfc.
virtual boost::shared_ptr< PoolParser > createPoolConfigParser() const
Returns an instance of the Pool6Parser to be used in parsing the address pools.
virtual boost::shared_ptr< PoolParser > createPoolConfigParser() const
Returns an instance of the Pool4Parser to be used in parsing the address pools.
std::string toText() const
Convert the address to a string.
bool check_iface_
Check if the specified interface exists in the system.
static const isc::data::SimpleKeywords POOL4_PARAMETERS
This table defines all pool parameters.
ReplaceClientNameMode
Defines the client name replacement modes.
A configuration holder for IPv6 subnet.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
PoolPtr poolMaker(asiolink::IOAddress &addr, uint32_t len, int32_t ignored)
Creates a Pool4 object given a IPv4 prefix and the prefix length.
target_type getAndConvert(isc::data::ConstElementPtr scope, const std::string &name, const std::string &type_name)
Returns a converted value from a scope.
SubnetPtr parse(isc::data::ConstElementPtr subnet)
parses a subnet description and returns Subnet{4,6} structure
bool check_iface_
Check if the specified interface exists in the system.
#define DHCP6_OPTION_SPACE
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
Subnet6Ptr parse(data::ConstElementPtr subnet)
Parses a single IPv6 subnet configuration and adds to the Configuration Manager.
void parse(const isc::dhcp::Network::RelayInfoPtr &relay_info, isc::data::ConstElementPtr relay_elem)
parses the actual relay parameters
static IfaceMgr & instance()
IfaceMgr is a singleton class.
isc::dhcp::SubnetPtr subnet_
Pointer to the created subnet object.
#define DHCP4_OPTION_SPACE
global std option spaces
PoolPtr poolMaker(asiolink::IOAddress &addr, uint32_t len, int32_t ptype)
Creates a Pool6 object given a IPv6 prefix and the prefix length.
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
The Element class represents a piece of data, used by the command channel and configuration parts...
static const isc::data::SimpleKeywords OPTION6_DEF_PARAMETERS
This table defines all option definition parameters.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
isc::dhcp::Network::RelayInfoPtr relay_info_
Pointer to relay information.
void parse(PoolStoragePtr pools, data::ConstElementPtr pools_list)
parses the actual structure
const isc::util::Triplet< uint32_t > parseIntTriplet(const data::ConstElementPtr &scope, const std::string &name)
Parses an integer triplet.
NameChangeProtocol
Defines the list of socket protocols supported.
boost::shared_ptr< PoolStorage > PoolStoragePtr
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
static size_t setAllDefaults(isc::data::ConstElementPtr d2_config)
Sets all defaults for D2 client configuration.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
NameChangeFormat stringToNcrFormat(const std::string &fmt_str)
Function which converts labels to NameChangeFormat enum values.
isc::data::ConstElementPtr user_context_
User context (optional, may be null)
static PoolIterativeAllocationStatePtr create(const PoolPtr &pool)
Factory function creating the state instance from pool.
string trim(const string &instring)
Trim Leading and Trailing Spaces.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
virtual boost::shared_ptr< Subnet6ConfigParser > createSubnetConfigParser() const
Returns an instance of the Subnet6ConfigParser to be used in parsing the subnets. ...
Subnet4ConfigParser(bool check_iface=true)
Constructor.
Parser for a list of host reservations for a subnet.
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
void parse(CfgOptionDefPtr cfg, isc::data::ConstElementPtr def_list)
Parses a list of option definitions, create them and store in cfg.
const isc::log::MessageID DHCPSRV_CFGMGR_OPTION_DUPLICATE
virtual void parse(PoolStoragePtr pools, isc::data::ConstElementPtr pool_structure, const uint16_t address_family)
parses the actual structure
The IOAddress class represents an IP addresses (version agnostic)
Subnet6ConfigParser(bool check_iface=true)
Constructor.
bool empty() const
Checks if the encapsulated value is empty.
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
virtual boost::shared_ptr< PdPoolParser > createPdPoolConfigParser() const
Returns an instance of the PdPoolParser to be used in parsing the prefix delegation pools...
bool check_iface_
Check if the specified interface exists in the system.
void parse(PoolStoragePtr pools, data::ConstElementPtr pd_pool_list)
Parse configuration entries.
void validateResv(const Subnet4Ptr &subnet, ConstHostPtr host)
Verifies the host reservation address is in the subnet range.
void parse(PoolStoragePtr pools, data::ConstElementPtr pd_pool_)
Builds a prefix delegation pool from the given configuration.
std::vector< PoolPtr > PoolStorage
a collection of pools
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
RelayInfoParser(const isc::dhcp::Option::Universe &family)
constructor
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Pool information for IPv4 addresses.
void parse(PoolStoragePtr pools, data::ConstElementPtr pools_list)
parses the actual structure
short getFamily() const
Returns the address family.
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
virtual void duplicateOptionWarning(uint32_t code, asiolink::IOAddress &addr)
Issues a DHCP6 server specific warning regarding duplicate subnet options.