Browse Source

[3389a] Moved re-detect default to simple_parse[46]

Francis Dupont 7 years ago
parent
commit
9176623787

+ 0 - 3
src/bin/dhcp4/json_config_parser.cc

@@ -488,9 +488,6 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set,
                 if (check_only) {
                     // No re-detection in check only mode
                     ifaces_cfg->set("re-detect", Element::create(false));
-                } else if (!ifaces_cfg->contains("re-detect")) {
-                    // Else the default is to re-detect
-                    ifaces_cfg->set("re-detect", Element::create(true));
                 }
                 IfacesConfigParser parser(AF_INET);
                 CfgIfacePtr cfg_iface = srv_cfg->getCfgIface();

+ 12 - 0
src/bin/dhcp4/simple_parser4.cc

@@ -75,6 +75,11 @@ const SimpleDefaults SimpleParser4::SUBNET4_DEFAULTS = {
     { "4o6-subnet",       Element::string,  "" },
 };
 
+/// @brief This table defines default values for interfaces for DHCPv4.
+const SimpleDefaults SimpleParser4::IFACE4_DEFAULTS = {
+    { "re-detect", Element::boolean, "true" }
+};
+
 /// @brief List of parameters that can be inherited from the global to subnet4 scope.
 ///
 /// Some parameters may be defined on both global (directly in Dhcp4) and
@@ -120,6 +125,13 @@ size_t SimpleParser4::setAllDefaults(isc::data::ElementPtr global) {
         cnt += setListDefaults(subnets, SUBNET4_DEFAULTS);
     }
 
+    // Set the defaults for interfaces config
+    ConstElementPtr ifaces_cfg = global->get("interfaces-config");
+    if (ifaces_cfg) {
+        ElementPtr mutable_cfg = boost::const_pointer_cast<Element>(ifaces_cfg);
+        cnt += setDefaults(mutable_cfg, IFACE4_DEFAULTS);
+    }
+
     return (cnt);
 }
 

+ 1 - 0
src/bin/dhcp4/simple_parser4.h

@@ -41,6 +41,7 @@ public:
     static const isc::data::SimpleDefaults OPTION4_DEFAULTS;
     static const isc::data::SimpleDefaults GLOBAL4_DEFAULTS;
     static const isc::data::SimpleDefaults SUBNET4_DEFAULTS;
+    static const isc::data::SimpleDefaults IFACE4_DEFAULTS;
     static const isc::data::ParamsList INHERIT_GLOBAL_TO_SUBNET4;
 };
 

+ 0 - 3
src/bin/dhcp6/json_config_parser.cc

@@ -699,9 +699,6 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set,
                 if (check_only) {
                     // No re-detection in check only mode
                     ifaces_cfg->set("re-detect", Element::create(false));
-                } else if (!ifaces_cfg->contains("re-detect")) {
-                    // Else the default is to re-detect
-                    ifaces_cfg->set("re-detect", Element::create(true));
                 }
                 IfacesConfigParser parser(AF_INET6);
                 CfgIfacePtr cfg_iface = srv_config->getCfgIface();

+ 12 - 0
src/bin/dhcp6/simple_parser6.cc

@@ -72,6 +72,11 @@ const SimpleDefaults SimpleParser6::SUBNET6_DEFAULTS = {
     { "interface-id",     Element::string,  "" },
 };
 
+/// @brief This table defines default values for interfaces for DHCPv6.
+const SimpleDefaults SimpleParser6::IFACE6_DEFAULTS = {
+    { "re-detect", Element::boolean, "true" }
+};
+
 /// @brief List of parameters that can be inherited from the global to subnet6 scope.
 ///
 /// Some parameters may be defined on both global (directly in Dhcp6) and
@@ -119,6 +124,13 @@ size_t SimpleParser6::setAllDefaults(isc::data::ElementPtr global) {
         cnt += setListDefaults(subnets, SUBNET6_DEFAULTS);
     }
 
+    // Set the defaults for interfaces config
+    ConstElementPtr ifaces_cfg = global->get("interfaces-config");
+    if (ifaces_cfg) {
+        ElementPtr mutable_cfg = boost::const_pointer_cast<Element>(ifaces_cfg);
+        cnt += setDefaults(mutable_cfg, IFACE6_DEFAULTS);
+    }
+
     return (cnt);
 }
 

+ 1 - 0
src/bin/dhcp6/simple_parser6.h

@@ -42,6 +42,7 @@ public:
     static const isc::data::SimpleDefaults OPTION6_DEFAULTS;
     static const isc::data::SimpleDefaults GLOBAL6_DEFAULTS;
     static const isc::data::SimpleDefaults SUBNET6_DEFAULTS;
+    static const isc::data::SimpleDefaults IFACE6_DEFAULTS;
     static const isc::data::ParamsList INHERIT_GLOBAL_TO_SUBNET6;
 };