]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#893] reverted changes
authorRazvan Becheriu <razvan@isc.org>
Thu, 16 Apr 2020 11:42:34 +0000 (14:42 +0300)
committerRazvan Becheriu <razvan@isc.org>
Thu, 16 Apr 2020 11:42:34 +0000 (14:42 +0300)
src/bin/dhcp4/json_config_parser.cc
src/lib/dhcpsrv/parsers/simple_parser4.cc
src/lib/dhcpsrv/parsers/simple_parser6.cc

index a234eee0d8975198837a2cadc579749e05f1e3f6..4b89918356f56f010c7d1084538f085c336134e0 100644 (file)
 #include <database/dbaccess_parser.h>
 #include <database/backend_selector.h>
 #include <database/server_selector.h>
-#include <dhcp/libdhcp++.h>
-#include <dhcp/option_definition.h>
 #include <dhcp4/dhcp4_log.h>
 #include <dhcp4/dhcp4_srv.h>
 #include <dhcp4/json_config_parser.h>
+#include <dhcp/libdhcp++.h>
+#include <dhcp/option_definition.h>
 #include <dhcpsrv/cb_ctl_dhcp4.h>
 #include <dhcpsrv/cfg_option.h>
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/config_backend_dhcp4_mgr.h>
 #include <dhcpsrv/db_type.h>
-#include <dhcpsrv/host_data_source_factory.h>
 #include <dhcpsrv/parsers/client_class_def_parser.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/expiration_config_parser.h>
@@ -33,6 +32,7 @@
 #include <dhcpsrv/parsers/simple_parser4.h>
 #include <dhcpsrv/parsers/shared_networks_list_parser.h>
 #include <dhcpsrv/parsers/sanity_checks_parser.h>
+#include <dhcpsrv/host_data_source_factory.h>
 #include <dhcpsrv/timer_mgr.h>
 #include <process/config_ctl_parser.h>
 #include <hooks/hooks_parser.h>
 #include <util/encode/hex.h>
 #include <util/strutil.h>
 
-#include <boost/algorithm/string.hpp>
 #include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
 
-#include <iostream>
 #include <limits>
-#include <map>
+#include <iostream>
+#include <iomanip>
 #include <netinet/in.h>
 #include <vector>
+#include <map>
 
 using namespace std;
 using namespace isc;
-using namespace isc::data;
 using namespace isc::dhcp;
+using namespace isc::data;
 using namespace isc::asiolink;
 using namespace isc::hooks;
 using namespace isc::process;
@@ -335,13 +336,13 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
     // have to be restored to global storages.
     bool rollback = false;
     // config_pair holds the details of the current parser when iterating over
-    // the parsers.  It is declared outside the loop so in case of error, the
-    // name of the failing parser can be retrieved within the "catch" clause.
+    // the parsers.  It is declared outside the loops so in case of an error,
+    // the name of the failing parser can be retrieved in the "catch" clause.
     ConfigPair config_pair;
     ElementPtr mutable_cfg;
     SrvConfigPtr srv_cfg;
     try {
-        // Get the staging configuration.
+        // Get the staging configuration
         srv_cfg = CfgMgr::instance().getStagingCfg();
 
         // This is a way to convert ConstElementPtr to ElementPtr.
@@ -668,14 +669,12 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
         catch (const isc::Exception& ex) {
             LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
             answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
-            // An error occurred, so make sure to restore the original data.
             rollback = true;
         } catch (...) {
             // For things like bad_cast in boost::lexical_cast
             LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_EXCEPTION);
             answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, "undefined configuration"
                                                " parsing error");
-            // An error occurred, so make sure to restore the original data.
             rollback = true;
         }
     }
@@ -692,7 +691,6 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
             err << "during update from config backend database: " << ex.what();
             LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(err.str());
             answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
-            // An error occurred, so make sure to restore the original data.
             rollback = true;
         } catch (...) {
             // For things like bad_cast in boost::lexical_cast
@@ -701,7 +699,6 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
                 << "undefined configuration parsing error";
             LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(err.str());
             answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
-            // An error occurred, so make sure to restore the original data.
             rollback = true;
         }
     }
index 4a6a3e03a16432b6e406f4f9ff121e6a100cc808..d4e9b0cece70596da8fce165832cd55af58093aa 100644 (file)
@@ -6,10 +6,10 @@
 
 #include <config.h>
 
-#include <cc/data.h>
 #include <dhcpsrv/parsers/simple_parser4.h>
-
+#include <cc/data.h>
 #include <boost/foreach.hpp>
+#include <iostream>
 
 using namespace isc::data;
 
@@ -244,7 +244,7 @@ const SimpleDefaults SimpleParser4::SUBNET4_DEFAULTS = {
 /// @brief This table defines default values for each IPv4 subnet that is
 ///        part of a shared network
 ///
-/// This is mostly the same as @ref SUBNET4_DEFAULTS, except the parameters
+/// This is mostly the same as @ref SUBNET4_DEFAULTS, except two parameters
 /// that can be derived from shared-network, but cannot from global scope.
 /// Those are: interface and reservation-mode.
 const SimpleDefaults SimpleParser4::SHARED_SUBNET4_DEFAULTS = {
@@ -254,7 +254,7 @@ const SimpleDefaults SimpleParser4::SHARED_SUBNET4_DEFAULTS = {
     { "4o6-subnet",       Element::string,  "" },
 };
 
-/// @brief List of parameters that can be inherited from the global to subnet4 scope.
+/// @brief List of parameters that can be inherited to subnet4 scope.
 ///
 /// Some parameters may be defined on both global (directly in Dhcp4) and
 /// subnet (Dhcp4/subnet4/...) scope. If not defined in the subnet scope,
@@ -374,10 +374,12 @@ size_t SimpleParser4::setAllDefaults(ElementPtr global) {
     // Set global defaults first.
     cnt = setDefaults(global, GLOBAL4_DEFAULTS);
 
-    // Now set the defaults for each specified option definition
+    // Now set option definition defaults for each specified option definition
     ConstElementPtr option_defs = global->get("option-def");
     if (option_defs) {
-        cnt += setListDefaults(option_defs, OPTION4_DEF_DEFAULTS);
+        BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) {
+            cnt += SimpleParser::setDefaults(option_def, OPTION4_DEF_DEFAULTS);
+        }
     }
 
     // Set the defaults for option data
@@ -413,8 +415,8 @@ size_t SimpleParser4::setAllDefaults(ElementPtr global) {
         }
     }
 
-    // Set the defaults for dhcp-queue-control.  If the element isn't there
-    // we'll add it.
+    // Set the defaults for dhcp-queue-control.  If the element isn't
+    // there we'll add it.
     ConstElementPtr queue_control = global->get("dhcp-queue-control");
     ElementPtr mutable_cfg;
     if (queue_control) {
index e01bbf1a5ff6c28d96f42948e35ffe4cf037e0a8..f61fa3f964a162f23708a5c57fb047f3dcfa1858 100644 (file)
@@ -389,13 +389,17 @@ size_t SimpleParser6::setAllDefaults(ElementPtr global) {
     // Now set the defaults for each specified option definition
     ConstElementPtr option_defs = global->get("option-def");
     if (option_defs) {
-        cnt += setListDefaults(option_defs, OPTION6_DEF_DEFAULTS);
+        BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) {
+            cnt += SimpleParser::setDefaults(option_def, OPTION6_DEF_DEFAULTS);
+        }
     }
 
     // Set the defaults for option data
     ConstElementPtr options = global->get("option-data");
     if (options) {
-        cnt += setListDefaults(options, OPTION6_DEFAULTS);
+        BOOST_FOREACH(ElementPtr single_option, options->listValue()) {
+            cnt += SimpleParser::setDefaults(single_option, OPTION6_DEFAULTS);
+        }
     }
 
     // Now set the defaults for defined subnets