diff options
-rw-r--r-- | src/bin/dhcp4/ctrl_dhcp4_srv.cc | 14 | ||||
-rw-r--r-- | src/bin/dhcp4/ctrl_dhcp4_srv.h | 13 | ||||
-rw-r--r-- | src/bin/dhcp6/ctrl_dhcp6_srv.cc | 14 | ||||
-rw-r--r-- | src/bin/dhcp6/ctrl_dhcp6_srv.h | 13 |
4 files changed, 54 insertions, 0 deletions
diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index cddadb086a..097b045fd2 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -107,6 +107,16 @@ ControlledDhcpv4Srv::processCommand(const string& command, } } +ConstElementPtr +ControlledDhcpv4Srv::commandLeasesReclaimHandler(const string&, ConstElementPtr args) { + + + server_->alloc_engine_->reclaimExpiredLeases4(0, 0, true); + ConstElementPtr answer = isc::config::createAnswer(0, + "Leases successfully reclaimed/"); + return (answer); +} + isc::data::ConstElementPtr ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) { @@ -212,6 +222,9 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t port /*= DHCP4_SERVER_PORT*/) /// @todo: register config-reload (see CtrlDhcpv4Srv::commandConfigReloadHandler) /// @todo: register libreload (see CtrlDhcpv4Srv::commandLibReloadHandler) + CommandMgr::instance().registerCommand("leases-reclaim", + boost::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler, this, _1, _2)); + // Register statistic related commands CommandMgr::instance().registerCommand("statistic-get", boost::bind(&StatsMgr::statisticGetHandler, _1, _2)); @@ -251,6 +264,7 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() { // Deregister any registered commands CommandMgr::instance().deregisterCommand("shutdown"); + CommandMgr::instance().deregisterCommand("leases-reclaim"); CommandMgr::instance().deregisterCommand("statistic-get"); CommandMgr::instance().deregisterCommand("statistic-reset"); CommandMgr::instance().deregisterCommand("statistic-remove"); diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.h b/src/bin/dhcp4/ctrl_dhcp4_srv.h index 1cd7f78561..338dbfe2f8 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.h +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.h @@ -151,6 +151,19 @@ private: isc::data::ConstElementPtr args); + /// @brief handler for processing 'leases-reclaim' command + /// + /// This handler processes leases-reclaim command, which triggers + /// the leases reclamation immediately + /// + /// @param command (parameter ignored) + /// @param args (parameter ignored) + /// + /// @return status of the command + isc::data::ConstElementPtr + commandLeasesReclaimHandler(const std::string& command, + isc::data::ConstElementPtr args); + /// @brief Reclaims expired IPv4 leases and reschedules timer. /// /// This is a wrapper method for @c AllocEngine::reclaimExpiredLeases4. diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index 91f983cf6a..f3247436ab 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -69,6 +69,16 @@ ControlledDhcpv6Srv::commandConfigReloadHandler(const string&, ConstElementPtr a return (processConfig(args)); } +ConstElementPtr +ControlledDhcpv6Srv::commandLeasesReclaimHandler(const string&, ConstElementPtr args) { + + + server_->alloc_engine_->reclaimExpiredLeases6(0, 0, true); + ConstElementPtr answer = isc::config::createAnswer(0, + "Leases successfully reclaimed/"); + return (answer); +} + isc::data::ConstElementPtr ControlledDhcpv6Srv::processCommand(const std::string& command, isc::data::ConstElementPtr args) { @@ -208,6 +218,9 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port) /// @todo: register config-reload (see CtrlDhcpv4Srv::commandConfigReloadHandler) /// @todo: register libreload (see CtrlDhcpv4Srv::commandLibReloadHandler) + CommandMgr::instance().registerCommand("leases-reclaim", + boost::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler, this, _1, _2)); + // Register statistic related commands CommandMgr::instance().registerCommand("statistic-get", boost::bind(&StatsMgr::statisticGetHandler, _1, _2)); @@ -247,6 +260,7 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() { // Deregister any registered commands CommandMgr::instance().deregisterCommand("shutdown"); + CommandMgr::instance().deregisterCommand("leases-reclaim"); CommandMgr::instance().deregisterCommand("statistic-get"); CommandMgr::instance().deregisterCommand("statistic-reset"); CommandMgr::instance().deregisterCommand("statistic-remove"); diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.h b/src/bin/dhcp6/ctrl_dhcp6_srv.h index 07c411c10c..3e1c26f28a 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.h +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.h @@ -150,6 +150,19 @@ private: commandConfigReloadHandler(const std::string& command, isc::data::ConstElementPtr args); + /// @brief handler for processing 'leases-reclaim' command + /// + /// This handler processes leases-reclaim command, which triggers + /// the leases reclamation immediately + /// + /// @param command (parameter ignored) + /// @param args (parameter ignored) + /// + /// @return status of the command + isc::data::ConstElementPtr + commandLeasesReclaimHandler(const std::string& command, + isc::data::ConstElementPtr args); + /// @brief Reclaims expired IPv6 leases and reschedules timer. /// /// This is a wrapper method for @c AllocEngine::reclaimExpiredLeases6. |