Browse Source

[5033] Some fixes (1,2,4 of review)

Francis Dupont 8 years ago
parent
commit
ee50101f97

+ 2 - 0
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

+ 2 - 0
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,
 

+ 3 - 11
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<std::string, ConstElementPtr> 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<Element>(d2_client);
+        cnt += SimpleParser::setDefaults(mutable_d2, D2_CLIENT_CONFIG_DEFAULTS);
     }
 
     return (cnt);

+ 0 - 1
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,

+ 3 - 11
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<std::string, ConstElementPtr> 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<Element>(d2_client);
+        cnt += SimpleParser::setDefaults(mutable_d2, D2_CLIENT_CONFIG_DEFAULTS);
     }
 
     return (cnt);