summaryrefslogtreecommitdiffstats
path: root/src/Net
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-02-28 19:09:43 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-02-28 19:09:43 +0100
commit46c110f7a14e4b5d0e8bd27259f7744ae8a36382 (patch)
tree94693ecffb8f1c553c12ea3a30920b2008e27b11 /src/Net
parent8f85624a76934b14e0ba0f49413f471f8f4aa4f1 (diff)
downloadmad-46c110f7a14e4b5d0e8bd27259f7744ae8a36382.tar
mad-46c110f7a14e4b5d0e8bd27259f7744ae8a36382.zip
DaemonListRequest und DaemonStateUpdateRequest benutzen jetzt XML
Diffstat (limited to 'src/Net')
-rw-r--r--src/Net/Packets/HostListPacket.cpp83
-rw-r--r--src/Net/Packets/HostListPacket.h80
-rw-r--r--src/Net/Packets/HostStatePacket.cpp50
-rw-r--r--src/Net/Packets/HostStatePacket.h74
-rw-r--r--src/Net/Packets/Makefile.am4
-rw-r--r--src/Net/Packets/Makefile.in9
6 files changed, 5 insertions, 295 deletions
diff --git a/src/Net/Packets/HostListPacket.cpp b/src/Net/Packets/HostListPacket.cpp
deleted file mode 100644
index 659b621..0000000
--- a/src/Net/Packets/HostListPacket.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * HostListPacket.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 "HostListPacket.h"
-#include <cstring>
-#include <sstream>
-
-namespace Mad {
-namespace Net {
-namespace Packets {
-
-void HostListPacket::assemblePacket() {
- std::string 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());
-
- nHosts = (uint16_t*)rawData->data;
- hostData = (HostData*)(rawData->data + sizeof(uint16_t));
- charData = (char*)(rawData->data + sizeof(uint16_t) + sizeof(HostData)*hostList.size());
-
- std::memcpy(charData, str.c_str(), str.length());
-
- *nHosts = htons(hostList.size());
-
- for(size_t i = 0; i < hostList.size(); ++i) {
- hostData[i].state = htons((uint16_t)hostList[i].getState());
- }
-}
-
-void HostListPacket::parsePacket() {
- hostList.clear();
-
- if(getLength() < sizeof(uint16_t))
- return;
-
- nHosts = (uint16_t*)rawData->data;
- hostList.resize(ntohs(*nHosts));
-
- if(getLength() < sizeof(uint16_t) + sizeof(HostData)*hostList.size())
- setLength(sizeof(uint16_t) + sizeof(HostData)*hostList.size());
-
- nHosts = (uint16_t*)rawData->data;
- hostData = (HostData*)(rawData->data + sizeof(uint16_t));
- charData = (char*)(rawData->data + sizeof(uint16_t) + sizeof(HostData)*hostList.size());
-
- std::istringstream stream(std::string(charData, getLength() - (sizeof(uint16_t)+sizeof(HostData)*hostList.size())));
-
- for(size_t i = 0; i < hostList.size(); ++i) {
- hostList[i].setState((Common::HostInfo::State)ntohs(hostData[i].state));
-
- if(!stream.eof()) {
- std::string str;
-
- std::getline(stream, str);
- hostList[i].setName(str);
- std::getline(stream, str);
- hostList[i].setIP(str);
- }
- }
-}
-
-}
-}
-}
diff --git a/src/Net/Packets/HostListPacket.h b/src/Net/Packets/HostListPacket.h
deleted file mode 100644
index 2cec9b0..0000000
--- a/src/Net/Packets/HostListPacket.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * HostListPacket.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_HOSTLISTPACKET_H_
-#define MAD_NET_PACKETS_HOSTLISTPACKET_H_
-
-#include "../Packet.h"
-#include <Common/HostInfo.h>
-
-#include <vector>
-
-
-namespace Mad {
-namespace Net {
-namespace Packets {
-
-class HostListPacket : public Packet {
- protected:
- struct HostData {
- uint16_t state;
- };
-
- uint16_t *nHosts;
- HostData *hostData;
- char *charData;
-
- std::vector<Common::HostInfo> hostList;
-
- void assemblePacket();
- void parsePacket();
-
- public:
- HostListPacket(Type type, uint16_t requestId, const std::vector<Common::HostInfo> &hosts) : Packet(type, requestId), hostList(hosts) {
- assemblePacket();
- }
-
- HostListPacket(const Packet &p) : Packet(p) {
- parsePacket();
- }
-
- HostListPacket& operator=(const Packet &p) {
- Packet::operator=(p);
- parsePacket();
-
- return *this;
- }
-
- HostListPacket& operator=(const HostListPacket &p) {
- Packet::operator=(p);
- parsePacket();
-
- return *this;
- }
-
- const std::vector<Common::HostInfo>& getHostInfo() const {
- return hostList;
- }
-};
-
-}
-}
-}
-
-#endif /* MAD_NET_PACKETS_HOSTLISTPACKET_H_ */
diff --git a/src/Net/Packets/HostStatePacket.cpp b/src/Net/Packets/HostStatePacket.cpp
deleted file mode 100644
index d34d9d5..0000000
--- a/src/Net/Packets/HostStatePacket.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * HostStatePacket.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 "HostStatePacket.h"
-
-namespace Mad {
-namespace Net {
-namespace Packets {
-
-HostStatePacket::HostStatePacket(Type type, uint16_t requestId, const std::string &name, Common::HostInfo::State state)
-: Packet(type, requestId)
-{
- setLength(sizeof(HostStateData) + name.length());
- hostStateData = (HostStateData*)&rawData->data;
-
- hostStateData->state = htons(state);
-
- std::memcpy(hostStateData->name, name.c_str(), name.length());
-}
-
-HostStatePacket& HostStatePacket::operator=(const Packet &p) {
- Packet::operator=(p);
-
- if(getLength() < sizeof(HostStateData))
- setLength(sizeof(HostStateData));
-
- hostStateData = (HostStateData*)&rawData->data;
-
- return *this;
-}
-
-}
-}
-}
diff --git a/src/Net/Packets/HostStatePacket.h b/src/Net/Packets/HostStatePacket.h
deleted file mode 100644
index 5a34275..0000000
--- a/src/Net/Packets/HostStatePacket.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * HostStatePacket.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_HOSTSTATEPACKET_H_
-#define MAD_NET_PACKETS_HOSTSTATEPACKET_H_
-
-#include "../Packet.h"
-#include <Common/HostInfo.h>
-
-#include <string>
-
-namespace Mad {
-namespace Net {
-namespace Packets {
-
-class HostStatePacket : public Packet {
- protected:
- struct HostStateData {
- uint16_t state;
- uint8_t name[0];
- };
-
- HostStateData *hostStateData;
-
- public:
- HostStatePacket(Type type, uint16_t requestId, const std::string &name, Common::HostInfo::State state);
-
- HostStatePacket(const Packet &p) : Packet(p) {
- if(getLength() < sizeof(HostStateData))
- setLength(sizeof(HostStateData));
-
- hostStateData = (HostStateData*)&rawData->data;
- }
-
- HostStatePacket(const HostStatePacket &p) : Packet(p) {
- hostStateData = (HostStateData*)&rawData->data;
- }
-
- HostStatePacket& operator=(const Packet &p);
-
- HostStatePacket& operator=(const HostStatePacket &p) {
- return (*this = (Packet)p);
- }
-
- std::string getName() const {
- return std::string((char*)hostStateData->name, getLength()-sizeof(HostStateData));
- }
-
- Common::HostInfo::State getState() const {
- return (Common::HostInfo::State)ntohs(hostStateData->state);
- }
-};
-
-}
-}
-}
-
-#endif /* MAD_NET_PACKETS_HOSTSTATEPACKET_H_ */
diff --git a/src/Net/Packets/Makefile.am b/src/Net/Packets/Makefile.am
index 9ce8f9d..99030d4 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 HostListPacket.cpp HostStatePacket.cpp
+libpackets_la_SOURCES = ErrorPacket.cpp FSInfoPacket.cpp
-noinst_HEADERS = ErrorPacket.h FSInfoPacket.h HostListPacket.h HostStatePacket.h
+noinst_HEADERS = ErrorPacket.h FSInfoPacket.h
diff --git a/src/Net/Packets/Makefile.in b/src/Net/Packets/Makefile.in
index 239e753..551550a 100644
--- a/src/Net/Packets/Makefile.in
+++ b/src/Net/Packets/Makefile.in
@@ -50,8 +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 \
- HostListPacket.lo HostStatePacket.lo
+am_libpackets_la_OBJECTS = ErrorPacket.lo FSInfoPacket.lo
libpackets_la_OBJECTS = $(am_libpackets_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
@@ -217,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 HostListPacket.cpp HostStatePacket.cpp
-noinst_HEADERS = ErrorPacket.h FSInfoPacket.h HostListPacket.h HostStatePacket.h
+libpackets_la_SOURCES = ErrorPacket.cpp FSInfoPacket.cpp
+noinst_HEADERS = ErrorPacket.h FSInfoPacket.h
all: all-am
.SUFFIXES:
@@ -272,8 +271,6 @@ distclean-compile:
@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@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<