diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-03-01 00:51:00 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-03-01 00:51:00 +0100 |
commit | 63907817cb057f497f03a28016d408885cbe41ea (patch) | |
tree | a9ad6b0b19bff7722b21375137ba6e53c8869c91 /src/Net | |
parent | 46c110f7a14e4b5d0e8bd27259f7744ae8a36382 (diff) | |
download | mad-63907817cb057f497f03a28016d408885cbe41ea.tar mad-63907817cb057f497f03a28016d408885cbe41ea.zip |
Alle uebrigen Requests ausser GSSAPIAuthRequest in XmlRequests umgewandelt
Diffstat (limited to 'src/Net')
-rw-r--r-- | src/Net/Packet.h | 9 | ||||
-rw-r--r-- | src/Net/Packets/FSInfoPacket.cpp | 87 | ||||
-rw-r--r-- | src/Net/Packets/FSInfoPacket.h | 81 | ||||
-rw-r--r-- | src/Net/Packets/Makefile.am | 4 | ||||
-rw-r--r-- | src/Net/Packets/Makefile.in | 7 |
5 files changed, 7 insertions, 181 deletions
diff --git a/src/Net/Packet.h b/src/Net/Packet.h index 47d44c7..34f3428 100644 --- a/src/Net/Packet.h +++ b/src/Net/Packet.h @@ -31,13 +31,8 @@ namespace Net { class Packet { public: enum Type { - OK = 0x0000, ERROR = 0x0001, DISCONNECT = 0x0002, - GSSAPI_AUTH = 0x0010, IDENTIFY = 0x0011, - LIST_DAEMONS = 0x0020, - 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, + OK = 0x0000, ERROR = 0x0001, + GSSAPI_AUTH = 0x0010, XML = 0xFFFF }; diff --git a/src/Net/Packets/FSInfoPacket.cpp b/src/Net/Packets/FSInfoPacket.cpp deleted file mode 100644 index c328f8a..0000000 --- a/src/Net/Packets/FSInfoPacket.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4e973aa..0000000 --- a/src/Net/Packets/FSInfoPacket.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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/Makefile.am b/src/Net/Packets/Makefile.am index 99030d4..8ae6b8b 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 FSInfoPacket.cpp +libpackets_la_SOURCES = ErrorPacket.cpp -noinst_HEADERS = ErrorPacket.h FSInfoPacket.h +noinst_HEADERS = ErrorPacket.h diff --git a/src/Net/Packets/Makefile.in b/src/Net/Packets/Makefile.in index 551550a..cced0ce 100644 --- a/src/Net/Packets/Makefile.in +++ b/src/Net/Packets/Makefile.in @@ -50,7 +50,7 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libpackets_la_LIBADD = -am_libpackets_la_OBJECTS = ErrorPacket.lo FSInfoPacket.lo +am_libpackets_la_OBJECTS = ErrorPacket.lo libpackets_la_OBJECTS = $(am_libpackets_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp @@ -216,8 +216,8 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libpackets.la -libpackets_la_SOURCES = ErrorPacket.cpp FSInfoPacket.cpp -noinst_HEADERS = ErrorPacket.h FSInfoPacket.h +libpackets_la_SOURCES = ErrorPacket.cpp +noinst_HEADERS = ErrorPacket.h all: all-am .SUFFIXES: @@ -270,7 +270,6 @@ 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@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |