summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-10-08 23:08:21 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-10-08 23:08:21 +0200
commit58c5d4eefdf1cdee0651f7c74ffd1501adbdc9c3 (patch)
tree340e4f8ccfd172e197db6aa20cd6cfc7bec0f40e /src
parent3bb4da8601bd4d6de56d57507faf7fa115a15037 (diff)
downloadmad-58c5d4eefdf1cdee0651f7c74ffd1501adbdc9c3.tar
mad-58c5d4eefdf1cdee0651f7c74ffd1501adbdc9c3.zip
fsinfo-Befehl implementiert
Diffstat (limited to 'src')
-rw-r--r--src/Client/CommandManager.cpp83
-rw-r--r--src/Client/CommandManager.h6
-rw-r--r--src/Client/CommandParser.cpp21
-rw-r--r--src/Client/CommandParser.h1
-rw-r--r--src/Client/Requests/DaemonFSInfoRequest.cpp47
-rw-r--r--src/Client/Requests/DaemonFSInfoRequest.h48
-rw-r--r--src/Client/Requests/Makefile.am4
-rw-r--r--src/Client/Requests/Makefile.in10
-rw-r--r--src/Common/Backends/SystemBackendPosix.cpp31
-rw-r--r--src/Common/RequestHandlers/FSInfoRequestHandler.cpp57
-rw-r--r--src/Common/RequestHandlers/FSInfoRequestHandler.h50
-rw-r--r--src/Common/RequestHandlers/Makefile.am4
-rw-r--r--src/Common/RequestHandlers/Makefile.in7
-rw-r--r--src/Common/Requests/FSInfoRequest.cpp (renamed from src/Core/Requests/DaemonStatusRequest.cpp)21
-rw-r--r--src/Common/Requests/FSInfoRequest.h (renamed from src/Core/Requests/DaemonStatusRequest.h)18
-rw-r--r--src/Common/Requests/Makefile.am4
-rw-r--r--src/Common/Requests/Makefile.in9
-rw-r--r--src/Common/Requests/StatusRequest.cpp (renamed from src/Client/Requests/CoreStatusRequest.cpp)10
-rw-r--r--src/Common/Requests/StatusRequest.h (renamed from src/Client/Requests/CoreStatusRequest.h)16
-rw-r--r--src/Core/ConnectionManager.cpp4
-rw-r--r--src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp71
-rw-r--r--src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h56
-rw-r--r--src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp4
-rw-r--r--src/Core/RequestHandlers/DaemonStatusRequestHandler.h3
-rw-r--r--src/Core/RequestHandlers/Makefile.am6
-rw-r--r--src/Core/RequestHandlers/Makefile.in15
-rw-r--r--src/Core/Requests/Makefile.am4
-rw-r--r--src/Core/Requests/Makefile.in7
-rw-r--r--src/Net/Connection.cpp2
-rw-r--r--src/Net/Packet.cpp24
-rw-r--r--src/Net/Packet.h6
-rw-r--r--src/Net/Packets/FSInfoPacket.cpp87
-rw-r--r--src/Net/Packets/FSInfoPacket.h81
-rw-r--r--src/Net/Packets/HostListPacket.cpp10
-rw-r--r--src/Net/Packets/Makefile.am4
-rw-r--r--src/Net/Packets/Makefile.in10
-rw-r--r--src/mad.cpp2
37 files changed, 751 insertions, 92 deletions
diff --git a/src/Client/CommandManager.cpp b/src/Client/CommandManager.cpp
index 2a20b29..08a2780 100644
--- a/src/Client/CommandManager.cpp
+++ b/src/Client/CommandManager.cpp
@@ -20,9 +20,11 @@
#include "CommandManager.h"
#include <Common/HostInfo.h>
#include <Common/Logger.h>
+#include <Net/Packets/FSInfoPacket.h>
#include <Net/Packets/HostListPacket.h>
#include <Net/Packets/HostStatusPacket.h>
+#include <cmath>
#include <iostream>
#include <vector>
@@ -30,6 +32,48 @@
namespace Mad {
namespace Client {
+void CommandManager::printFSInfo(const Net::Packets::FSInfoPacket &packet) {
+ const std::string units[] = {
+ "kB", "MB", "GB", "TB", ""
+ };
+
+ const std::vector<Common::SystemBackend::FSInfo>& fsList = packet.getFSInfo();
+
+ for(std::vector<Common::SystemBackend::FSInfo>::const_iterator fs = fsList.begin(); fs != fsList.end(); ++fs) {
+ unsigned usedUnit = 0, totalUnit = 0;
+
+ float used = fs->used;
+ float total = fs->total;
+ float available = fs->available;
+
+ while(used >= 1024 && !units[usedUnit+1].empty()) {
+ ++usedUnit;
+ used /= 1024;
+ available /= 1024;
+ }
+
+ while(total >= 1024 && !units[totalUnit+1].empty()) {
+ ++totalUnit;
+ total /= 1024;
+ }
+
+ std::string nameString = fs->mountedOn + " (" + fs->fsName + ")";
+
+ if(nameString.length() < 32) {
+ nameString.resize(32, ' ');
+ }
+ else {
+ nameString += '\n';
+ nameString.resize(nameString.length() + 32, ' ');
+ }
+
+ std::printf("\t%s%.*f%s", nameString.c_str(), (used < 10) ? 2 : 1, used, (usedUnit == totalUnit) ? "" : (" " + units[usedUnit]).c_str());
+ std::printf("/%.*f %s (%.1f%%)\n", (total < 10) ? 2 : 1, total, units[totalUnit].c_str(), std::min(100*used/(used+available), 100.0f));
+ }
+
+ std::printf("\n");
+}
+
void CommandManager::printHostStatus(const Net::Packets::HostStatusPacket &packet) {
if(packet.getUptime()) {
unsigned long days = packet.getUptime()/86400;
@@ -82,11 +126,10 @@ void CommandManager::printHostStatus(const Net::Packets::HostStatusPacket &packe
}
}
-void CommandManager::coreStatusRequestFinished(const Common::Request<Net::Packets::HostStatusPacket> &request) {
+
+void CommandManager::daemonCommandRequestFinished(const Common::Request<> &request) {
try {
- const Net::Packets::HostStatusPacket &packet = request.getResult();
- std::cout << "Server status:" << std::endl;
- printHostStatus(packet);
+ request.getResult();
}
catch(Common::Exception &exception) {
Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", exception.strerror().c_str());
@@ -95,9 +138,11 @@ void CommandManager::coreStatusRequestFinished(const Common::Request<Net::Packet
requestFinished();
}
-void CommandManager::daemonCommandRequestFinished(const Common::Request<> &request) {
+void CommandManager::daemonFSInfoRequestFinished(const Common::Request<Net::Packets::FSInfoPacket> &request) {
try {
- request.getResult();
+ const Net::Packets::FSInfoPacket &packet = request.getResult();
+ std::cout << "Host file system usage:" << std::endl;
+ printFSInfo(packet);
}
catch(Common::Exception &exception) {
Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", exception.strerror().c_str());
@@ -131,5 +176,31 @@ void CommandManager::disconnectRequestFinished(const Common::Request<> &request)
requestFinished();
}
+void CommandManager::fsInfoRequestFinished(const Common::Request<Net::Packets::FSInfoPacket> &request) {
+ try {
+ const Net::Packets::FSInfoPacket &packet = request.getResult();
+ std::cout << "Server file system usage:" << std::endl;
+ printFSInfo(packet);
+ }
+ catch(Common::Exception &exception) {
+ Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", exception.strerror().c_str());
+ }
+
+ requestFinished();
+}
+
+void CommandManager::statusRequestFinished(const Common::Request<Net::Packets::HostStatusPacket> &request) {
+ try {
+ const Net::Packets::HostStatusPacket &packet = request.getResult();
+ std::cout << "Server status:" << std::endl;
+ printHostStatus(packet);
+ }
+ catch(Common::Exception &exception) {
+ Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", exception.strerror().c_str());
+ }
+
+ requestFinished();
+}
+
}
}
diff --git a/src/Client/CommandManager.h b/src/Client/CommandManager.h
index f93d07f..1937c0f 100644
--- a/src/Client/CommandManager.h
+++ b/src/Client/CommandManager.h
@@ -26,6 +26,7 @@ namespace Mad {
namespace Net {
namespace Packets {
+class FSInfoPacket;
class HostStatusPacket;
class HostListPacket;
}
@@ -49,12 +50,15 @@ class CommandManager {
finished();
}
+ void printFSInfo(const Net::Packets::FSInfoPacket &packet);
void printHostStatus(const Net::Packets::HostStatusPacket &packet);
- void coreStatusRequestFinished(const Common::Request<Net::Packets::HostStatusPacket> &request);
void daemonCommandRequestFinished(const Common::Request<> &request);
+ void daemonFSInfoRequestFinished(const Common::Request<Net::Packets::FSInfoPacket> &request);
void daemonStatusRequestFinished(const Common::Request<Net::Packets::HostStatusPacket> &request);
void disconnectRequestFinished(const Common::Request<> &request);
+ void fsInfoRequestFinished(const Common::Request<Net::Packets::FSInfoPacket> &request);
+ void statusRequestFinished(const Common::Request<Net::Packets::HostStatusPacket> &request);
public:
CommandManager() : activeRequests(0), disconnect(false) {}
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index 135f771..ab3dd50 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -19,13 +19,15 @@
#include "CommandParser.h"
#include "InformationManager.h"
-#include "Requests/CoreStatusRequest.h"
+#include "Requests/DaemonFSInfoRequest.h"
#include "Requests/DaemonCommandRequest.h"
#include "Requests/DaemonStatusRequest.h"
#include <Common/Exception.h>
#include <Common/Logger.h>
#include <Common/RequestManager.h>
+#include <Common/Requests/FSInfoRequest.h>
#include <Common/Requests/DisconnectRequest.h>
+#include <Common/Requests/StatusRequest.h>
#include <Net/Packets/HostListPacket.h>
#include <Net/Packets/HostStatusPacket.h>
@@ -37,6 +39,7 @@ namespace Mad {
namespace Client {
const CommandParser::Command CommandParser::commands[] = {
+ {{"fsinfo", 0}, "fsinfo [host]", "Displays file system usage information", "Displays file system usage information of a host or the server (if no host is given).", &CommandParser::fsinfoCommand},
{{"help", "?", 0}, "help [command]", "Displays usage information about commands", "Displays usage information about a command. If no command is given, a list of all available commands is displayed.", &CommandParser::helpCommand},
{{"list_hosts", "hosts", 0}, "list_hosts [-a]", "Lists the currently active hosts", "Lists the currently active hosts.\n\n -a\tAlso list inactive hosts", &CommandParser::listHostsCommand},
{{"reboot", 0}, "reboot *|host...", "Reboots host", "Reboots hosts. * will reboot all hosts.", &CommandParser::rebootCommand},
@@ -102,6 +105,20 @@ std::map<std::string, Common::HostInfo> CommandParser::parseHostList(const std::
}
+void CommandParser::fsinfoCommand(const std::vector<std::string> &args) {
+ if(args.size() == 1)
+ Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::FSInfoRequest(sigc::mem_fun(commandManager, &CommandManager::fsInfoRequestFinished))));
+ else if(args.size() == 2)
+ Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Requests::DaemonFSInfoRequest(args[1], sigc::mem_fun(commandManager, &CommandManager::daemonFSInfoRequestFinished))));
+ else {
+ Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ printUsage("fsinfo");
+ return;
+ }
+
+ commandManager.activeRequests++;
+}
+
void CommandParser::helpCommand(const std::vector<std::string> &args) {
if(args.size() == 1) {
std::cout << "Available commands:" << std::endl << std::endl;
@@ -221,7 +238,7 @@ void CommandParser::shutdownCommand(const std::vector<std::string> &args) {
void CommandParser::statusCommand(const std::vector<std::string> &args) {
if(args.size() == 1)
- Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Requests::CoreStatusRequest(sigc::mem_fun(commandManager, &CommandManager::coreStatusRequestFinished))));
+ Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::StatusRequest(sigc::mem_fun(commandManager, &CommandManager::statusRequestFinished))));
else if(args.size() == 2)
Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(commandManager, &CommandManager::daemonStatusRequestFinished))));
else {
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h
index daca0b9..660f548 100644
--- a/src/Client/CommandParser.h
+++ b/src/Client/CommandParser.h
@@ -60,6 +60,7 @@ class CommandParser {
std::map<std::string, Common::HostInfo> parseHostList(const std::vector<std::string> &args, bool mustBeActive = false);
+ void fsinfoCommand(const std::vector<std::string> &args);
void helpCommand(const std::vector<std::string> &args);
void listHostsCommand(const std::vector<std::string> &args);
void rebootCommand(const std::vector<std::string> &args);
diff --git a/src/Client/Requests/DaemonFSInfoRequest.cpp b/src/Client/Requests/DaemonFSInfoRequest.cpp
new file mode 100644
index 0000000..eb26cf4
--- /dev/null
+++ b/src/Client/Requests/DaemonFSInfoRequest.cpp
@@ -0,0 +1,47 @@
+/*
+ * DaemonFSInfoRequest.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "DaemonFSInfoRequest.h"
+#include <Net/Connection.h>
+#include <Net/Packets/ErrorPacket.h>
+
+namespace Mad {
+namespace Client {
+namespace Requests {
+
+void DaemonFSInfoRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ connection->send(Net::Packet(Net::Packet::DAEMON_FS_INFO, requestId, daemon.c_str(), daemon.length()));
+}
+
+void DaemonFSInfoRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(packet.getType() == Net::Packet::ERROR) {
+ finishWithError(Net::Packets::ErrorPacket(packet).getException());
+ return;
+ }
+ else if(packet.getType() != Net::Packet::OK) {
+ finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET));
+ return; // TODO Logging
+ }
+
+ finish(Net::Packets::FSInfoPacket(packet));
+}
+
+}
+}
+}
diff --git a/src/Client/Requests/DaemonFSInfoRequest.h b/src/Client/Requests/DaemonFSInfoRequest.h
new file mode 100644
index 0000000..d966b8d
--- /dev/null
+++ b/src/Client/Requests/DaemonFSInfoRequest.h
@@ -0,0 +1,48 @@
+/*
+ * DaemonFSInfoRequest.h
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_CLIENT_REQUESTS_DAEMONFSINFOREQUEST_H_
+#define MAD_CLIENT_REQUESTS_DAEMONFSINFOREQUEST_H_
+
+#include <Common/Request.h>
+#include <Net/Packets/FSInfoPacket.h>
+
+#include <string>
+
+namespace Mad {
+namespace Client {
+namespace Requests {
+
+class DaemonFSInfoRequest : public Common::Request<Net::Packets::FSInfoPacket> {
+ private:
+ std::string daemon;
+
+ protected:
+ virtual void sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
+
+ public:
+ DaemonFSInfoRequest(const std::string &daemon0, slot_type slot) : Common::Request<Net::Packets::FSInfoPacket>(slot), daemon(daemon0) {}
+};
+
+}
+}
+}
+
+#endif /* MAD_CLIENT_REQUESTS_DAEMONFSINFOREQUEST_H_ */
diff --git a/src/Client/Requests/Makefile.am b/src/Client/Requests/Makefile.am
index 8c4f542..a96b265 100644
--- a/src/Client/Requests/Makefile.am
+++ b/src/Client/Requests/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = CoreStatusRequest.cpp DaemonCommandRequest.cpp DaemonListRequest.cpp DaemonStatusRequest.cpp
+librequests_la_SOURCES = DaemonCommandRequest.cpp DaemonFSInfoRequest.cpp DaemonListRequest.cpp DaemonStatusRequest.cpp
-noinst_HEADERS = CoreStatusRequest.h DaemonCommandRequest.h DaemonListRequest.h DaemonStatusRequest.h
+noinst_HEADERS = DaemonCommandRequest.h DaemonFSInfoRequest.h DaemonListRequest.h DaemonStatusRequest.h
diff --git a/src/Client/Requests/Makefile.in b/src/Client/Requests/Makefile.in
index 9336dbb..a074523 100644
--- a/src/Client/Requests/Makefile.in
+++ b/src/Client/Requests/Makefile.in
@@ -48,8 +48,8 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequests_la_LIBADD =
-am_librequests_la_OBJECTS = CoreStatusRequest.lo \
- DaemonCommandRequest.lo DaemonListRequest.lo \
+am_librequests_la_OBJECTS = DaemonCommandRequest.lo \
+ DaemonFSInfoRequest.lo DaemonListRequest.lo \
DaemonStatusRequest.lo
librequests_la_OBJECTS = $(am_librequests_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
@@ -189,8 +189,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = CoreStatusRequest.cpp DaemonCommandRequest.cpp DaemonListRequest.cpp DaemonStatusRequest.cpp
-noinst_HEADERS = CoreStatusRequest.h DaemonCommandRequest.h DaemonListRequest.h DaemonStatusRequest.h
+librequests_la_SOURCES = DaemonCommandRequest.cpp DaemonFSInfoRequest.cpp DaemonListRequest.cpp DaemonStatusRequest.cpp
+noinst_HEADERS = DaemonCommandRequest.h DaemonFSInfoRequest.h DaemonListRequest.h DaemonStatusRequest.h
all: all-am
.SUFFIXES:
@@ -242,8 +242,8 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoreStatusRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonCommandRequest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonFSInfoRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonListRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonStatusRequest.Plo@am__quote@
diff --git a/src/Common/Backends/SystemBackendPosix.cpp b/src/Common/Backends/SystemBackendPosix.cpp
index ca8b440..acb6bb6 100644
--- a/src/Common/Backends/SystemBackendPosix.cpp
+++ b/src/Common/Backends/SystemBackendPosix.cpp
@@ -19,8 +19,10 @@
#include "SystemBackendPosix.h"
+#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <sstream>
#include <fcntl.h>
#include <signal.h>
@@ -62,9 +64,32 @@ SystemBackendPosix::~SystemBackendPosix() {
void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const sigc::slot<void, const std::vector<FSInfo>& > &callback) {
- // TODO Process df output
+ std::vector<FSInfo> ret;
+ std::istringstream stream(output);
+ std::string str;
- callback(std::vector<FSInfo>());
+ std::getline(stream, str); // ignore first line
+
+ while(!stream.eof()) {
+ std::getline(stream, str);
+
+ char *fsName = new char[str.length()+1];
+ char *mountedOn = new char[str.length()+1];
+
+ FSInfo info;
+
+ if(std::sscanf(str.c_str(), "%s %lld %lld %lld %*d%% %s", fsName, &info.total, &info.used, &info.available, mountedOn) == 5) {
+ info.fsName = fsName;
+ info.mountedOn = mountedOn;
+
+ ret.push_back(info);
+ }
+
+ delete [] fsName;
+ delete [] mountedOn;
+ }
+
+ callback(ret);
}
bool SystemBackendPosix::fsInfo(const sigc::slot<void, const std::vector<FSInfo>& > &callback) {
@@ -200,7 +225,7 @@ bool SystemBackendPosix::execWithOutput(const sigc::slot<void, int, const std::s
dup2(pipeHandles[1], STDOUT_FILENO); // set the new pipe as stdout
close(pipeHandles[1]);
- bool ret = (posix_spawnp(&pid, filename.c_str(), 0, 0, args.first, args.second) == 0);
+ bool ret (posix_spawnp(&pid, filename.c_str(), 0, 0, args.first, args.second) == 0);
if(ret)
processesWithOutput.insert(std::make_pair(pid, std::make_pair(resultHandler, pipeHandles[0])));
diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.cpp b/src/Common/RequestHandlers/FSInfoRequestHandler.cpp
new file mode 100644
index 0000000..5d71277
--- /dev/null
+++ b/src/Common/RequestHandlers/FSInfoRequestHandler.cpp
@@ -0,0 +1,57 @@
+/*
+ * FSInfoRequestHandler.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FSInfoRequestHandler.h"
+#include "../Logger.h"
+#include <Net/Connection.h>
+#include <Net/Packets/ErrorPacket.h>
+#include <Net/Packets/FSInfoPacket.h>
+
+namespace Mad {
+namespace Common {
+namespace RequestHandlers {
+
+void FSInfoRequestHandler::handlePacket(Net::Connection *con, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::FS_INFO) {
+ Logger::log(Logger::ERROR, "Received an unexpected packet.");
+ con->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Exception(Exception::UNEXPECTED_PACKET)));
+
+ signalFinished().emit();
+ return;
+ }
+
+ // TODO Require authentication
+
+ connection = con;
+ requestId = packet.getRequestId();
+
+ if(!SystemBackend::getFSInfo(sigc::mem_fun(this, &FSInfoRequestHandler::fsInfoHandler))) {
+ con->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Exception(Exception::NOT_IMPLEMENTED)));
+ signalFinished().emit();
+ }
+}
+
+void FSInfoRequestHandler::fsInfoHandler(const std::vector<SystemBackend::FSInfo> &info) {
+ connection->send(Net::Packets::FSInfoPacket(Net::Packet::OK, requestId, info));
+ signalFinished().emit();
+}
+
+}
+}
+}
diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.h b/src/Common/RequestHandlers/FSInfoRequestHandler.h
new file mode 100644
index 0000000..8de89ce
--- /dev/null
+++ b/src/Common/RequestHandlers/FSInfoRequestHandler.h
@@ -0,0 +1,50 @@
+/*
+ * FSInfoRequestHandler.h
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_COMMON_REQUESTHANDLERS_FSINFOREQUESTHANDLER_H_
+#define MAD_COMMON_REQUESTHANDLERS_FSINFOREQUESTHANDLER_H_
+
+#include "../RequestHandler.h"
+#include "../SystemBackend.h"
+
+#include <stdint.h>
+
+namespace Mad {
+namespace Common {
+namespace RequestHandlers {
+
+class FSInfoRequestHandler : public RequestHandler {
+ private:
+ Net::Connection *connection;
+ uint16_t requestId;
+
+ void fsInfoHandler(const std::vector<SystemBackend::FSInfo> &info);
+
+ protected:
+ virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
+
+ public:
+ FSInfoRequestHandler() {}
+};
+
+}
+}
+}
+
+#endif /* MAD_COMMON_REQUESTHANDLERS_FSINFOREQUESTHANDLER_H_ */
diff --git a/src/Common/RequestHandlers/Makefile.am b/src/Common/RequestHandlers/Makefile.am
index 4a266e8..0572641 100644
--- a/src/Common/RequestHandlers/Makefile.am
+++ b/src/Common/RequestHandlers/Makefile.am
@@ -1,5 +1,5 @@
noinst_LTLIBRARIES = librequesthandlers.la
-librequesthandlers_la_SOURCES = DisconnectRequestHandler.cpp StatusRequestHandler.cpp
+librequesthandlers_la_SOURCES = DisconnectRequestHandler.cpp FSInfoRequestHandler.cpp StatusRequestHandler.cpp
-noinst_HEADERS = DisconnectRequestHandler.h StatusRequestHandler.h
+noinst_HEADERS = DisconnectRequestHandler.h FSInfoRequestHandler.h StatusRequestHandler.h
diff --git a/src/Common/RequestHandlers/Makefile.in b/src/Common/RequestHandlers/Makefile.in
index 8139c28..a332620 100644
--- a/src/Common/RequestHandlers/Makefile.in
+++ b/src/Common/RequestHandlers/Makefile.in
@@ -49,7 +49,7 @@ CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequesthandlers_la_LIBADD =
am_librequesthandlers_la_OBJECTS = DisconnectRequestHandler.lo \
- StatusRequestHandler.lo
+ FSInfoRequestHandler.lo StatusRequestHandler.lo
librequesthandlers_la_OBJECTS = $(am_librequesthandlers_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -188,8 +188,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequesthandlers.la
-librequesthandlers_la_SOURCES = DisconnectRequestHandler.cpp StatusRequestHandler.cpp
-noinst_HEADERS = DisconnectRequestHandler.h StatusRequestHandler.h
+librequesthandlers_la_SOURCES = DisconnectRequestHandler.cpp FSInfoRequestHandler.cpp StatusRequestHandler.cpp
+noinst_HEADERS = DisconnectRequestHandler.h FSInfoRequestHandler.h StatusRequestHandler.h
all: all-am
.SUFFIXES:
@@ -242,6 +242,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisconnectRequestHandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FSInfoRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StatusRequestHandler.Plo@am__quote@
.cpp.o:
diff --git a/src/Core/Requests/DaemonStatusRequest.cpp b/src/Common/Requests/FSInfoRequest.cpp
index 3b028c9..c8492ff 100644
--- a/src/Core/Requests/DaemonStatusRequest.cpp
+++ b/src/Common/Requests/FSInfoRequest.cpp
@@ -1,5 +1,5 @@
/*
- * DaemonStatusRequest.cpp
+ * FSInfoRequest.cpp
*
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
*
@@ -17,26 +17,29 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "DaemonStatusRequest.h"
-#include <Common/RequestManager.h>
+#include "FSInfoRequest.h"
+#include <Net/Connection.h>
+
+#include <iostream>
namespace Mad {
-namespace Core {
+namespace Common {
namespace Requests {
-void DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- connection->send(Net::Packet(Net::Packet::STATUS, requestId));
+void FSInfoRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ connection->send(Net::Packet(Net::Packet::FS_INFO, requestId));
}
-void DaemonStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+void FSInfoRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::OK) {
- finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET));
+ finishWithError(Exception(Exception::UNEXPECTED_PACKET));
return; // TODO Logging
}
- finish(Net::Packets::HostStatusPacket(packet));
+ finish(Net::Packets::FSInfoPacket(packet));
}
}
}
}
+
diff --git a/src/Core/Requests/DaemonStatusRequest.h b/src/Common/Requests/FSInfoRequest.h
index 09cbc2b..9ae7673 100644
--- a/src/Core/Requests/DaemonStatusRequest.h
+++ b/src/Common/Requests/FSInfoRequest.h
@@ -1,5 +1,5 @@
/*
- * DaemonStatusRequest.h
+ * FSInfoRequest.h
*
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
*
@@ -17,27 +17,27 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_CORE_REQUESTS_DAEMONSTATUSREQUEST_H_
-#define MAD_CORE_REQUESTS_DAEMONSTATUSREQUEST_H_
+#ifndef MAD_COMMON_REQUESTS_FSINFOREQUEST_H_
+#define MAD_COMMON_REQUESTS_FSINFOREQUEST_H_
-#include <Common/Request.h>
-#include <Net/Packets/HostStatusPacket.h>
+#include "../Request.h"
+#include <Net/Packets/FSInfoPacket.h>
namespace Mad {
-namespace Core {
+namespace Common {
namespace Requests {
-class DaemonStatusRequest : public Common::Request<Net::Packets::HostStatusPacket> {
+class FSInfoRequest : public Request<Net::Packets::FSInfoPacket> {
protected:
virtual void sendRequest(Net::Connection *connection, uint16_t requestId);
virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
public:
- DaemonStatusRequest(slot_type slot) : Common::Request<Net::Packets::HostStatusPacket>(slot) {}
+ FSInfoRequest(slot_type slot) : Request<Net::Packets::FSInfoPacket>(slot) {}
};
}
}
}
-#endif /* MAD_CORE_REQUESTS_DAEMONSTATUSREQUEST_H_ */
+#endif /* MAD_COMMON_REQUESTS_FSINFOREQUEST_H_ */
diff --git a/src/Common/Requests/Makefile.am b/src/Common/Requests/Makefile.am
index d455da6..ff116fc 100644
--- a/src/Common/Requests/Makefile.am
+++ b/src/Common/Requests/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = DisconnectRequest.cpp GSSAPIAuthRequest.cpp
+librequests_la_SOURCES = DisconnectRequest.cpp FSInfoRequest.cpp GSSAPIAuthRequest.cpp StatusRequest.cpp
-noinst_HEADERS = DisconnectRequest.h GSSAPIAuthRequest.h
+noinst_HEADERS = DisconnectRequest.h FSInfoRequest.h GSSAPIAuthRequest.h StatusRequest.h
diff --git a/src/Common/Requests/Makefile.in b/src/Common/Requests/Makefile.in
index 6de55d0..5b5e2fe 100644
--- a/src/Common/Requests/Makefile.in
+++ b/src/Common/Requests/Makefile.in
@@ -48,7 +48,8 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequests_la_LIBADD =
-am_librequests_la_OBJECTS = DisconnectRequest.lo GSSAPIAuthRequest.lo
+am_librequests_la_OBJECTS = DisconnectRequest.lo FSInfoRequest.lo \
+ GSSAPIAuthRequest.lo StatusRequest.lo
librequests_la_OBJECTS = $(am_librequests_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -187,8 +188,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = DisconnectRequest.cpp GSSAPIAuthRequest.cpp
-noinst_HEADERS = DisconnectRequest.h GSSAPIAuthRequest.h
+librequests_la_SOURCES = DisconnectRequest.cpp FSInfoRequest.cpp GSSAPIAuthRequest.cpp StatusRequest.cpp
+noinst_HEADERS = DisconnectRequest.h FSInfoRequest.h GSSAPIAuthRequest.h StatusRequest.h
all: all-am
.SUFFIXES:
@@ -241,7 +242,9 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisconnectRequest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FSInfoRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StatusRequest.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/Client/Requests/CoreStatusRequest.cpp b/src/Common/Requests/StatusRequest.cpp
index 69e3ecf..dbaba23 100644
--- a/src/Client/Requests/CoreStatusRequest.cpp
+++ b/src/Common/Requests/StatusRequest.cpp
@@ -17,20 +17,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "CoreStatusRequest.h"
+#include "StatusRequest.h"
#include <Net/Connection.h>
namespace Mad {
-namespace Client {
+namespace Common {
namespace Requests {
-void CoreStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+void StatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
connection->send(Net::Packet(Net::Packet::STATUS, requestId));
}
-void CoreStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+void StatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::OK) {
- finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET));
+ finishWithError(Exception(Exception::UNEXPECTED_PACKET));
return; // TODO Logging
}
diff --git a/src/Client/Requests/CoreStatusRequest.h b/src/Common/Requests/StatusRequest.h
index f57f4bf..5712404 100644
--- a/src/Client/Requests/CoreStatusRequest.h
+++ b/src/Common/Requests/StatusRequest.h
@@ -1,5 +1,5 @@
/*
- * CoreStatusRequest.h
+ * StatusRequest.h
*
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
*
@@ -17,27 +17,27 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_CLIENT_REQUESTS_CORESTATUSREQUEST_H_
-#define MAD_CLIENT_REQUESTS_CORESTATUSREQUEST_H_
+#ifndef MAD_COMMON_REQUESTS_STATUSREQUEST_H_
+#define MAD_COMMON_REQUESTS_STATUSREQUEST_H_
-#include <Common/Request.h>
+#include "../Request.h"
#include <Net/Packets/HostStatusPacket.h>
namespace Mad {
-namespace Client {
+namespace Common {
namespace Requests {
-class CoreStatusRequest : public Common::Request<Net::Packets::HostStatusPacket> {
+class StatusRequest : public Request<Net::Packets::HostStatusPacket> {
protected:
virtual void sendRequest(Net::Connection *connection, uint16_t requestId);
virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
public:
- CoreStatusRequest(slot_type slot) : Common::Request<Net::Packets::HostStatusPacket>(slot) {}
+ StatusRequest(slot_type slot) : Request<Net::Packets::HostStatusPacket>(slot) {}
};
}
}
}
-#endif /* MAD_CLIENT_REQUESTS_CORESTATUSREQUEST_H_ */
+#endif /* MAD_COMMON_REQUESTS_STATUSREQUEST_H_ */
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index 93d6d3f..a41b024 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -20,9 +20,11 @@
#include "ConnectionManager.h"
#include "ConfigManager.h"
#include <Common/Logger.h>
+#include <Common/RequestHandlers/FSInfoRequestHandler.h>
#include <Common/RequestHandlers/StatusRequestHandler.h>
#include "Requests/DaemonStateUpdateRequest.h"
#include "RequestHandlers/DaemonCommandRequestHandler.h"
+#include "RequestHandlers/DaemonFSInfoRequestHandler.h"
#include "RequestHandlers/DaemonListRequestHandler.h"
#include "RequestHandlers/DaemonStatusRequestHandler.h"
#include "RequestHandlers/GSSAPIAuthRequestHandler.h"
@@ -78,9 +80,11 @@ void ConnectionManager::updateState(const std::string &name, Common::HostInfo::S
ConnectionManager::ConnectionManager() {
Common::RequestManager::init(true);
+ Common::RequestManager::getRequestManager()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>(Net::Packet::FS_INFO);
Common::RequestManager::getRequestManager()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>(Net::Packet::STATUS);
Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::DaemonCommandRequestHandler>(Net::Packet::DAEMON_COMMAND_REBOOT);
Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::DaemonCommandRequestHandler>(Net::Packet::DAEMON_COMMAND_SHUTDOWN);
+ Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::DaemonFSInfoRequestHandler>(Net::Packet::DAEMON_FS_INFO);
Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::DaemonListRequestHandler>(Net::Packet::LIST_DAEMONS);
Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::DaemonStatusRequestHandler>(Net::Packet::DAEMON_STATUS);
Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::GSSAPIAuthRequestHandler>(Net::Packet::GSSAPI_AUTH);
diff --git a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp
new file mode 100644
index 0000000..1267520
--- /dev/null
+++ b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp
@@ -0,0 +1,71 @@
+/*
+ * DaemonFSInfoRequestHandler.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "DaemonFSInfoRequestHandler.h"
+#include "../ConnectionManager.h"
+#include <Common/Logger.h>
+#include <Common/Requests/FSInfoRequest.h>
+#include <Net/Packets/ErrorPacket.h>
+#include <Net/Packets/FSInfoPacket.h>
+
+
+namespace Mad {
+namespace Core {
+namespace RequestHandlers {
+
+void DaemonFSInfoRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::DAEMON_FS_INFO) {
+ Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
+ connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
+
+ signalFinished().emit();
+ return;
+ }
+
+ // TODO Require authentication
+
+ con = connection;
+ requestId = packet.getRequestId();
+
+ std::string daemonName((char*)packet.getData(), packet.getLength());
+
+ try {
+ Net::Connection *daemonCon = ConnectionManager::getConnectionManager()->getDaemonConnection(daemonName);
+ Common::RequestManager::getRequestManager()->sendRequest(daemonCon, std::auto_ptr<Common::RequestBase>(new Common::Requests::FSInfoRequest(sigc::mem_fun(this, &DaemonFSInfoRequestHandler::requestFinished))));
+ }
+ catch(Common::Exception &e) {
+ connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), e));
+ }
+}
+
+void DaemonFSInfoRequestHandler::requestFinished(const Common::Request<Net::Packets::FSInfoPacket> &request) {
+ try {
+ const Net::Packet &packet = request.getResult();
+ con->send(Net::Packet(Net::Packet::OK, requestId, packet.getData(), packet.getLength()));
+ }
+ catch(Common::Exception &e) {
+ con->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, requestId, e));
+ }
+
+ signalFinished().emit();
+}
+
+}
+}
+}
diff --git a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h
new file mode 100644
index 0000000..2f6c69c
--- /dev/null
+++ b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h
@@ -0,0 +1,56 @@
+/*
+ * DaemonFSInfoRequestHandler.h
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_CORE_REQUESTHANDLERS_DAEMONFSINFOREQUESTHANDLER_H_
+#define MAD_CORE_REQUESTHANDLERS_DAEMONFSINFOREQUESTHANDLER_H_
+
+#include <Common/RequestHandler.h>
+#include <Common/Request.h>
+#include <stdint.h>
+
+namespace Mad {
+
+namespace Net {
+namespace Packets {
+class FSInfoPacket;
+}
+}
+
+namespace Core {
+namespace RequestHandlers {
+
+class DaemonFSInfoRequestHandler : public Common::RequestHandler {
+ private:
+ Net::Connection *con;
+ uint16_t requestId;
+
+ void requestFinished(const Common::Request<Net::Packets::FSInfoPacket> &request);
+
+ protected:
+ virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
+
+ public:
+ DaemonFSInfoRequestHandler() {}
+};
+
+}
+}
+}
+
+#endif /* MAD_CORE_REQUESTHANDLERS_DAEMONFSINFOREQUESTHANDLER_H_ */
diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
index 7fcf9fe..4add098 100644
--- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
@@ -20,7 +20,7 @@
#include "DaemonStatusRequestHandler.h"
#include "../ConnectionManager.h"
#include <Common/Logger.h>
-#include <Core/Requests/DaemonStatusRequest.h>
+#include <Common/Requests/StatusRequest.h>
#include <Net/Packets/ErrorPacket.h>
#include <Net/Packets/HostStatusPacket.h>
@@ -47,7 +47,7 @@ void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, const
try {
Net::Connection *daemonCon = ConnectionManager::getConnectionManager()->getDaemonConnection(daemonName);
- Common::RequestManager::getRequestManager()->sendRequest(daemonCon, std::auto_ptr<Common::RequestBase>(new Requests::DaemonStatusRequest(sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished))));
+ Common::RequestManager::getRequestManager()->sendRequest(daemonCon, std::auto_ptr<Common::RequestBase>(new Common::Requests::StatusRequest(sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished))));
}
catch(Common::Exception &e) {
connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), e));
diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
index d8edc41..36fabc0 100644
--- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
+++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
@@ -33,9 +33,6 @@ class HostStatusPacket;
}
namespace Core {
-
-class ConnectionManager;
-
namespace RequestHandlers {
class DaemonStatusRequestHandler : public Common::RequestHandler {
diff --git a/src/Core/RequestHandlers/Makefile.am b/src/Core/RequestHandlers/Makefile.am
index 484df59..79aef5e 100644
--- a/src/Core/RequestHandlers/Makefile.am
+++ b/src/Core/RequestHandlers/Makefile.am
@@ -1,4 +1,6 @@
noinst_LTLIBRARIES = librequesthandlers.la
-librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp LogRequestHandler.cpp
+librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp \
+ IdentifyRequestHandler.cpp LogRequestHandler.cpp
-noinst_HEADERS = DaemonCommandRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h LogRequestHandler.h
+noinst_HEADERS = DaemonCommandRequestHandler.h DaemonFSInfoRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h \
+ IdentifyRequestHandler.h LogRequestHandler.h
diff --git a/src/Core/RequestHandlers/Makefile.in b/src/Core/RequestHandlers/Makefile.in
index e0dc6f2..46c1381 100644
--- a/src/Core/RequestHandlers/Makefile.in
+++ b/src/Core/RequestHandlers/Makefile.in
@@ -49,9 +49,9 @@ CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequesthandlers_la_LIBADD =
am_librequesthandlers_la_OBJECTS = DaemonCommandRequestHandler.lo \
- DaemonListRequestHandler.lo DaemonStatusRequestHandler.lo \
- GSSAPIAuthRequestHandler.lo IdentifyRequestHandler.lo \
- LogRequestHandler.lo
+ DaemonFSInfoRequestHandler.lo DaemonListRequestHandler.lo \
+ DaemonStatusRequestHandler.lo GSSAPIAuthRequestHandler.lo \
+ IdentifyRequestHandler.lo LogRequestHandler.lo
librequesthandlers_la_OBJECTS = $(am_librequesthandlers_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -190,8 +190,12 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequesthandlers.la
-librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp LogRequestHandler.cpp
-noinst_HEADERS = DaemonCommandRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h LogRequestHandler.h
+librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp \
+ IdentifyRequestHandler.cpp LogRequestHandler.cpp
+
+noinst_HEADERS = DaemonCommandRequestHandler.h DaemonFSInfoRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h \
+ IdentifyRequestHandler.h LogRequestHandler.h
+
all: all-am
.SUFFIXES:
@@ -244,6 +248,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonCommandRequestHandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonFSInfoRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonListRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonStatusRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequestHandler.Plo@am__quote@
diff --git a/src/Core/Requests/Makefile.am b/src/Core/Requests/Makefile.am
index e69088b..f101b84 100644
--- a/src/Core/Requests/Makefile.am
+++ b/src/Core/Requests/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = CommandRequest.cpp DaemonStateUpdateRequest.cpp DaemonStatusRequest.cpp
+librequests_la_SOURCES = CommandRequest.cpp DaemonStateUpdateRequest.cpp
-noinst_HEADERS = CommandRequest.h DaemonStateUpdateRequest.h DaemonStatusRequest.h
+noinst_HEADERS = CommandRequest.h DaemonStateUpdateRequest.h
diff --git a/src/Core/Requests/Makefile.in b/src/Core/Requests/Makefile.in
index e6367a2..26aa0fe 100644
--- a/src/Core/Requests/Makefile.in
+++ b/src/Core/Requests/Makefile.in
@@ -49,7 +49,7 @@ CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequests_la_LIBADD =
am_librequests_la_OBJECTS = CommandRequest.lo \
- DaemonStateUpdateRequest.lo DaemonStatusRequest.lo
+ DaemonStateUpdateRequest.lo
librequests_la_OBJECTS = $(am_librequests_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -188,8 +188,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = CommandRequest.cpp DaemonStateUpdateRequest.cpp DaemonStatusRequest.cpp
-noinst_HEADERS = CommandRequest.h DaemonStateUpdateRequest.h DaemonStatusRequest.h
+librequests_la_SOURCES = CommandRequest.cpp DaemonStateUpdateRequest.cpp
+noinst_HEADERS = CommandRequest.h DaemonStateUpdateRequest.h
all: all-am
.SUFFIXES:
@@ -243,7 +243,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CommandRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonStateUpdateRequest.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonStatusRequest.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index 8eee0cc..03e9f73 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -225,6 +225,8 @@ bool Connection::rawSend(const uint8_t *data, unsigned long length) {
std::memcpy(trans.data, data, length);
transS.push(trans);
+ doSend();
+
return true;
}
diff --git a/src/Net/Packet.cpp b/src/Net/Packet.cpp
index 9e05f24..976fd65 100644
--- a/src/Net/Packet.cpp
+++ b/src/Net/Packet.cpp
@@ -46,5 +46,29 @@ Packet& Packet::operator=(const Packet &p) {
return *this;
}
+
+uint64_t Packet::htonll(uint64_t val) {
+ union {
+ uint32_t u32[2];
+ uint64_t u64;
+ } ret;
+
+ ret.u32[0] = htonl(val >> 32);
+ ret.u32[1] = htonl(val);
+
+ return ret.u64;
+}
+
+uint64_t Packet::ntohll(uint64_t val) {
+ union {
+ uint32_t u32[2];
+ uint64_t u64;
+ } v;
+
+ v.u64 = val;
+
+ return (((uint64_t)ntohl(v.u32[0])) << 32) | ntohl(v.u32[1]);
+}
+
}
}
diff --git a/src/Net/Packet.h b/src/Net/Packet.h
index 366746b..2ec1634 100644
--- a/src/Net/Packet.h
+++ b/src/Net/Packet.h
@@ -34,7 +34,7 @@ class Packet {
OK = 0x0000, ERROR = 0x0001, DISCONNECT = 0x0002, LOG = 0x0003,
GSSAPI_AUTH = 0x0010, IDENTIFY = 0x0011,
LIST_DAEMONS = 0x0020,
- STATUS = 0x0030, DAEMON_STATUS = 0x0031,
+ STATUS = 0x0030, DAEMON_STATUS = 0x0031, FS_INFO = 0x0032, DAEMON_FS_INFO = 0x0033,
COMMAND_SHUTDOWN = 0x0040, COMMAND_REBOOT = 0x0041,
DAEMON_COMMAND_SHUTDOWN = 0x0050, DAEMON_COMMAND_REBOOT = 0x0051,
DAEMON_STATE_UPDATE = 0x0060
@@ -94,6 +94,10 @@ class Packet {
unsigned long getRawDataLength() const {
return sizeof(Data) + ntohs(rawData->length);
}
+
+
+ static uint64_t htonll(uint64_t val);
+ static uint64_t ntohll(uint64_t val);
};
}
diff --git a/src/Net/Packets/FSInfoPacket.cpp b/src/Net/Packets/FSInfoPacket.cpp
new file mode 100644
index 0000000..c328f8a
--- /dev/null
+++ b/src/Net/Packets/FSInfoPacket.cpp
@@ -0,0 +1,87 @@
+/*
+ * FSInfoPacket.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FSInfoPacket.h"
+#include <cstring>
+#include <sstream>
+
+namespace Mad {
+namespace Net {
+namespace Packets {
+
+void FSInfoPacket::assemblePacket() {
+ std::string str;
+
+ for(std::vector<Common::SystemBackend::FSInfo>::iterator fs = fsList.begin(); fs != fsList.end(); ++fs)
+ str += fs->fsName + "\n" + fs->mountedOn + "\n";
+
+ setLength(sizeof(uint16_t) + sizeof(FSData)*fsList.size() + str.length());
+
+ nFS = (uint16_t*)rawData->data;
+ fsData = (FSData*)(rawData->data + sizeof(uint16_t));
+ charData = (char*)(rawData->data + sizeof(uint16_t) + sizeof(FSData)*fsList.size());
+
+ std::memcpy(charData, str.c_str(), str.length());
+
+ *nFS = htons(fsList.size());
+
+ for(size_t i = 0; i < fsList.size(); ++i) {
+ fsData[i].total = htonll(fsList[i].total);
+ fsData[i].used = htonll(fsList[i].used);
+ fsData[i].available = htonll(fsList[i].available);
+ }
+}
+
+void FSInfoPacket::parsePacket() {
+ fsList.clear();
+
+ if(getLength() < sizeof(uint16_t))
+ return;
+
+ nFS = (uint16_t*)rawData->data;
+ fsList.resize(ntohs(*nFS));
+
+ if(getLength() < sizeof(uint16_t) + sizeof(FSData)*fsList.size())
+ setLength(sizeof(uint16_t) + sizeof(FSData)*fsList.size());
+
+ nFS = (uint16_t*)rawData->data;
+ fsData = (FSData*)(rawData->data + sizeof(uint16_t));
+ charData = (char*)(rawData->data + sizeof(uint16_t) + sizeof(FSData)*fsList.size());
+
+ std::istringstream stream(std::string(charData, getLength() - (sizeof(uint16_t)+sizeof(FSData)*fsList.size())));
+
+ for(size_t i = 0; i < fsList.size(); ++i) {
+ fsList[i].total = ntohll(fsData[i].total);
+ fsList[i].used = ntohll(fsData[i].used);
+ fsList[i].available = ntohll(fsData[i].available);
+
+ if(!stream.eof()) {
+ std::string str;
+
+ std::getline(stream, str);
+ fsList[i].fsName = str;
+ std::getline(stream, str);
+ fsList[i].mountedOn = str;
+ }
+ }
+}
+
+}
+}
+}
diff --git a/src/Net/Packets/FSInfoPacket.h b/src/Net/Packets/FSInfoPacket.h
new file mode 100644
index 0000000..4e973aa
--- /dev/null
+++ b/src/Net/Packets/FSInfoPacket.h
@@ -0,0 +1,81 @@
+/*
+ * FSInfoPacket.h
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_NET_PACKETS_FSINFOPACKET_H_
+#define MAD_NET_PACKETS_FSINFOPACKET_H_
+
+#include "../Packet.h"
+#include <Common/SystemBackend.h>
+
+#include <vector>
+
+namespace Mad {
+namespace Net {
+namespace Packets {
+
+class FSInfoPacket : public Packet {
+ protected:
+ struct FSData {
+ uint64_t total;
+ uint64_t used;
+ uint64_t available;
+ };
+
+ uint16_t *nFS;
+ FSData *fsData;
+ char *charData;
+
+ std::vector<Common::SystemBackend::FSInfo> fsList;
+
+ void assemblePacket();
+ void parsePacket();
+
+ public:
+ FSInfoPacket(Type type, uint16_t requestId, const std::vector<Common::SystemBackend::FSInfo> &fs) : Packet(type, requestId), fsList(fs) {
+ assemblePacket();
+ }
+
+ FSInfoPacket(const Packet &p) : Packet(p) {
+ parsePacket();
+ }
+
+ FSInfoPacket& operator=(const Packet &p) {
+ Packet::operator=(p);
+ parsePacket();
+
+ return *this;
+ }
+
+ FSInfoPacket& operator=(const FSInfoPacket &p) {
+ Packet::operator=(p);
+ parsePacket();
+
+ return *this;
+ }
+
+ const std::vector<Common::SystemBackend::FSInfo>& getFSInfo() const {
+ return fsList;
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_NET_PACKETS_FSINFOPACKET_H_ */
diff --git a/src/Net/Packets/HostListPacket.cpp b/src/Net/Packets/HostListPacket.cpp
index 8c3d395..659b621 100644
--- a/src/Net/Packets/HostListPacket.cpp
+++ b/src/Net/Packets/HostListPacket.cpp
@@ -26,14 +26,10 @@ namespace Net {
namespace Packets {
void HostListPacket::assemblePacket() {
- std::ostringstream stream;
+ std::string str;
- for(std::vector<Common::HostInfo>::iterator host = hostList.begin(); host != hostList.end(); ++host) {
- stream << host->getName() << std::endl;
- stream << host->getIP() << std::endl;
- }
-
- std::string str = stream.str();
+ for(std::vector<Common::HostInfo>::iterator host = hostList.begin(); host != hostList.end(); ++host)
+ str += host->getName() + "\n" + host->getIP() + "\n";
setLength(sizeof(uint16_t) + sizeof(HostData)*hostList.size() + str.length());
diff --git a/src/Net/Packets/Makefile.am b/src/Net/Packets/Makefile.am
index 19dcc7c..311d9da 100644
--- a/src/Net/Packets/Makefile.am
+++ b/src/Net/Packets/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = libpackets.la
-libpackets_la_SOURCES = ErrorPacket.cpp HostListPacket.cpp HostStatePacket.cpp HostStatusPacket.cpp LogPacket.cpp
+libpackets_la_SOURCES = ErrorPacket.cpp FSInfoPacket.cpp HostListPacket.cpp HostStatePacket.cpp HostStatusPacket.cpp LogPacket.cpp
-noinst_HEADERS = ErrorPacket.h HostListPacket.h HostStatePacket.h HostStatusPacket.h LogPacket.h
+noinst_HEADERS = ErrorPacket.h FSInfoPacket.h HostListPacket.h HostStatePacket.h HostStatusPacket.h LogPacket.h
diff --git a/src/Net/Packets/Makefile.in b/src/Net/Packets/Makefile.in
index b500da6..587a36c 100644
--- a/src/Net/Packets/Makefile.in
+++ b/src/Net/Packets/Makefile.in
@@ -48,8 +48,9 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libpackets_la_LIBADD =
-am_libpackets_la_OBJECTS = ErrorPacket.lo HostListPacket.lo \
- HostStatePacket.lo HostStatusPacket.lo LogPacket.lo
+am_libpackets_la_OBJECTS = ErrorPacket.lo FSInfoPacket.lo \
+ HostListPacket.lo HostStatePacket.lo HostStatusPacket.lo \
+ LogPacket.lo
libpackets_la_OBJECTS = $(am_libpackets_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -188,8 +189,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = libpackets.la
-libpackets_la_SOURCES = ErrorPacket.cpp HostListPacket.cpp HostStatePacket.cpp HostStatusPacket.cpp LogPacket.cpp
-noinst_HEADERS = ErrorPacket.h HostListPacket.h HostStatePacket.h HostStatusPacket.h LogPacket.h
+libpackets_la_SOURCES = ErrorPacket.cpp FSInfoPacket.cpp HostListPacket.cpp HostStatePacket.cpp HostStatusPacket.cpp LogPacket.cpp
+noinst_HEADERS = ErrorPacket.h FSInfoPacket.h HostListPacket.h HostStatePacket.h HostStatusPacket.h LogPacket.h
all: all-am
.SUFFIXES:
@@ -242,6 +243,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ErrorPacket.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FSInfoPacket.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HostListPacket.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HostStatePacket.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HostStatusPacket.Plo@am__quote@
diff --git a/src/mad.cpp b/src/mad.cpp
index 47dbfec..d6e0ae3 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -25,6 +25,7 @@
#include "Common/Backends/ConsoleLogger.h"
#include "Common/Request.h"
#include "Common/RequestManager.h"
+#include "Common/RequestHandlers/FSInfoRequestHandler.h"
#include "Common/RequestHandlers/StatusRequestHandler.h"
#include "Daemon/Backends/NetworkLogger.h"
#include "Daemon/Requests/IdentifyRequest.h"
@@ -46,6 +47,7 @@ int main() {
Net::Connection::init();
Common::RequestManager::init(false);
+ Common::RequestManager::getRequestManager()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>(Net::Packet::FS_INFO);
Common::RequestManager::getRequestManager()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>(Net::Packet::STATUS);
Common::RequestManager::getRequestManager()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>(Net::Packet::COMMAND_REBOOT);
Common::RequestManager::getRequestManager()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>(Net::Packet::COMMAND_SHUTDOWN);