| Kea 3.0.2-git

pointer_converter.h
Go to the documentation of this file.
1// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef POINTER_CONVERTER_H
8#define POINTER_CONVERTER_H
9
10#include <hooks/hooks.h>
11
12 namespace isc {
13 namespace hooks {
14
24
25 class PointerConverter {
26 public:
33 PointerConverter(void* dlsym_ptr) {
34 memset(&pointers_, 0, sizeof(pointers_));
35 pointers_.dlsym_ptr = dlsym_ptr;
36 }
37
46 PointerConverter(CalloutPtr callout_ptr) {
47 memset(&pointers_, 0, sizeof(pointers_));
48 pointers_.callout_ptr = callout_ptr;
49 }
50
57
63 void* dlsymPtr() const {
64 return (pointers_.dlsym_ptr);
65 }
66
70 CalloutPtr calloutPtr() const {
71 return (pointers_.callout_ptr);
72 }
73
77 load_function_ptr loadPtr() const {
78 return (pointers_.load_ptr);
79 }
80
84 unload_function_ptr unloadPtr() const {
85 return (pointers_.unload_ptr);
86 }
87
91 version_function_ptr versionPtr() const {
92 return (pointers_.version_ptr);
93 }
94
98 multi_threading_compatible_function_ptr multiThreadingCompatiblePtr() const {
99 return (pointers_.multi_threading_compatible_ptr);
100 }
101
103
104 private:
105
107 union {
108 void* dlsym_ptr; // void* returned by dlsym
109 CalloutPtr callout_ptr; // Pointer to callout
110 load_function_ptr load_ptr; // Pointer to load function
111 unload_function_ptr unload_ptr; // Pointer to unload function
112 version_function_ptr version_ptr; // Pointer to version function
113 multi_threading_compatible_function_ptr multi_threading_compatible_ptr;
114 // Pointer to multi_threading_compatible function
115 } pointers_;
116};
117
118} // namespace hooks
119} // namespace isc
120
121
122#endif // POINTER_CONVERTER_H
isc::hooks::PointerConverter::PointerConverter
PointerConverter(void *dlsym_ptr)
Constructor.
Definition pointer_converter.h:33
isc::hooks::PointerConverter::multiThreadingCompatiblePtr
multi_threading_compatible_function_ptr multiThreadingCompatiblePtr() const
Return pointer to multi_threading_compatible function.
Definition pointer_converter.h:98
isc::hooks::PointerConverter::PointerConverter
PointerConverter(CalloutPtr callout_ptr)
Constructor.
Definition pointer_converter.h:46
isc::hooks::PointerConverter::load_ptr
load_function_ptr load_ptr
Definition pointer_converter.h:110
isc::hooks::PointerConverter::version_ptr
version_function_ptr version_ptr
Definition pointer_converter.h:112
isc::hooks::PointerConverter::dlsym_ptr
void * dlsym_ptr
Definition pointer_converter.h:108
isc::hooks::PointerConverter::unloadPtr
unload_function_ptr unloadPtr() const
Return pointer to unload function.
Definition pointer_converter.h:84
isc::hooks::PointerConverter::versionPtr
version_function_ptr versionPtr() const
Return pointer to version function.
Definition pointer_converter.h:91
isc::hooks::PointerConverter::callout_ptr
CalloutPtr callout_ptr
Definition pointer_converter.h:109
isc::hooks::PointerConverter::dlsymPtr
void * dlsymPtr() const
Return pointer returned by dlsym call.
Definition pointer_converter.h:63
isc::hooks::PointerConverter::calloutPtr
CalloutPtr calloutPtr() const
Return pointer to callout function.
Definition pointer_converter.h:70
isc::hooks::PointerConverter::loadPtr
load_function_ptr loadPtr() const
Return pointer to load function.
Definition pointer_converter.h:77
isc::hooks::PointerConverter::unload_ptr
unload_function_ptr unload_ptr
Definition pointer_converter.h:111
isc::hooks::PointerConverter::multi_threading_compatible_ptr
multi_threading_compatible_function_ptr multi_threading_compatible_ptr
Definition pointer_converter.h:113
hooks.h
isc::hooks
Definition callout_handle.cc:21
isc::hooks::CalloutPtr
int(* CalloutPtr)(CalloutHandle &)
Typedef for a callout pointer. (Callouts must have "C" linkage.).
Definition library_handle.h:22
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148