From: Francis Dupont Date: Thu, 12 Apr 2018 10:23:34 +0000 (+0200) Subject: [5458a] Reported dhcp6 srv configured patch from Radius X-Git-Tag: trac5488_base~2^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=378a6d5283d6a64670a9b993b49bfa0532b46e9b;p=thirdparty%2Fkea.git [5458a] Reported dhcp6 srv configured patch from Radius --- diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index 8fd9d1eb87..f0d39bb6f9 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -32,6 +32,23 @@ using namespace std; namespace { +/// Structure that holds registered hook indexes. +struct CtrlDhcp6Hooks { + int hooks_index_dhcp6_srv_configured_; + + /// Constructor that registers hook points for the DHCPv6 server. + CtrlDhcp6Hooks() { + hooks_index_dhcp6_srv_configured_ = HooksManager::registerHook("dhcp6_srv_configured"); + } + +}; + +// 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. +CtrlDhcp6Hooks Hooks; + // Name of the file holding server identifier. static const char* SERVER_DUID_FILE = "kea-dhcp6-serverid"; @@ -663,6 +680,25 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) { // exception free. LibDHCP::commitRuntimeOptionDefs(); + // This hook point notifies hooks libraries that the configuration of the + // DHCPv6 server has completed. It provides the hook library with the pointer + // to the common IO service object, new server configuration in the JSON + // format and with the pointer to the configuration storage where the + // parsed configuration is stored. + if (HooksManager::calloutsPresent(Hooks.hooks_index_dhcp6_srv_configured_)) { + CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle(); + + callout_handle->setArgument("io_context", srv->getIOService()); + callout_handle->setArgument("json_config", config); + callout_handle->setArgument("server_config", CfgMgr::instance().getStagingCfg()); + + HooksManager::callCallouts(Hooks.hooks_index_dhcp6_srv_configured_, + *callout_handle); + + // Ignore status code as none of them would have an effect on further + // operation. + } + return (answer); }