Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
682cac0d
Commit
682cac0d
authored
Jul 09, 2013
by
Tomek Mrugalski
🛰
Browse files
[2995] Hook point registration now matches guide document.
parent
19c93b08
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
View file @
682cac0d
...
...
@@ -157,11 +157,6 @@ public:
}
virtual
~
Dhcpv4SrvTest
()
{
// Remove all registered hook points (it must be done even for tests that
// do not use hooks as the base class - Dhcpv4Srv calls allocation engine
// that registers hooks)
isc
::
hooks
::
ServerHooks
::
getServerHooks
().
reset
();
}
/// @brief Add 'Parameter Request List' option to the packet.
...
...
src/bin/dhcp6/dhcp6_srv.cc
View file @
682cac0d
...
...
@@ -56,6 +56,30 @@ using namespace isc::hooks;
using
namespace
isc
::
util
;
using
namespace
std
;
namespace
{
/// Structure that holds registered hook indexes
struct
Dhcp6Hooks
{
int
hook_index_pkt6_receive_
;
///< index for "pkt6_receive" hook point
int
hook_index_subnet6_select_
;
///< index for "subnet6_select" hook point
int
hook_index_pkt6_send_
;
///< index for "pkt6_send" hook point
/// Constructor that registers hook points for DHCPv6 engine
Dhcp6Hooks
()
{
hook_index_pkt6_receive_
=
HooksManager
::
registerHook
(
"pkt6_receive"
);
hook_index_subnet6_select_
=
HooksManager
::
registerHook
(
"subnet6_select"
);
hook_index_pkt6_send_
=
HooksManager
::
registerHook
(
"pkt6_send"
);
}
};
// Declare a Hooks object. As this is outside any function or method, it
// will be instantiated (and the constructor run) when the module is loaded.
// As a result, the hook indexes will be defined before any method in this
// module is called.
Dhcp6Hooks
Hooks
;
};
// anonymous namespace
namespace
isc
{
namespace
dhcp
{
...
...
@@ -112,9 +136,9 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
alloc_engine_
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
100
));
// Register hook points
hook_index_pkt6_receive_
=
Hooks
Manager
::
registerHook
(
"
pkt6_receive
"
)
;
hook_index_subnet6_select_
=
Hooks
Manager
::
registerHook
(
"
subnet6_select
"
)
;
hook_index_pkt6_send_
=
Hooks
Manager
::
registerHook
(
"
pkt6_send
"
)
;
hook_index_pkt6_receive_
=
Hooks
.
hook_index_
pkt6_receive
_
;
hook_index_subnet6_select_
=
Hooks
.
hook_index_
subnet6_select
_
;
hook_index_pkt6_send_
=
Hooks
.
hook_index_
pkt6_send
_
;
/// @todo call loadLibraries() when handling configuration changes
vector
<
string
>
libraries
;
// no libraries at this time
...
...
@@ -133,9 +157,6 @@ Dhcpv6Srv::~Dhcpv6Srv() {
IfaceMgr
::
instance
().
closeSockets
();
LeaseMgrFactory
::
destroy
();
/// @todo Unregister hooks once ServerHooks::deregisterHooks() becomes
/// available
}
void
Dhcpv6Srv
::
shutdown
()
{
...
...
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
View file @
682cac0d
...
...
@@ -109,10 +109,6 @@ public:
}
virtual
~
NakedDhcpv6Srv
()
{
// Remove all registered hook points (it must be done even for tests that
// do not use hooks as the base class - Dhcpv6Srv registers hooks)
ServerHooks
::
getServerHooks
().
reset
();
// Close the lease database
LeaseMgrFactory
::
destroy
();
}
...
...
src/lib/dhcpsrv/alloc_engine.cc
View file @
682cac0d
...
...
@@ -26,6 +26,26 @@
using
namespace
isc
::
asiolink
;
using
namespace
isc
::
hooks
;
namespace
{
/// Structure that holds registered hook indexes
struct
Dhcp6Hooks
{
int
hook_index_lease6_select_
;
///< index for "lease6_receive" hook point
/// Constructor that registers hook points for AllocationEngine
Dhcp6Hooks
()
{
hook_index_lease6_select_
=
HooksManager
::
registerHook
(
"lease6_select"
);
}
};
// Declare a Hooks object. As this is outside any function or method, it
// will be instantiated (and the constructor run) when the module is loaded.
// As a result, the hook indexes will be defined before any method in this
// module is called.
Dhcp6Hooks
Hooks
;
};
// anonymous namespace
namespace
isc
{
namespace
dhcp
{
...
...
@@ -167,7 +187,7 @@ AllocEngine::AllocEngine(AllocType engine_type, unsigned int attempts)
}
// Register hook points
hook_index_lease6_select_
=
ServerHooks
::
getServerHooks
().
registerHook
(
"
lease6_select
"
)
;
hook_index_lease6_select_
=
Hooks
.
hook_index_
lease6_select
_
;
}
Lease6Ptr
...
...
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
View file @
682cac0d
...
...
@@ -112,10 +112,6 @@ public:
virtual
~
AllocEngine6Test
()
{
factory_
.
destroy
();
// Remove all registered hook points (it must be done even for tests that
// do not use hooks as the base class - Dhcpv6Srv registers hooks
ServerHooks
::
getServerHooks
().
reset
();
}
DuidPtr
duid_
;
///< client-identifier (value used in tests)
...
...
@@ -184,10 +180,6 @@ public:
virtual
~
AllocEngine4Test
()
{
factory_
.
destroy
();
// Remove all registered hook points (it must be done even for tests that
// do not use hooks as the base class - Dhcpv6Srv registers hooks
ServerHooks
::
getServerHooks
().
reset
();
}
ClientIdPtr
clientid_
;
///< Client-identifier (value used in tests)
...
...
@@ -1045,7 +1037,8 @@ public:
}
virtual
~
HookAllocEngine6Test
()
{
HooksManager
::
preCalloutsLibraryHandle
().
deregisterAllCallouts
(
"lease6_select"
);
}
/// @brief clears out buffers, so callouts can store received arguments
...
...
src/lib/hooks/server_hooks.cc
View file @
682cac0d
...
...
@@ -55,7 +55,8 @@ ServerHooks::registerHook(const string& name) {
inverse_hooks_
[
index
]
=
name
;
// Log it if debug is enabled
LOG_DEBUG
(
hooks_logger
,
HOOKS_DBG_TRACE
,
HOOKS_HOOK_REGISTERED
).
arg
(
name
);
/// @todo See todo comment in reset() below.
//LOG_DEBUG(hooks_logger, HOOKS_DBG_TRACE, HOOKS_HOOK_REGISTERED).arg(name);
// ... and return numeric index.
return
(
index
);
...
...
@@ -85,7 +86,12 @@ ServerHooks::reset() {
// Log a warning - although this is done during testing, it should never be
// seen in a production system.
LOG_WARN
(
hooks_logger
,
HOOKS_HOOK_LIST_RESET
);
/// @todo Implement proper workaround here. The issue is when the first
/// module (e.g. Dhcp6Srv module) initializes global structure it calls
/// HooksManager::registerHooks() which in turn creates ServerHooks object.
/// Its constructor calls reset() method, but the loggers are not initialized
/// yet and exception is thrown.
//LOG_WARN(hooks_logger, HOOKS_HOOK_LIST_RESET);
}
// Find the name associated with a hook index.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment