From: Francis Dupont Date: Thu, 12 Jan 2017 20:16:43 +0000 (+0100) Subject: [5033] Some fixes (1,2,4 of review) X-Git-Tag: trac5112_base~6^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee50101f9711dbc32fca06f88290566b1c7811bc;p=thirdparty%2Fkea.git [5033] Some fixes (1,2,4 of review) --- diff --git a/doc/Makefile.am b/doc/Makefile.am index dff8c492ed..312996b2fd 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -20,6 +20,7 @@ nobase_dist_doc_DATA += examples/kea4/pgsql-reservations.json nobase_dist_doc_DATA += examples/kea4/reservations.json nobase_dist_doc_DATA += examples/kea4/several-subnets.json nobase_dist_doc_DATA += examples/kea4/single-subnet.json +nobase_dist_doc_DATA += examples/kea4/with-ddns.json nobase_dist_doc_DATA += examples/kea6/advanced.json nobase_dist_doc_DATA += examples/kea6/backends.json nobase_dist_doc_DATA += examples/kea6/classify.json @@ -35,6 +36,7 @@ nobase_dist_doc_DATA += examples/kea6/several-subnets.json nobase_dist_doc_DATA += examples/kea6/simple.json nobase_dist_doc_DATA += examples/kea6/softwire46.json nobase_dist_doc_DATA += examples/kea6/stateless.json +nobase_dist_doc_DATA += examples/kea6/with-ddns.json devel: mkdir -p html diff --git a/src/bin/dhcp4/parser_context.h b/src/bin/dhcp4/parser_context.h index 6f65360c0e..2df13e4f86 100644 --- a/src/bin/dhcp4/parser_context.h +++ b/src/bin/dhcp4/parser_context.h @@ -187,6 +187,8 @@ public: ///< Used while parsing content of Dhcp4. DHCP4, + // not yet DHCP6, + ///< Used while parsing content of Logging LOGGING, diff --git a/src/bin/dhcp4/simple_parser4.cc b/src/bin/dhcp4/simple_parser4.cc index ce80900f0b..9a581a6bfb 100644 --- a/src/bin/dhcp4/simple_parser4.cc +++ b/src/bin/dhcp4/simple_parser4.cc @@ -123,17 +123,9 @@ size_t SimpleParser4::setAllDefaults(isc::data::ElementPtr global) { ConstElementPtr d2_client = global->get("dhcp-ddns"); /// @todo - what if it's not in global? should we add it? if (d2_client) { - // Because "dhcp-ddns" is a MapElement and global->get() - // returns a ConstElementPtr, then we get a map we can't - // change. So go thru gyrations to create a non-const - // map, update it with default values and then replace - // the one in global with the new one. Ick. - std::map d2_map; - d2_client->getValue(d2_map); - ElementPtr new_map(new MapElement()); - new_map->setValue(d2_map); - cnt += SimpleParser::setDefaults(new_map, D2_CLIENT_CONFIG_DEFAULTS); - global->set("dhcp-ddns", new_map); + // Get the mutable form of d2 client config + ElementPtr mutable_d2 = boost::const_pointer_cast(d2_client); + cnt += SimpleParser::setDefaults(mutable_d2, D2_CLIENT_CONFIG_DEFAULTS); } return (cnt); diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h index ea260d398c..9a1ae41956 100644 --- a/src/bin/dhcp6/parser_context.h +++ b/src/bin/dhcp6/parser_context.h @@ -191,7 +191,6 @@ public: DHCP6, // not yet DHCP4, - // not yet DHCP_DDNS, ///< Used while parsing content of Logging LOGGING, diff --git a/src/bin/dhcp6/simple_parser6.cc b/src/bin/dhcp6/simple_parser6.cc index 48c5573afe..1840993fdc 100644 --- a/src/bin/dhcp6/simple_parser6.cc +++ b/src/bin/dhcp6/simple_parser6.cc @@ -125,17 +125,9 @@ size_t SimpleParser6::setAllDefaults(isc::data::ElementPtr global) { ConstElementPtr d2_client = global->get("dhcp-ddns"); /// @todo - what if it's not in global? should we add it? if (d2_client) { - // Because "dhcp-ddns" is a MapElement and global->get() - // returns a ConstElementPtr, then we get a map we can't - // change. So go thru gyrations to create a non-const - // map, update it with default values and then replace - // the one in global with the new one. Ick. - std::map d2_map; - d2_client->getValue(d2_map); - ElementPtr new_map(new MapElement()); - new_map->setValue(d2_map); - cnt += SimpleParser::setDefaults(new_map, D2_CLIENT_CONFIG_DEFAULTS); - global->set("dhcp-ddns", new_map); + // Get the mutable form of d2 client config + ElementPtr mutable_d2 = boost::const_pointer_cast(d2_client); + cnt += SimpleParser::setDefaults(mutable_d2, D2_CLIENT_CONFIG_DEFAULTS); } return (cnt);