diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:15:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:15:43 +0000 |
commit | f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 (patch) | |
tree | 49e44c6f87febed37efb953ab5485aa49f6481a7 /src/bin/d2/tests/configured_library.cc | |
parent | Initial commit. (diff) | |
download | isc-kea-upstream.tar.xz isc-kea-upstream.zip |
Adding upstream version 2.4.1.upstream/2.4.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/bin/d2/tests/configured_library.cc')
-rw-r--r-- | src/bin/d2/tests/configured_library.cc | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/bin/d2/tests/configured_library.cc b/src/bin/d2/tests/configured_library.cc new file mode 100644 index 0000000..3aeb94d --- /dev/null +++ b/src/bin/d2/tests/configured_library.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2021 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 +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +/// @brief d2_srv_configured callout testing library + +#include <config.h> +#include <cc/data.h> +#include <hooks/hooks.h> + +using namespace isc::data; +using namespace isc::hooks; +using namespace std; + +namespace { + +extern "C" { + +// d2_srv_configured callout. +int +d2_srv_configured(CalloutHandle& handle) { + // Get the parameters. + ConstElementPtr cfg; + string error; + handle.getArgument("json_config", cfg); + handle.getArgument("error", error); + + if (cfg) { + ConstElementPtr uc = cfg->get("user-context"); + if (uc) { + ConstElementPtr msg = uc->get("error"); + if (msg && (msg->getType() == Element::string)) { + error += msg->stringValue(); + } + } + } + + if (!error.empty()) { + handle.setArgument("error", error); + handle.setStatus(CalloutHandle::NEXT_STEP_DROP); + } + return (0); +} + +// Framework functions. +int +version() { + return (KEA_HOOKS_VERSION); +} + +// load() initializes the user library if the main image was statically linked. +int +load(isc::hooks::LibraryHandle&) { +#ifdef USE_STATIC_LINK + hooksStaticLinkInit(); +#endif + return (0); +} + +} +} |