24#include <boost/algorithm/string.hpp>
25#include <boost/foreach.hpp>
26#include <boost/lexical_cast.hpp>
27#include <boost/scoped_ptr.hpp>
55 std::string source_str = source_elem->stringValue();
58 mac_sources.
add(source);
62 <<
"' was specified twice (" << value->getPosition() <<
")");
63 }
catch (
const std::exception& ex) {
65 << source_str <<
"' to any recognized MAC source:"
66 << ex.
what() <<
" (" << value->getPosition() <<
")");
82 if (value->getType() != Element::map) {
85 ", i.e. a structure defined within { }");
90template<
typename SearchKey>
92OptionDataParser::findOptionDefinition(
const std::string& option_space,
93 const SearchKey& search_key)
const {
110 ->get(option_space, search_key);
119 : address_family_(address_family) {
126 if (address_family_ == AF_INET) {
133 std::string name =
getString(option_def,
"name");
134 int64_t code64 =
getInteger(option_def,
"code");
135 std::string type =
getString(option_def,
"type");
139 bool array_type =
getBoolean(option_def,
"array");
140 std::string record_types =
getString(option_def,
"record-types");
141 std::string space =
getString(option_def,
"space");
142 std::string encapsulates =
getString(option_def,
"encapsulate");
149 }
else if (address_family_ == AF_INET &&
150 code64 > std::numeric_limits<uint8_t>::max()) {
152 <<
"', it must not be greater than '"
153 <<
static_cast<int>(std::numeric_limits<uint8_t>::max())
154 <<
"' (" <<
getPosition(
"code", option_def) <<
")");
155 }
else if (address_family_ == AF_INET6 &&
156 code64 > std::numeric_limits<uint16_t>::max()) {
158 <<
"', it must not be greater than '"
159 << std::numeric_limits<uint16_t>::max()
160 <<
"' (" <<
getPosition(
"code", option_def) <<
")");
162 uint32_t code =
static_cast<uint32_t
>(code64);
176 <<
"reserved for PAD ("
180 <<
"reserved for END ("
189 <<
"reserved value ("
198 if (!encapsulates.empty()) {
202 << name <<
"', comprising an array of data"
203 <<
" fields may not encapsulate any option space ("
204 << option_def->getPosition() <<
")");
206 }
else if (encapsulates == space) {
208 <<
" an option space it belongs to: '"
209 << space <<
"." << name <<
"' is set to"
210 <<
" encapsulate '" << space <<
"' ("
211 << option_def->getPosition() <<
")");
215 encapsulates.c_str()));
224 def->setContext(user_context);
228 std::vector<std::string> record_tokens =
232 BOOST_FOREACH(std::string record_type, record_tokens) {
235 if (!record_type.empty()) {
236 def->addRecordField(record_type);
240 <<
" specified for the option definition: "
242 <<
getPosition(
"record-types", option_def) <<
")");
249 }
catch (
const std::exception& ex) {
251 <<
" (" << option_def->getPosition() <<
")");
261 : address_family_(address_family) {
266 if (!option_def_list) {
269 <<
" option definitions is NULL ("
270 << option_def_list->getPosition() <<
")");
274 BOOST_FOREACH(
ConstElementPtr option_def, option_def_list->listValue()) {
278 }
catch (
const std::exception& ex) {
281 << option_def->getPosition() <<
")");
299 if (relay_elem->getType() != Element::map) {
306 if (address && addresses) {
308 "specify either ip-address or ip-addresses, not both");
311 if (!address && !addresses) {
320 relay_elem, relay_info);
327 if (addresses->getType() != Element::list) {
329 "(" <<
getPosition(
"ip-addresses", relay_elem) <<
")");
332 BOOST_FOREACH(
ConstElementPtr address_element, addresses->listValue()) {
333 addAddress(
"ip-addresses", address_element->stringValue(),
334 relay_elem, relay_info);
340 const std::string& address_str,
343 boost::scoped_ptr<isc::asiolink::IOAddress> ip;
346 }
catch (
const std::exception& ex) {
348 <<
" is not a valid: "
365 relay_info->addAddress(*ip);
366 }
catch (
const std::exception& ex) {
368 <<
"to relay info: " << ex.
what()
378 const uint16_t address_family) {
380 if (address_family == AF_INET) {
390 "definition: (" << pool_structure->getPosition() <<
")");
396 string txt = text_pool->stringValue();
399 boost::erase_all(txt,
" ");
400 boost::erase_all(txt,
"\t");
405 size_t pos = txt.find(
"/");
406 if (pos != string::npos) {
413 string prefix_len = txt.substr(pos + 1);
425 int val_len = boost::lexical_cast<int>(prefix_len);
426 if ((val_len < std::numeric_limits<uint8_t>::min()) ||
427 (val_len > std::numeric_limits<uint8_t>::max())) {
431 len =
static_cast<uint8_t
>(val_len);
434 "definition: " << txt <<
" ("
435 << text_pool->getPosition() <<
")");
440 pools->push_back(pool);
441 }
catch (
const std::exception& ex) {
443 << txt <<
" (" << text_pool->getPosition() <<
")");
452 if (pos != string::npos) {
459 "definition: " << txt <<
" ("
460 << text_pool->getPosition() <<
")");
465 pools->push_back(pool);
466 }
catch (
const std::exception& ex) {
468 << txt <<
" (" << text_pool->getPosition() <<
")");
475 << text_pool->stringValue() <<
476 ". There are two acceptable formats <min address-max address>"
478 << text_pool->getPosition() <<
")");
485 if (user_context->getType() != Element::map) {
487 << user_context->getPosition() <<
")");
489 pool->setContext(user_context);
498 option_parser.
parse(cfg, option_data);
499 }
catch (
const std::exception& ex) {
501 <<
" (" << option_data->getPosition() <<
")");
508 string cclass = client_class->stringValue();
509 if (!cclass.empty()) {
510 pool->allowClientClass(cclass);
515 ConstElementPtr class_list = pool_structure->get(
"require-client-classes");
517 const std::vector<data::ElementPtr>& classes = class_list->listValue();
518 for (
auto cclass = classes.cbegin();
519 cclass != classes.cend(); ++cclass) {
520 if (((*cclass)->getType() != Element::string) ||
521 (*cclass)->stringValue().empty()) {
523 << (*cclass)->getPosition() <<
")");
525 pool->requireClientClass((*cclass)->stringValue());
548 parser.
parse(pools, pool, AF_INET);
556 address_family_(family),
558 check_iface_(check_iface) {
566 if (options_params) {
580 createSubnet(subnet);
581 }
catch (
const std::exception& ex) {
583 "subnet configuration failed: " << ex.
what());
591 std::string subnet_txt;
593 subnet_txt =
getString(params,
"subnet");
594 }
catch (
const DhcpConfigError &) {
597 "mandatory 'subnet' parameter is missing for a subnet being"
598 " configured (" << params->getPosition() <<
")");
602 boost::erase_all(subnet_txt,
" ");
603 boost::erase_all(subnet_txt,
"\t");
610 size_t pos = subnet_txt.find(
"/");
611 if (pos == string::npos) {
614 "Invalid subnet syntax (prefix/len expected):" << subnet_txt
615 <<
" (" << elem->getPosition() <<
")");
625 len = boost::lexical_cast<unsigned int>(subnet_txt.substr(pos + 1));
626 }
catch (
const boost::bad_lexical_cast&) {
628 isc_throw(DhcpConfigError,
"prefix length: '" <<
629 subnet_txt.substr(pos+1) <<
"' is not an integer ("
630 << elem->getPosition() <<
")");
634 if ((addr.isV6() && len > 128) ||
635 (addr.isV4() && len > 32)) {
638 "Invalid prefix length specified for subnet: " << len
639 <<
" (" << elem->getPosition() <<
")");
646 for (PoolStorage::iterator it =
pools_->begin(); it !=
pools_->end();
650 }
catch (
const BadValue& ex) {
654 ex.what() <<
" (" << params->getPosition() <<
")");
661 if (user_context->getType() != Element::map) {
663 << user_context->getPosition() <<
")");
665 subnet_->setContext(user_context);
700 "Failed to create an IPv4 subnet (" <<
701 subnet->getPosition() <<
")");
708 "Invalid Subnet4 cast in Subnet4ConfigParser::parse");
722 for (
auto h = hosts.begin(); h != hosts.end(); ++h) {
746 mutable_params = boost::const_pointer_cast<Element>(params);
751 NetworkPtr network = boost::dynamic_pointer_cast<Network>(subnet4);
754 std::ostringstream output;
755 output << addr <<
"/" <<
static_cast<int>(len) <<
" with params: ";
757 bool has_renew = !subnet4->getT1().unspecified();
758 bool has_rebind = !subnet4->getT2().unspecified();
764 renew = subnet4->getT1().get();
765 output <<
"t1=" << renew <<
", ";
768 rebind = subnet4->getT2().get();
769 output <<
"t2=" << rebind <<
", ";
772 if (has_renew && has_rebind && (renew > rebind)) {
774 <<
") is greater than the value of rebind-timer ("
778 if (!subnet4->getValid().unspecified()) {
779 output <<
"valid-lifetime=" << subnet4->getValid().get();
785 if (params->contains(
"match-client-id")) {
786 bool match_client_id =
getBoolean(params,
"match-client-id");
787 subnet4->setMatchClientId(match_client_id);
791 if (params->contains(
"authoritative")) {
792 bool authoritative =
getBoolean(params,
"authoritative");
793 subnet4->setAuthoritative(authoritative);
799 if (params->contains(
"next-server")) {
802 next_server =
getString(params,
"next-server");
803 if (!next_server.empty()) {
804 subnet4->setSiaddr(
IOAddress(next_server));
810 pos = next->getPosition().str();
812 pos = params->getPosition().str();
815 << next_server <<
"(" << pos <<
")");
820 if (params->contains(
"server-hostname")) {
821 std::string sname =
getString(params,
"server-hostname");
822 if (!sname.empty()) {
827 << sname.length() <<
" ("
828 <<
error->getPosition() <<
")");
830 subnet4->setSname(sname);
835 if (params->contains(
"boot-file-name")) {
836 std::string filename =
getString(params,
"boot-file-name");
837 if (!filename.empty()) {
842 << filename.length() <<
" ("
843 <<
error->getPosition() <<
")");
845 subnet4->setFilename(filename);
851 if (params->contains(
"interface")) {
852 std::string iface =
getString(params,
"interface");
853 if (!iface.empty()) {
857 <<
" for subnet " << subnet4->toText()
858 <<
" is not present in the system ("
859 <<
error->getPosition() <<
")");
862 subnet4->setIface(iface);
867 if (params->contains(
"client-class")) {
868 string client_class =
getString(params,
"client-class");
869 if (!client_class.empty()) {
870 subnet4->allowClientClass(client_class);
877 const std::vector<data::ElementPtr>& classes = class_list->listValue();
878 for (
auto cclass = classes.cbegin();
879 cclass != classes.cend(); ++cclass) {
880 if (((*cclass)->getType() != Element::string) ||
881 (*cclass)->stringValue().empty()) {
883 << (*cclass)->getPosition() <<
")");
885 subnet4->requireClientClass((*cclass)->stringValue());
890 if (params->contains(
"4o6-interface")) {
891 string iface4o6 =
getString(params,
"4o6-interface");
892 if (!iface4o6.empty()) {
893 subnet4->get4o6().setIface4o6(iface4o6);
894 subnet4->get4o6().enabled(
true);
899 if (params->contains(
"4o6-subnet")) {
900 string subnet4o6 =
getString(params,
"4o6-subnet");
901 if (!subnet4o6.empty()) {
902 size_t slash = subnet4o6.find(
"/");
903 if (slash == std::string::npos) {
905 << subnet4o6 <<
", expected format: prefix6/length");
907 string prefix = subnet4o6.substr(0, slash);
908 string lenstr = subnet4o6.substr(slash + 1);
912 len = boost::lexical_cast<unsigned int>(lenstr.c_str());
913 }
catch (
const boost::bad_lexical_cast &) {
915 "4o6-subnet parameter: " << subnet4o6 <<
", expected 0..128 value");
917 subnet4->get4o6().setSubnet4o6(
IOAddress(prefix), len);
918 subnet4->get4o6().enabled(
true);
923 if (params->contains(
"4o6-interface-id")) {
924 std::string ifaceid =
getString(params,
"4o6-interface-id");
925 if (!ifaceid.empty()) {
928 subnet4->get4o6().setInterfaceId(opt);
929 subnet4->get4o6().enabled(
true);
941 options_->copyTo(*subnet4->getCfgOption());
955 const IOAddress& address = host->getIPv4Reservation();
956 if (!address.
isV4Zero() && !subnet->inRange(address)) {
958 <<
"' is not within the IPv4 subnet '"
959 << subnet->
toText() <<
"'");
966 : check_iface_(check_iface) {
973 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
983 cfg->getCfgSubnets4()->add(subnet);
985 }
catch (
const std::exception& ex) {
987 << subnet_json->getPosition() <<
")");
998 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
1004 auto ret = subnets.insert(subnet);
1007 "can't store subnet because of conflict");
1010 }
catch (
const std::exception& ex) {
1012 << subnet_json->getPosition() <<
")");
1026 (ptype), addr, len)));
1033 (ptype), min, max)));
1043 parser.
parse(pools, pool, AF_INET6);
1056 std::string addr_str =
getString(pd_pool_,
"prefix");
1058 uint8_t prefix_len =
getUint8(pd_pool_,
"prefix-len");
1060 uint8_t delegated_len =
getUint8(pd_pool_,
"delegated-len");
1062 std::string excluded_prefix_str =
"::";
1063 if (pd_pool_->contains(
"excluded-prefix")) {
1064 excluded_prefix_str =
getString(pd_pool_,
"excluded-prefix");
1067 uint8_t excluded_prefix_len = 0;
1068 if (pd_pool_->contains(
"excluded-prefix-len")) {
1069 excluded_prefix_len =
getUint8(pd_pool_,
"excluded-prefix-len");
1075 opts_parser.
parse(options_, option_data);
1080 user_context_ = user_context;
1085 client_class_ = client_class;
1098 excluded_prefix_len));
1100 options_->copyTo(*pool_->getCfgOption());
1101 }
catch (
const std::exception& ex) {
1106 <<
" (" << pd_pool_->getPosition() <<
")");
1109 if (user_context_) {
1110 pool_->setContext(user_context_);
1113 if (client_class_) {
1114 string cclass = client_class_->stringValue();
1115 if (!cclass.empty()) {
1116 pool_->allowClientClass(cclass);
1121 const std::vector<data::ElementPtr>& classes = class_list->listValue();
1122 for (
auto cclass = classes.cbegin();
1123 cclass != classes.cend(); ++cclass) {
1124 if (((*cclass)->getType() != Element::string) ||
1125 (*cclass)->stringValue().empty()) {
1127 << (*cclass)->getPosition() <<
")");
1129 pool_->requireClientClass((*cclass)->stringValue());
1134 pools->push_back(pool_);
1144 parser.
parse(pools, pd_pool);
1176 "Failed to create an IPv6 subnet (" <<
1177 subnet->getPosition() <<
")");
1184 "Invalid Subnet6 cast in Subnet6ConfigParser::parse");
1198 for (
auto h = hosts.begin(); h != hosts.end(); ++h) {
1212 .arg(code).arg(addr.
toText());
1226 if (params->contains(
"rapid-commit")) {
1227 rapid_commit =
getBoolean(params,
"rapid-commit");
1243 mutable_params = boost::const_pointer_cast<Element>(params);
1256 std::ostringstream output;
1257 output << addr <<
"/" <<
static_cast<int>(len) <<
" with params: ";
1260 bool has_renew = !subnet6->
getT1().unspecified();
1261 bool has_rebind = !subnet6->
getT2().unspecified();
1263 int64_t rebind = -1;
1266 renew = subnet6->
getT1().get();
1267 output <<
"t1=" << renew <<
", ";
1270 rebind = subnet6->
getT2().get();
1271 output <<
"t2=" << rebind <<
", ";
1274 if (has_renew && has_rebind && (renew > rebind)) {
1276 <<
") is greater than the value of rebind-timer ("
1281 output <<
"preferred-lifetime=" << subnet6->
getPreferred().get() <<
", ";
1283 if (!subnet6->
getValid().unspecified()) {
1284 output <<
"valid-lifetime=" << subnet6->
getValid().get();
1287 output <<
", rapid-commit is "
1296 if (params->contains(
"interface-id")) {
1297 ifaceid =
getString(params,
"interface-id");
1301 if (params->contains(
"interface")) {
1311 "parser error: interface (defined for locally reachable "
1312 "subnets) and interface-id (defined for subnets reachable"
1313 " via relays) cannot be defined at the same time for "
1314 "subnet " << addr <<
"/" << (
int)len <<
"("
1315 << params->getPosition() <<
")");
1320 std::string ifaceid_value = ifaceid.
get();
1321 OptionBuffer tmp(ifaceid_value.begin(), ifaceid_value.end());
1332 <<
" for subnet " << subnet6->
toText()
1333 <<
" is not present in the system ("
1334 <<
error->getPosition() <<
")");
1341 if (params->contains(
"client-class")) {
1342 string client_class =
getString(params,
"client-class");
1343 if (!client_class.empty()) {
1348 if (params->contains(
"require-client-classes")) {
1352 const std::vector<data::ElementPtr>& classes = class_list->listValue();
1353 for (
auto cclass = classes.cbegin();
1354 cclass != classes.cend(); ++cclass) {
1355 if (((*cclass)->getType() != Element::string) ||
1356 (*cclass)->stringValue().empty()) {
1358 << (*cclass)->getPosition() <<
")");
1384 for (
auto it = range.first; it != range.second; ++it) {
1385 const IOAddress& address = it->second.getPrefix();
1386 if (!subnet->inRange(address)) {
1388 <<
"' is not within the IPv6 subnet '"
1389 << subnet->
toText() <<
"'");
1397 : check_iface_(check_iface) {
1404 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
1413 cfg->getCfgSubnets6()->add(subnet);
1415 }
catch (
const std::exception& ex) {
1417 << subnet_json->getPosition() <<
")");
1427 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
1433 auto ret = subnets.insert(subnet);
1436 "can't store subnet because of conflict");
1439 }
catch (
const std::exception& ex) {
1441 << subnet_json->getPosition() <<
")");
1453 const std::string& name) {
1456 (scope, name,
"NameChangeRequest protocol"));
1461 const std::string& name) {
1464 (scope, name,
"NameChangeRequest format"));
1469 const std::string& name) {
1472 (scope, name,
"ReplaceClientName mode"));
1480 bool enable_updates =
getBoolean(client_config,
"enable-updates");
1484 uint32_t server_port =
getUint32(client_config,
"server-port");
1486 std::string sender_ip_str =
getString(client_config,
"sender-ip");
1488 uint32_t sender_port =
getUint32(client_config,
"sender-port");
1490 uint32_t max_queue_size =
getUint32(client_config,
"max-queue-size");
1493 getProtocol(client_config,
"ncr-protocol");
1496 getFormat(client_config,
"ncr-format");
1499 if (sender_ip_str.empty()) {
1506 }
catch (
const std::exception& ex) {
1508 <<
") specified for parameter 'sender-ip' ("
1509 <<
getPosition(
"sender-ip", client_config) <<
")");
1519 <<
" is not supported. ("
1520 <<
getPosition(
"ncr-format", client_config) <<
")");
1526 <<
" is not supported. ("
1527 <<
getPosition(
"ncr-protocol", client_config) <<
")");
1532 "D2ClientConfig error: address family mismatch: "
1533 <<
"server-ip: " << server_ip.
toText()
1534 <<
" is: " << (server_ip.
isV4() ?
"IPv4" :
"IPv6")
1535 <<
" while sender-ip: " << sender_ip.
toText()
1536 <<
" is: " << (sender_ip.
isV4() ?
"IPv4" :
"IPv6")
1537 <<
" (" <<
getPosition(
"sender-ip", client_config) <<
")");
1540 if (server_ip == sender_ip && server_port == sender_port) {
1542 "D2ClientConfig error: server and sender cannot"
1543 " share the exact same IP address/port: "
1544 << server_ip.
toText() <<
"/" << server_port
1545 <<
" (" <<
getPosition(
"sender-ip", client_config) <<
")");
1558 }
catch (
const std::exception& ex) {
1560 << client_config->getPosition() <<
")");
1566 new_config->setContext(user_context);
1575 {
"server-ip", Element::string,
"127.0.0.1" },
1576 {
"server-port", Element::integer,
"53001" },
1579 {
"sender-ip", Element::string,
"" },
1580 {
"sender-port", Element::integer,
"0" },
1581 {
"max-queue-size", Element::integer,
"1024" },
1582 {
"ncr-protocol", Element::string,
"UDP" },
1583 {
"ncr-format", Element::string,
"JSON" }
1588 ElementPtr mutable_d2 = boost::const_pointer_cast<Element>(d2_config);
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.
bool isV4Zero() const
Convenience function to check if it is an IPv4 zero address.
std::string toText() const
Convert the address to a string.
bool isV4() const
Convenience function to check for an IPv4 address.
short getFamily() const
Returns the address family.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
const dhcp::Triplet< uint32_t > parseIntTriplet(const data::ConstElementPtr &scope, const std::string &name)
Parses an integer triplet.
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.
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.
void parseCacheParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to lease cache settings.
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.
Represents selection of interfaces for DHCP server.
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
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Represents option data configuration for the DHCP server.
void parse(SrvConfig &srv_cfg, isc::data::ConstElementPtr value)
"Parses" control-socket 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.
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.
static void setRuntimeOptionDefs(const OptionDefSpaceContainer &defs)
Copies option definitions created at runtime.
static OptionDefinitionPtr getOptionDef(const std::string &space, const uint16_t code)
Return the first option definition matching a particular option code.
static OptionDefinitionPtr getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id, const uint16_t code)
Returns vendor option definition for a given vendor-id and code.
static uint32_t optionSpaceToVendorId(const std::string &option_space)
Converts option space name to vendor id.
void parse(CfgMACSource &mac_sources, isc::data::ConstElementPtr value)
parses parameters value
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
util::Optional< bool > getRapidCommit(const Inheritance &inheritance=Inheritance::ALL) const
Returns boolean value indicating that the Rapid Commit option is supported or unsupported for the sub...
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Holds optional information about relay.
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
void requireClientClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to classes required to be evaluated.
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Sets the supported class to class class_name.
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Parser for option data values within a subnet.
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
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
Parser for IPv6 prefix delegation definitions.
PdPoolParser()
Constructor.
void parse(PoolStoragePtr pools, data::ConstElementPtr pd_pool_)
Builds a prefix delegation pool from the given configuration.
Parser for a list of 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
Parser for IPv4 pool definitions.
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.
Parser for IPv6 pool definitions.
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 void parse(PoolStoragePtr pools, isc::data::ConstElementPtr pool_structure, const uint16_t address_family)
parses the actual structure
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.
Specialization of the pool list parser for DHCPv4.
void parse(PoolStoragePtr pools, data::ConstElementPtr pools_list)
parses the actual structure
Specialization of the pool list parser for DHCPv6.
void parse(PoolStoragePtr pools, data::ConstElementPtr pools_list)
parses the actual structure
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.
void setControlSocketInfo(const isc::data::ConstElementPtr &control_socket)
Sets information about the control socket.
Subnet4ConfigParser(bool check_iface=true)
Constructor.
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)
Parses a single IPv4 subnet configuration and adds to the Configuration Manager.
A configuration holder for IPv4 subnet.
virtual void duplicate_option_warning(uint32_t code, asiolink::IOAddress &addr)
Issues a DHCP6 server specific warning regarding duplicate subnet options.
Subnet6Ptr parse(data::ConstElementPtr subnet)
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.
void validateResvs(const Subnet6Ptr &subnet, ConstHostPtr host)
Verifies host reservation addresses are in the subnet range.
Subnet6ConfigParser(bool check_iface=true)
Constructor.
A configuration holder for IPv6 subnet.
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.
CfgOptionPtr options_
Pointer to the options configuration.
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.
SubnetPtr parse(isc::data::ConstElementPtr subnet)
parses a subnet description and returns Subnet{4,6} structure
isc::dhcp::Network::RelayInfoPtr relay_info_
Pointer to relay information.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
bool check_iface_
Check if the specified interface exists in the system.
PoolStoragePtr pools_
Storage for pools belonging to this subnet.
virtual std::string toText() const
Returns textual representation of the subnet (e.g.
bool check_iface_
Check if the specified interface exists in the system.
Subnets4ListConfigParser(bool check_iface=true)
constructor
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
Subnets6ListConfigParser(bool check_iface=true)
constructor
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
bool check_iface_
Check if the specified interface exists in the system.
This template specifies a parameter value.
A template representing an optional value.
T get() const
Retrieves the encapsulated value.
bool empty() const
Checks if the encapsulated value is empty.
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
#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.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
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< 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.
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.
const isc::log::MessageID DHCPSRV_CFGMGR_RELAY_IP_ADDRESS_DEPRECATED
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.
const int DHCPSRV_DBG_TRACE_DETAIL
Additional information.
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
Unique identifier for a subnet (both v4 and v6)
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
string trim(const string &instring)
Trim Leading and Trailing Spaces.
vector< string > tokens(const std::string &text, const std::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.