]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[575-cb-cmds-unknown-fields-in-arguments-should-raise-an-error] Moved parameters...
authorFrancis Dupont <fdupont@isc.org>
Wed, 3 Jul 2019 21:14:52 +0000 (23:14 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sun, 7 Jul 2019 09:07:09 +0000 (11:07 +0200)
13 files changed:
src/lib/dhcpsrv/parsers/dhcp_parsers.cc
src/lib/dhcpsrv/parsers/dhcp_parsers.h
src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.cc
src/lib/dhcpsrv/parsers/expiration_config_parser.cc
src/lib/dhcpsrv/parsers/ifaces_config_parser.cc
src/lib/dhcpsrv/parsers/option_data_parser.cc
src/lib/dhcpsrv/parsers/option_data_parser.h
src/lib/dhcpsrv/parsers/shared_network_parser.cc
src/lib/dhcpsrv/parsers/shared_network_parser.h
src/lib/dhcpsrv/parsers/simple_parser4.cc
src/lib/dhcpsrv/parsers/simple_parser4.h
src/lib/dhcpsrv/parsers/simple_parser6.cc
src/lib/dhcpsrv/parsers/simple_parser6.h

index 303e4e6861bd922c2289eaad4930aa21d7c4ced2..8d7fc4f7c79e25ef5d3b1ea9a79ce0ad3877c48b 100644 (file)
@@ -15,6 +15,8 @@
 #include <dhcpsrv/parsers/host_reservation_parser.h>
 #include <dhcpsrv/parsers/host_reservations_list_parser.h>
 #include <dhcpsrv/parsers/option_data_parser.h>
+#include <dhcpsrv/parsers/simple_parser4.h>
+#include <dhcpsrv/parsers/simple_parser6.h>
 #include <dhcpsrv/cfg_mac_source.h>
 #include <util/encode/hex.h>
 #include <util/strutil.h>
@@ -112,20 +114,6 @@ OptionDataParser::findOptionDefinition(const std::string& option_space,
 
 // ******************************** OptionDefParser ****************************
 
-const SimpleKeywords
-OptionDefParser::OPTION_DEF_PARAMETERS = {
-    { "name",         Element::string },
-    { "code",         Element::integer },
-    { "type",         Element::string },
-    { "record-types", Element::string },
-    { "space",        Element::string },
-    { "encapsulate",  Element::string },
-    { "array",        Element::boolean, },
-    { "user-context", Element::map },
-    { "comment",      Element::string },
-    { "metadata",     Element::map }
-};
-
 OptionDefParser::OptionDefParser(const uint16_t address_family)
     : address_family_(address_family) {
 }
@@ -134,7 +122,11 @@ std::pair<isc::dhcp::OptionDefinitionPtr, std::string>
 OptionDefParser::parse(ConstElementPtr option_def) {
 
     // Check parameters.
-    checkKeywords(OPTION_DEF_PARAMETERS, option_def);
+    if (address_family_ == AF_INET) {
+        checkKeywords(SimpleParser4::OPTION4_DEF_PARAMETERS, option_def);
+    } else {
+        checkKeywords(SimpleParser6::OPTION6_DEF_PARAMETERS, option_def);
+    }
 
     // Get mandatory parameters.
     std::string name = getString(option_def, "name");
@@ -381,23 +373,16 @@ RelayInfoParser::addAddress(const std::string& name,
 
 //****************************** PoolParser ********************************
 
-const SimpleKeywords
-PoolParser::POOL_PARAMETERS = {
-    { "pool",                   Element::string },
-    { "option-data",            Element::list },
-    { "client-class",           Element::string },
-    { "require-client-classes", Element::list },
-    { "user-context",           Element::map },
-    { "comment",                Element::string },
-    { "metadata",               Element::map }
-};
-
 void
 PoolParser::parse(PoolStoragePtr pools,
                   ConstElementPtr pool_structure,
                   const uint16_t address_family) {
 
-    checkKeywords(POOL_PARAMETERS, pool_structure);
+    if (address_family == AF_INET) {
+        checkKeywords(SimpleParser4::POOL4_PARAMETERS, pool_structure);
+    } else {
+        checkKeywords(SimpleParser6::POOL6_PARAMETERS, pool_structure);
+    }
 
     ConstElementPtr text_pool = pool_structure->get("pool");
 
@@ -691,37 +676,6 @@ SubnetConfigParser::createSubnet(ConstElementPtr params) {
 
 //****************************** Subnet4ConfigParser *************************
 
-const SimpleKeywords
-Subnet4ConfigParser::SUBNET4_PARAMETERS = {
-    { "valid-lifetime",         Element::integer },
-    { "renew-timer",            Element::integer },
-    { "rebind-timer",           Element::integer },
-    { "option-data",            Element::list },
-    { "pools",                  Element::list },
-    { "subnet",                 Element::string },
-    { "interface",              Element::string },
-    { "id",                     Element::integer },
-    { "client-class",           Element::string },
-    { "require-client-classes", Element::list },
-    { "reservations",           Element::list },
-    { "reservation-mode",       Element::string },
-    { "relay",                  Element::map },
-    { "match-client-id",        Element::boolean },
-    { "authoritative",          Element::boolean },
-    { "next-server",            Element::string },
-    { "server-hostname",        Element::string },
-    { "boot-file-name",         Element::string },
-    { "4o6-interface",          Element::string },
-    { "4o6-interface-id",       Element::string },
-    { "4o6-subnet",             Element::string },
-    { "user-context",           Element::map },
-    { "comment",                Element::string },
-    { "calculate-tee-times",    Element::boolean },
-    { "t1-percent",             Element::real },
-    { "t2-percent",             Element::real },
-    { "metadata",               Element::map }
-};
-
 Subnet4ConfigParser::Subnet4ConfigParser()
     :SubnetConfigParser(AF_INET) {
 }
@@ -729,7 +683,7 @@ Subnet4ConfigParser::Subnet4ConfigParser()
 Subnet4Ptr
 Subnet4ConfigParser::parse(ConstElementPtr subnet) {
     // Check parameters.
-    checkKeywords(SUBNET4_PARAMETERS, subnet);
+    checkKeywords(SimpleParser4::SUBNET4_PARAMETERS, subnet);
 
     /// Parse Pools first.
     ConstElementPtr pools = subnet->get("pools");
@@ -1053,27 +1007,12 @@ Pools6ListParser::parse(PoolStoragePtr pools, ConstElementPtr pools_list) {
 
 //**************************** PdPoolParser ******************************
 
-const SimpleKeywords
-PdPoolParser::PD_POOL_PARAMETERS = {
-    { "prefix",                 Element::string },
-    { "prefix-len",             Element::integer },
-    { "delegated-len",          Element::integer },
-    { "option-data",            Element::list },
-    { "client-class",           Element::string },
-    { "require-client-classes", Element::list },
-    { "excluded-prefix",        Element::string },
-    { "excluded-prefix-len",    Element::integer },
-    { "user-context",           Element::map },
-    { "comment",                Element::string },
-    { "metadata",               Element::map }
-};
-
 PdPoolParser::PdPoolParser() : options_(new CfgOption()) {
 }
 
 void
 PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_) {
-    checkKeywords(PD_POOL_PARAMETERS, pd_pool_);
+    checkKeywords(SimpleParser6::PD_POOL6_PARAMETERS, pd_pool_);
 
     std::string addr_str = getString(pd_pool_, "prefix");
 
@@ -1169,33 +1108,6 @@ PdPoolsListParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_list) {
 
 //**************************** Subnet6ConfigParser ***********************
 
-const SimpleKeywords
-Subnet6ConfigParser::SUBNET6_PARAMETERS = {
-    { "preferred-lifetime",     Element::integer },
-    { "valid-lifetime",         Element::integer },
-    { "renew-timer",            Element::integer },
-    { "rebind-timer",           Element::integer },
-    { "option-data",            Element::list },
-    { "pools",                  Element::list },
-    { "pd-pools",               Element::list },
-    { "subnet",                 Element::string },
-    { "interface",              Element::string },
-    { "interface-id",           Element::string },
-    { "id",                     Element::integer },
-    { "rapid-commit",           Element::boolean },
-    { "client-class",           Element::string },
-    { "require-client-classes", Element::list },
-    { "reservations",           Element::list },
-    { "reservation-mode",       Element::string },
-    { "relay",                  Element::map },
-    { "user-context",           Element::map },
-    { "comment",                Element::string },
-    { "calculate-tee-times",    Element::boolean },
-    { "t1-percent",             Element::real },
-    { "t2-percent",             Element::real },
-    { "metadata",               Element::map }
-};
-
 Subnet6ConfigParser::Subnet6ConfigParser()
     : SubnetConfigParser(AF_INET6) {
 }
@@ -1203,7 +1115,7 @@ Subnet6ConfigParser::Subnet6ConfigParser()
 Subnet6Ptr
 Subnet6ConfigParser::parse(ConstElementPtr subnet) {
     // Check parameters.
-    checkKeywords(SUBNET6_PARAMETERS, subnet);
+    checkKeywords(SimpleParser6::SUBNET6_PARAMETERS, subnet);
 
     /// Parse all pools first.
     ConstElementPtr pools = subnet->get("pools");
index 6d274749dcda390cec1742e3bfe162b7bd185527..8333c4b74962c0e1a80c567c54d9bd748148d438 100644 (file)
@@ -242,13 +242,6 @@ public:
     OptionDefinitionTuple
     parse(isc::data::ConstElementPtr option_def);
 
-    /// @brief This table defines all option definition parameters.
-    ///
-    /// Boolean, integer, real and string types are for scalar parameters,
-    /// list and map types for entries.
-    /// Order follows option_def_param rules in bison grammar.
-    static const isc::data::SimpleKeywords OPTION_DEF_PARAMETERS;
-
 private:
     /// @brief Address family: @c AF_INET or @c AF_INET6.
     uint16_t address_family_;
@@ -316,13 +309,6 @@ public:
                        isc::data::ConstElementPtr pool_structure,
                        const uint16_t address_family);
 
-    /// @brief This table defines all pool parameters.
-    ///
-    /// Boolean, integer, real and string types are for scalar parameters,
-    /// list and map types for entries.
-    /// Order follows pool_param rules in bison grammar.
-    static const isc::data::SimpleKeywords POOL_PARAMETERS;
-
 protected:
     /// @brief Creates a Pool object given a IPv4 prefix and the prefix length.
     ///
@@ -561,13 +547,6 @@ public:
     /// @return a pointer to created Subnet4 object
     Subnet4Ptr parse(data::ConstElementPtr subnet);
 
-    /// @brief This table defines all subnet parameters for DHCPv4.
-    ///
-    /// Boolean, integer, real and string types are for scalar parameters,
-    /// list and map types for entries.
-    /// Order follows subnet4_param rule in bison grammar.
-    static const isc::data::SimpleKeywords SUBNET4_PARAMETERS;
-
 protected:
 
     /// @brief Instantiates the IPv4 Subnet based on a given IPv4 address
@@ -690,13 +669,6 @@ public:
     /// @throw DhcpConfigError if configuration parsing fails.
     void parse(PoolStoragePtr pools, data::ConstElementPtr pd_pool_);
 
-    /// @brief This table defines all prefix delegation pool parameters.
-    ///
-    /// Boolean, integer, real and string types are for scalar parameters,
-    /// list and map types for entries.
-    /// Order follows pd_pool_param rules in bison grammar.
-    static const isc::data::SimpleKeywords PD_POOL_PARAMETERS;
-
 private:
 
     /// Pointer to the created pool object.
@@ -758,13 +730,6 @@ public:
     /// @return a pointer to created Subnet6 object
     Subnet6Ptr parse(data::ConstElementPtr subnet);
 
-    /// @brief This table defines all subnet parameters for DHCPv6.
-    ///
-    /// Boolean, integer, real and string types are for scalar parameters,
-    /// list and map types for entries.
-    /// Order follows subnet6_param rule in bison grammar.
-    static const isc::data::SimpleKeywords SUBNET6_PARAMETERS;
-
 protected:
     /// @brief Issues a DHCP6 server specific warning regarding duplicate subnet
     /// options.
index 728c06338af9aa57be880141b94be2d9ec060ce8..47eeac962da6082b8228beae832ac168b9688b07 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -18,10 +18,10 @@ using namespace isc::data;
 namespace isc {
 namespace dhcp {
 
-data::ElementPtr 
+data::ElementPtr
 DHCPQueueControlParser::parse(const isc::data::ConstElementPtr& control_elem) {
     // All we really do here is verify that it is a map that
-    // contains at least queue-type.  All other content depends 
+    // contains at least queue-type.  All other content depends
     // on the packet queue implementation of that type.
     if (control_elem->getType() != Element::map) {
         isc_throw(DhcpConfigError, "dhcp-queue-control must be a map");
index 57ff60b925d6cd2b8d67be9c9ca42e998879a423..3bbe33386063680d38092c30b86df5903a9a9357 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015,2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -44,7 +44,7 @@ ExpirationConfigParser::parse(ConstElementPtr expiration_config) {
         param = "max-reclaim-leases";
         if (expiration_config->contains(param)) {
             cfg->setMaxReclaimLeases(getInteger(expiration_config, param));
-        }                          
+        }
 
         param = "max-reclaim-time";
         if (expiration_config->contains(param)) {
index ed90f64898e8c91336c10e5834e4a711688db7e4..f8e97b24d0ccfce5bbe6f05e3c3b354053326339 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -41,7 +41,7 @@ void
 IfacesConfigParser::parse(const CfgIfacePtr& cfg,
                           const isc::data::ConstElementPtr& ifaces_config) {
 
-    // Check for re-detect before calling parseInterfacesList() 
+    // Check for re-detect before calling parseInterfacesList()
     bool re_detect = getBoolean(ifaces_config, "re-detect");
     cfg->setReDetect(re_detect);
     if (re_detect) {
index 4e430e438f706023b02769329ee5152487397911..99177fae0534137ec494241c3d85f97f5d0bc22a 100644 (file)
@@ -13,6 +13,8 @@
 #include <dhcp/option_space.h>
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/parsers/option_data_parser.h>
+#include <dhcpsrv/parsers/simple_parser4.h>
+#include <dhcpsrv/parsers/simple_parser6.h>
 #include <util/encode/hex.h>
 #include <util/strutil.h>
 #include <boost/foreach.hpp>
@@ -27,19 +29,6 @@ namespace dhcp {
 
 // **************************** OptionDataParser *************************
 
-const SimpleKeywords
-OptionDataParser::OPTION_PARAMETERS = {
-    { "name",         Element::string },
-    { "data",         Element::string },
-    { "code",         Element::integer },
-    { "space",        Element::string },
-    { "csv-format",   Element::boolean },
-    { "always-send",  Element::boolean },
-    { "user-context", Element::map },
-    { "comment",      Element::string },
-    { "metadata",     Element::map }
-};
-
 OptionDataParser::OptionDataParser(const uint16_t address_family,
                                    CfgOptionDefPtr cfg_option_def)
     : address_family_(address_family), cfg_option_def_(cfg_option_def) {
@@ -49,7 +38,11 @@ std::pair<OptionDescriptor, std::string>
 OptionDataParser::parse(isc::data::ConstElementPtr single_option) {
 
     // Check parameters.
-    checkKeywords(OPTION_PARAMETERS, single_option);
+    if (address_family_ == AF_INET) {
+        checkKeywords(SimpleParser4::OPTION4_PARAMETERS, single_option);
+    } else {
+        checkKeywords(SimpleParser6::OPTION6_PARAMETERS, single_option);
+    }
 
     // Try to create the option instance.
     std::pair<OptionDescriptor, std::string> opt = createOption(single_option);
index 1c4bee2d378522c7d4791e7c934a801295d1fb7c..13044c324b98e73cbcfc86195ca63cfab30dc65d 100644 (file)
@@ -65,13 +65,6 @@ public:
     std::pair<OptionDescriptor, std::string>
     parse(isc::data::ConstElementPtr single_option);
 
-    /// @brief This table defines all option parameters.
-    ///
-    /// Boolean, integer, real and string types are for scalar parameters,
-    /// list and map types for entries.
-    /// Order follows option_param rules in bison grammar.
-    static const isc::data::SimpleKeywords OPTION_PARAMETERS;
-
 private:
 
     /// @brief Finds an option definition within an option space
index 6444d6cc78d636535d471c612ba37d60c2d078b9..4ec06d6381ae74f76ca6ba89190fe971568eea8a 100644 (file)
@@ -13,6 +13,8 @@
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/option_data_parser.h>
 #include <dhcpsrv/parsers/shared_network_parser.h>
+#include <dhcpsrv/parsers/simple_parser4.h>
+#include <dhcpsrv/parsers/simple_parser6.h>
 #include <dhcpsrv/shared_network.h>
 #include <boost/pointer_cast.hpp>
 #include <string>
@@ -24,39 +26,14 @@ using namespace isc::util;
 namespace isc {
 namespace dhcp {
 
-const SimpleKeywords
-SharedNetwork4Parser::SHARED_NETWORK4_PARAMETERS = {
-    { "name",                   Element::string },
-    { "subnet4",                Element::list },
-    { "interface",              Element::string },
-    { "renew-timer",            Element::integer },
-    { "rebind-timer",           Element::integer },
-    { "option-data",            Element::list },
-    { "match-client-id",        Element::boolean },
-    { "authoritative",          Element::boolean },
-    { "next-server",            Element::string },
-    { "server-hostname",        Element::string },
-    { "boot-file-name",         Element::string },
-    { "relay",                  Element::map },
-    { "reservation-mode",       Element::string },
-    { "client-class",           Element::string },
-    { "require-client-classes", Element::list },
-    { "valid-lifetime",         Element::integer },
-    { "user-context",           Element::map },
-    { "comment",                Element::string },
-    { "calculate-tee-times",    Element::boolean },
-    { "t1-percent",             Element::real },
-    { "t2-percent",             Element::real },
-    { "metadata",               Element::map }
-};
-
 SharedNetwork4Ptr
 SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data) {
     SharedNetwork4Ptr shared_network;
     try {
 
         // Check parameters.
-        checkKeywords(SHARED_NETWORK4_PARAMETERS, shared_network_data);
+        checkKeywords(SimpleParser4::SHARED_NETWORK4_PARAMETERS,
+                      shared_network_data);
 
         // Make sure that the network name has been specified. The name is required
         // to create a SharedNetwork4 object.
@@ -215,37 +192,14 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data) {
     return (shared_network);
 }
 
-const SimpleKeywords
-SharedNetwork6Parser::SHARED_NETWORK6_PARAMETERS = {
-    { "name",                   Element::string },
-    { "subnet6",                Element::list },
-    { "interface",              Element::string },
-    { "interface-id",           Element::string },
-    { "renew-timer",            Element::integer },
-    { "rebind-timer",           Element::integer },
-    { "option-data",            Element::list },
-    { "relay",                  Element::map },
-    { "reservation-mode",       Element::string },
-    { "client-class",           Element::string },
-    { "require-client-classes", Element::list },
-    { "preferred-lifetime",     Element::integer },
-    { "rapid-commit",           Element::boolean },
-    { "valid-lifetime",         Element::integer },
-    { "user-context",           Element::map },
-    { "comment",                Element::string },
-    { "calculate-tee-times",    Element::boolean },
-    { "t1-percent",             Element::real },
-    { "t2-percent",             Element::real },
-    { "metadata",               Element::map }
-};
-
 SharedNetwork6Ptr
 SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data) {
     SharedNetwork6Ptr shared_network;
     std::string name;
     try {
         // Check parameters.
-        checkKeywords(SHARED_NETWORK6_PARAMETERS, shared_network_data);
+        checkKeywords(SimpleParser6::SHARED_NETWORK6_PARAMETERS,
+                      shared_network_data);
 
         // Make sure that the network name has been specified. The name is required
         // to create a SharedNetwork6 object.
@@ -389,4 +343,3 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data) {
 
 } // end of namespace isc::dhcp
 } // end of namespace isc
-
index 3e6a16e55ac6e339492604cce5330d80baf66e1c..fa4a03a737f0a2ed04268352dedefdf2f019f17f 100644 (file)
@@ -21,13 +21,6 @@ namespace dhcp {
 class SharedNetwork4Parser : public BaseNetworkParser {
 public:
 
-    /// @brief This table defines all shared network parameters for DHCPv4.
-    ///
-    /// Boolean, integer, real and string types are for scalar parameters,
-    /// list and map types for entries.
-    /// Order follows shared_network_param rule in bison grammar.
-    static const isc::data::SimpleKeywords SHARED_NETWORK4_PARAMETERS;
-
     /// @brief Parses shared configuration information for IPv4 shared network.
     ///
     /// @param shared_network_data Data element holding shared network
@@ -42,14 +35,6 @@ public:
 /// @brief Implements parser for IPv6 shared networks.
 class SharedNetwork6Parser : public BaseNetworkParser {
 public:
-
-    /// @brief This table defines all shared network parameters for DHCPv6.
-    ///
-    /// Boolean, integer, real and string types are for scalar parameters,
-    /// list and map types for entries.
-    /// Order follows shared_network_param rule in bison grammar.
-    static const isc::data::SimpleKeywords SHARED_NETWORK6_PARAMETERS;
-
     /// @brief Parses shared configuration information for IPv6 shared network.
     ///
     /// @param shared_network_data Data element holding shared network
index e38c2f328b97612107b2bb108256e1242c86cb5f..4236d480a406ea080e627d431bc9b8cd9322a817 100644 (file)
@@ -79,6 +79,46 @@ const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = {
     { "hostname-char-replacement",    Element::string }
 };
 
+/// @brief This table defines default global values for DHCPv4
+///
+/// Some of the global parameters defined in the global scope (i.e. directly
+/// in Dhcp4) are optional. If not defined, the following values will be
+/// used.
+const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = {
+    { "valid-lifetime",            Element::integer, "7200" },
+    { "decline-probation-period",  Element::integer, "86400" }, // 24h
+    { "dhcp4o6-port",              Element::integer, "0" },
+    { "echo-client-id",            Element::boolean, "true" },
+    { "match-client-id",           Element::boolean, "true" },
+    { "authoritative",             Element::boolean, "false" },
+    { "next-server",               Element::string,  "0.0.0.0" },
+    { "server-hostname",           Element::string,  "" },
+    { "boot-file-name",            Element::string,  "" },
+    { "server-tag",                Element::string,  "" },
+    { "reservation-mode",          Element::string,  "all" },
+    { "calculate-tee-times",       Element::boolean, "false" },
+    { "t1-percent",                Element::real,    ".50" },
+    { "t2-percent",                Element::real,    ".875" }
+};
+
+/// @brief This table defines all option definition parameters.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows option_def_param rules in bison grammar.
+const SimpleKeywords SimpleParser4::OPTION4_DEF_PARAMETERS = {
+    { "name",         Element::string },
+    { "code",         Element::integer },
+    { "type",         Element::string },
+    { "record-types", Element::string },
+    { "space",        Element::string },
+    { "encapsulate",  Element::string },
+    { "array",        Element::boolean, },
+    { "user-context", Element::map },
+    { "comment",      Element::string },
+    { "metadata",     Element::map }
+};
+
 /// @brief This table defines default values for option definitions in DHCPv4.
 ///
 /// Dhcp4 may contain an array called option-def that enumerates new option
@@ -90,6 +130,23 @@ const SimpleDefaults SimpleParser4::OPTION4_DEF_DEFAULTS = {
     { "encapsulate",  Element::string,  "" }
 };
 
+/// @brief This table defines all option parameters.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows option_param rules in bison grammar.
+const SimpleKeywords SimpleParser4::OPTION4_PARAMETERS = {
+    { "name",         Element::string },
+    { "data",         Element::string },
+    { "code",         Element::integer },
+    { "space",        Element::string },
+    { "csv-format",   Element::boolean },
+    { "always-send",  Element::boolean },
+    { "user-context", Element::map },
+    { "comment",      Element::string },
+    { "metadata",     Element::map }
+};
+
 /// @brief This table defines default values for options in DHCPv4.
 ///
 /// Dhcp4 usually contains option values (option-data) defined in global,
@@ -101,26 +158,39 @@ const SimpleDefaults SimpleParser4::OPTION4_DEFAULTS = {
     { "always-send",  Element::boolean, "false"}
 };
 
-/// @brief This table defines default global values for DHCPv4
+/// @brief This table defines all subnet parameters for DHCPv4.
 ///
-/// Some of the global parameters defined in the global scope (i.e. directly
-/// in Dhcp4) are optional. If not defined, the following values will be
-/// used.
-const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = {
-    { "valid-lifetime",            Element::integer, "7200" },
-    { "decline-probation-period",  Element::integer, "86400" }, // 24h
-    { "dhcp4o6-port",              Element::integer, "0" },
-    { "echo-client-id",            Element::boolean, "true" },
-    { "match-client-id",           Element::boolean, "true" },
-    { "authoritative",             Element::boolean, "false" },
-    { "next-server",               Element::string,  "0.0.0.0" },
-    { "server-hostname",           Element::string,  "" },
-    { "boot-file-name",            Element::string,  "" },
-    { "server-tag",                Element::string,  "" },
-    { "reservation-mode",          Element::string,  "all" },
-    { "calculate-tee-times",       Element::boolean, "false" },
-    { "t1-percent",                Element::real,    ".50" },
-    { "t2-percent",                Element::real,    ".875" }
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows subnet4_param rule in bison grammar.
+const SimpleKeywords SimpleParser4::SUBNET4_PARAMETERS = {
+    { "valid-lifetime",         Element::integer },
+    { "renew-timer",            Element::integer },
+    { "rebind-timer",           Element::integer },
+    { "option-data",            Element::list },
+    { "pools",                  Element::list },
+    { "subnet",                 Element::string },
+    { "interface",              Element::string },
+    { "id",                     Element::integer },
+    { "client-class",           Element::string },
+    { "require-client-classes", Element::list },
+    { "reservations",           Element::list },
+    { "reservation-mode",       Element::string },
+    { "relay",                  Element::map },
+    { "match-client-id",        Element::boolean },
+    { "authoritative",          Element::boolean },
+    { "next-server",            Element::string },
+    { "server-hostname",        Element::string },
+    { "boot-file-name",         Element::string },
+    { "4o6-interface",          Element::string },
+    { "4o6-interface-id",       Element::string },
+    { "4o6-subnet",             Element::string },
+    { "user-context",           Element::map },
+    { "comment",                Element::string },
+    { "calculate-tee-times",    Element::boolean },
+    { "t1-percent",             Element::real },
+    { "t2-percent",             Element::real },
+    { "metadata",               Element::map }
 };
 
 /// @brief This table defines default values for each IPv4 subnet.
@@ -152,29 +222,6 @@ const SimpleDefaults SimpleParser4::SHARED_SUBNET4_DEFAULTS = {
     { "4o6-subnet",       Element::string,  "" },
 };
 
-/// @brief This table defines default values for each IPv4 shared network.
-const SimpleDefaults SimpleParser4::SHARED_NETWORK4_DEFAULTS = {
-    { "client-class",     Element::string, "" },
-    { "interface",        Element::string, "" }
-};
-
-/// @brief This table defines default values for interfaces for DHCPv4.
-const SimpleDefaults SimpleParser4::IFACE4_DEFAULTS = {
-    { "re-detect", Element::boolean, "true" }
-};
-
-/// @brief This table defines default values for dhcp-queue-control in DHCPv4.
-const SimpleDefaults SimpleParser4::DHCP_QUEUE_CONTROL4_DEFAULTS = {
-    { "enable-queue",   Element::boolean, "false"},
-    { "queue-type",     Element::string,  "kea-ring4"},
-    { "capacity",       Element::integer, "500"}
-};
-
-/// @brief This defines default values for sanity checking for DHCPv4.
-const SimpleDefaults SimpleParser4::SANITY_CHECKS4_DEFAULTS = {
-    { "lease-checks", Element::string, "warn" }
-};
-
 /// @brief List of parameters that can be inherited to subnet4 scope.
 ///
 /// Some parameters may be defined on both global (directly in Dhcp4) and
@@ -204,13 +251,81 @@ const ParamsList SimpleParser4::INHERIT_TO_SUBNET4 = {
     "t2-percent"
 };
 
+/// @brief This table defines all pool parameters.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows pool_param rules in bison grammar.
+const SimpleKeywords SimpleParser4::POOL4_PARAMETERS = {
+    { "pool",                   Element::string },
+    { "option-data",            Element::list },
+    { "client-class",           Element::string },
+    { "require-client-classes", Element::list },
+    { "user-context",           Element::map },
+    { "comment",                Element::string },
+    { "metadata",               Element::map }
+};
+
+/// @brief This table defines all shared network parameters for DHCPv4.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows shared_network_param rule in bison grammar.
+const SimpleKeywords SimpleParser4::SHARED_NETWORK4_PARAMETERS = {
+    { "name",                   Element::string },
+    { "subnet4",                Element::list },
+    { "interface",              Element::string },
+    { "renew-timer",            Element::integer },
+    { "rebind-timer",           Element::integer },
+    { "option-data",            Element::list },
+    { "match-client-id",        Element::boolean },
+    { "authoritative",          Element::boolean },
+    { "next-server",            Element::string },
+    { "server-hostname",        Element::string },
+    { "boot-file-name",         Element::string },
+    { "relay",                  Element::map },
+    { "reservation-mode",       Element::string },
+    { "client-class",           Element::string },
+    { "require-client-classes", Element::list },
+    { "valid-lifetime",         Element::integer },
+    { "user-context",           Element::map },
+    { "comment",                Element::string },
+    { "calculate-tee-times",    Element::boolean },
+    { "t1-percent",             Element::real },
+    { "t2-percent",             Element::real },
+    { "metadata",               Element::map }
+};
+
+/// @brief This table defines default values for each IPv4 shared network.
+const SimpleDefaults SimpleParser4::SHARED_NETWORK4_DEFAULTS = {
+    { "client-class",     Element::string, "" },
+    { "interface",        Element::string, "" }
+};
+
+/// @brief This table defines default values for interfaces for DHCPv4.
+const SimpleDefaults SimpleParser4::IFACE4_DEFAULTS = {
+    { "re-detect", Element::boolean, "true" }
+};
+
+/// @brief This table defines default values for dhcp-queue-control in DHCPv4.
+const SimpleDefaults SimpleParser4::DHCP_QUEUE_CONTROL4_DEFAULTS = {
+    { "enable-queue",   Element::boolean, "false"},
+    { "queue-type",     Element::string,  "kea-ring4"},
+    { "capacity",       Element::integer, "500"}
+};
+
+/// @brief This defines default values for sanity checking for DHCPv4.
+const SimpleDefaults SimpleParser4::SANITY_CHECKS4_DEFAULTS = {
+    { "lease-checks", Element::string, "warn" }
+};
+
 /// @}
 
 /// ---------------------------------------------------------------------------
 /// --- end of default values -------------------------------------------------
 /// ---------------------------------------------------------------------------
 
-size_t SimpleParser4::setAllDefaults(isc::data::ElementPtr global) {
+size_t SimpleParser4::setAllDefaults(ElementPtr global) {
     size_t cnt = 0;
 
     // Set global defaults first.
@@ -285,7 +400,7 @@ size_t SimpleParser4::setAllDefaults(isc::data::ElementPtr global) {
     return (cnt);
 }
 
-size_t SimpleParser4::deriveParameters(isc::data::ElementPtr global) {
+size_t SimpleParser4::deriveParameters(ElementPtr global) {
     size_t cnt = 0;
 
     // Now derive global parameters into subnets.
index d2f0b0acf410a003702a09ae05023e19b54d575f..063c6377667e02eb853f9109c61d919dbd9bed25 100644 (file)
@@ -38,16 +38,27 @@ public:
 
     // see simple_parser4.cc for comments for those parameters
     static const isc::data::SimpleKeywords GLOBAL4_PARAMETERS;
+    static const isc::data::SimpleDefaults GLOBAL4_DEFAULTS;
+
+    static const isc::data::SimpleKeywords OPTION4_DEF_PARAMETERS;
     static const isc::data::SimpleDefaults OPTION4_DEF_DEFAULTS;
+
+    static const isc::data::SimpleKeywords OPTION4_PARAMETERS;
     static const isc::data::SimpleDefaults OPTION4_DEFAULTS;
-    static const isc::data::SimpleDefaults GLOBAL4_DEFAULTS;
+
+    static const isc::data::SimpleKeywords SUBNET4_PARAMETERS;
     static const isc::data::SimpleDefaults SUBNET4_DEFAULTS;
     static const isc::data::SimpleDefaults SHARED_SUBNET4_DEFAULTS;
+    static const isc::data::ParamsList INHERIT_TO_SUBNET4;
+
+    static const isc::data::SimpleKeywords POOL4_PARAMETERS;
+
+    static const isc::data::SimpleKeywords SHARED_NETWORK4_PARAMETERS;
     static const isc::data::SimpleDefaults SHARED_NETWORK4_DEFAULTS;
+
     static const isc::data::SimpleDefaults IFACE4_DEFAULTS;
     static const isc::data::SimpleDefaults DHCP_QUEUE_CONTROL4_DEFAULTS;
     static const isc::data::SimpleDefaults SANITY_CHECKS4_DEFAULTS;
-    static const isc::data::ParamsList INHERIT_TO_SUBNET4;
 };
 
 };
index 73e85c59b0e84a55c7a02f3a2bb54bcba5eb3767..37914ff17292be7e7173e0e032fcf7f95933d24b 100644 (file)
@@ -79,6 +79,41 @@ const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = {
     { "hostname-char-replacement",    Element::string }
 };
 
+/// @brief This table defines default global values for DHCPv6
+///
+/// Some of the global parameters defined in the global scope (i.e. directly
+/// in Dhcp6) are optional. If not defined, the following values will be
+/// used.
+const SimpleDefaults SimpleParser6::GLOBAL6_DEFAULTS = {
+    { "preferred-lifetime",       Element::integer, "3600" },
+    { "valid-lifetime",           Element::integer, "7200" },
+    { "decline-probation-period", Element::integer, "86400" }, // 24h
+    { "dhcp4o6-port",             Element::integer, "0" },
+    { "server-tag",               Element::string,  "" },
+    { "reservation-mode",         Element::string,  "all" },
+    { "calculate-tee-times",      Element::boolean, "true" },
+    { "t1-percent",               Element::real,    ".50" },
+    { "t2-percent",               Element::real,    ".80" }
+};
+
+/// @brief This table defines all option definition parameters.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows option_def_param rules in bison grammar.
+const SimpleKeywords SimpleParser6::OPTION6_DEF_PARAMETERS = {
+    { "name",         Element::string },
+    { "code",         Element::integer },
+    { "type",         Element::string },
+    { "record-types", Element::string },
+    { "space",        Element::string },
+    { "encapsulate",  Element::string },
+    { "array",        Element::boolean, },
+    { "user-context", Element::map },
+    { "comment",      Element::string },
+    { "metadata",     Element::map }
+};
+
 /// @brief This table defines default values for option definitions in DHCPv6.
 ///
 /// Dhcp6 may contain an array called option-def that enumerates new option
@@ -90,6 +125,23 @@ const SimpleDefaults SimpleParser6::OPTION6_DEF_DEFAULTS = {
     { "encapsulate",  Element::string,  "" }
 };
 
+/// @brief This table defines all option parameters.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows option_param rules in bison grammar.
+const SimpleKeywords SimpleParser6::OPTION6_PARAMETERS = {
+    { "name",         Element::string },
+    { "data",         Element::string },
+    { "code",         Element::integer },
+    { "space",        Element::string },
+    { "csv-format",   Element::boolean },
+    { "always-send",  Element::boolean },
+    { "user-context", Element::map },
+    { "comment",      Element::string },
+    { "metadata",     Element::map }
+};
+
 /// @brief This table defines default values for options in DHCPv6.
 ///
 /// Dhcp6 usually contains option values (option-data) defined in global,
@@ -101,21 +153,35 @@ const SimpleDefaults SimpleParser6::OPTION6_DEFAULTS = {
     { "always-send",  Element::boolean, "false"}
 };
 
-/// @brief This table defines default global values for DHCPv6
+/// @brief This table defines all subnet parameters for DHCPv6.
 ///
-/// Some of the global parameters defined in the global scope (i.e. directly
-/// in Dhcp6) are optional. If not defined, the following values will be
-/// used.
-const SimpleDefaults SimpleParser6::GLOBAL6_DEFAULTS = {
-    { "preferred-lifetime",       Element::integer, "3600" },
-    { "valid-lifetime",           Element::integer, "7200" },
-    { "decline-probation-period", Element::integer, "86400" }, // 24h
-    { "dhcp4o6-port",             Element::integer, "0" },
-    { "server-tag",               Element::string,  "" },
-    { "reservation-mode",         Element::string,  "all" },
-    { "calculate-tee-times",      Element::boolean, "true" },
-    { "t1-percent",               Element::real,    ".50" },
-    { "t2-percent",               Element::real,    ".80" }
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows subnet6_param rule in bison grammar.
+const SimpleKeywords SimpleParser6::SUBNET6_PARAMETERS = {
+    { "preferred-lifetime",     Element::integer },
+    { "valid-lifetime",         Element::integer },
+    { "renew-timer",            Element::integer },
+    { "rebind-timer",           Element::integer },
+    { "option-data",            Element::list },
+    { "pools",                  Element::list },
+    { "pd-pools",               Element::list },
+    { "subnet",                 Element::string },
+    { "interface",              Element::string },
+    { "interface-id",           Element::string },
+    { "id",                     Element::integer },
+    { "rapid-commit",           Element::boolean },
+    { "client-class",           Element::string },
+    { "require-client-classes", Element::list },
+    { "reservations",           Element::list },
+    { "reservation-mode",       Element::string },
+    { "relay",                  Element::map },
+    { "user-context",           Element::map },
+    { "comment",                Element::string },
+    { "calculate-tee-times",    Element::boolean },
+    { "t1-percent",             Element::real },
+    { "t2-percent",             Element::real },
+    { "metadata",               Element::map }
 };
 
 /// @brief This table defines default values for each IPv6 subnet.
@@ -127,11 +193,6 @@ const SimpleDefaults SimpleParser6::SUBNET6_DEFAULTS = {
     { "interface-id",     Element::string,  "" }
 };
 
-/// @brief This table defines default values for each IPv6 subnet.
-const SimpleDefaults SimpleParser6::SHARED_SUBNET6_DEFAULTS = {
-    { "id",               Element::integer, "0" } // 0 means autogenerate
-};
-
 /// @brief This table defines default values for each IPv6 shared network.
 const SimpleDefaults SimpleParser6::SHARED_NETWORK6_DEFAULTS = {
     { "client-class",     Element::string,  "" },
@@ -140,24 +201,6 @@ const SimpleDefaults SimpleParser6::SHARED_NETWORK6_DEFAULTS = {
     { "rapid-commit",     Element::boolean, "false" } // rapid-commit disabled by default
 };
 
-
-/// @brief This table defines default values for interfaces for DHCPv6.
-const SimpleDefaults SimpleParser6::IFACE6_DEFAULTS = {
-    { "re-detect", Element::boolean, "true" }
-};
-
-/// @brief This table defines default values for dhcp-queue-control in DHCPv4.
-const SimpleDefaults SimpleParser6::DHCP_QUEUE_CONTROL6_DEFAULTS = {
-    { "enable-queue",   Element::boolean, "false"},
-    { "queue-type",     Element::string,  "kea-ring6"},
-    { "capacity",       Element::integer, "500"}
-};
-
-/// @brief This defines default values for sanity checking for DHCPv6.
-const SimpleDefaults SimpleParser6::SANITY_CHECKS6_DEFAULTS = {
-    { "lease-checks", Element::string, "warn" }
-};
-
 /// @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
@@ -187,13 +230,97 @@ const ParamsList SimpleParser6::INHERIT_TO_SUBNET6 = {
     "t2-percent"
 };
 
+/// @brief This table defines all pool parameters.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows pool_param rules in bison grammar.
+const SimpleKeywords SimpleParser6::POOL6_PARAMETERS = {
+    { "pool",                   Element::string },
+    { "option-data",            Element::list },
+    { "client-class",           Element::string },
+    { "require-client-classes", Element::list },
+    { "user-context",           Element::map },
+    { "comment",                Element::string },
+    { "metadata",               Element::map }
+};
+
+/// @brief This table defines all prefix delegation pool parameters.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows pd_pool_param rules in bison grammar.
+const SimpleKeywords SimpleParser6::PD_POOL6_PARAMETERS = {
+    { "prefix",                 Element::string },
+    { "prefix-len",             Element::integer },
+    { "delegated-len",          Element::integer },
+    { "option-data",            Element::list },
+    { "client-class",           Element::string },
+    { "require-client-classes", Element::list },
+    { "excluded-prefix",        Element::string },
+    { "excluded-prefix-len",    Element::integer },
+    { "user-context",           Element::map },
+    { "comment",                Element::string },
+    { "metadata",               Element::map }
+};
+
+/// @brief This table defines all shared network parameters for DHCPv6.
+///
+/// Boolean, integer, real and string types are for scalar parameters,
+/// list and map types for entries.
+/// Order follows shared_network_param rule in bison grammar.
+const SimpleKeywords SimpleParser6::SHARED_NETWORK6_PARAMETERS = {
+    { "name",                   Element::string },
+    { "subnet6",                Element::list },
+    { "interface",              Element::string },
+    { "interface-id",           Element::string },
+    { "renew-timer",            Element::integer },
+    { "rebind-timer",           Element::integer },
+    { "option-data",            Element::list },
+    { "relay",                  Element::map },
+    { "reservation-mode",       Element::string },
+    { "client-class",           Element::string },
+    { "require-client-classes", Element::list },
+    { "preferred-lifetime",     Element::integer },
+    { "rapid-commit",           Element::boolean },
+    { "valid-lifetime",         Element::integer },
+    { "user-context",           Element::map },
+    { "comment",                Element::string },
+    { "calculate-tee-times",    Element::boolean },
+    { "t1-percent",             Element::real },
+    { "t2-percent",             Element::real },
+    { "metadata",               Element::map }
+};
+
+/// @brief This table defines default values for each IPv6 subnet.
+const SimpleDefaults SimpleParser6::SHARED_SUBNET6_DEFAULTS = {
+    { "id",               Element::integer, "0" } // 0 means autogenerate
+};
+
+/// @brief This table defines default values for interfaces for DHCPv6.
+const SimpleDefaults SimpleParser6::IFACE6_DEFAULTS = {
+    { "re-detect", Element::boolean, "true" }
+};
+
+/// @brief This table defines default values for dhcp-queue-control in DHCPv4.
+const SimpleDefaults SimpleParser6::DHCP_QUEUE_CONTROL6_DEFAULTS = {
+    { "enable-queue",   Element::boolean, "false"},
+    { "queue-type",     Element::string,  "kea-ring6"},
+    { "capacity",       Element::integer, "500"}
+};
+
+/// @brief This defines default values for sanity checking for DHCPv6.
+const SimpleDefaults SimpleParser6::SANITY_CHECKS6_DEFAULTS = {
+    { "lease-checks", Element::string, "warn" }
+};
+
 /// @}
 
 /// ---------------------------------------------------------------------------
 /// --- end of default values -------------------------------------------------
 /// ---------------------------------------------------------------------------
 
-size_t SimpleParser6::setAllDefaults(isc::data::ElementPtr global) {
+size_t SimpleParser6::setAllDefaults(ElementPtr global) {
     size_t cnt = 0;
 
     // Set global defaults first.
@@ -270,7 +397,7 @@ size_t SimpleParser6::setAllDefaults(isc::data::ElementPtr global) {
     return (cnt);
 }
 
-size_t SimpleParser6::deriveParameters(isc::data::ElementPtr global) {
+size_t SimpleParser6::deriveParameters(ElementPtr global) {
     size_t cnt = 0;
     // Now derive global parameters into subnets.
     ConstElementPtr subnets = global->get("subnet6");
index 65067f7803f8811d482de7dd9ba6259086f6aabb..5ab2cd972a976bab5f4a3fd792581b95e72af654 100644 (file)
@@ -39,16 +39,28 @@ public:
 
     // see simple_parser6.cc for comments for those parameters
     static const isc::data::SimpleKeywords GLOBAL6_PARAMETERS;
+    static const isc::data::SimpleDefaults GLOBAL6_DEFAULTS;
+
+    static const isc::data::SimpleKeywords OPTION6_DEF_PARAMETERS;
     static const isc::data::SimpleDefaults OPTION6_DEF_DEFAULTS;
+
+    static const isc::data::SimpleKeywords OPTION6_PARAMETERS;
     static const isc::data::SimpleDefaults OPTION6_DEFAULTS;
-    static const isc::data::SimpleDefaults GLOBAL6_DEFAULTS;
+
+    static const isc::data::SimpleKeywords SUBNET6_PARAMETERS;
     static const isc::data::SimpleDefaults SUBNET6_DEFAULTS;
     static const isc::data::SimpleDefaults SHARED_SUBNET6_DEFAULTS;
+    static const isc::data::ParamsList INHERIT_TO_SUBNET6;
+
+    static const isc::data::SimpleKeywords POOL6_PARAMETERS;
+    static const isc::data::SimpleKeywords PD_POOL6_PARAMETERS;
+
+    static const isc::data::SimpleKeywords SHARED_NETWORK6_PARAMETERS;
     static const isc::data::SimpleDefaults SHARED_NETWORK6_DEFAULTS;
+
     static const isc::data::SimpleDefaults IFACE6_DEFAULTS;
     static const isc::data::SimpleDefaults DHCP_QUEUE_CONTROL6_DEFAULTS;
     static const isc::data::SimpleDefaults SANITY_CHECKS6_DEFAULTS;
-    static const isc::data::ParamsList INHERIT_TO_SUBNET6;
 };
 
 };