16 const string DHCP4_SPACE =
"dhcp4";
17 const string DHCP6_SPACE =
"dhcp6";
23 AdaptorConfig::AdaptorConfig() {
26 AdaptorConfig::~AdaptorConfig() {
33 if (!subnets || subnets->empty()) {
44 if (!collectID(subnet, set)) {
54 const string& subsel) {
55 if (!networks || networks->empty()) {
65 for (
size_t i = 0; i < networks->size(); ++i) {
69 if (!subnets->empty()) {
72 if (!subnetsCollectID(subnets, set)) {
77 network->remove(subsel);
87 if (!subnets || subnets->empty()) {
92 for (
size_t i = 0; i < subnets->size(); ++i) {
94 assignID(subnet, set, next);
101 const string& subsel) {
102 if (!networks || networks->empty()) {
109 if (!subnets || subnets->empty()) {
113 for (
size_t i = 0; i < subnets->size(); ++i) {
115 assignID(subnet, set, next);
122 if (!pools || pools->empty()) {
129 for (
size_t i = 0; i < pools->size(); ++i) {
131 AdaptorPool::canonizePool(pool);
137 if (!subnets || subnets->empty()) {
143 sanitizePools(subnet->get(
"pools"));
149 const string& subsel) {
150 if (!networks || networks->empty()) {
156 sanitizePoolsInSubnets(network->get(subsel));
164 if (!defs || defs->empty()) {
171 for (
size_t i = 0; i < defs->size(); ++i) {
175 setSpace(def, space);
184 if (!options || options->empty()) {
191 for (
size_t i = 0; i < options->size(); ++i) {
193 setSpace(option, space);
194 setCode(option, codes);
202 if (!classes || classes->empty()) {
208 for (
size_t i = 0; i < classes->size(); ++i) {
211 if (space == DHCP4_SPACE) {
214 if (!options->empty()) {
216 sanitizeOptionDefList(options, space, codes);
219 cclass->remove(
"option-def");
227 if (!options->empty()) {
229 sanitizeOptionDataList(options, space, codes);
232 cclass->remove(
"option-data");
241 if (!pools || pools->empty()) {
246 for (
size_t i = 0; i < pools->size(); ++i) {
250 if (!options->empty()) {
251 sanitizeOptionDataList(options, space, codes);
253 pool->remove(
"option-data");
262 if (!hosts || hosts->empty()) {
267 for (
size_t i = 0; i < hosts->size(); ++i) {
271 if (!options->empty()) {
272 sanitizeOptionDataList(options, space, codes);
274 host->remove(
"option-data");
284 if (!subnets || subnets->empty()) {
289 for (
size_t i = 0; i < subnets->size(); ++i) {
295 if (!options->empty()) {
296 sanitizeOptionDataList(options, space, codes);
298 subnet->remove(
"option-data");
305 if (!pools->empty()) {
306 sanitizeOptionPools(pools, space, codes);
308 subnet->remove(
"pools");
313 if (space == DHCP6_SPACE) {
316 if (!pools->empty()) {
317 sanitizeOptionPools(pools, space, codes);
319 subnet->remove(
"pd-pools");
327 if (!hosts->empty()) {
328 sanitizeOptionHosts(hosts, space, codes);
330 subnet->remove(
"reservations");
340 if (!networks || networks->empty()) {
346 for (
size_t i = 0; i < networks->size(); ++i) {
347 ElementPtr network = networks->getNonConst(i);
352 if (!options->empty()) {
353 sanitizeOptionDataList(options, space, codes);
355 network->remove(
"option-data");
358 string subnet =
"subnet";
359 if (space == DHCP4_SPACE) {
368 if (!subnets->empty()) {
369 sanitizeOptionSubnets(subnets, space, codes);
371 network->remove(subnet);
379 if (!pools || pools->empty()) {
384 for (
size_t i = 0; i < pools->size(); ++i) {
387 if (requires && requires->empty()) {
388 pool->remove(
"require-client-classes");
395 if (!subnets || subnets->empty()) {
400 for (
size_t i = 0; i < subnets->size(); ++i) {
402 sanitizeRequireClassesPools(subnet->get(
"pools"));
403 sanitizeRequireClassesPools(subnet->get(
"pd-pools"));
405 if (requires && requires->empty()) {
406 subnet->remove(
"require-client-classes");
413 const string& subsel) {
414 if (!networks || networks->empty()) {
419 for (
size_t i = 0; i < networks->size(); ++i) {
420 ElementPtr network = networks->getNonConst(i);
421 sanitizeRequireClassesSubnets(network->get(subsel));
423 if (requires && requires->empty()) {
424 network->remove(
"require-client-classes");
432 if (!hosts || hosts->empty()) {
437 for (
size_t i = 0; i < hosts->size(); ++i) {
439 quoteIdentifier(host);
446 if (!subnets || subnets->empty()) {
452 sanitizeHostList(subnet->get(
"reservations"));
458 const string& space) {
459 if (!networks || networks->empty()) {
465 if (space == DHCP4_SPACE) {
466 sanitizeHostSubnets(network->get(
"subnet4"));
468 sanitizeHostSubnets(network->get(
"subnet6"));
475 if (!subnets || subnets->empty()) {
480 for (
size_t i = 0; i < subnets->size(); ++i) {
488 const string& subsel) {
489 if (!networks || networks->empty()) {
494 for (
size_t i = 0; i < networks->size(); ++i) {
495 ElementPtr network = networks->getNonConst(i);
496 updateRelay(network);
497 sanitizeRelaySubnets(network->get(subsel));
510 mutable_dhcp->
remove(
"hosts-database");
512 list->add(boost::const_pointer_cast<Element>(database));
513 mutable_dhcp->set(
"hosts-databases", list);
519 if (!options || !options->empty()) {
524 mutable_dhcp->
remove(
"relay-supplied-options");
528 AdaptorConfig::preProcess(
ElementPtr dhcp,
const string& subsel,
529 const string& space) {
533 bool have_ids =
true;
537 if (!subnets->empty()) {
538 if (!subnetsCollectID(subnets, set)) {
542 dhcp->remove(subsel);
547 if (!networks->empty()) {
548 if (!sharedNetworksCollectID(networks, set, subsel)) {
552 dhcp->remove(
"shared-networks");
558 subnetsAssignID(subnets, set, next);
559 sharedNetworksAssignID(networks, set, next, subsel);
563 initCodes(codes, space);;
566 if (!defs->empty()) {
567 sanitizeOptionDefList(defs, space, codes);
569 dhcp->remove(
"option-def");
574 if (!options->empty()) {
575 sanitizeOptionDataList(options, space, codes);
577 dhcp->remove(
"option-data");
582 if (!classes->empty()) {
583 sanitizeOptionClasses(classes, space, codes);
585 dhcp->remove(
"client-classes");
590 if (!hosts->empty()) {
591 sanitizeHostList(hosts);
592 sanitizeOptionHosts(hosts, space, codes);
594 dhcp->remove(
"reservations");
597 sanitizeOptionSubnets(subnets, space, codes);
598 sanitizeOptionSharedNetworks(networks, space, codes);
600 sanitizePoolsInSubnets(subnets);
601 sanitizePoolsInSharedNetworks(networks, subsel);
603 sanitizeHostSubnets(subnets);
604 SanitizeHostsInSharedNetworks(networks, space);
606 sanitizeRelaySubnets(subnets);
607 sanitizeRelayInSharedNetworks(networks, subsel);
609 sanitizeRequireClassesSubnets(subnets);
610 requireClassesSharedNetworks(networks, subsel);
612 sanitizeDatabase(dhcp);
614 if (space == DHCP6_SPACE) {
615 sanitizeRelaySuppliedOptions(dhcp);
624 if (config->getType() != Element::map) {
627 if (config->contains(
"Logging")) {
635 preProcess(mutable_dhcp,
"subnet4", DHCP4_SPACE);
643 if (config->getType() != Element::map) {
646 if (config->contains(
"Logging")) {
654 preProcess(mutable_dhcp,
"subnet6", DHCP6_SPACE);
std::map< std::string, uint16_t > OptionCodes
Map for DHCP option definitions handling code and an index built from space and name.
boost::shared_ptr< Element > ElementPtr
#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...
boost::shared_ptr< const Element > ConstElementPtr
Defines the logger used by the top-level component of kea-dhcp-ddns.
The Element class represents a piece of data, used by the command channel and configuration parts...
std::set< isc::dhcp::SubnetID > SubnetIDSet
Set of SubnetIDs.
virtual void remove(const int i)
Removes the element at the given position.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)