// 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/.
-#ifndef LEASE_CMD_LOG_H
-#define LEASE_CMD_LOG_H
+#ifndef MYSQL_CB_LOG_H
+#define MYSQL_CB_LOG_H
#include <log/logger_support.h>
#include <log/macros.h>
"MYSQL_CB_CREATE_UPDATE_SHARED_NETWORK_OPTION6", "create or update shared network: %1 option",
"MYSQL_CB_CREATE_UPDATE_SUBNET4", "create or update subnet: %1",
"MYSQL_CB_CREATE_UPDATE_SUBNET6", "create or update subnet: %1",
- "MYSQL_CB_DEINIT_OK", "unloading MYSQL CB hooks library successful",
+ "MYSQL_CB_DEINIT_OK", "unloading MySQL CB hooks library successful",
"MYSQL_CB_DELETE_ALL_CLIENT_CLASSES4", "delete all client classes",
"MYSQL_CB_DELETE_ALL_CLIENT_CLASSES4_RESULT", "deleted: %1 entries",
"MYSQL_CB_DELETE_ALL_CLIENT_CLASSES6", "delete all client classes",
"MYSQL_CB_GET_SUBNET6_BY_SUBNET_ID", "retrieving subnet by subnet id: %1",
"MYSQL_CB_GET_TYPE4", "get type",
"MYSQL_CB_GET_TYPE6", "get type",
- "MYSQL_CB_INIT_OK", "loading MYSQL CB hooks library successful",
+ "MYSQL_CB_INIT_OK", "loading MySQL CB hooks library successful",
"MYSQL_CB_NO_TLS", "TLS was required but is not used",
"MYSQL_CB_RECONNECT_ATTEMPT_FAILED4", "database reconnect failed: %1",
"MYSQL_CB_RECONNECT_ATTEMPT_FAILED6", "database reconnect failed: %1",
Logged at debug log level 40.
Debug message issued when triggered an action to create or update subnet
-% MYSQL_CB_DEINIT_OK unloading MYSQL CB hooks library successful
+% MYSQL_CB_DEINIT_OK unloading MySQL CB hooks library successful
This informational message indicates that the MySQL Configuration Backend hooks
library has been unloaded successfully.
Logged at debug log level 40.
Debug message issued when triggered an action to retrieve type
-% MYSQL_CB_INIT_OK loading MYSQL CB hooks library successful
+% MYSQL_CB_INIT_OK loading MySQL CB hooks library successful
This informational message indicates that the MySQL Configuration Backend hooks
library has been loaded successfully. Enjoy!
--- /dev/null
+/mysql_hb_messages.cc -diff merge=ours
+/mysql_hb_messages.h -diff merge=ours
# convenience archive
noinst_LTLIBRARIES = libmysqlhb.la
-libmysqlhb_la_SOURCES = mysql_host_data_source.cc mysql_host_data_source.h
+libmysqlhb_la_SOURCES = mysql_hb_callouts.cc
+libmysqlhb_la_SOURCES += mysql_hb_log.cc mysql_hb_log.h
+libmysqlhb_la_SOURCES += mysql_hb_messages.cc mysql_hb_messages.h
+libmysqlhb_la_SOURCES += mysql_host_data_source.cc mysql_host_data_source.h
+libmysqlhb_la_SOURCES += version.cc
libmysqlhb_la_CXXFLAGS = $(AM_CXXFLAGS)
libmysqlhb_la_CPPFLAGS = $(AM_CPPFLAGS)
--- /dev/null
+hook_load_unittests
+SUBDIRS = .
+
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/mysql_hb -I$(top_srcdir)/src/hooks/dhcp/mysql_hb
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -DLIBDHCP_MYSQL_HB_SO=\"$(abs_top_builddir)/src/hooks/dhcp/mysql_hb/.libs/libdhcp_mysql_hb.so\"
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+EXTRA_DIST =
+
+CLEANFILES = *.gcno *.gcda
+
+TESTS_ENVIRONMENT = \
+ $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
+if HAVE_GTEST
+
+TESTS = hook_load_unittests
+
+hook_load_unittests_SOURCES =
+hook_load_unittests_SOURCES += load_unload_unittests.cc
+hook_load_unittests_SOURCES += run_unittests.cc
+hook_load_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES)
+hook_load_unittests_CXXFLAGS = $(AM_CXXFLAGS)
+hook_load_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+
+hook_load_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+hook_load_unittests_LDADD += $(LOG4CPLUS_LIBS)
+hook_load_unittests_LDADD += $(CRYPTO_LIBS)
+hook_load_unittests_LDADD += $(BOOST_LIBS)
+hook_load_unittests_LDADD += $(GTEST_LDADD)
+
+noinst_PROGRAMS = $(TESTS)
+
+endif
--- /dev/null
+// Copyright (C) 2024 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/.
+
+/// @file This file contains tests which exercise the load and unload
+/// functions in the ddns tuning hook library. In order to test the load
+/// function, one must be able to pass it hook library parameters. The
+/// the only way to populate these parameters is by actually loading the
+/// library via HooksManager::loadLibraries().
+
+#include <config.h>
+
+#include <dhcpsrv/testutils/lib_load_test_fixture.h>
+#include <testutils/gtest_utils.h>
+
+#include <gtest/gtest.h>
+#include <errno.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::hooks;
+using namespace isc::data;
+using namespace isc::dhcp;
+using namespace isc::process;
+
+namespace {
+
+/// @brief Test fixture for testing loading and unloading the MySQL hb library
+class MySqlHbLibLoadTest : public isc::test::LibLoadTest {
+public:
+ /// @brief Constructor
+ MySqlHbLibLoadTest() : LibLoadTest(LIBDHCP_MYSQL_HB_SO) {
+ }
+
+ /// @brief Destructor
+ virtual ~MySqlHbLibLoadTest() {
+ unloadLibraries();
+ }
+};
+
+// Simple V4 test that checks the library can be loaded and unloaded several times.
+TEST_F(MySqlHbLibLoadTest, validLoad4) {
+ validDaemonTest("kea-dhcp4");
+}
+
+// Simple V6 test that checks the library can be loaded and unloaded several times.
+TEST_F(MySqlHbLibLoadTest, validLoad6) {
+ validDaemonTest("kea-dhcp6", AF_INET6);
+}
+
+// Simple test that checks the library cannot by loaded by invalid daemons.
+TEST_F(MySqlHbLibLoadTest, invalidDaemonLoad) {
+ invalidDaemonTest("kea-ctrl-agent");
+ invalidDaemonTest("kea-dhcp-ddns");
+ invalidDaemonTest("bogus");
+}
+
+} // end of anonymous namespace
--- /dev/null
+// Copyright (C) 2024 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/.
+
+#include <config.h>
+
+#include <log/logger_support.h>
+#include <gtest/gtest.h>
+
+int
+main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+ isc::log::initLogger();
+ int result = RUN_ALL_TESTS();
+
+ return (result);
+}
--- /dev/null
+// Copyright (C) 2024 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/.
+
+// Functions accessed by the hooks framework use C linkage to avoid the name
+// mangling that accompanies use of the C++ compiler as well as to avoid
+// issues related to namespaces.
+
+#include <config.h>
+
+#include <asiolink/io_service_mgr.h>
+#include <dhcpsrv/base_host_data_source.h>
+#include <dhcpsrv/cfgmgr.h>
+#include <hooks/hooks.h>
+#include <process/daemon.h>
+#include <mysql_hb_log.h>
+#include <mysql_host_data_source.h>
+
+#include <sstream>
+#include <string>
+
+using namespace isc::asiolink;
+using namespace isc::dhcp;
+using namespace isc::hooks;
+using namespace isc::log;
+using namespace isc::process;
+using namespace std;
+
+extern "C" {
+
+/// @brief This function is called when the library is loaded.
+///
+/// @param handle library handle
+/// @return 0 when initialization is successful, 1 otherwise
+
+int load(LibraryHandle& /* handle */) {
+ // Make the hook library not loadable by d2 or ca.
+ uint16_t family = CfgMgr::instance().getFamily();
+ const std::string& proc_name = Daemon::getProcName();
+ if (family == AF_INET) {
+ if (proc_name != "kea-dhcp4") {
+ isc_throw(isc::Unexpected, "Bad process name: " << proc_name
+ << ", expected kea-dhcp4");
+ }
+ } else {
+ if (proc_name != "kea-dhcp6") {
+ isc_throw(isc::Unexpected, "Bad process name: " << proc_name
+ << ", expected kea-dhcp6");
+ }
+ }
+
+ // Register MySQL HB factories with Host Managers
+ isc::dhcp::HostDataSourceFactory::registerFactory("mysql", MySqlHostDataSource::factory, true);
+
+ LOG_INFO(mysql_hb_logger, MYSQL_HB_INIT_OK);
+ return (0);
+}
+
+/// @brief This function is called when the library is unloaded.
+///
+/// @return 0 if deregistration was successful, 1 otherwise
+int unload() {
+ // Unregister the factories and remove MySQL backends
+ isc::dhcp::HostDataSourceFactory::deregisterFactory("mysql", true);
+
+ LOG_INFO(mysql_hb_logger, MYSQL_HB_DEINIT_OK);
+ return (0);
+}
+
+/// @brief This function is called to retrieve the multi-threading compatibility.
+///
+/// @note: the compatibility is based on the assumption this hook library
+/// is always called from the main thread.
+///
+/// @return 1 which means compatible with multi-threading.
+int multi_threading_compatible() {
+ return (1);
+}
+
+} // end extern "C"
--- /dev/null
+// Copyright (C) 2019-2022 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/.
+
+#include <config.h>
+
+#include <mysql_hb_log.h>
+
+namespace isc {
+namespace dhcp {
+
+isc::log::Logger mysql_hb_logger("mysql-hb-hooks");
+
+} // namespace dhcp
+} // namespace isc
--- /dev/null
+// Copyright (C) 2019-2022 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/.
+
+#ifndef MYSQL_HB_LOG_H
+#define MYSQL_HB_LOG_H
+
+#include <log/logger_support.h>
+#include <log/macros.h>
+#include <mysql_hb_messages.h>
+
+namespace isc {
+namespace dhcp {
+
+extern isc::log::Logger mysql_hb_logger;
+
+} // namespace dhcp
+} // namespace isc
+
+#endif
--- /dev/null
+// File created from ../../../../src/hooks/dhcp/mysql_hb/mysql_hb_messages.mes
+
+#include <cstddef>
+#include <log/message_types.h>
+#include <log/message_initializer.h>
+
+extern const isc::log::MessageID MYSQL_HB_DB = "MYSQL_HB_DB";
+extern const isc::log::MessageID MYSQL_HB_DEINIT_OK = "MYSQL_HB_DEINIT_OK";
+extern const isc::log::MessageID MYSQL_HB_INIT_OK = "MYSQL_HB_INIT_OK";
+
+namespace {
+
+const char* values[] = {
+ "MYSQL_HB_DB", "opening MySQL hosts database: %1",
+ "MYSQL_HB_DEINIT_OK", "unloading MySQL HB hooks library successful",
+ "MYSQL_HB_INIT_OK", "loading MySQL HB hooks library successful",
+ NULL
+};
+
+const isc::log::MessageInitializer initializer(values);
+
+} // Anonymous namespace
+
--- /dev/null
+// File created from ../../../../src/hooks/dhcp/mysql_hb/mysql_hb_messages.mes
+
+#ifndef MYSQL_HB_MESSAGES_H
+#define MYSQL_HB_MESSAGES_H
+
+#include <log/message_types.h>
+
+extern const isc::log::MessageID MYSQL_HB_DB;
+extern const isc::log::MessageID MYSQL_HB_DEINIT_OK;
+extern const isc::log::MessageID MYSQL_HB_INIT_OK;
+
+#endif // MYSQL_HB_MESSAGES_H
+% MYSQL_HB_DB opening MySQL hosts database: %1
+Logged at debug log level 50.
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a MySQL hosts database. The parameters of the
+connection including database name and username needed to access it
+(but not the password if any) are logged.
+
+% MYSQL_HB_DEINIT_OK unloading MySQL HB hooks library successful
+This informational message indicates that the MySQL Host Backend hooks
+library has been unloaded successfully.
+
+% MYSQL_HB_INIT_OK loading MySQL HB hooks library successful
+This informational message indicates that the MySQL Host Backend hooks
+library has been loaded successfully. Enjoy!
#include <database/db_exceptions.h>
#include <dhcpsrv/base_host_data_source.h>
#include <dhcpsrv/host_data_source_factory.h>
+#include <mysql_hb_log.h>
#include <mysql/mysql_connection.h>
#include <stdint.h>
private:
/// @brief Pointer to the implementation of the @ref MySqlHostDataSource.
MySqlHostDataSourceImplPtr impl_;
+
+public:
+ /// @brief Factory class method.
+ ///
+ /// @param parameters A data structure relating keywords and values
+ /// concerned with the database.
+ ///
+ /// @return The MySQL Host Manager.
+ static HostDataSourcePtr
+ factory(const isc::db::DatabaseConnection::ParameterMap& parameters) {
+ LOG_INFO(mysql_hb_logger, MYSQL_HB_DB)
+ .arg(isc::db::DatabaseConnection::redactedAccessString(parameters));
+ return (HostDataSourcePtr(new MySqlHostDataSource(parameters)));
+ }
};
struct MySqlHostDataSourceInit {
// Constructor registers
MySqlHostDataSourceInit() {
- isc::dhcp::HostDataSourceFactory::registerFactory("mysql", factory, true);
+ isc::dhcp::HostDataSourceFactory::registerFactory("mysql", MySqlHostDataSource::factory, true);
}
// Destructor deregisters
~MySqlHostDataSourceInit() {
isc::dhcp::HostDataSourceFactory::deregisterFactory("mysql", true);
}
-
- // Factory class method
- static HostDataSourcePtr
- factory(const isc::db::DatabaseConnection::ParameterMap& parameters) {
- // TODO - fix messages
- //LOG_INFO(hosts_logger, DHCPSRV_MYSQL_HOST_DB)
- // .arg(DatabaseConnection::redactedAccessString(parameters));
- return (HostDataSourcePtr(new MySqlHostDataSource(parameters)));
- }
};
}
--- /dev/null
+// Copyright (C) 2024 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/.
+
+#include <config.h>
+
+#include <hooks/hooks.h>
+
+extern "C" {
+
+/// @brief returns Kea hooks version.
+int version() {
+ return (KEA_HOOKS_VERSION);
+}
+
+}
--- /dev/null
+/mysql_lb_messages.cc -diff merge=ours
+/mysql_lb_messages.h -diff merge=ours
# convenience archive
noinst_LTLIBRARIES = libmysqllb.la
-libmysqllb_la_SOURCES = mysql_lease_mgr.cc mysql_lease_mgr.h
+libmysqllb_la_SOURCES = mysql_lb_callouts.cc
+libmysqllb_la_SOURCES += mysql_lb_log.cc mysql_lb_log.h
+libmysqllb_la_SOURCES += mysql_lb_messages.cc mysql_lb_messages.h
+libmysqllb_la_SOURCES += mysql_lease_mgr.cc mysql_lease_mgr.h
+libmysqllb_la_SOURCES += version.cc
libmysqllb_la_CXXFLAGS = $(AM_CXXFLAGS)
libmysqllb_la_CPPFLAGS = $(AM_CPPFLAGS)
--- /dev/null
+hook_load_unittests
+SUBDIRS = .
+
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/mysql_lb -I$(top_srcdir)/src/hooks/dhcp/mysql_lb
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -DLIBDHCP_MYSQL_LB_SO=\"$(abs_top_builddir)/src/hooks/dhcp/mysql_lb/.libs/libdhcp_mysql_lb.so\"
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+EXTRA_DIST =
+
+CLEANFILES = *.gcno *.gcda
+
+TESTS_ENVIRONMENT = \
+ $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
+if HAVE_GTEST
+
+TESTS = hook_load_unittests
+
+hook_load_unittests_SOURCES =
+hook_load_unittests_SOURCES += load_unload_unittests.cc
+hook_load_unittests_SOURCES += run_unittests.cc
+hook_load_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES)
+hook_load_unittests_CXXFLAGS = $(AM_CXXFLAGS)
+hook_load_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+
+hook_load_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+hook_load_unittests_LDADD += $(LOG4CPLUS_LIBS)
+hook_load_unittests_LDADD += $(CRYPTO_LIBS)
+hook_load_unittests_LDADD += $(BOOST_LIBS)
+hook_load_unittests_LDADD += $(GTEST_LDADD)
+
+noinst_PROGRAMS = $(TESTS)
+
+endif
--- /dev/null
+// Copyright (C) 2024 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/.
+
+/// @file This file contains tests which exercise the load and unload
+/// functions in the ddns tuning hook library. In order to test the load
+/// function, one must be able to pass it hook library parameters. The
+/// the only way to populate these parameters is by actually loading the
+/// library via HooksManager::loadLibraries().
+
+#include <config.h>
+
+#include <dhcpsrv/testutils/lib_load_test_fixture.h>
+#include <testutils/gtest_utils.h>
+
+#include <gtest/gtest.h>
+#include <errno.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::hooks;
+using namespace isc::data;
+using namespace isc::dhcp;
+using namespace isc::process;
+
+namespace {
+
+/// @brief Test fixture for testing loading and unloading the MySQL lb library
+class MySqlLbLibLoadTest : public isc::test::LibLoadTest {
+public:
+ /// @brief Constructor
+ MySqlLbLibLoadTest() : LibLoadTest(LIBDHCP_MYSQL_LB_SO) {
+ }
+
+ /// @brief Destructor
+ virtual ~MySqlLbLibLoadTest() {
+ unloadLibraries();
+ }
+};
+
+// Simple V4 test that checks the library can be loaded and unloaded several times.
+TEST_F(MySqlLbLibLoadTest, validLoad4) {
+ validDaemonTest("kea-dhcp4");
+}
+
+// Simple V6 test that checks the library can be loaded and unloaded several times.
+TEST_F(MySqlLbLibLoadTest, validLoad6) {
+ validDaemonTest("kea-dhcp6", AF_INET6);
+}
+
+// Simple test that checks the library cannot by loaded by invalid daemons.
+TEST_F(MySqlLbLibLoadTest, invalidDaemonLoad) {
+ invalidDaemonTest("kea-ctrl-agent");
+ invalidDaemonTest("kea-dhcp-ddns");
+ invalidDaemonTest("bogus");
+}
+
+} // end of anonymous namespace
--- /dev/null
+// Copyright (C) 2024 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/.
+
+#include <config.h>
+
+#include <log/logger_support.h>
+#include <gtest/gtest.h>
+
+int
+main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+ isc::log::initLogger();
+ int result = RUN_ALL_TESTS();
+
+ return (result);
+}
--- /dev/null
+// Copyright (C) 2024 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/.
+
+// Functions accessed by the hooks framework use C linkage to avoid the name
+// mangling that accompanies use of the C++ compiler as well as to avoid
+// issues related to namespaces.
+
+#include <config.h>
+
+#include <asiolink/io_service_mgr.h>
+#include <dhcpsrv/cfgmgr.h>
+#include <hooks/hooks.h>
+#include <process/daemon.h>
+#include <mysql_lb_log.h>
+#include <mysql_lease_mgr.h>
+#include <dhcpsrv/lease_mgr_factory.h>
+
+#include <sstream>
+#include <string>
+
+using namespace isc::asiolink;
+using namespace isc::dhcp;
+using namespace isc::hooks;
+using namespace isc::log;
+using namespace isc::process;
+using namespace std;
+
+extern "C" {
+
+/// @brief This function is called when the library is loaded.
+///
+/// @param handle library handle
+/// @return 0 when initialization is successful, 1 otherwise
+
+int load(LibraryHandle& /* handle */) {
+ // Make the hook library not loadable by d2 or ca.
+ uint16_t family = CfgMgr::instance().getFamily();
+ const std::string& proc_name = Daemon::getProcName();
+ if (family == AF_INET) {
+ if (proc_name != "kea-dhcp4") {
+ isc_throw(isc::Unexpected, "Bad process name: " << proc_name
+ << ", expected kea-dhcp4");
+ }
+ } else {
+ if (proc_name != "kea-dhcp6") {
+ isc_throw(isc::Unexpected, "Bad process name: " << proc_name
+ << ", expected kea-dhcp6");
+ }
+ }
+
+ // Register MySQL LB factories with Lease Managers
+ LeaseMgrFactory::registerFactory("mysql", MySqlLeaseMgr::factory, true);
+
+ LOG_INFO(mysql_lb_logger, MYSQL_LB_INIT_OK);
+ return (0);
+}
+
+/// @brief This function is called when the library is unloaded.
+///
+/// @return 0 if deregistration was successful, 1 otherwise
+int unload() {
+ // Unregister the factories and remove MySQL backends
+ LeaseMgrFactory::deregisterFactory("mysql", true);
+
+ LOG_INFO(mysql_lb_logger, MYSQL_LB_DEINIT_OK);
+ return (0);
+}
+
+/// @brief This function is called to retrieve the multi-threading compatibility.
+///
+/// @note: the compatibility is based on the assumption this hook library
+/// is always called from the main thread.
+///
+/// @return 1 which means compatible with multi-threading.
+int multi_threading_compatible() {
+ return (1);
+}
+
+} // end extern "C"
--- /dev/null
+// Copyright (C) 2019-2022 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/.
+
+#include <config.h>
+
+#include <mysql_lb_log.h>
+
+namespace isc {
+namespace dhcp {
+
+isc::log::Logger mysql_lb_logger("mysql-lb-hooks");
+
+} // namespace dhcp
+} // namespace isc
--- /dev/null
+// Copyright (C) 2019-2022 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/.
+
+#ifndef MYSQL_LB_LOG_H
+#define MYSQL_LB_LOG_H
+
+#include <log/logger_support.h>
+#include <log/macros.h>
+#include <mysql_lb_messages.h>
+
+namespace isc {
+namespace dhcp {
+
+extern isc::log::Logger mysql_lb_logger;
+
+} // namespace dhcp
+} // namespace isc
+
+#endif
--- /dev/null
+// File created from ../../../../src/hooks/dhcp/mysql_lb/mysql_lb_messages.mes
+
+#include <cstddef>
+#include <log/message_types.h>
+#include <log/message_initializer.h>
+
+extern const isc::log::MessageID MYSQL_LB_DB = "MYSQL_LB_DB";
+extern const isc::log::MessageID MYSQL_LB_DEINIT_OK = "MYSQL_LB_DEINIT_OK";
+extern const isc::log::MessageID MYSQL_LB_INIT_OK = "MYSQL_LB_INIT_OK";
+
+namespace {
+
+const char* values[] = {
+ "MYSQL_LB_DB", "opening MySQL lease database: %1",
+ "MYSQL_LB_DEINIT_OK", "unloading MySQL LB hooks library successful",
+ "MYSQL_LB_INIT_OK", "loading MySQL LB hooks library successful",
+ NULL
+};
+
+const isc::log::MessageInitializer initializer(values);
+
+} // Anonymous namespace
+
--- /dev/null
+// File created from ../../../../src/hooks/dhcp/mysql_lb/mysql_lb_messages.mes
+
+#ifndef MYSQL_LB_MESSAGES_H
+#define MYSQL_LB_MESSAGES_H
+
+#include <log/message_types.h>
+
+extern const isc::log::MessageID MYSQL_LB_DB;
+extern const isc::log::MessageID MYSQL_LB_DEINIT_OK;
+extern const isc::log::MessageID MYSQL_LB_INIT_OK;
+
+#endif // MYSQL_LB_MESSAGES_H
+% MYSQL_LB_DB opening MySQL lease database: %1
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a MySQL lease database. The parameters of the
+connection including database name and username needed to access it
+(but not the password if any) are logged.
+
+% MYSQL_LB_DEINIT_OK unloading MySQL LB hooks library successful
+This informational message indicates that the MySQL Lease Backend hooks
+library has been unloaded successfully.
+
+% MYSQL_LB_INIT_OK loading MySQL LB hooks library successful
+This informational message indicates that the MySQL Lease Backend hooks
+library has been loaded successfully. Enjoy!
#define MYSQL_LEASE_MGR_H
#include <asiolink/io_service.h>
+#include <database/database_connection.h>
#include <dhcp/hwaddr.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
+#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/tracking_lease_mgr.h>
+#include <mysql_lb_log.h>
#include <mysql/mysql_connection.h>
#include <boost/scoped_ptr.hpp>
/// @brief Timer name used to register database reconnect timer.
std::string timer_name_;
+
+public:
+ /// @brief Factory class method.
+ ///
+ /// @param parameters A data structure relating keywords and values
+ /// concerned with the database.
+ ///
+ /// @return The MySQL Lease Manager.
+ static TrackingLeaseMgrPtr
+ factory(const isc::db::DatabaseConnection::ParameterMap& parameters) {
+ LOG_INFO(mysql_lb_logger, MYSQL_LB_DB)
+ .arg(isc::db::DatabaseConnection::redactedAccessString(parameters));
+ return (TrackingLeaseMgrPtr(new MySqlLeaseMgr(parameters)));
+ }
};
struct MySqlLeaseMgrInit {
// Constructor registers
MySqlLeaseMgrInit() {
- LeaseMgrFactory::registerFactory("mysql", factory, true);
+ LeaseMgrFactory::registerFactory("mysql", MySqlLeaseMgr::factory, true);
}
// Destructor deregisters
~MySqlLeaseMgrInit() {
LeaseMgrFactory::deregisterFactory("mysql", true);
}
-
- // Factory class method
- static TrackingLeaseMgrPtr
- factory(const isc::db::DatabaseConnection::ParameterMap& parameters) {
- // TODO - fix messages
- //LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_DB)
- // .arg(DatabaseConnection::redactedAccessString(parameters));
- return (TrackingLeaseMgrPtr(new MySqlLeaseMgr(parameters)));
- }
};
} // namespace dhcp
--- /dev/null
+// Copyright (C) 2024 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/.
+
+#include <config.h>
+
+#include <hooks/hooks.h>
+
+extern "C" {
+
+/// @brief returns Kea hooks version.
+int version() {
+ return (KEA_HOOKS_VERSION);
+}
+
+}
// 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/.
-#ifndef LEASE_CMD_LOG_H
-#define LEASE_CMD_LOG_H
+#ifndef PGSQL_CB_LOG_H
+#define PGSQL_CB_LOG_H
#include <log/logger_support.h>
#include <log/macros.h>
"PGSQL_CB_CREATE_UPDATE_SHARED_NETWORK_OPTION6", "create or update shared network: %1 option",
"PGSQL_CB_CREATE_UPDATE_SUBNET4", "create or update subnet: %1",
"PGSQL_CB_CREATE_UPDATE_SUBNET6", "create or update subnet: %1",
- "PGSQL_CB_DEINIT_OK", "unloading Postgres CB hooks library successful",
+ "PGSQL_CB_DEINIT_OK", "unloading PostgreSQL CB hooks library successful",
"PGSQL_CB_DELETE_ALL_CLIENT_CLASSES4", "delete all client classes",
"PGSQL_CB_DELETE_ALL_CLIENT_CLASSES4_RESULT", "deleted: %1 entries",
"PGSQL_CB_DELETE_ALL_CLIENT_CLASSES6", "delete all client classes",
"PGSQL_CB_GET_SUBNET6_BY_SUBNET_ID", "retrieving subnet by subnet id: %1",
"PGSQL_CB_GET_TYPE4", "get type",
"PGSQL_CB_GET_TYPE6", "get type",
- "PGSQL_CB_INIT_OK", "loading Postgres CB hooks library successful",
+ "PGSQL_CB_INIT_OK", "loading PostgreSQL CB hooks library successful",
"PGSQL_CB_NO_TLS_SUPPORT", "Attempt to configure TLS (unsupported for PostgreSQL): %1",
"PGSQL_CB_RECONNECT_ATTEMPT_FAILED4", "database reconnect failed: %1",
"PGSQL_CB_RECONNECT_ATTEMPT_FAILED6", "database reconnect failed: %1",
Logged at debug log level 40.
Debug message issued when triggered an action to create or update subnet
-% PGSQL_CB_DEINIT_OK unloading Postgres CB hooks library successful
-This informational message indicates that the Postgres Configuration Backend hooks
+% PGSQL_CB_DEINIT_OK unloading PostgreSQL CB hooks library successful
+This informational message indicates that the PostgreSQL Configuration Backend hooks
library has been unloaded successfully.
% PGSQL_CB_DELETE_ALL_CLIENT_CLASSES4 delete all client classes
Logged at debug log level 40.
Debug message issued when triggered an action to retrieve type
-% PGSQL_CB_INIT_OK loading Postgres CB hooks library successful
-This informational message indicates that the Postgres Configuration Backend hooks
+% PGSQL_CB_INIT_OK loading PostgreSQL CB hooks library successful
+This informational message indicates that the PostgreSQL Configuration Backend hooks
library has been loaded successfully. Enjoy!
% PGSQL_CB_NO_TLS_SUPPORT Attempt to configure TLS (unsupported for PostgreSQL): %1
--- /dev/null
+/pgsql_hb_messages.cc -diff merge=ours
+/pgsql_hb_messages.h -diff merge=ours
# convenience archive
noinst_LTLIBRARIES = libpgsqlhb.la
-libpgsqlhb_la_SOURCES = pgsql_host_data_source.cc pgsql_host_data_source.h
+libpgsqlhb_la_SOURCES = pgsql_hb_callouts.cc
+libpgsqlhb_la_SOURCES += pgsql_hb_log.cc pgsql_hb_log.h
+libpgsqlhb_la_SOURCES += pgsql_hb_messages.cc pgsql_hb_messages.h
+libpgsqlhb_la_SOURCES += pgsql_host_data_source.cc pgsql_host_data_source.h
+libpgsqlhb_la_SOURCES += version.cc
libpgsqlhb_la_CXXFLAGS = $(AM_CXXFLAGS)
libpgsqlhb_la_CPPFLAGS = $(AM_CPPFLAGS)
--- /dev/null
+hook_load_unittests
+SUBDIRS = .
+
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/pgsql_hb -I$(top_srcdir)/src/hooks/dhcp/pgsql_hb
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -DLIBDHCP_PGSQL_HB_SO=\"$(abs_top_builddir)/src/hooks/dhcp/pgsql_hb/.libs/libdhcp_pgsql_hb.so\"
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+EXTRA_DIST =
+
+CLEANFILES = *.gcno *.gcda
+
+TESTS_ENVIRONMENT = \
+ $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
+if HAVE_GTEST
+
+TESTS = hook_load_unittests
+
+hook_load_unittests_SOURCES =
+hook_load_unittests_SOURCES += load_unload_unittests.cc
+hook_load_unittests_SOURCES += run_unittests.cc
+hook_load_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES)
+hook_load_unittests_CXXFLAGS = $(AM_CXXFLAGS)
+hook_load_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+
+hook_load_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+hook_load_unittests_LDADD += $(LOG4CPLUS_LIBS)
+hook_load_unittests_LDADD += $(CRYPTO_LIBS)
+hook_load_unittests_LDADD += $(BOOST_LIBS)
+hook_load_unittests_LDADD += $(GTEST_LDADD)
+
+noinst_PROGRAMS = $(TESTS)
+
+endif
--- /dev/null
+// Copyright (C) 2024 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/.
+
+/// @file This file contains tests which exercise the load and unload
+/// functions in the ddns tuning hook library. In order to test the load
+/// function, one must be able to pass it hook library parameters. The
+/// the only way to populate these parameters is by actually loading the
+/// library via HooksManager::loadLibraries().
+
+#include <config.h>
+
+#include <dhcpsrv/testutils/lib_load_test_fixture.h>
+#include <testutils/gtest_utils.h>
+
+#include <gtest/gtest.h>
+#include <errno.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::hooks;
+using namespace isc::data;
+using namespace isc::dhcp;
+using namespace isc::process;
+
+namespace {
+
+/// @brief Test fixture for testing loading and unloading the PgSQL hb library
+class PgSqlHbLibLoadTest : public isc::test::LibLoadTest {
+public:
+ /// @brief Constructor
+ PgSqlHbLibLoadTest() : LibLoadTest(LIBDHCP_PGSQL_HB_SO) {
+ }
+
+ /// @brief Destructor
+ virtual ~PgSqlHbLibLoadTest() {
+ unloadLibraries();
+ }
+};
+
+// Simple V4 test that checks the library can be loaded and unloaded several times.
+TEST_F(PgSqlHbLibLoadTest, validLoad4) {
+ validDaemonTest("kea-dhcp4");
+}
+
+// Simple V6 test that checks the library can be loaded and unloaded several times.
+TEST_F(PgSqlHbLibLoadTest, validLoad6) {
+ validDaemonTest("kea-dhcp6", AF_INET6);
+}
+
+// Simple test that checks the library cannot by loaded by invalid daemons.
+TEST_F(PgSqlHbLibLoadTest, invalidDaemonLoad) {
+ invalidDaemonTest("kea-ctrl-agent");
+ invalidDaemonTest("kea-dhcp-ddns");
+ invalidDaemonTest("bogus");
+}
+
+} // end of anonymous namespace
--- /dev/null
+// Copyright (C) 2024 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/.
+
+#include <config.h>
+
+#include <log/logger_support.h>
+#include <gtest/gtest.h>
+
+int
+main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+ isc::log::initLogger();
+ int result = RUN_ALL_TESTS();
+
+ return (result);
+}
--- /dev/null
+// Copyright (C) 2024 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/.
+
+// Functions accessed by the hooks framework use C linkage to avoid the name
+// mangling that accompanies use of the C++ compiler as well as to avoid
+// issues related to namespaces.
+
+#include <config.h>
+
+#include <asiolink/io_service_mgr.h>
+#include <dhcpsrv/base_host_data_source.h>
+#include <dhcpsrv/cfgmgr.h>
+#include <hooks/hooks.h>
+#include <process/daemon.h>
+#include <pgsql_hb_log.h>
+#include <pgsql_host_data_source.h>
+
+#include <sstream>
+#include <string>
+
+using namespace isc::asiolink;
+using namespace isc::dhcp;
+using namespace isc::hooks;
+using namespace isc::log;
+using namespace isc::process;
+using namespace std;
+
+extern "C" {
+
+/// @brief This function is called when the library is loaded.
+///
+/// @param handle library handle
+/// @return 0 when initialization is successful, 1 otherwise
+
+int load(LibraryHandle& /* handle */) {
+ // Make the hook library not loadable by d2 or ca.
+ uint16_t family = CfgMgr::instance().getFamily();
+ const std::string& proc_name = Daemon::getProcName();
+ if (family == AF_INET) {
+ if (proc_name != "kea-dhcp4") {
+ isc_throw(isc::Unexpected, "Bad process name: " << proc_name
+ << ", expected kea-dhcp4");
+ }
+ } else {
+ if (proc_name != "kea-dhcp6") {
+ isc_throw(isc::Unexpected, "Bad process name: " << proc_name
+ << ", expected kea-dhcp6");
+ }
+ }
+
+ // Register PgSQL HB factories with Host Managers
+ isc::dhcp::HostDataSourceFactory::registerFactory("postgresql", PgSqlHostDataSource::factory, true);
+
+ LOG_INFO(pgsql_hb_logger, PGSQL_HB_INIT_OK);
+ return (0);
+}
+
+/// @brief This function is called when the library is unloaded.
+///
+/// @return 0 if deregistration was successful, 1 otherwise
+int unload() {
+ // Unregister the factories and remove PgSQL backends
+ isc::dhcp::HostDataSourceFactory::deregisterFactory("postgresql", true);
+
+ LOG_INFO(pgsql_hb_logger, PGSQL_HB_DEINIT_OK);
+ return (0);
+}
+
+/// @brief This function is called to retrieve the multi-threading compatibility.
+///
+/// @note: the compatibility is based on the assumption this hook library
+/// is always called from the main thread.
+///
+/// @return 1 which means compatible with multi-threading.
+int multi_threading_compatible() {
+ return (1);
+}
+
+} // end extern "C"
--- /dev/null
+// Copyright (C) 2019-2022 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/.
+
+#include <config.h>
+
+#include <pgsql_hb_log.h>
+
+namespace isc {
+namespace dhcp {
+
+isc::log::Logger pgsql_hb_logger("pgsql-hb-hooks");
+
+} // namespace dhcp
+} // namespace isc
--- /dev/null
+// Copyright (C) 2019-2022 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/.
+
+#ifndef PGSQL_HB_LOG_H
+#define PGSQL_HB_LOG_H
+
+#include <log/logger_support.h>
+#include <log/macros.h>
+#include <pgsql_hb_messages.h>
+
+namespace isc {
+namespace dhcp {
+
+extern isc::log::Logger pgsql_hb_logger;
+
+} // namespace dhcp
+} // namespace isc
+
+#endif
--- /dev/null
+// File created from ../../../../src/hooks/dhcp/pgsql_hb/pgsql_hb_messages.mes
+
+#include <cstddef>
+#include <log/message_types.h>
+#include <log/message_initializer.h>
+
+extern const isc::log::MessageID PGSQL_HB_DB = "PGSQL_HB_DB";
+extern const isc::log::MessageID PGSQL_HB_DEINIT_OK = "PGSQL_HB_DEINIT_OK";
+extern const isc::log::MessageID PGSQL_HB_INIT_OK = "PGSQL_HB_INIT_OK";
+
+namespace {
+
+const char* values[] = {
+ "PGSQL_HB_DB", "opening PostgreSQL hosts database: %1",
+ "PGSQL_HB_DEINIT_OK", "unloading PostgreSQL HB hooks library successful",
+ "PGSQL_HB_INIT_OK", "loading PostgreSQL HB hooks library successful",
+ NULL
+};
+
+const isc::log::MessageInitializer initializer(values);
+
+} // Anonymous namespace
+
--- /dev/null
+// File created from ../../../../src/hooks/dhcp/pgsql_hb/pgsql_hb_messages.mes
+
+#ifndef PGSQL_HB_MESSAGES_H
+#define PGSQL_HB_MESSAGES_H
+
+#include <log/message_types.h>
+
+extern const isc::log::MessageID PGSQL_HB_DB;
+extern const isc::log::MessageID PGSQL_HB_DEINIT_OK;
+extern const isc::log::MessageID PGSQL_HB_INIT_OK;
+
+#endif // PGSQL_HB_MESSAGES_H
+% PGSQL_HB_DB opening PostgreSQL hosts database: %1
+Logged at debug log level 50.
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a PostgreSQL hosts database. The parameters of the
+connection including database name and username needed to access it
+(but not the password if any) are logged.
+
+% PGSQL_HB_DEINIT_OK unloading PostgreSQL HB hooks library successful
+This informational message indicates that the PostgreSQL Host Backend hooks
+library has been unloaded successfully.
+
+% PGSQL_HB_INIT_OK loading PostgreSQL HB hooks library successful
+This informational message indicates that the PostgreSQL Host Backend hooks
+library has been loaded successfully. Enjoy!
#include <database/database_connection.h>
#include <dhcpsrv/base_host_data_source.h>
#include <dhcpsrv/host_data_source_factory.h>
+#include <pgsql_hb_log.h>
#include <pgsql/pgsql_connection.h>
#include <pgsql/pgsql_exchange.h>
private:
/// @brief Pointer to the implementation of the @ref PgSqlHostDataSource.
PgSqlHostDataSourceImplPtr impl_;
+
+public:
+ /// @brief Factory class method.
+ ///
+ /// @param parameters A data structure relating keywords and values
+ /// concerned with the database.
+ ///
+ /// @return The PostgreSQL Host Manager.
+ static HostDataSourcePtr
+ factory(const isc::db::DatabaseConnection::ParameterMap& parameters) {
+ LOG_INFO(pgsql_hb_logger, PGSQL_HB_DB)
+ .arg(isc::db::DatabaseConnection::redactedAccessString(parameters));
+ return (HostDataSourcePtr(new PgSqlHostDataSource(parameters)));
+ }
};
struct PgSqlHostDataSourceInit {
// Constructor registers
PgSqlHostDataSourceInit() {
- isc::dhcp::HostDataSourceFactory::registerFactory("postgresql", factory, true);
+ isc::dhcp::HostDataSourceFactory::registerFactory("postgresql", PgSqlHostDataSource::factory, true);
}
// Destructor deregisters
~PgSqlHostDataSourceInit() {
isc::dhcp::HostDataSourceFactory::deregisterFactory("postgresql", true);
}
-
- // Factory class method
- static HostDataSourcePtr
- factory(const isc::db::DatabaseConnection::ParameterMap& parameters) {
- // TODO - fix messages
- //LOG_INFO(hosts_logger, DHCPSRV_PGSQL_HOST_DB)
- // .arg(DatabaseConnection::redactedAccessString(parameters));
- return (HostDataSourcePtr(new PgSqlHostDataSource(parameters)));
- }
};
} // namespace dhcp
--- /dev/null
+// Copyright (C) 2024 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/.
+
+#include <config.h>
+
+#include <hooks/hooks.h>
+
+extern "C" {
+
+/// @brief returns Kea hooks version.
+int version() {
+ return (KEA_HOOKS_VERSION);
+}
+
+}
--- /dev/null
+/pgsql_lb_messages.cc -diff merge=ours
+/pgsql_lb_messages.h -diff merge=ours
# convenience archive
noinst_LTLIBRARIES = libpgsqllb.la
-libpgsqllb_la_SOURCES = pgsql_lease_mgr.cc pgsql_lease_mgr.h
+libpgsqllb_la_SOURCES = pgsql_lb_callouts.cc
+libpgsqllb_la_SOURCES += pgsql_lb_log.cc pgsql_lb_log.h
+libpgsqllb_la_SOURCES += pgsql_lb_messages.cc pgsql_lb_messages.h
+libpgsqllb_la_SOURCES += pgsql_lease_mgr.cc pgsql_lease_mgr.h
+libpgsqllb_la_SOURCES += version.cc
libpgsqllb_la_CXXFLAGS = $(AM_CXXFLAGS)
libpgsqllb_la_CPPFLAGS = $(AM_CPPFLAGS)
--- /dev/null
+hook_load_unittests
+SUBDIRS = .
+
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/pgsql_lb -I$(top_srcdir)/src/hooks/dhcp/pgsql_lb
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -DLIBDHCP_PGSQL_LB_SO=\"$(abs_top_builddir)/src/hooks/dhcp/pgsql_lb/.libs/libdhcp_pgsql_lb.so\"
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+EXTRA_DIST =
+
+CLEANFILES = *.gcno *.gcda
+
+TESTS_ENVIRONMENT = \
+ $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
+if HAVE_GTEST
+
+TESTS = hook_load_unittests
+
+hook_load_unittests_SOURCES =
+hook_load_unittests_SOURCES += load_unload_unittests.cc
+hook_load_unittests_SOURCES += run_unittests.cc
+hook_load_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES)
+hook_load_unittests_CXXFLAGS = $(AM_CXXFLAGS)
+hook_load_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+
+hook_load_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+hook_load_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+hook_load_unittests_LDADD += $(LOG4CPLUS_LIBS)
+hook_load_unittests_LDADD += $(CRYPTO_LIBS)
+hook_load_unittests_LDADD += $(BOOST_LIBS)
+hook_load_unittests_LDADD += $(GTEST_LDADD)
+
+noinst_PROGRAMS = $(TESTS)
+
+endif
--- /dev/null
+// Copyright (C) 2024 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/.
+
+/// @file This file contains tests which exercise the load and unload
+/// functions in the ddns tuning hook library. In order to test the load
+/// function, one must be able to pass it hook library parameters. The
+/// the only way to populate these parameters is by actually loading the
+/// library via HooksManager::loadLibraries().
+
+#include <config.h>
+
+#include <dhcpsrv/testutils/lib_load_test_fixture.h>
+#include <testutils/gtest_utils.h>
+
+#include <gtest/gtest.h>
+#include <errno.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::hooks;
+using namespace isc::data;
+using namespace isc::dhcp;
+using namespace isc::process;
+
+namespace {
+
+/// @brief Test fixture for testing loading and unloading the PgSQL lb library
+class PgSqlLbLibLoadTest : public isc::test::LibLoadTest {
+public:
+ /// @brief Constructor
+ PgSqlLbLibLoadTest() : LibLoadTest(LIBDHCP_PGSQL_LB_SO) {
+ }
+
+ /// @brief Destructor
+ virtual ~PgSqlLbLibLoadTest() {
+ unloadLibraries();
+ }
+};
+
+// Simple V4 test that checks the library can be loaded and unloaded several times.
+TEST_F(PgSqlLbLibLoadTest, validLoad4) {
+ validDaemonTest("kea-dhcp4");
+}
+
+// Simple V6 test that checks the library can be loaded and unloaded several times.
+TEST_F(PgSqlLbLibLoadTest, validLoad6) {
+ validDaemonTest("kea-dhcp6", AF_INET6);
+}
+
+// Simple test that checks the library cannot by loaded by invalid daemons.
+TEST_F(PgSqlLbLibLoadTest, invalidDaemonLoad) {
+ invalidDaemonTest("kea-ctrl-agent");
+ invalidDaemonTest("kea-dhcp-ddns");
+ invalidDaemonTest("bogus");
+}
+
+} // end of anonymous namespace
--- /dev/null
+// Copyright (C) 2024 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/.
+
+#include <config.h>
+
+#include <log/logger_support.h>
+#include <gtest/gtest.h>
+
+int
+main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+ isc::log::initLogger();
+ int result = RUN_ALL_TESTS();
+
+ return (result);
+}
--- /dev/null
+// Copyright (C) 2024 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/.
+
+// Functions accessed by the hooks framework use C linkage to avoid the name
+// mangling that accompanies use of the C++ compiler as well as to avoid
+// issues related to namespaces.
+
+#include <config.h>
+
+#include <asiolink/io_service_mgr.h>
+#include <dhcpsrv/cfgmgr.h>
+#include <hooks/hooks.h>
+#include <process/daemon.h>
+#include <pgsql_lb_log.h>
+#include <pgsql_lease_mgr.h>
+#include <dhcpsrv/lease_mgr_factory.h>
+
+#include <sstream>
+#include <string>
+
+using namespace isc::asiolink;
+using namespace isc::dhcp;
+using namespace isc::hooks;
+using namespace isc::log;
+using namespace isc::process;
+using namespace std;
+
+extern "C" {
+
+/// @brief This function is called when the library is loaded.
+///
+/// @param handle library handle
+/// @return 0 when initialization is successful, 1 otherwise
+
+int load(LibraryHandle& /* handle */) {
+ // Make the hook library not loadable by d2 or ca.
+ uint16_t family = CfgMgr::instance().getFamily();
+ const std::string& proc_name = Daemon::getProcName();
+ if (family == AF_INET) {
+ if (proc_name != "kea-dhcp4") {
+ isc_throw(isc::Unexpected, "Bad process name: " << proc_name
+ << ", expected kea-dhcp4");
+ }
+ } else {
+ if (proc_name != "kea-dhcp6") {
+ isc_throw(isc::Unexpected, "Bad process name: " << proc_name
+ << ", expected kea-dhcp6");
+ }
+ }
+
+ // Register PgSQL LB factories with Lease Managers
+ LeaseMgrFactory::registerFactory("postgresql", PgSqlLeaseMgr::factory, true);
+
+ LOG_INFO(pgsql_lb_logger, PGSQL_LB_INIT_OK);
+ return (0);
+}
+
+/// @brief This function is called when the library is unloaded.
+///
+/// @return 0 if deregistration was successful, 1 otherwise
+int unload() {
+ // Unregister the factories and remove PgSQL backends
+ LeaseMgrFactory::deregisterFactory("postgresql", true);
+
+ LOG_INFO(pgsql_lb_logger, PGSQL_LB_DEINIT_OK);
+ return (0);
+}
+
+/// @brief This function is called to retrieve the multi-threading compatibility.
+///
+/// @note: the compatibility is based on the assumption this hook library
+/// is always called from the main thread.
+///
+/// @return 1 which means compatible with multi-threading.
+int multi_threading_compatible() {
+ return (1);
+}
+
+} // end extern "C"
--- /dev/null
+// Copyright (C) 2019-2022 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/.
+
+#include <config.h>
+
+#include <pgsql_lb_log.h>
+
+namespace isc {
+namespace dhcp {
+
+isc::log::Logger pgsql_lb_logger("pgsql-lb-hooks");
+
+} // namespace dhcp
+} // namespace isc
--- /dev/null
+// Copyright (C) 2019-2022 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/.
+
+#ifndef PGSQL_LB_LOG_H
+#define PGSQL_LB_LOG_H
+
+#include <log/logger_support.h>
+#include <log/macros.h>
+#include <pgsql_lb_messages.h>
+
+namespace isc {
+namespace dhcp {
+
+extern isc::log::Logger pgsql_lb_logger;
+
+} // namespace dhcp
+} // namespace isc
+
+#endif
--- /dev/null
+// File created from ../../../../src/hooks/dhcp/pgsql_lb/pgsql_lb_messages.mes
+
+#include <cstddef>
+#include <log/message_types.h>
+#include <log/message_initializer.h>
+
+extern const isc::log::MessageID PGSQL_LB_DB = "PGSQL_LB_DB";
+extern const isc::log::MessageID PGSQL_LB_DEINIT_OK = "PGSQL_LB_DEINIT_OK";
+extern const isc::log::MessageID PGSQL_LB_INIT_OK = "PGSQL_LB_INIT_OK";
+
+namespace {
+
+const char* values[] = {
+ "PGSQL_LB_DB", "opening PostgreSQL lease database: %1",
+ "PGSQL_LB_DEINIT_OK", "unloading PostgreSQL LB hooks library successful",
+ "PGSQL_LB_INIT_OK", "loading PostgreSQL LB hooks library successful",
+ NULL
+};
+
+const isc::log::MessageInitializer initializer(values);
+
+} // Anonymous namespace
+
--- /dev/null
+// File created from ../../../../src/hooks/dhcp/pgsql_lb/pgsql_lb_messages.mes
+
+#ifndef PGSQL_LB_MESSAGES_H
+#define PGSQL_LB_MESSAGES_H
+
+#include <log/message_types.h>
+
+extern const isc::log::MessageID PGSQL_LB_DB;
+extern const isc::log::MessageID PGSQL_LB_DEINIT_OK;
+extern const isc::log::MessageID PGSQL_LB_INIT_OK;
+
+#endif // PGSQL_LB_MESSAGES_H
+% PGSQL_LB_DB opening PostgreSQL lease database: %1
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a PostgreSQL lease database. The parameters of the
+connection including database name and username needed to access it
+(but not the password if any) are logged.
+
+% PGSQL_LB_DEINIT_OK unloading PostgreSQL LB hooks library successful
+This informational message indicates that the PostgreSLQ Lease Backend hooks
+library has been unloaded successfully.
+
+% PGSQL_LB_INIT_OK loading PostgreSQL LB hooks library successful
+This informational message indicates that the PostgreSQL Lease Backend hooks
+library has been loaded successfully. Enjoy!
#define PGSQL_LEASE_MGR_H
#include <asiolink/io_service.h>
+#include <database/database_connection.h>
#include <dhcp/hwaddr.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
-#include <dhcpsrv/lease_mgr.h>
+#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/tracking_lease_mgr.h>
+#include <pgsql_lb_log.h>
#include <pgsql/pgsql_connection.h>
#include <pgsql/pgsql_exchange.h>
/// @brief Timer name used to register database reconnect timer.
std::string timer_name_;
+
+public:
+ /// @brief Factory class method.
+ ///
+ /// @param parameters A data structure relating keywords and values
+ /// concerned with the database.
+ ///
+ /// @return The PostgreSQL Lease Manager.
+ static TrackingLeaseMgrPtr
+ factory(const isc::db::DatabaseConnection::ParameterMap& parameters) {
+ LOG_INFO(pgsql_lb_logger, PGSQL_LB_DB)
+ .arg(isc::db::DatabaseConnection::redactedAccessString(parameters));
+ return (TrackingLeaseMgrPtr(new PgSqlLeaseMgr(parameters)));
+ }
};
struct PgSqlLeaseMgrInit {
// Constructor registers
PgSqlLeaseMgrInit() {
- LeaseMgrFactory::registerFactory("postgresql", factory, true);
+ LeaseMgrFactory::registerFactory("postgresql", PgSqlLeaseMgr::factory, true);
}
// Destructor deregisters
~PgSqlLeaseMgrInit() {
LeaseMgrFactory::deregisterFactory("postgresql", true);
}
-
- // Factory class method
- static TrackingLeaseMgrPtr
- factory(const isc::db::DatabaseConnection::ParameterMap& parameters) {
- // TODO - fix messages
- //LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_DB)
- // .arg(DatabaseConnection::redactedAccessString(parameters));
- return (TrackingLeaseMgrPtr(new PgSqlLeaseMgr(parameters)));
- }
};
} // namespace dhcp
--- /dev/null
+// Copyright (C) 2024 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/.
+
+#include <config.h>
+
+#include <hooks/hooks.h>
+
+extern "C" {
+
+/// @brief returns Kea hooks version.
+int version() {
+ return (KEA_HOOKS_VERSION);
+}
+
+}
extern const isc::log::MessageID DHCPSRV_MYSQL_ADD_ADDR4 = "DHCPSRV_MYSQL_ADD_ADDR4";
extern const isc::log::MessageID DHCPSRV_MYSQL_ADD_ADDR6 = "DHCPSRV_MYSQL_ADD_ADDR6";
extern const isc::log::MessageID DHCPSRV_MYSQL_COMMIT = "DHCPSRV_MYSQL_COMMIT";
-extern const isc::log::MessageID DHCPSRV_MYSQL_DB = "DHCPSRV_MYSQL_DB";
extern const isc::log::MessageID DHCPSRV_MYSQL_DELETED_EXPIRED_RECLAIMED = "DHCPSRV_MYSQL_DELETED_EXPIRED_RECLAIMED";
extern const isc::log::MessageID DHCPSRV_MYSQL_DELETE_ADDR = "DHCPSRV_MYSQL_DELETE_ADDR";
extern const isc::log::MessageID DHCPSRV_MYSQL_DELETE_EXPIRED_RECLAIMED4 = "DHCPSRV_MYSQL_DELETE_EXPIRED_RECLAIMED4";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_HWADDR = "DHCPSRV_MYSQL_GET_SUBID_HWADDR";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_PAGE6 = "DHCPSRV_MYSQL_GET_SUBID_PAGE6";
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_VERSION = "DHCPSRV_MYSQL_GET_VERSION";
-extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB = "DHCPSRV_MYSQL_HOST_DB";
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_GET_VERSION = "DHCPSRV_MYSQL_HOST_DB_GET_VERSION";
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_READONLY = "DHCPSRV_MYSQL_HOST_DB_READONLY";
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED = "DHCPSRV_MYSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED";
extern const isc::log::MessageID DHCPSRV_PGSQL_ADD_ADDR4 = "DHCPSRV_PGSQL_ADD_ADDR4";
extern const isc::log::MessageID DHCPSRV_PGSQL_ADD_ADDR6 = "DHCPSRV_PGSQL_ADD_ADDR6";
extern const isc::log::MessageID DHCPSRV_PGSQL_COMMIT = "DHCPSRV_PGSQL_COMMIT";
-extern const isc::log::MessageID DHCPSRV_PGSQL_DB = "DHCPSRV_PGSQL_DB";
extern const isc::log::MessageID DHCPSRV_PGSQL_DELETE_ADDR = "DHCPSRV_PGSQL_DELETE_ADDR";
extern const isc::log::MessageID DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED4 = "DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED4";
extern const isc::log::MessageID DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED6 = "DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED6";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_HWADDR = "DHCPSRV_PGSQL_GET_SUBID_HWADDR";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_PAGE6 = "DHCPSRV_PGSQL_GET_SUBID_PAGE6";
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_VERSION = "DHCPSRV_PGSQL_GET_VERSION";
-extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB = "DHCPSRV_PGSQL_HOST_DB";
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_GET_VERSION = "DHCPSRV_PGSQL_HOST_DB_GET_VERSION";
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_READONLY = "DHCPSRV_PGSQL_HOST_DB_READONLY";
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED = "DHCPSRV_PGSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED";
"DHCPSRV_MYSQL_ADD_ADDR4", "adding IPv4 lease with address %1",
"DHCPSRV_MYSQL_ADD_ADDR6", "adding IPv6 lease with address %1, lease type %2",
"DHCPSRV_MYSQL_COMMIT", "committing to MySQL database",
- "DHCPSRV_MYSQL_DB", "opening MySQL lease database: %1",
"DHCPSRV_MYSQL_DELETED_EXPIRED_RECLAIMED", "deleted %1 reclaimed leases from the database",
"DHCPSRV_MYSQL_DELETE_ADDR", "deleting lease for address %1",
"DHCPSRV_MYSQL_DELETE_EXPIRED_RECLAIMED4", "deleting reclaimed IPv4 leases that expired more than %1 seconds ago",
"DHCPSRV_MYSQL_GET_SUBID_HWADDR", "obtaining IPv4 lease for subnet ID %1 and hardware address %2",
"DHCPSRV_MYSQL_GET_SUBID_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3",
"DHCPSRV_MYSQL_GET_VERSION", "obtaining schema version information",
- "DHCPSRV_MYSQL_HOST_DB", "opening MySQL hosts database: %1",
"DHCPSRV_MYSQL_HOST_DB_GET_VERSION", "obtaining schema version information for the MySQL hosts database",
"DHCPSRV_MYSQL_HOST_DB_READONLY", "MySQL host database opened for read access only",
"DHCPSRV_MYSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED", "database reconnect failed: %1",
"DHCPSRV_PGSQL_ADD_ADDR4", "adding IPv4 lease with address %1",
"DHCPSRV_PGSQL_ADD_ADDR6", "adding IPv6 lease with address %1, lease type %2",
"DHCPSRV_PGSQL_COMMIT", "committing to PostgreSQL database",
- "DHCPSRV_PGSQL_DB", "opening PostgreSQL lease database: %1",
"DHCPSRV_PGSQL_DELETE_ADDR", "deleting lease for address %1",
"DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED4", "deleting reclaimed IPv4 leases that expired more than %1 seconds ago",
"DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED6", "deleting reclaimed IPv6 leases that expired more than %1 seconds ago",
"DHCPSRV_PGSQL_GET_SUBID_HWADDR", "obtaining IPv4 lease for subnet ID %1 and hardware address %2",
"DHCPSRV_PGSQL_GET_SUBID_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2 for subnet ID %3",
"DHCPSRV_PGSQL_GET_VERSION", "obtaining schema version information",
- "DHCPSRV_PGSQL_HOST_DB", "opening PostgreSQL hosts database: %1",
"DHCPSRV_PGSQL_HOST_DB_GET_VERSION", "obtaining schema version information for the PostgreSQL hosts database",
"DHCPSRV_PGSQL_HOST_DB_READONLY", "PostgreSQL host database opened for read access only",
"DHCPSRV_PGSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED", "database reconnect failed: %1",
extern const isc::log::MessageID DHCPSRV_MYSQL_ADD_ADDR4;
extern const isc::log::MessageID DHCPSRV_MYSQL_ADD_ADDR6;
extern const isc::log::MessageID DHCPSRV_MYSQL_COMMIT;
-extern const isc::log::MessageID DHCPSRV_MYSQL_DB;
extern const isc::log::MessageID DHCPSRV_MYSQL_DELETED_EXPIRED_RECLAIMED;
extern const isc::log::MessageID DHCPSRV_MYSQL_DELETE_ADDR;
extern const isc::log::MessageID DHCPSRV_MYSQL_DELETE_EXPIRED_RECLAIMED4;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_HWADDR;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_SUBID_PAGE6;
extern const isc::log::MessageID DHCPSRV_MYSQL_GET_VERSION;
-extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB;
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_GET_VERSION;
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_READONLY;
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED;
extern const isc::log::MessageID DHCPSRV_PGSQL_ADD_ADDR4;
extern const isc::log::MessageID DHCPSRV_PGSQL_ADD_ADDR6;
extern const isc::log::MessageID DHCPSRV_PGSQL_COMMIT;
-extern const isc::log::MessageID DHCPSRV_PGSQL_DB;
extern const isc::log::MessageID DHCPSRV_PGSQL_DELETE_ADDR;
extern const isc::log::MessageID DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED4;
extern const isc::log::MessageID DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED6;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_HWADDR;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_PAGE6;
extern const isc::log::MessageID DHCPSRV_PGSQL_GET_VERSION;
-extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB;
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_GET_VERSION;
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_READONLY;
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED;
committed to the database. Note that depending on the MySQL settings,
the commit may not include a write to disk.
-% DHCPSRV_MYSQL_DB opening MySQL lease database: %1
-This informational message is logged when a DHCP server (either V4 or
-V6) is about to open a MySQL lease database. The parameters of the
-connection including database name and username needed to access it
-(but not the password if any) are logged.
-
% DHCPSRV_MYSQL_DELETED_EXPIRED_RECLAIMED deleted %1 reclaimed leases from the database
Logged at debug log level 50.
A debug message issued when the server has removed a number of reclaimed
A debug message issued when the server is about to obtain schema version
information from the MySQL database.
-% DHCPSRV_MYSQL_HOST_DB opening MySQL hosts database: %1
-Logged at debug log level 50.
-This informational message is logged when a DHCP server (either V4 or
-V6) is about to open a MySQL hosts database. The parameters of the
-connection including database name and username needed to access it
-(but not the password if any) are logged.
-
% DHCPSRV_MYSQL_HOST_DB_GET_VERSION obtaining schema version information for the MySQL hosts database
Logged at debug log level 50.
A debug message issued when the server is about to obtain schema version
committed to the database. Note that depending on the PostgreSQL settings,
the commit may not include a write to disk.
-% DHCPSRV_PGSQL_DB opening PostgreSQL lease database: %1
-This informational message is logged when a DHCP server (either V4 or
-V6) is about to open a PostgreSQL lease database. The parameters of the
-connection including database name and username needed to access it
-(but not the password if any) are logged.
-
% DHCPSRV_PGSQL_DELETE_ADDR deleting lease for address %1
Logged at debug log level 50.
A debug message issued when the server is attempting to delete a lease for
A debug message issued when the server is about to obtain schema version
information from the PostgreSQL database.
-% DHCPSRV_PGSQL_HOST_DB opening PostgreSQL hosts database: %1
-Logged at debug log level 50.
-This informational message is logged when a DHCP server (either V4 or
-V6) is about to open a PostgreSQL hosts database. The parameters of the
-connection including database name and username needed to access it
-(but not the password if any) are logged.
-
% DHCPSRV_PGSQL_HOST_DB_GET_VERSION obtaining schema version information for the PostgreSQL hosts database
Logged at debug log level 50.
A debug message issued when the server is about to obtain schema version