34 const boost::shared_ptr<CalloutManager>& manager)
35 : dl_handle_(NULL), index_(index), manager_(manager),
41 "instantiating a LibraryManager object");
53 : dl_handle_(NULL), index_(-1), manager_(), library_name_(name)
76 dl_handle_ = dlopen(library_name_.c_str(), RTLD_NOW | RTLD_LOCAL);
77 if (dl_handle_ == NULL) {
82 return (dl_handle_ != NULL);
92 if (dl_handle_ != NULL) {
93 status = dlclose(dl_handle_);
103 return (status == 0);
114 int version = KEA_HOOKS_VERSION - 1;
122 if (
version == KEA_HOOKS_VERSION) {
125 .arg(library_name_).arg(
version);
130 .arg(
version).arg(KEA_HOOKS_VERSION);
145 if (!multi_threading_enabled) {
150 PointerConverter pc(dlsym(dl_handle_, MULTI_THREADING_COMPATIBLE_FUNCTION_NAME));
166 if (compatible == 0) {
170 return (compatible != 0);
179 manager_->setLibraryIndex(index_);
183 for (
size_t i = 0; i < hook_names.size(); ++i) {
186 void* dlsym_ptr = dlsym(dl_handle_, hook_names[i].c_str());
190 manager_->getLibraryHandle().registerCallout(hook_names[i],
194 .arg(hook_names[i]).arg(dlsym_ptr);
215 manager_->setLibraryIndex(index_);
216 status = (*pc.
loadPtr())(manager_->getLibraryHandle());
219 .arg(library_name_).arg(ex.
what());
250 if (dl_handle_ == NULL) {
273 .arg(library_name_).arg(ex.
what());
299 manager_->setLibraryIndex(index_);
300 for (
size_t i = 0; i < hooks.size(); ++i) {
301 bool removed = manager_->deregisterAllCallouts(hooks[i], index_);
304 .arg(hooks[i]).arg(library_name_);
381 if (dl_handle_ != NULL) {
int version()
returns Kea hooks version.
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
LibraryManager(const std::string &name, int index, const boost::shared_ptr< CalloutManager > &manager)
Constructor.
bool unloadLibrary()
Unloads a library.
static bool validateLibrary(const std::string &name, bool multi_threading_enabled=false)
Validate library.
bool openLibrary()
Open library.
bool closeLibrary()
Close library.
~LibraryManager()
Destructor.
bool checkMultiThreadingCompatible(bool multi_threading_enabled) const
Check multi-threading compatibility.
bool checkVersion() const
Check library version.
void registerStandardCallouts()
Register standard callouts.
bool runLoad()
Run the load function if present.
bool prepareUnloadLibrary()
Prepares library unloading.
bool loadLibrary(bool multi_threading_enabled=false)
Loads a library.
Local class for conversion of void pointers to function pointers.
multi_threading_compatible_function_ptr multiThreadingCompatiblePtr() const
Return pointer to multi_threading_compatible function.
unload_function_ptr unloadPtr() const
Return pointer to unload function.
version_function_ptr versionPtr() const
Return pointer to version function.
CalloutPtr calloutPtr() const
Return pointer to callout function.
load_function_ptr loadPtr() const
Return pointer to load function.
static ServerHooks & getServerHooks()
Return ServerHooks object.
std::vector< std::string > getHookNames() const
Get hook names.
static void logDuplicatedMessages()
List duplicated log messages.
static void loadDictionary(bool ignore_duplicates=false)
Run-Time Initialization.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Logging initialization functions.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
void hooksStaticLinkInit()
User-Library Initialization for Statically-Linked Kea.
const isc::log::MessageID HOOKS_LIBRARY_UNLOADED
const isc::log::MessageID HOOKS_LIBRARY_MULTI_THREADING_COMPATIBLE
const isc::log::MessageID HOOKS_LIBRARY_MULTI_THREADING_NOT_COMPATIBLE
const isc::log::MessageID HOOKS_LOAD_FRAMEWORK_EXCEPTION
const isc::log::MessageID HOOKS_UNLOAD_SUCCESS
const isc::log::MessageID HOOKS_LIBRARY_VERSION
const isc::log::MessageID HOOKS_NO_UNLOAD
const isc::log::MessageID HOOKS_VERSION_EXCEPTION
const isc::log::MessageID HOOKS_STD_CALLOUT_REGISTERED
isc::log::Logger hooks_logger("hooks")
Hooks Logger.
const isc::log::MessageID HOOKS_LIBRARY_UNLOADING
const isc::log::MessageID HOOKS_LIBRARY_LOADED
const isc::log::MessageID HOOKS_INCORRECT_VERSION
const isc::log::MessageID HOOKS_LIBRARY_LOADING
const isc::log::MessageID HOOKS_UNLOAD_EXCEPTION
const int HOOKS_DBG_CALLS
const isc::log::MessageID HOOKS_LOAD_ERROR
const int HOOKS_DBG_TRACE
Hooks debug Logging levels.
const isc::log::MessageID HOOKS_LIBRARY_CLOSED
const isc::log::MessageID HOOKS_LOAD_EXCEPTION
const isc::log::MessageID HOOKS_OPEN_ERROR
const isc::log::MessageID HOOKS_UNLOAD_FRAMEWORK_EXCEPTION
const isc::log::MessageID HOOKS_UNLOAD_ERROR
const isc::log::MessageID HOOKS_LOAD_SUCCESS
const isc::log::MessageID HOOKS_CLOSE_ERROR
const isc::log::MessageID HOOKS_NO_VERSION
const isc::log::MessageID HOOKS_NO_LOAD
const isc::log::MessageID HOOKS_CALLOUTS_REMOVED
const isc::log::MessageID HOOKS_MULTI_THREADING_COMPATIBLE_EXCEPTION
void initLogger(const string &root, isc::log::Severity severity, int dbglevel, const char *file, bool buffer)
Run-time initialization.
bool isLoggingInitialized()
Is logging initialized?
Defines the logger used by the top-level component of kea-lfc.