From: Thomas Markwalder Date: Tue, 16 Jun 2020 14:37:49 +0000 (-0400) Subject: [#1235] Addressed review comments X-Git-Tag: Kea-1.7.9~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=151b22b5bb68ab93867c82c8c850fe4692a72210;p=thirdparty%2Fkea.git [#1235] Addressed review comments src/lib/dhcp/libdhcp++.cc src/lib/dhcp/std_option_defs.h Removed LQ_QUERY_OPTION_SPACE, using DHCP6_OPTION_SPACE instead src/lib/dhcp/tests/libdhcp++_unittest.cc Updated unit test src/lib/dhcpsrv/cfg_duid.* CfgDUID::create() - reset the internal DUID value --- diff --git a/src/lib/dhcp/libdhcp++.cc b/src/lib/dhcp/libdhcp++.cc index 994e7a638a..6a6ba1344b 100644 --- a/src/lib/dhcp/libdhcp++.cc +++ b/src/lib/dhcp/libdhcp++.cc @@ -50,7 +50,6 @@ const OptionDefParamsEncapsulation OPTION_DEF_PARAMS[] = { { LW_V6_OPTION_DEFINITIONS, LW_V6_OPTION_DEFINITIONS_SIZE, LW_V6_OPTION_SPACE }, { V4V6_RULE_OPTION_DEFINITIONS, V4V6_RULE_OPTION_DEFINITIONS_SIZE, V4V6_RULE_OPTION_SPACE }, { V4V6_BIND_OPTION_DEFINITIONS, V4V6_BIND_OPTION_DEFINITIONS_SIZE, V4V6_BIND_OPTION_SPACE }, - { LQ_QUERY_OPTION_DEFINITIONS, LQ_QUERY_OPTION_DEFINITIONS_SIZE, LQ_QUERY_OPTION_SPACE }, { LAST_RESORT_V4_OPTION_DEFINITIONS, LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE, LAST_RESORT_V4_OPTION_SPACE }, { NULL, 0, "" } }; diff --git a/src/lib/dhcp/std_option_defs.h b/src/lib/dhcp/std_option_defs.h index a08434a68f..9c08a1d215 100644 --- a/src/lib/dhcp/std_option_defs.h +++ b/src/lib/dhcp/std_option_defs.h @@ -27,7 +27,6 @@ #define DHCP_AGENT_OPTION_SPACE "dhcp-agent-options-space" #define VENDOR_OPTION_SPACE "vendor-opts-space" #define VENDOR_ENCAPSULATED_OPTION_SPACE "vendor-encapsulated-options-space" -#define LQ_QUERY_OPTION_SPACE "lq-query-option-space" // NOTE: // When adding a new space, make sure you also update @@ -431,7 +430,7 @@ const OptionDefParams STANDARD_V6_OPTION_DEFINITIONS[] = { NO_RECORD_DEF, "" }, { "ero", D6O_ERO, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" }, { "lq-query", D6O_LQ_QUERY, OPT_RECORD_TYPE, false, - RECORD_DEF(LQ_QUERY_RECORDS), LQ_QUERY_OPTION_SPACE }, + RECORD_DEF(LQ_QUERY_RECORDS), DHCP6_OPTION_SPACE }, { "client-data", D6O_CLIENT_DATA, OPT_EMPTY_TYPE, false, NO_RECORD_DEF, DHCP6_OPTION_SPACE }, { "clt-time", D6O_CLT_TIME, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" }, @@ -565,18 +564,6 @@ const int V4V6_BIND_OPTION_DEFINITIONS_SIZE = sizeof(V4V6_BIND_OPTION_DEFINITIONS) / sizeof(V4V6_BIND_OPTION_DEFINITIONS[0]); -/// @brief LQ_QUERY suboption definitions (v6) -const OptionDefParams LQ_QUERY_OPTION_DEFINITIONS[] = { - { "clientid", D6O_CLIENTID, OPT_BINARY_TYPE, false, NO_RECORD_DEF, ""}, - { "iaaddr", D6O_IAADDR, OPT_RECORD_TYPE, false, RECORD_DEF(IAADDR_RECORDS), ""}, - { "oro", D6O_ORO, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" } -}; - -const int LQ_QUERY_OPTION_DEFINITIONS_SIZE = - sizeof(LQ_QUERY_OPTION_DEFINITIONS) / - sizeof(LQ_QUERY_OPTION_DEFINITIONS[0]); - - } // namespace } // namespace dhcp diff --git a/src/lib/dhcp/tests/libdhcp++_unittest.cc b/src/lib/dhcp/tests/libdhcp++_unittest.cc index a803536d8c..3e2e143f9c 100644 --- a/src/lib/dhcp/tests/libdhcp++_unittest.cc +++ b/src/lib/dhcp/tests/libdhcp++_unittest.cc @@ -1925,7 +1925,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) { typeid(OptionIntArray)); LibDhcpTest::testStdOptionDefs6(D6O_LQ_QUERY, begin, end, - typeid(OptionCustom), LQ_QUERY_OPTION_SPACE); + typeid(OptionCustom), DHCP6_OPTION_SPACE); LibDhcpTest::testStdOptionDefs6(D6O_CLIENT_DATA, begin, end, typeid(OptionCustom), DHCP6_OPTION_SPACE); diff --git a/src/lib/dhcpsrv/cfg_duid.cc b/src/lib/dhcpsrv/cfg_duid.cc index 90b344f457..fe17f208cb 100644 --- a/src/lib/dhcpsrv/cfg_duid.cc +++ b/src/lib/dhcpsrv/cfg_duid.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015,2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2020 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 @@ -53,6 +53,9 @@ CfgDUID::setIdentifier(const std::string& identifier_as_hex) { DuidPtr CfgDUID::create(const std::string& duid_file_path) { + // Forget the current DUID. + current_duid_.reset(); + // Use DUID factory to create a DUID instance. DUIDFactory factory(persist() ? duid_file_path : ""); @@ -72,8 +75,10 @@ CfgDUID::create(const std::string& duid_file_path) { << " to create a new DUID"); } - // Return generated DUID. + // Save the newly created DUID. current_duid_ = factory.get(); + + // Return generated DUID. return (current_duid_); } diff --git a/src/lib/dhcpsrv/cfg_duid.h b/src/lib/dhcpsrv/cfg_duid.h index 91fea0cc8a..6897ee65a4 100644 --- a/src/lib/dhcpsrv/cfg_duid.h +++ b/src/lib/dhcpsrv/cfg_duid.h @@ -112,6 +112,9 @@ public: /// @brief Creates instance of a DUID from the current configuration. /// + /// The newly created DUID is retained internally to make it accessible + /// anywhere. + /// /// @param duid_file_path Absolute path to a DUID file. /// @return Pointer to an instance of new DUID. DuidPtr create(const std::string& duid_file_path);