17 const string DHCP4_SPACE =
"dhcp4";
18 const string DHCP6_SPACE =
"dhcp6";
28 if (!subnets || subnets->empty()) {
38 for (
ElementPtr const& subnet : subnets->listValue()) {
39 if (!collectID(subnet, set)) {
49 const string& subsel) {
50 if (!networks || networks->empty()) {
60 for (
size_t i = 0; i < networks->size(); ++i) {
64 if (!subnets->empty()) {
67 if (!subnetsCollectID(subnets, set)) {
72 network->remove(subsel);
82 if (!subnets || subnets->empty()) {
87 for (
size_t i = 0; i < subnets->size(); ++i) {
89 assignID(subnet, set, next);
96 const string& subsel) {
97 if (!networks || networks->empty()) {
102 for (
ElementPtr const& network : networks->listValue()) {
104 if (!subnets || subnets->empty()) {
108 for (
size_t i = 0; i < subnets->size(); ++i) {
110 assignID(subnet, set, next);
117 if (!pools || pools->empty()) {
124 for (
size_t i = 0; i < pools->size(); ++i) {
126 AdaptorPool::canonizePool(pool);
132 if (!subnets || subnets->empty()) {
137 for (
ElementPtr const& subnet : subnets->listValue()) {
138 sanitizePools(subnet->get(
"pools"));
144 const string& subsel) {
145 if (!networks || networks->empty()) {
150 for (
ElementPtr const& network : networks->listValue()) {
151 sanitizePoolsInSubnets(network->get(subsel));
159 if (!defs || defs->empty()) {
166 for (
size_t i = 0; i < defs->size(); ++i) {
170 setSpace(def, space);
179 if (!options || options->empty()) {
186 for (
size_t i = 0; i < options->size(); ++i) {
188 setSpace(option, space);
189 setCode(option, codes);
197 if (!classes || classes->empty()) {
203 for (
size_t i = 0; i < classes->size(); ++i) {
206 if (space == DHCP4_SPACE) {
209 if (!options->empty()) {
211 sanitizeOptionDefList(options, space, codes);
214 cclass->remove(
"option-def");
222 if (!options->empty()) {
224 sanitizeOptionDataList(options, space, codes);
227 cclass->remove(
"option-data");
236 if (!pools || pools->empty()) {
241 for (
size_t i = 0; i < pools->size(); ++i) {
245 if (!options->empty()) {
246 sanitizeOptionDataList(options, space, codes);
248 pool->remove(
"option-data");
257 if (!hosts || hosts->empty()) {
262 for (
size_t i = 0; i < hosts->size(); ++i) {
266 if (!options->empty()) {
267 sanitizeOptionDataList(options, space, codes);
269 host->remove(
"option-data");
279 if (!subnets || subnets->empty()) {
284 for (
size_t i = 0; i < subnets->size(); ++i) {
290 if (!options->empty()) {
291 sanitizeOptionDataList(options, space, codes);
293 subnet->remove(
"option-data");
300 if (!pools->empty()) {
301 sanitizeOptionPools(pools, space, codes);
303 subnet->remove(
"pools");
308 if (space == DHCP6_SPACE) {
311 if (!pd_pools->empty()) {
312 sanitizeOptionPools(pd_pools, space, codes);
314 subnet->remove(
"pd-pools");
322 if (!hosts->empty()) {
323 sanitizeOptionHosts(hosts, space, codes);
325 subnet->remove(
"reservations");
335 if (!networks || networks->empty()) {
341 for (
size_t i = 0; i < networks->size(); ++i) {
342 ElementPtr network = networks->getNonConst(i);
347 if (!options->empty()) {
348 sanitizeOptionDataList(options, space, codes);
350 network->remove(
"option-data");
353 string subnet =
"subnet";
354 if (space == DHCP4_SPACE) {
363 if (!subnets->empty()) {
364 sanitizeOptionSubnets(subnets, space, codes);
366 network->remove(subnet);
374 if (!pools || pools->empty()) {
379 for (
size_t i = 0; i < pools->size(); ++i) {
382 if (require && require->empty()) {
383 pool->remove(
"require-client-classes");
390 if (!subnets || subnets->empty()) {
395 for (
size_t i = 0; i < subnets->size(); ++i) {
397 sanitizeRequireClassesPools(subnet->get(
"pools"));
398 sanitizeRequireClassesPools(subnet->get(
"pd-pools"));
400 if (require && require->empty()) {
401 subnet->remove(
"require-client-classes");
408 const string& subsel) {
409 if (!networks || networks->empty()) {
414 for (
size_t i = 0; i < networks->size(); ++i) {
415 ElementPtr network = networks->getNonConst(i);
416 sanitizeRequireClassesSubnets(network->get(subsel));
418 if (require && require->empty()) {
419 network->remove(
"require-client-classes");
427 if (!hosts || hosts->empty()) {
432 for (
size_t i = 0; i < hosts->size(); ++i) {
434 quoteIdentifier(host);
441 if (!subnets || subnets->empty()) {
446 for (
ElementPtr const& subnet : subnets->listValue()) {
447 sanitizeHostList(subnet->get(
"reservations"));
453 const string& space) {
454 if (!networks || networks->empty()) {
459 for (
ElementPtr const& network : networks->listValue()) {
460 if (space == DHCP4_SPACE) {
461 sanitizeHostSubnets(network->get(
"subnet4"));
463 sanitizeHostSubnets(network->get(
"subnet6"));
470 if (!subnets || subnets->empty()) {
475 for (
size_t i = 0; i < subnets->size(); ++i) {
483 const string& subsel) {
484 if (!networks || networks->empty()) {
489 for (
size_t i = 0; i < networks->size(); ++i) {
490 ElementPtr network = networks->getNonConst(i);
491 updateRelay(network);
492 sanitizeRelaySubnets(network->get(subsel));
504 dhcp->remove(
"hosts-database");
506 list->add(
copy(database, 0));
507 dhcp->set(
"hosts-databases", list);
511 AdaptorConfig::sanitizeRelaySuppliedOptions(
ElementPtr dhcp) {
513 if (!options || !options->empty()) {
517 dhcp->remove(
"relay-supplied-options");
521 AdaptorConfig::preProcess(
ElementPtr dhcp,
const string& subsel,
522 const string& space) {
526 bool have_ids =
true;
530 if (!subnets->empty()) {
531 if (!subnetsCollectID(subnets, set)) {
535 dhcp->remove(subsel);
540 if (!networks->empty()) {
541 if (!sharedNetworksCollectID(networks, set, subsel)) {
545 dhcp->remove(
"shared-networks");
551 subnetsAssignID(subnets, set, next);
552 sharedNetworksAssignID(networks, set, next, subsel);
556 initCodes(codes, space);
559 if (!defs->empty()) {
560 sanitizeOptionDefList(defs, space, codes);
562 dhcp->remove(
"option-def");
567 if (!options->empty()) {
568 sanitizeOptionDataList(options, space, codes);
570 dhcp->remove(
"option-data");
575 if (!classes->empty()) {
576 sanitizeOptionClasses(classes, space, codes);
578 dhcp->remove(
"client-classes");
583 if (!hosts->empty()) {
584 sanitizeHostList(hosts);
585 sanitizeOptionHosts(hosts, space, codes);
587 dhcp->remove(
"reservations");
590 sanitizeOptionSubnets(subnets, space, codes);
591 sanitizeOptionSharedNetworks(networks, space, codes);
593 sanitizePoolsInSubnets(subnets);
594 sanitizePoolsInSharedNetworks(networks, subsel);
596 sanitizeHostSubnets(subnets);
597 SanitizeHostsInSharedNetworks(networks, space);
599 sanitizeRelaySubnets(subnets);
600 sanitizeRelayInSharedNetworks(networks, subsel);
602 sanitizeRequireClassesSubnets(subnets);
603 requireClassesSharedNetworks(networks, subsel);
605 sanitizeDatabase(dhcp);
607 if (space == DHCP6_SPACE) {
608 sanitizeRelaySuppliedOptions(dhcp);
617 if (config->getType() != Element::map) {
620 if (config->contains(
"Logging")) {
628 preProcess(mutable_dhcp,
"subnet4", DHCP4_SPACE);
629 config->set(
"Dhcp4", mutable_dhcp);
637 if (config->getType() != Element::map) {
640 if (config->contains(
"Logging")) {
648 preProcess(mutable_dhcp,
"subnet6", DHCP6_SPACE);
649 config->set(
"Dhcp6", mutable_dhcp);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::set< dhcp::SubnetID > SubnetIDSet
Ordered list aka set of subnetIDs.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
std::unordered_map< std::string, uint16_t > OptionCodes
Map for DHCP option definitions handling code and an index built from space and name.
Defines the logger used by the top-level component of kea-lfc.