From f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:15:43 +0200 Subject: Adding upstream version 2.4.1. Signed-off-by: Daniel Baumann --- src/bin/d2/tests/configured_library.cc | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/bin/d2/tests/configured_library.cc (limited to 'src/bin/d2/tests/configured_library.cc') 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 +#include +#include + +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); +} + +} +} -- cgit v1.2.3