diff options
| author | Francis Dupont <fdupont@isc.org> | 2019-03-02 03:12:59 +0100 |
|---|---|---|
| committer | Francis Dupont <fdupont@isc.org> | 2019-03-07 10:50:34 -0500 |
| commit | 723efb56e823194200ab00dffcbed75f2864ffaf (patch) | |
| tree | 8f0a1c127198822528d6bf4c945a6b26416cad9d | |
| parent | b5f499e42ae801c4822e3ea4aac026c6573d6e4d (diff) | |
[499-global-keywords-entries] Added global parameter lists519-dhcp-server-response-an-empty-rai-field_base509-improve-disabling-client-id-lookup_base498-pkg-config-usage-in-kea-libs-is-wrong_base494-dhcp4configparser-sharednetworkssanitychecks-is-buggy_base
| -rw-r--r-- | doc/examples/kea4/all-keys.json | 1 | ||||
| -rw-r--r-- | src/bin/dhcp4/tests/parser_unittest.cc | 15 | ||||
| -rw-r--r-- | src/bin/dhcp6/tests/parser_unittest.cc | 15 | ||||
| -rw-r--r-- | src/lib/dhcpsrv/parsers/simple_parser4.cc | 44 | ||||
| -rw-r--r-- | src/lib/dhcpsrv/parsers/simple_parser4.h | 3 | ||||
| -rw-r--r-- | src/lib/dhcpsrv/parsers/simple_parser6.cc | 39 | ||||
| -rw-r--r-- | src/lib/dhcpsrv/parsers/simple_parser6.h | 3 |
7 files changed, 114 insertions, 6 deletions
diff --git a/doc/examples/kea4/all-keys.json b/doc/examples/kea4/all-keys.json index f0997ba52e..6c889c924c 100644 --- a/doc/examples/kea4/all-keys.json +++ b/doc/examples/kea4/all-keys.json @@ -689,6 +689,7 @@ // Queue type was mandatory. "queue-type": "kea-ring4" } + // Missing: calculate-tee-times, t1-percent, t2-percent }, // Logging configuration begins here. diff --git a/src/bin/dhcp4/tests/parser_unittest.cc b/src/bin/dhcp4/tests/parser_unittest.cc index e8598d009d..61ff0b1173 100644 --- a/src/bin/dhcp4/tests/parser_unittest.cc +++ b/src/bin/dhcp4/tests/parser_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-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 @@ -7,8 +7,8 @@ #include <config.h> #include <gtest/gtest.h> -#include <cc/data.h> #include <dhcp4/parser_context.h> +#include <dhcpsrv/parsers/simple_parser4.h> #include <testutils/io_utils.h> #include <testutils/user_context_utils.h> @@ -288,6 +288,17 @@ TEST(ParserTest, file) { } } +// This test loads the all-keys.json file and check global parameters. +TEST(ParserTest, globalParameters) { + ConstElementPtr json; + Parser4Context ctx; + string fname = string(CFG_EXAMPLES) + "/" + "all-keys.json"; + EXPECT_NO_THROW(json = ctx.parseFile(fname, Parser4Context::PARSER_DHCP4)); + EXPECT_NO_THROW(json = json->get("Dhcp4")); + SimpleParser4 parser; + EXPECT_NO_THROW(parser.checkKeywords(parser.GLOBAL4_PARAMETERS, json)); +} + // Basic test that checks if it's possible to specify outbound-interface. TEST(ParserTest, outboundIface) { std::string fname = string(CFG_EXAMPLES) + "/" + "advanced.json"; diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc index 16b22a9e7a..84ab706ec4 100644 --- a/src/bin/dhcp6/tests/parser_unittest.cc +++ b/src/bin/dhcp6/tests/parser_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-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 @@ -7,8 +7,8 @@ #include <config.h> #include <gtest/gtest.h> -#include <cc/data.h> #include <dhcp6/parser_context.h> +#include <dhcpsrv/parsers/simple_parser6.h> #include <testutils/io_utils.h> #include <testutils/user_context_utils.h> @@ -298,6 +298,17 @@ TEST(ParserTest, file) { } } +// This test loads the all-keys.json file and check global parameters. +TEST(ParserTest, globalParameters) { + ConstElementPtr json; + Parser6Context ctx; + string fname = string(CFG_EXAMPLES) + "/" + "all-keys.json"; + EXPECT_NO_THROW(json = ctx.parseFile(fname, Parser6Context::PARSER_DHCP6)); + EXPECT_NO_THROW(json = json->get("Dhcp6")); + SimpleParser6 parser; + EXPECT_NO_THROW(parser.checkKeywords(parser.GLOBAL6_PARAMETERS, json)); +} + /// @brief Tests error conditions in Dhcp6Parser /// /// @param txt text to be parsed diff --git a/src/lib/dhcpsrv/parsers/simple_parser4.cc b/src/lib/dhcpsrv/parsers/simple_parser4.cc index d73bb9a006..f2b19f43d5 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser4.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser4.cc @@ -30,6 +30,50 @@ namespace dhcp { /// /// @{ +/// @brief This table defines all global parameters in DHCPv4. +/// +/// Boolean, integer, real and string types are for scalar parameters, +/// list and map types for entries. +/// Order follows global_param rule in bison grammar. +const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = { + { "valid-lifetime", Element::integer }, + { "renew-timer", Element::integer }, + { "rebind-timer", Element::integer }, + { "decline-probation-period", Element::integer }, + { "subnet4", Element::list }, + { "shared-networks", Element::list }, + { "interfaces-config", Element::map }, + { "lease-database", Element::map }, + { "hosts-database", Element::map }, + { "hosts-databases", Element::list }, + { "host-reservation-identifiers", Element::list }, + { "client-classes", Element::list }, + { "option-def", Element::list }, + { "option-data", Element::list }, + { "hooks-libraries", Element::list }, + { "expired-leases-processing", Element::map }, + { "dhcp4o6-port", Element::integer }, + { "control-socket", Element::map }, + { "dhcp-queue-control", Element::map }, + { "dhcp-ddns", Element::map }, + { "echo-client-id", Element::boolean }, + { "match-client-id", Element::boolean }, + { "authoritative", Element::boolean }, + { "next-server", Element::string }, + { "server-hostname", Element::string }, + { "boot-file-name", Element::string }, + { "user-context", Element::map }, + { "comment", Element::string }, + { "sanity-checks", Element::map }, + { "reservations", Element::list }, + { "config-control", Element::map }, + { "server-tag", Element::string }, + { "reservation-mode", Element::string }, + { "calculate-tee-times", Element::boolean }, + { "t1-percent", Element::real }, + { "t2-percent", Element::real } +}; + /// @brief This table defines default values for option definitions in DHCPv4. /// /// Dhcp4 may contain an array called option-def that enumerates new option diff --git a/src/lib/dhcpsrv/parsers/simple_parser4.h b/src/lib/dhcpsrv/parsers/simple_parser4.h index ef7657eff0..069deb27ef 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser4.h +++ b/src/lib/dhcpsrv/parsers/simple_parser4.h @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-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 @@ -37,6 +37,7 @@ public: static size_t deriveParameters(isc::data::ElementPtr global); // see simple_parser4.cc for comments for those parameters + static const isc::data::SimpleKeywords GLOBAL4_PARAMETERS; static const isc::data::SimpleDefaults OPTION4_DEF_DEFAULTS; static const isc::data::SimpleDefaults OPTION4_DEFAULTS; static const isc::data::SimpleDefaults GLOBAL4_DEFAULTS; diff --git a/src/lib/dhcpsrv/parsers/simple_parser6.cc b/src/lib/dhcpsrv/parsers/simple_parser6.cc index df07d0d427..37fd49d240 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser6.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser6.cc @@ -29,6 +29,45 @@ namespace dhcp { /// /// @{ +/// @brief This table defines all global parameters in DHCPv6. +/// +/// Boolean, integer, real and string types are for scalar parameters, +/// list and map types for entries. +/// Order follows global_param rule in bison grammar. +const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = { + { "preferred-lifetime", Element::integer }, + { "valid-lifetime", Element::integer }, + { "renew-timer", Element::integer }, + { "rebind-timer", Element::integer }, + { "decline-probation-period", Element::integer }, + { "subnet6", Element::list }, + { "shared-networks", Element::list }, + { "interfaces-config", Element::map }, + { "lease-database", Element::map }, + { "hosts-database", Element::map }, + { "hosts-databases", Element::list }, + { "mac-sources", Element::list }, + { "relay-supplied-options", Element::list }, + { "host-reservation-identifiers", Element::list }, + { "client-classes", Element::list }, + { "option-def", Element::list }, + { "option-data", Element::list }, + { "hooks-libraries", Element::list }, + { "expired-leases-processing", Element::map }, + { "server-id", Element::map }, + { "dhcp4o6-port", Element::integer }, + { "control-socket", Element::map }, + { "dhcp-queue-control", Element::map }, + { "dhcp-ddns", Element::map }, + { "user-context", Element::map }, + { "comment", Element::string }, + { "sanity-checks", Element::map }, + { "reservations", Element::list }, + { "config-control", Element::map }, + { "server-tag", Element::string }, + { "reservation-mode", Element::string } +}; + /// @brief This table defines default values for option definitions in DHCPv6. /// /// Dhcp6 may contain an array called option-def that enumerates new option diff --git a/src/lib/dhcpsrv/parsers/simple_parser6.h b/src/lib/dhcpsrv/parsers/simple_parser6.h index 2c49bb5c5c..0004811561 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser6.h +++ b/src/lib/dhcpsrv/parsers/simple_parser6.h @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-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 @@ -38,6 +38,7 @@ public: static size_t deriveParameters(isc::data::ElementPtr global); // see simple_parser6.cc for comments for those parameters + static const isc::data::SimpleKeywords GLOBAL6_PARAMETERS; static const isc::data::SimpleDefaults OPTION6_DEF_DEFAULTS; static const isc::data::SimpleDefaults OPTION6_DEFAULTS; static const isc::data::SimpleDefaults GLOBAL6_DEFAULTS; |
