2019-05-14 21:23:50 +02:00
|
|
|
// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
|
2018-09-14 09:37:47 +02:00
|
|
|
//
|
|
|
|
// 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 <hooks/hooks.h>
|
2018-10-10 14:51:59 -04:00
|
|
|
#include <mysql_cb_dhcp4.h>
|
2019-05-14 21:23:50 +02:00
|
|
|
#include <mysql_cb_dhcp6.h>
|
2018-09-14 09:37:47 +02:00
|
|
|
|
2019-05-09 12:30:27 +03:00
|
|
|
using namespace isc::cb;
|
|
|
|
using namespace isc::dhcp;
|
2018-09-14 09:37:47 +02:00
|
|
|
using namespace isc::hooks;
|
2019-05-09 12:30:27 +03:00
|
|
|
using namespace isc::log;
|
2018-09-14 09:37:47 +02:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
/// @brief This function is called when the library is loaded.
|
|
|
|
///
|
|
|
|
/// @param handle library handle
|
|
|
|
/// @return 0 when initialization is successful, 1 otherwise
|
2018-10-10 14:51:59 -04:00
|
|
|
|
2018-09-27 17:04:09 +02:00
|
|
|
int load(LibraryHandle& /* handle */) {
|
2019-05-09 12:30:27 +03:00
|
|
|
LOG_INFO(mysql_cb_logger, MYSQL_CB_INIT_OK);
|
2019-05-14 21:23:50 +02:00
|
|
|
// Register MySQL CB factories with CB Managers
|
2018-10-10 14:51:59 -04:00
|
|
|
isc::dhcp::MySqlConfigBackendDHCPv4::registerBackendType();
|
2019-05-14 21:23:50 +02:00
|
|
|
isc::dhcp::MySqlConfigBackendDHCPv6::registerBackendType();
|
2018-10-10 14:51:59 -04:00
|
|
|
|
2018-09-14 09:37:47 +02:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief This function is called when the library is unloaded.
|
|
|
|
///
|
|
|
|
/// @return 0 if deregistration was successful, 1 otherwise
|
|
|
|
int unload() {
|
2019-05-09 12:30:27 +03:00
|
|
|
LOG_INFO(mysql_cb_logger, MYSQL_CB_DEINIT_OK);
|
2019-05-14 21:23:50 +02:00
|
|
|
// Unregister the factories and remove MySQL backends
|
2018-10-10 14:51:59 -04:00
|
|
|
isc::dhcp::MySqlConfigBackendDHCPv4::unregisterBackendType();
|
2019-05-14 21:23:50 +02:00
|
|
|
isc::dhcp::MySqlConfigBackendDHCPv6::unregisterBackendType();
|
2018-09-14 09:37:47 +02:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2019-11-07 01:38:38 +01:00
|
|
|
/// @brief This function is called to know 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);
|
|
|
|
}
|
2018-09-14 09:37:47 +02:00
|
|
|
|
|
|
|
} // end extern "C"
|