From: Francis Dupont Date: Fri, 10 Jul 2020 15:19:36 +0000 (+0200) Subject: [#1182] Made getParameters public X-Git-Tag: Kea-1.7.10~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e79e9ce17f9482b7970f4ce108e2609aeaaf753a;p=thirdparty%2Fkea.git [#1182] Made getParameters public --- diff --git a/src/lib/hooks/library_handle.cc b/src/lib/hooks/library_handle.cc index da6ec25c29..b070448e7a 100644 --- a/src/lib/hooks/library_handle.cc +++ b/src/lib/hooks/library_handle.cc @@ -101,7 +101,7 @@ isc::data::ConstElementPtr LibraryHandle::getParameter(const std::string& name) { // Try to find appropriate parameter. May return null pointer isc::data::ConstElementPtr params = getParameters(); - if (!params) { + if (!params || (params->getType() != isc::data::Element::map)) { return (isc::data::ConstElementPtr()); } diff --git a/src/lib/hooks/library_handle.h b/src/lib/hooks/library_handle.h index bc1de1729a..14af40c729 100644 --- a/src/lib/hooks/library_handle.h +++ b/src/lib/hooks/library_handle.h @@ -194,11 +194,18 @@ public: isc::data::ConstElementPtr getParameter(const std::string& name); + /// @brief Get configuration parameter common code. + /// + /// @return configuration parameters. + isc::data::ConstElementPtr getParameters(); + /// @brief Returns names of configuration parameters for the library. /// /// This method returns a vector of strings reflecting names of /// configuration parameters specified in the configuration file. /// + /// @note: kept for backward compatibility. + /// @return a vector with parameter entry names. std::vector getParameterNames(); private: @@ -221,11 +228,6 @@ private: /// @param Unused - should be the object to copy. LibraryHandle& operator=(const LibraryHandle&); - /// @brief Get configuration parameter common code. - /// - /// @return configuration parameters. - isc::data::ConstElementPtr getParameters(); - /// Back pointer to the collection object for the library CalloutManager& callout_manager_; diff --git a/src/lib/hooks/tests/callout_params_library.cc b/src/lib/hooks/tests/callout_params_library.cc index 3fb7ab309a..d35fc008f0 100644 --- a/src/lib/hooks/tests/callout_params_library.cc +++ b/src/lib/hooks/tests/callout_params_library.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-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 @@ -36,6 +36,7 @@ version() { /// @param handle passed by the hooks framework /// @return 0 if load was successful, non-zero for errors int load(LibraryHandle& handle) { + ConstElementPtr elems = handle.getParameters(); ConstElementPtr string_elem = handle.getParameter("svalue"); ConstElementPtr int_elem = handle.getParameter("ivalue"); ConstElementPtr bool_elem = handle.getParameter("bvalue"); @@ -107,10 +108,22 @@ int load(LibraryHandle& handle) { return (10); } + // Check elems map. + if (!elems) { + return (11); + } + string expected_str = "{ " + "\"bvalue\": true, " + "\"ivalue\": 42, " + "\"svalue\": \"string value\"" + " }"; + if (expected_str != elems->str()) { + return (12); + } + // All validation steps were successful. The library has all the parameters // it needs, so we should report a success. return (0); } - -}; +}