Commit 4126296c authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[experiments/get-config] Experimental implementation

parent bdf3bae8
...@@ -66,6 +66,14 @@ ControlledDhcpv4Srv::commandConfigReloadHandler(const string&, ...@@ -66,6 +66,14 @@ ControlledDhcpv4Srv::commandConfigReloadHandler(const string&,
return (commandSetConfigHandler("set-config", args)); return (commandSetConfigHandler("set-config", args));
} }
ConstElementPtr
ControlledDhcpv4Srv::commandGetConfigHandler(const string&,
ConstElementPtr /*args*/) {
ConstElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement();
return (createAnswer(0, config));
}
ConstElementPtr ConstElementPtr
ControlledDhcpv4Srv::commandSetConfigHandler(const string&, ControlledDhcpv4Srv::commandSetConfigHandler(const string&,
ConstElementPtr args) { ConstElementPtr args) {
...@@ -181,6 +189,9 @@ ControlledDhcpv4Srv::processCommand(const string& command, ...@@ -181,6 +189,9 @@ ControlledDhcpv4Srv::processCommand(const string& command,
} else if (command == "set-config") { } else if (command == "set-config") {
return (srv->commandSetConfigHandler(command, args)); return (srv->commandSetConfigHandler(command, args));
} else if (command == "get-config") {
return (srv->commandGetConfigHandler(command, args));
} else if (command == "leases-reclaim") { } else if (command == "leases-reclaim") {
return (srv->commandLeasesReclaimHandler(command, args)); return (srv->commandLeasesReclaimHandler(command, args));
} }
...@@ -323,6 +334,9 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t port /*= DHCP4_SERVER_PORT*/) ...@@ -323,6 +334,9 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t port /*= DHCP4_SERVER_PORT*/)
CommandMgr::instance().registerCommand("set-config", CommandMgr::instance().registerCommand("set-config",
boost::bind(&ControlledDhcpv4Srv::commandSetConfigHandler, this, _1, _2)); boost::bind(&ControlledDhcpv4Srv::commandSetConfigHandler, this, _1, _2));
CommandMgr::instance().registerCommand("get-config",
boost::bind(&ControlledDhcpv4Srv::commandGetConfigHandler, this, _1, _2));
CommandMgr::instance().registerCommand("leases-reclaim", CommandMgr::instance().registerCommand("leases-reclaim",
boost::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler, this, _1, _2)); boost::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler, this, _1, _2));
...@@ -364,6 +378,7 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() { ...@@ -364,6 +378,7 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
CommandMgr::instance().closeCommandSocket(); CommandMgr::instance().closeCommandSocket();
// Deregister any registered commands // Deregister any registered commands
CommandMgr::instance().deregisterCommand("get-config");
CommandMgr::instance().deregisterCommand("shutdown"); CommandMgr::instance().deregisterCommand("shutdown");
CommandMgr::instance().deregisterCommand("libreload"); CommandMgr::instance().deregisterCommand("libreload");
CommandMgr::instance().deregisterCommand("set-config"); CommandMgr::instance().deregisterCommand("set-config");
......
...@@ -144,6 +144,10 @@ private: ...@@ -144,6 +144,10 @@ private:
commandConfigReloadHandler(const std::string& command, commandConfigReloadHandler(const std::string& command,
isc::data::ConstElementPtr args); isc::data::ConstElementPtr args);
isc::data::ConstElementPtr
commandGetConfigHandler(const std::string& command,
isc::data::ConstElementPtr args);
/// @brief handler for processing 'set-config' command /// @brief handler for processing 'set-config' command
/// ///
/// This handler processes set-config command, which processes /// This handler processes set-config command, which processes
......
...@@ -71,6 +71,14 @@ ControlledDhcpv6Srv::commandConfigReloadHandler(const string&, ConstElementPtr a ...@@ -71,6 +71,14 @@ ControlledDhcpv6Srv::commandConfigReloadHandler(const string&, ConstElementPtr a
return (commandSetConfigHandler("set-config", args)); return (commandSetConfigHandler("set-config", args));
} }
ConstElementPtr
ControlledDhcpv6Srv::commandGetConfigHandler(const string&,
ConstElementPtr /*args*/) {
ConstElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement();
return (createAnswer(0, config));
}
ConstElementPtr ConstElementPtr
ControlledDhcpv6Srv::commandSetConfigHandler(const string&, ControlledDhcpv6Srv::commandSetConfigHandler(const string&,
ConstElementPtr args) { ConstElementPtr args) {
...@@ -189,6 +197,9 @@ ControlledDhcpv6Srv::processCommand(const std::string& command, ...@@ -189,6 +197,9 @@ ControlledDhcpv6Srv::processCommand(const std::string& command,
} else if (command == "set-config") { } else if (command == "set-config") {
return (srv->commandSetConfigHandler(command, args)); return (srv->commandSetConfigHandler(command, args));
} else if (command == "get-config") {
return (srv->commandGetConfigHandler(command, args));
} else if (command == "leases-reclaim") { } else if (command == "leases-reclaim") {
return (srv->commandLeasesReclaimHandler(command, args)); return (srv->commandLeasesReclaimHandler(command, args));
} }
...@@ -352,6 +363,9 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port) ...@@ -352,6 +363,9 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port)
CommandMgr::instance().registerCommand("set-config", CommandMgr::instance().registerCommand("set-config",
boost::bind(&ControlledDhcpv6Srv::commandSetConfigHandler, this, _1, _2)); boost::bind(&ControlledDhcpv6Srv::commandSetConfigHandler, this, _1, _2));
CommandMgr::instance().registerCommand("get-config",
boost::bind(&ControlledDhcpv6Srv::commandGetConfigHandler, this, _1, _2));
CommandMgr::instance().registerCommand("leases-reclaim", CommandMgr::instance().registerCommand("leases-reclaim",
boost::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler, this, _1, _2)); boost::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler, this, _1, _2));
...@@ -393,6 +407,7 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() { ...@@ -393,6 +407,7 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
CommandMgr::instance().closeCommandSocket(); CommandMgr::instance().closeCommandSocket();
// Deregister any registered commands // Deregister any registered commands
CommandMgr::instance().deregisterCommand("get-config");
CommandMgr::instance().deregisterCommand("shutdown"); CommandMgr::instance().deregisterCommand("shutdown");
CommandMgr::instance().deregisterCommand("libreload"); CommandMgr::instance().deregisterCommand("libreload");
CommandMgr::instance().deregisterCommand("set-config"); CommandMgr::instance().deregisterCommand("set-config");
......
...@@ -144,6 +144,10 @@ private: ...@@ -144,6 +144,10 @@ private:
commandConfigReloadHandler(const std::string& command, commandConfigReloadHandler(const std::string& command,
isc::data::ConstElementPtr args); isc::data::ConstElementPtr args);
isc::data::ConstElementPtr
commandGetConfigHandler(const std::string& command,
isc::data::ConstElementPtr args);
/// @brief handler for processing 'set-config' command /// @brief handler for processing 'set-config' command
/// ///
/// This handler processes set-config command, which processes /// This handler processes set-config command, which processes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment