Kea  1.5.0
pointer_converter.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 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 
26 public:
34  memset(&pointers_, 0, sizeof(pointers_));
35  pointers_.dlsym_ptr = dlsym_ptr;
36  }
37 
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 
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 
96 
97 private:
98 
100  union {
101  void* dlsym_ptr; // void* returned by dlsym
102  CalloutPtr callout_ptr; // Pointer to callout
103  load_function_ptr load_ptr; // Pointer to load function
104  unload_function_ptr unload_ptr; // Pointer to unload function
105  version_function_ptr version_ptr; // Pointer to version function
106  } pointers_;
107 };
108 
109 } // namespace hooks
110 } // namespace isc
111 
112 
113 #endif // POINTER_CONVERTER_H
isc::hooks::PointerConverter::dlsymPtr
void * dlsymPtr() const
Return pointer returned by dlsym call.
Definition: pointer_converter.h:63
isc::hooks::PointerConverter::dlsym_ptr
void * dlsym_ptr
Definition: pointer_converter.h:101
hooks.h
isc::hooks::PointerConverter::callout_ptr
CalloutPtr callout_ptr
Definition: pointer_converter.h:102
isc::hooks::PointerConverter::versionPtr
version_function_ptr versionPtr() const
Return pointer to version function.
Definition: pointer_converter.h:91
isc::hooks::PointerConverter::load_ptr
load_function_ptr load_ptr
Definition: pointer_converter.h:103
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::hooks::PointerConverter::PointerConverter
PointerConverter(CalloutPtr callout_ptr)
Constructor.
Definition: pointer_converter.h:46
isc::hooks::PointerConverter::unloadPtr
unload_function_ptr unloadPtr() const
Return pointer to unload function.
Definition: pointer_converter.h:84
isc::hooks::PointerConverter::calloutPtr
CalloutPtr calloutPtr() const
Return pointer to callout function.
Definition: pointer_converter.h:70
isc::hooks::PointerConverter
Local class for conversion of void pointers to function pointers.
Definition: pointer_converter.h:25
isc::hooks::CalloutPtr
int(* CalloutPtr)(CalloutHandle &)
Typedef for a callout pointer. (Callouts must have "C" linkage.)
Definition: library_handle.h:22
isc::hooks::PointerConverter::loadPtr
load_function_ptr loadPtr() const
Return pointer to load function.
Definition: pointer_converter.h:77
isc::hooks::PointerConverter::version_ptr
version_function_ptr version_ptr
Definition: pointer_converter.h:105
isc::hooks::PointerConverter::PointerConverter
PointerConverter(void *dlsym_ptr)
Constructor.
Definition: pointer_converter.h:33
isc::hooks::PointerConverter::unload_ptr
unload_function_ptr unload_ptr
Definition: pointer_converter.h:104