18 #include <boost/algorithm/string.hpp> 19 #include <boost/foreach.hpp> 20 #include <boost/lexical_cast.hpp> 21 #include <boost/scoped_ptr.hpp> 48 std::string source_str = source_elem->stringValue();
50 source = CfgMACSource::MACSourceFromText(source_str);
51 mac_sources.
add(source);
55 <<
"' was specified twice (" << value->getPosition() <<
")");
56 }
catch (
const std::exception& ex) {
58 << source_str <<
"' to any recognized MAC source:" 59 << ex.
what() <<
" (" << value->getPosition() <<
")");
75 if (value->getType() != Element::map) {
78 ", i.e. a structure defined within { }");
83 template<
typename SearchKey>
85 OptionDataParser::findOptionDefinition(
const std::string& option_space,
86 const SearchKey& search_key)
const {
92 uint32_t vendor_id = LibDHCP::optionSpaceToVendorId(option_space);
95 Option::V4 : Option::V6;
96 def = LibDHCP::getVendorOptionDef(u, vendor_id, search_key);
102 def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef()
103 ->get(option_space, search_key);
111 std::pair<isc::dhcp::OptionDefinitionPtr, std::string>
115 std::string name = getString(option_def,
"name");
116 uint32_t code = getInteger(option_def,
"code");
117 std::string type = getString(option_def,
"type");
121 bool array_type = getBoolean(option_def,
"array");
122 std::string record_types = getString(option_def,
"record-types");
123 std::string space = getString(option_def,
"space");
124 std::string encapsulates = getString(option_def,
"encapsulate");
127 if (!OptionSpace::validateName(space)) {
130 << getPosition(
"space", option_def) <<
")");
137 if (!encapsulates.empty()) {
141 <<
"name" <<
"', comprising an array of data" 142 <<
" fields may not encapsulate any option space (" 143 << option_def->getPosition() <<
")");
145 }
else if (encapsulates == space) {
147 <<
" an option space it belongs to: '" 148 << space <<
"." << name <<
"' is set to" 149 <<
" encapsulate '" << space <<
"' (" 150 << option_def->getPosition() <<
")");
154 encapsulates.c_str()));
163 def->setContext(user_context);
167 std::vector<std::string> record_tokens =
171 BOOST_FOREACH(std::string record_type, record_tokens) {
174 if (!record_type.empty()) {
175 def->addRecordField(record_type);
179 <<
" specified for the option definition: " 181 << getPosition(
"record-types", option_def) <<
")");
188 }
catch (
const std::exception& ex) {
190 <<
" (" << option_def->getPosition() <<
")");
194 return make_pair(def, space);
200 if (!option_def_list) {
203 <<
" option definitions is NULL (" 204 << option_def_list->getPosition() <<
")");
208 BOOST_FOREACH(
ConstElementPtr option_def, option_def_list->listValue()) {
211 def = parser.
parse(option_def);
213 storage->add(def.first, def.second);
214 }
catch (
const std::exception& ex) {
217 << option_def->getPosition() <<
")");
223 LibDHCP::setRuntimeOptionDefs(storage->getContainer());
235 if (relay_elem->getType() != Element::map) {
242 if (address && addresses) {
244 "specify either ip-address or ip-addresses, not both");
247 if (!address && !addresses) {
256 relay_elem, relay_info);
258 DHCPSRV_CFGMGR_RELAY_IP_ADDRESS_DEPRECATED)
263 if (addresses->getType() != Element::list) {
265 <<
" (" <<
getPosition(
"ip-addresses", relay_elem) <<
")");
268 BOOST_FOREACH(
ConstElementPtr address_element, addresses->listValue()) {
269 addAddress(
"ip-addresses", address_element->stringValue(),
270 relay_elem, relay_info);
276 const std::string& address_str,
279 boost::scoped_ptr<isc::asiolink::IOAddress> ip;
282 }
catch (
const std::exception& ex) {
284 <<
" is not a valid: " 301 relay_info->addAddress(*ip);
302 }
catch (
const std::exception& ex) {
304 <<
"to relay info: " << ex.
what()
314 const uint16_t address_family) {
320 "definition: (" << pool_structure->getPosition() <<
")");
326 string txt = text_pool->stringValue();
329 boost::erase_all(txt,
" ");
330 boost::erase_all(txt,
"\t");
335 size_t pos = txt.find(
"/");
336 if (pos != string::npos) {
343 string prefix_len = txt.substr(pos + 1);
355 int val_len = boost::lexical_cast<int>(prefix_len);
356 if ((val_len < std::numeric_limits<uint8_t>::min()) ||
357 (val_len > std::numeric_limits<uint8_t>::max())) {
361 len = static_cast<uint8_t>(val_len);
364 "definition: " << txt <<
" (" 365 << text_pool->getPosition() <<
")");
370 pools->push_back(pool);
371 }
catch (
const std::exception& ex) {
373 << txt <<
" (" << text_pool->getPosition() <<
")");
382 if (pos != string::npos) {
389 "definition: " << txt <<
" (" 390 << text_pool->getPosition() <<
")");
395 pools->push_back(pool);
396 }
catch (
const std::exception& ex) {
398 << txt <<
" (" << text_pool->getPosition() <<
")");
405 << text_pool->stringValue() <<
406 ". There are two acceptable formats <min address-max address>" 408 << text_pool->getPosition() <<
")");
415 if (user_context->getType() != Element::map) {
417 << user_context->getPosition() <<
")");
419 pool->setContext(user_context);
428 option_parser.
parse(cfg, option_data);
429 }
catch (
const std::exception& ex) {
431 <<
" (" << option_data->getPosition() <<
")");
438 string cclass = client_class->stringValue();
439 if (!cclass.empty()) {
440 pool->allowClientClass(cclass);
445 ConstElementPtr class_list = pool_structure->get(
"require-client-classes");
447 const std::vector<data::ElementPtr>& classes = class_list->listValue();
448 for (
auto cclass = classes.cbegin();
449 cclass != classes.cend(); ++cclass) {
450 if (((*cclass)->getType() != Element::string) ||
451 (*cclass)->stringValue().empty()) {
453 << (*cclass)->getPosition() <<
")");
455 pool->requireClientClass((*cclass)->stringValue());
478 parser.
parse(pools, pool, AF_INET);
486 address_family_(family),
495 if (options_params) {
509 createSubnet(subnet);
510 }
catch (
const std::exception& ex) {
512 "subnet configuration failed: " << ex.
what());
520 if ( (txt.compare(
"disabled") == 0) ||
521 (txt.compare(
"off") == 0) ) {
523 }
else if (txt.compare(
"out-of-pool") == 0) {
525 }
else if (txt.compare(
"global") == 0) {
527 }
else if (txt.compare(
"all") == 0) {
532 <<
"' into any valid reservation-mode values");
538 std::string subnet_txt;
540 subnet_txt =
getString(params,
"subnet");
541 }
catch (
const DhcpConfigError &) {
544 "mandatory 'subnet' parameter is missing for a subnet being" 545 " configured (" << params->getPosition() <<
")");
549 boost::erase_all(subnet_txt,
" ");
550 boost::erase_all(subnet_txt,
"\t");
557 size_t pos = subnet_txt.find(
"/");
558 if (pos == string::npos) {
561 "Invalid subnet syntax (prefix/len expected):" << subnet_txt
562 <<
" (" << elem->getPosition() <<
")");
572 len = boost::lexical_cast<unsigned int>(subnet_txt.substr(pos + 1));
573 }
catch (
const boost::bad_lexical_cast&) {
575 isc_throw(DhcpConfigError,
"prefix length: '" <<
576 subnet_txt.substr(pos+1) <<
"' is not an integer (" 577 << elem->getPosition() <<
")");
581 if ((addr.isV6() && len > 128) ||
582 (addr.isV4() && len > 32)) {
585 "Invalid prefix length specified for subnet: " << len
586 <<
" (" << elem->getPosition() <<
")");
593 for (PoolStorage::iterator it =
pools_->begin(); it !=
pools_->end();
597 }
catch (
const BadValue& ex) {
601 ex.what() <<
" (" << params->getPosition() <<
")");
608 if (user_context->getType() != Element::map) {
610 << user_context->getPosition() <<
")");
612 subnet_->setContext(user_context);
637 "Failed to create an IPv4 subnet (" <<
638 subnet->getPosition() <<
")");
645 "Invalid Subnet4 cast in Subnet4ConfigParser::parse");
659 for (
auto h = hosts.begin(); h != hosts.end(); ++h) {
674 if (params->contains(
"renew-timer")) {
679 if (params->contains(
"rebind-timer")) {
694 s << addr <<
"/" << static_cast<int>(len) <<
" with params: ";
697 s <<
"t1=" << t1 <<
", ";
700 s <<
"t2=" << t2 <<
", ";
702 s <<
"valid-lifetime=" << valid;
712 bool match_client_id =
getBoolean(params,
"match-client-id");
713 subnet4->setMatchClientId(match_client_id);
718 bool authoritative =
getBoolean(params,
"authoritative");
719 subnet4->setAuthoritative(authoritative);
726 next_server =
getString(params,
"next-server");
727 if (!next_server.empty()) {
728 subnet4->setSiaddr(
IOAddress(next_server));
734 pos = next->getPosition().str();
736 pos = params->getPosition().str();
739 << next_server <<
"(" << pos <<
")");
743 std::string sname =
getString(params,
"server-hostname");
744 if (!sname.empty()) {
749 << sname.length() <<
" (" 750 << error->getPosition() <<
")");
752 subnet4->setSname(sname);
756 std::string filename =
getString(params,
"boot-file-name");
757 if (!filename.empty()) {
762 << filename.length() <<
" (" 763 << error->getPosition() <<
")");
765 subnet4->setFilename(filename);
770 std::string iface =
getString(params,
"interface");
771 if (!iface.empty()) {
775 <<
" for subnet " << subnet4->toText()
776 <<
" is not present in the system (" 777 << error->getPosition() <<
")");
780 subnet4->setIface(iface);
786 std::string hr_mode =
getString(params,
"reservation-mode");
790 " of reservation-mode parameter: " << ex.
what()
791 <<
"(" <<
getPosition(
"reservation-mode", params) <<
")");
795 string client_class =
getString(params,
"client-class");
796 if (!client_class.empty()) {
797 subnet4->allowClientClass(client_class);
803 const std::vector<data::ElementPtr>& classes = class_list->listValue();
804 for (
auto cclass = classes.cbegin();
805 cclass != classes.cend(); ++cclass) {
806 if (((*cclass)->getType() != Element::string) ||
807 (*cclass)->stringValue().empty()) {
809 << (*cclass)->getPosition() <<
")");
811 subnet4->requireClientClass((*cclass)->stringValue());
817 string iface4o6 =
getString(params,
"4o6-interface");
818 if (!iface4o6.empty()) {
819 subnet4->get4o6().setIface4o6(iface4o6);
820 subnet4->get4o6().enabled(
true);
825 string subnet4o6 =
getString(params,
"4o6-subnet");
826 if (!subnet4o6.empty()) {
827 size_t slash = subnet4o6.find(
"/");
828 if (slash == std::string::npos) {
830 << subnet4o6 <<
", expected format: prefix6/length");
832 string prefix = subnet4o6.substr(0, slash);
833 string lenstr = subnet4o6.substr(slash + 1);
837 len = boost::lexical_cast<unsigned int>(lenstr.c_str());
838 }
catch (
const boost::bad_lexical_cast &) {
840 "4o6-subnet parameter: " << subnet4o6 <<
", expected 0..128 value");
842 subnet4->get4o6().setSubnet4o6(
IOAddress(prefix), len);
843 subnet4->get4o6().enabled(
true);
847 std::string ifaceid =
getString(params,
"4o6-interface-id");
848 if (!ifaceid.empty()) {
851 subnet4->get4o6().setInterfaceId(opt);
852 subnet4->get4o6().enabled(
true);
863 options_->copyTo(*subnet4->getCfgOption());
871 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
881 cfg->getCfgSubnets4()->add(subnet);
883 }
catch (
const std::exception& ex) {
885 << subnet_json->getPosition() <<
")");
896 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
902 subnets.push_back(subnet);
904 }
catch (
const std::exception& ex) {
906 << subnet_json->getPosition() <<
")");
919 return (
PoolPtr(
new Pool6(static_cast<isc::dhcp::Lease::Type>
920 (ptype), addr, len)));
926 return (
PoolPtr(
new Pool6(static_cast<isc::dhcp::Lease::Type>
927 (ptype), min, max)));
937 parser.
parse(pools, pool, AF_INET6);
948 std::string addr_str =
getString(pd_pool_,
"prefix");
950 uint8_t prefix_len =
getUint8(pd_pool_,
"prefix-len");
952 uint8_t delegated_len =
getUint8(pd_pool_,
"delegated-len");
954 std::string excluded_prefix_str =
"::";
955 if (pd_pool_->contains(
"excluded-prefix")) {
956 excluded_prefix_str =
getString(pd_pool_,
"excluded-prefix");
959 uint8_t excluded_prefix_len = 0;
960 if (pd_pool_->contains(
"excluded-prefix-len")) {
961 excluded_prefix_len =
getUint8(pd_pool_,
"excluded-prefix-len");
967 opts_parser.
parse(options_, option_data);
972 user_context_ = user_context;
977 client_class_ = client_class;
990 excluded_prefix_len));
992 options_->copyTo(*pool_->getCfgOption());
993 }
catch (
const std::exception& ex) {
998 <<
" (" << pd_pool_->getPosition() <<
")");
1001 if (user_context_) {
1002 pool_->setContext(user_context_);
1005 if (client_class_) {
1006 string cclass = client_class_->stringValue();
1007 if (!cclass.empty()) {
1008 pool_->allowClientClass(cclass);
1013 const std::vector<data::ElementPtr>& classes = class_list->listValue();
1014 for (
auto cclass = classes.cbegin();
1015 cclass != classes.cend(); ++cclass) {
1016 if (((*cclass)->getType() != Element::string) ||
1017 (*cclass)->stringValue().empty()) {
1019 << (*cclass)->getPosition() <<
")");
1021 pool_->requireClientClass((*cclass)->stringValue());
1026 pools->push_back(pool_);
1036 parser.
parse(pools, pd_pool);
1065 "Failed to create an IPv6 subnet (" <<
1066 subnet->getPosition() <<
")");
1073 "Invalid Subnet6 cast in Subnet6ConfigParser::parse");
1087 for (
auto h = hosts.begin(); h != hosts.end(); ++h) {
1100 .arg(code).arg(addr.
toText());
1123 bool rapid_commit =
getBoolean(params,
"rapid-commit");
1125 std::ostringstream output;
1126 output << addr <<
"/" << static_cast<int>(len)
1127 <<
" with params t1=" << t1 <<
", t2=" 1128 << t2 <<
", preferred-lifetime=" << pref
1129 <<
", valid-lifetime=" << valid
1130 <<
", rapid-commit is " << (rapid_commit ?
"enabled" :
"disabled");
1145 std::string ifaceid =
getString(params,
"interface-id");
1146 std::string iface =
getString(params,
"interface");
1151 if (!ifaceid.empty() && !iface.empty()) {
1153 "parser error: interface (defined for locally reachable " 1154 "subnets) and interface-id (defined for subnets reachable" 1155 " via relays) cannot be defined at the same time for " 1156 "subnet " << addr <<
"/" << (
int)len <<
"(" 1157 << params->getPosition() <<
")");
1161 if (!ifaceid.empty()) {
1169 if (!iface.empty()) {
1173 <<
" for subnet " << subnet6->
toText()
1174 <<
" is not present in the system (" 1175 << error->getPosition() <<
")");
1184 std::string hr_mode =
getString(params,
"reservation-mode");
1188 " of reservation-mode parameter: " << ex.
what()
1189 <<
"(" <<
getPosition(
"reservation-mode", params) <<
")");
1193 string client_class =
getString(params,
"client-class");
1194 if (!client_class.empty()) {
1201 const std::vector<data::ElementPtr>& classes = class_list->listValue();
1202 for (
auto cclass = classes.cbegin();
1203 cclass != classes.cend(); ++cclass) {
1204 if (((*cclass)->getType() != Element::string) ||
1205 (*cclass)->stringValue().empty()) {
1207 << (*cclass)->getPosition() <<
")");
1225 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
1234 cfg->getCfgSubnets6()->add(subnet);
1236 }
catch (
const std::exception& ex) {
1238 << subnet_json->getPosition() <<
")");
1248 BOOST_FOREACH(
ConstElementPtr subnet_json, subnets_list->listValue()) {
1253 subnets.push_back(subnet);
1255 }
catch (
const std::exception& ex) {
1257 << subnet_json->getPosition() <<
")");
1268 const std::string& name) {
1271 (scope, name,
"NameChangeRequest protocol"));
1276 const std::string& name) {
1279 (scope, name,
"NameChangeRequest format"));
1284 const std::string& name) {
1287 (scope, name,
"ReplaceClientName mode"));
1295 bool enable_updates =
getBoolean(client_config,
"enable-updates");
1299 uint32_t server_port =
getUint32(client_config,
"server-port");
1301 std::string sender_ip_str =
getString(client_config,
"sender-ip");
1303 uint32_t sender_port =
getUint32(client_config,
"sender-port");
1305 uint32_t max_queue_size =
getUint32(client_config,
"max-queue-size");
1308 getProtocol(client_config,
"ncr-protocol");
1311 getFormat(client_config,
"ncr-format");
1313 bool override_no_update =
1314 getBoolean(client_config,
"override-no-update");
1316 bool override_client_update =
1317 getBoolean(client_config,
"override-client-update");
1320 getMode(client_config,
"replace-client-name");
1322 std::string generated_prefix =
1323 getString(client_config,
"generated-prefix");
1325 std::string hostname_char_set =
1326 getString(client_config,
"hostname-char-set");
1328 std::string hostname_char_replacement =
1329 getString(client_config,
"hostname-char-replacement");
1332 std::string qualifying_suffix =
"";
1333 bool found_qualifying_suffix =
false;
1334 if (client_config->contains(
"qualifying-suffix")) {
1335 qualifying_suffix =
getString(client_config,
"qualifying-suffix");
1336 found_qualifying_suffix =
true;
1340 if (sender_ip_str.empty()) {
1347 }
catch (
const std::exception& ex) {
1349 <<
") specified for parameter 'sender-ip' (" 1350 <<
getPosition(
"sender-ip", client_config) <<
")");
1355 if (enable_updates && !found_qualifying_suffix) {
1357 "parameter 'qualifying-suffix' is required when " 1358 "updates are enabled (" 1359 << client_config->getPosition() <<
")");
1368 <<
" is not supported. (" 1369 <<
getPosition(
"ncr-format", client_config) <<
")");
1375 <<
" is not supported. (" 1376 <<
getPosition(
"ncr-protocol", client_config) <<
")");
1381 "D2ClientConfig error: address family mismatch: " 1382 <<
"server-ip: " << server_ip.
toText()
1383 <<
" is: " << (server_ip.
isV4() ?
"IPv4" :
"IPv6")
1384 <<
" while sender-ip: " << sender_ip.
toText()
1385 <<
" is: " << (sender_ip.
isV4() ?
"IPv4" :
"IPv6")
1386 <<
" (" <<
getPosition(
"sender-ip", client_config) <<
")");
1389 if (server_ip == sender_ip && server_port == sender_port) {
1391 "D2ClientConfig error: server and sender cannot" 1392 " share the exact same IP address/port: " 1393 << server_ip.
toText() <<
"/" << server_port
1394 <<
" (" <<
getPosition(
"sender-ip", client_config) <<
")");
1408 override_client_update,
1409 replace_client_name_mode,
1413 hostname_char_replacement));
1414 }
catch (
const std::exception& ex) {
1416 << client_config->getPosition() <<
")");
1422 new_config->setContext(user_context);
1431 {
"server-ip", Element::string,
"127.0.0.1" },
1432 {
"server-port", Element::integer,
"53001" },
1435 {
"sender-ip", Element::string,
"" },
1436 {
"sender-port", Element::integer,
"0" },
1437 {
"max-queue-size", Element::integer,
"1024" },
1438 {
"ncr-protocol", Element::string,
"UDP" },
1439 {
"ncr-format", Element::string,
"JSON" },
1440 {
"override-no-update", Element::boolean,
"false" },
1441 {
"override-client-update", Element::boolean,
"false" },
1442 {
"replace-client-name", Element::string,
"never" },
1443 {
"generated-prefix", Element::string,
"myhost" },
1444 {
"hostname-char-set", Element::string,
"" },
1445 {
"hostname-char-replacement", Element::string,
"" }
1451 ElementPtr mutable_d2 = boost::const_pointer_cast<Element>(d2_config);
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.
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.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
D2ClientConfigPtr parse(isc::data::ConstElementPtr d2_client_cfg)
Parses a given dhcp-ddns element into D2ClientConfig.
virtual void duplicate_option_warning(uint32_t code, asiolink::IOAddress &addr)
Issues a DHCP6 server specific warning regarding duplicate subnet options.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
Both out-of-pool and in-pool reservations are allowed.
Base class representing a DHCP option definition.
NameChangeProtocol stringToNcrProtocol(const std::string &protocol_str)
Function which converts labels to NameChangeProtocol enum values.
this class parses a single subnet
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Parser for IPv4 pool definitions.
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
Only global reservations are allowed.
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SubnetRandomAccessIndexTag > >, 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 > > >> Subnet6Collection
A collection of Subnet6 objects.
Specialization of the pool list parser for DHCPv6.
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.
static const size_t MAX_FILE_LEN
length of the FILE field in DHCPv4 message
static CfgMgr & instance()
returns a single instance of Configuration Manager
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Only out-of-pool reservations is allowed.
boost::shared_ptr< Option > OptionPtr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
This class parses a single IPv4 subnet.
void setControlSocketInfo(const isc::data::ConstElementPtr &control_socket)
Sets information about the control socket.
void clear()
Removes any configured MAC/Hardware address sources.
Universe
defines option universe DHCPv4 or DHCPv6
void add(uint32_t source)
Adds additional MAC/hardware address acquisition.
boost::shared_ptr< Element > ElementPtr
std::vector< HostPtr > HostCollection
Collection of the Host objects.
CfgOptionPtr options_
Pointer to the options configuration.
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.
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this subnet.
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
PdPoolParser()
Constructor.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Specialization of the pool list parser for DHCPv4.
PoolStoragePtr pools_
Storage for pools belonging to this subnet.
Parser for IPv6 prefix delegation definitions.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
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.
#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.
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.
Pool information for IPv6 addresses and prefixes.
Represents option data configuration for the DHCP server.
Subnet6ConfigParser()
Constructor.
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 allowClientClass(const isc::dhcp::ClientClass &class_name)
Sets the supported class to class class_name.
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.
bool unspecified() const
Check if the value has been specified.
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
boost::shared_ptr< const Element > ConstElementPtr
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
Parser for option data values within a subnet.
None - host reservation is disabled.
vector< string > tokens(const std::string &text, const std::string &delim, bool escape)
Split String into Tokens.
void setIface(const std::string &iface_name)
Sets local name of the interface for which this network is selected.
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.
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
HRMode
Specifies allowed host reservation mode.
Specifies current DHCP configuration.
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
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-dhcp-ddns.
std::string toText() const
Convert the address to a string.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SubnetRandomAccessIndexTag > >, 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 > > >> Subnet4Collection
A collection of Subnet4 objects.
Parser for a list of prefix delegation pools.
Parser for IPv6 pool definitions.
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
void requireClientClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to classes required to be evaluated.
static Network::HRMode hrModeFromText(const std::string &txt)
Attempts to convert text representation to HRMode enum.
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.
PoolPtr poolMaker(asiolink::IOAddress &addr, uint32_t len, int32_t ptype)
Creates a Pool6 object given a IPv6 prefix and the prefix length.
#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
void setHostReservationMode(HRMode mode)
Sets host reservation mode.
NameChangeProtocol
Defines the list of socket protocols supported.
OptionDefinitionTuple parse(isc::data::ConstElementPtr option_def)
Parses an entry that describes single option definition.
This class parses a single IPv6 subnet.
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.
string trim(const string &instring)
Trim Leading and Trailing Spaces.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
Parser for a list of host reservations for a subnet.
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
void setRapidCommit(const bool rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
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)
std::pair< isc::dhcp::OptionDefinitionPtr, std::string > OptionDefinitionTuple
SubnetConfigParser(uint16_t family)
constructor
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
void parse(PoolStoragePtr pools, data::ConstElementPtr pd_pool_list)
Parse configuration entries.
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
virtual std::string toText() const
Returns textual representation of the subnet (e.g.
Subnet4ConfigParser()
Constructor.
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
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.