summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-03-04 22:53:02 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-03-04 22:53:02 +0100
commitc316a3115bf790fb623f0765dd6b04f781af5b51 (patch)
treeb757067dcd2495bf8aa5d3ca6f42886eb55c93fa /src
parentd88e4d0da7ff801b0c58b5043ade0743547cfb90 (diff)
downloadmad-c316a3115bf790fb623f0765dd6b04f781af5b51.tar
mad-c316a3115bf790fb623f0765dd6b04f781af5b51.zip
Alte Request-Klassen entfernt
Diffstat (limited to 'src')
-rw-r--r--src/Client/CommandManager.cpp2
-rw-r--r--src/Client/CommandManager.h2
-rw-r--r--src/Client/CommandParser.h1
-rw-r--r--src/Common/Makefile.am2
-rw-r--r--src/Common/Makefile.in2
-rw-r--r--src/Common/Request.h92
-rw-r--r--src/Common/RequestBase.h39
-rw-r--r--src/Common/RequestHandler.h60
-rw-r--r--src/Common/RequestManager.cpp137
-rw-r--r--src/Common/RequestManager.h42
-rw-r--r--src/Common/XmlPacket.cpp2
-rw-r--r--src/Net/Connection.cpp4
-rw-r--r--src/Net/Packet.cpp28
-rw-r--r--src/Net/Packet.h24
-rw-r--r--src/mad.cpp1
15 files changed, 21 insertions, 417 deletions
diff --git a/src/Client/CommandManager.cpp b/src/Client/CommandManager.cpp
index 59de7c4..bcb3429 100644
--- a/src/Client/CommandManager.cpp
+++ b/src/Client/CommandManager.cpp
@@ -68,7 +68,7 @@ void CommandManager::printFSInfo(const Common::XmlPacket &packet) {
nameString.resize(32, ' ');
}
else {
- nameString += '\n';
+ nameString += "\n\t";
nameString.resize(nameString.length() + 32, ' ');
}
diff --git a/src/Client/CommandManager.h b/src/Client/CommandManager.h
index e2e5ff4..a49cda7 100644
--- a/src/Client/CommandManager.h
+++ b/src/Client/CommandManager.h
@@ -20,7 +20,7 @@
#ifndef MAD_CLIENT_COMMANDMANAGER_H_
#define MAD_CLIENT_COMMANDMANAGER_H_
-#include <Common/Request.h>
+#include <sigc++/signal.h>
namespace Mad {
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h
index cb38588..2827443 100644
--- a/src/Client/CommandParser.h
+++ b/src/Client/CommandParser.h
@@ -22,7 +22,6 @@
#include "CommandManager.h"
#include <Common/HostInfo.h>
-#include <Common/Request.h>
#include <map>
#include <string>
diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am
index 5d4fb09..79bc0b1 100644
--- a/src/Common/Makefile.am
+++ b/src/Common/Makefile.am
@@ -8,5 +8,5 @@ libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandler
noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h \
Initializable.h Logger.h LoggerBase.h LogManager.h ModuleManager.h \
- RemoteLogger.h Request.h RequestBase.h RequestHandler.h RequestManager.h \
+ RemoteLogger.h RequestManager.h \
SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h XmlRequest.h XmlRequestHandler.h
diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in
index 948343c..1f7bca5 100644
--- a/src/Common/Makefile.in
+++ b/src/Common/Makefile.in
@@ -245,7 +245,7 @@ libcommon_la_SOURCES = ActionManager.cpp ConfigEntry.cpp ConfigManager.cpp Excep
libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandlers.la ../../lib/libgnu.la
noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h \
Initializable.h Logger.h LoggerBase.h LogManager.h ModuleManager.h \
- RemoteLogger.h Request.h RequestBase.h RequestHandler.h RequestManager.h \
+ RemoteLogger.h RequestManager.h \
SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h XmlRequest.h XmlRequestHandler.h
all: all-recursive
diff --git a/src/Common/Request.h b/src/Common/Request.h
deleted file mode 100644
index 2317d5a..0000000
--- a/src/Common/Request.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Request.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_REQUEST_H_
-#define MAD_COMMON_REQUEST_H_
-
-#include "RequestBase.h"
-#include "Exception.h"
-
-#include <memory>
-#include <sigc++/adaptors/hide.h>
-
-namespace Mad {
-namespace Common {
-
-template<typename T = void> class Request : public RequestBase {
- private:
- sigc::signal<void,const Request<T>&> finished;
-
- std::auto_ptr<T> res;
- Exception exp;
-
- public:
- typedef sigc::slot<void,const Request<T>&> slot_type;
-
- protected:
- Request(slot_type slot) : exp(Exception::NOT_FINISHED) {
- finished.connect(slot);
- finished.connect(sigc::hide(signalFinished().make_slot()));
- }
-
- void finish(std::auto_ptr<T> result) {res = result; finished(*this);}
- void finish(const T& result) {res.reset(new T(result)); finished(*this);}
- void finishWithError(const Exception &e) {exp = e; finished(*this);}
-
- public:
- const T& getResult() const throw(Exception) {
- if(res.get())
- return *res;
-
- throw exp;
- }
-};
-
-template<> class Request<void> : public RequestBase {
- private:
- sigc::signal<void,const Request<void>&> finished;
-
- bool isFinished;
- Exception exp;
-
- public:
- typedef sigc::slot<void,const Request<void>&> slot_type;
-
- protected:
- Request(slot_type slot) : isFinished(false), exp(Exception::NOT_FINISHED) {
- finished.connect(slot);
- finished.connect(sigc::hide(signalFinished().make_slot()));
- }
-
- void finish() {isFinished = true; finished(*this);}
- void finishWithError(const Exception &e) {exp = e; finished(*this);}
-
- public:
- void getResult() const throw(Exception) {
- if(isFinished)
- return;
-
- throw exp;
- }
-};
-
-}
-}
-
-#endif /* MAD_COMMON_REQUEST_H_ */
diff --git a/src/Common/RequestBase.h b/src/Common/RequestBase.h
deleted file mode 100644
index 535f6d0..0000000
--- a/src/Common/RequestBase.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * RequestBase.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_REQUESTBASE_H_
-#define MAD_COMMON_REQUESTBASE_H_
-
-#include "RequestHandler.h"
-#include <stdint.h>
-
-namespace Mad {
-namespace Common {
-
-class RequestBase : public RequestHandler {
- protected:
- virtual void sendRequest(Net::Connection *connection, uint16_t requestId) = 0;
-
- friend class RequestManager;
-};
-
-}
-}
-
-#endif /* MAD_COMMON_REQUESTBASE_H_ */
diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h
deleted file mode 100644
index 434f969..0000000
--- a/src/Common/RequestHandler.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * RequestHandler.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_REQUESTHANDLER_H_
-#define MAD_COMMON_REQUESTHANDLER_H_
-
-#include <sigc++/signal.h>
-
-namespace Mad {
-
-namespace Net {
-class Connection;
-class Packet;
-}
-
-namespace Common {
-
-class RequestManager;
-
-class RequestHandler {
- private:
- sigc::signal<void> finished;
-
- // Prevent shallow copy
- RequestHandler(const RequestHandler &o);
- RequestHandler& operator=(const RequestHandler &o);
-
- protected:
- RequestHandler() {}
-
- sigc::signal<void> signalFinished() {return finished;}
-
- virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet) = 0;
-
- public:
- virtual ~RequestHandler() {}
-
- friend class RequestManager;
-};
-
-}
-}
-
-#endif /* MAD_COMMON_REQUESTHANDLER_H_ */
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index b5acc5c..de4f2ca 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -18,7 +18,6 @@
*/
#include "RequestManager.h"
-#include "Request.h"
#include "XmlRequest.h"
#include "XmlPacket.h"
#include "RequestHandlers/DisconnectRequestHandler.h"
@@ -33,40 +32,6 @@ namespace Common {
RequestManager RequestManager::requestManager;
-RequestManager::RequestMap::~RequestMap() {
- for(iterator it = begin(); it != end(); ++it)
- delete it->second;
-}
-
-bool RequestManager::RequestMap::addRequest(uint16_t id, RequestHandler *info) {
- if(!insert(std::make_pair(id, info)).second)
- return false;
-
- info->signalFinished().connect(sigc::hide_return(sigc::bind(sigc::mem_fun(this, &RequestManager::RequestMap::deleteRequest), id)));
-
- return true;
-}
-
-RequestHandler* RequestManager::RequestMap::findRequest(uint16_t id) {
- iterator it = find(id);
- if(it == end())
- return 0;
-
- return it->second;
-}
-
-bool RequestManager::RequestMap::deleteRequest(uint16_t id) {
- iterator it = find(id);
- if(it == end())
- return false;
-
- delete it->second;
-
- erase(it);
- return true;
-}
-
-
RequestManager::XmlRequestMap::~XmlRequestMap() {
for(iterator it = begin(); it != end(); ++it)
delete it->second;
@@ -102,60 +67,29 @@ bool RequestManager::XmlRequestMap::deleteRequest(uint16_t id) {
void RequestManager::receiveHandler(Net::Connection *connection, const Net::Packet &packet) {
- std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
-
- if(it == requestMaps.end()) {
- // TODO: Error
- Logger::log(Logger::ERROR, "Received a packet from an unregistered connection.");
-
- return;
- }
-
- RequestMap *requestMap = it->second;
- RequestHandler *request = requestMap->findRequest(packet.getRequestId());
+ XmlPacket xmlPacket(packet);
- if(request) {
- request->handlePacket(connection, packet);
-
- return;
- }
-
- std::map<Net::Connection*,XmlRequestMap*>::iterator it2 = xmlRequestMaps.find(connection);
- if(it2 == xmlRequestMaps.end()) {
+ std::map<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.find(connection);
+ if(it == xmlRequestMaps.end()) {
// TODO: Error
Logger::log(Logger::ERROR, "Received a packet from an unregistered connection.");
return;
}
- XmlRequestMap *xmlRequestMap = it2->second;
+ XmlRequestMap *xmlRequestMap = it->second;
XmlRequestHandler *xmlRequest = xmlRequestMap->findRequest(packet.getRequestId());
if(xmlRequest) {
- XmlPacket xmlPacket(packet);
xmlRequest->handlePacket(connection, packet.getRequestId(), xmlPacket);
-
return;
}
- if(packet.getType() == Net::Packet::XML) {
- XmlPacket xmlPacket(packet);
-
- std::map<std::string,XmlRequestHandlerFactory*>::iterator factoryIt = xmlRequestHandlerFactories.find(xmlPacket.getType());
- if(factoryIt != xmlRequestHandlerFactories.end()) {
- xmlRequest = factoryIt->second->createRequestHandler();
- xmlRequestMap->addRequest(packet.getRequestId(), xmlRequest);
- xmlRequest->handlePacket(connection, packet.getRequestId(), xmlPacket);
-
- return;
- }
- }
-
- std::map<Net::Packet::Type,RequestHandlerFactory*>::iterator factoryIt = requestHandlerFactories.find(packet.getType());
- if(factoryIt != requestHandlerFactories.end()) {
- request = factoryIt->second->createRequestHandler();
- requestMap->addRequest(packet.getRequestId(), request);
- request->handlePacket(connection, packet);
+ std::map<std::string,XmlRequestHandlerFactory*>::iterator factoryIt = xmlRequestHandlerFactories.find(xmlPacket.getType());
+ if(factoryIt != xmlRequestHandlerFactories.end()) {
+ xmlRequest = factoryIt->second->createRequestHandler();
+ xmlRequestMap->addRequest(packet.getRequestId(), xmlRequest);
+ xmlRequest->handlePacket(connection, packet.getRequestId(), xmlPacket);
return;
}
@@ -169,28 +103,6 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack
connection->send(ret.encode(requestId));
}
-bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr<RequestBase> request) {
- std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
-
- if(it == requestMaps.end()) {
- Logger::log(Logger::CRITICAL, "Trying to send a request over an unregistered connecion.");
- return false;
- }
-
- RequestMap *requestMap = it->second;
-
- uint16_t id;
- do {
- id = getRequestId();
- } while(requestMap->findRequest(id));
-
- request->sendRequest(connection, id);
-
- requestMap->addRequest(id, request.release());
-
- return true;
-}
-
bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr<XmlRequest> request) {
std::map<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.find(connection);
@@ -214,37 +126,18 @@ bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr<XmlR
}
void RequestManager::registerConnection(Net::Connection *connection) {
- requestMaps.insert(std::make_pair(connection, new RequestMap()));
xmlRequestMaps.insert(std::make_pair(connection, new XmlRequestMap()));
connection->signalReceive().connect(sigc::mem_fun(this, &RequestManager::receiveHandler));
}
void RequestManager::unregisterConnection(Net::Connection *connection) {
- std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
+ std::map<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.find(connection);
- if(it != requestMaps.end()) {
+ if(it != xmlRequestMaps.end()) {
delete it->second;
- requestMaps.erase(it);
+ xmlRequestMaps.erase(it);
}
-
- std::map<Net::Connection*,XmlRequestMap*>::iterator it2 = xmlRequestMaps.find(connection);
-
- if(it2 != xmlRequestMaps.end()) {
- delete it2->second;
- xmlRequestMaps.erase(it2);
- }
-}
-
-void RequestManager::unregisterPacketType(Net::Packet::Type type) {
- std::map<Net::Packet::Type,RequestHandlerFactory*>::iterator it = requestHandlerFactories.find(type);
-
- if(it == requestHandlerFactories.end())
- return;
-
- delete it->second;
-
- requestHandlerFactories.erase(it);
}
void RequestManager::unregisterPacketType(const std::string &type) {
@@ -265,15 +158,9 @@ RequestManager::RequestManager() : core(false), requestId(-1) {
RequestManager::~RequestManager() {
unregisterPacketType("Disconnect");
- for(std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it)
- delete it->second;
-
for(std::map<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.begin(); it != xmlRequestMaps.end(); ++it)
delete it->second;
- for(std::map<Net::Packet::Type,RequestHandlerFactory*>::iterator it = requestHandlerFactories.begin(); it != requestHandlerFactories.end(); ++it)
- delete it->second;
-
for(std::map<std::string,XmlRequestHandlerFactory*>::iterator it = xmlRequestHandlerFactories.begin(); it != xmlRequestHandlerFactories.end(); ++it)
delete it->second;
}
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index f4ad208..8a3d151 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -28,28 +28,11 @@
namespace Mad {
namespace Common {
-class RequestBase;
-class RequestHandler;
class XmlRequest;
class XmlRequestHandler;
class RequestManager {
private:
- class RequestMap : private std::map<uint16_t,RequestHandler*> {
- private:
- // Prevent shallow copy
- RequestMap(const RequestMap &o);
- RequestMap& operator=(const RequestMap &o);
-
- public:
- RequestMap() {}
- ~RequestMap();
-
- bool addRequest(uint16_t id, RequestHandler *info);
- RequestHandler* findRequest(uint16_t id);
- bool deleteRequest(uint16_t id);
- };
-
class XmlRequestMap : private std::map<uint16_t,XmlRequestHandler*> {
private:
// Prevent shallow copy
@@ -65,22 +48,6 @@ class RequestManager {
bool deleteRequest(uint16_t id);
};
- class RequestHandlerFactory {
- protected:
- RequestHandlerFactory() {}
-
- public:
- virtual RequestHandler* createRequestHandler() = 0;
- virtual ~RequestHandlerFactory() {}
- };
-
- template<class T> class SpecificRequestHandlerFactory : public RequestHandlerFactory {
- public:
- virtual RequestHandler* createRequestHandler() {
- return new T();
- }
- };
-
class XmlRequestHandlerFactory {
protected:
XmlRequestHandlerFactory() {}
@@ -99,12 +66,10 @@ class RequestManager {
static RequestManager requestManager;
- std::map<Net::Connection*,RequestMap*> requestMaps;
std::map<Net::Connection*,XmlRequestMap*> xmlRequestMaps;
bool core;
uint16_t requestId;
- std::map<Net::Packet::Type,RequestHandlerFactory*> requestHandlerFactories;
std::map<std::string,XmlRequestHandlerFactory*> xmlRequestHandlerFactories;
uint16_t getRequestId() {
@@ -137,19 +102,12 @@ class RequestManager {
void registerConnection(Net::Connection *connection);
void unregisterConnection(Net::Connection *connection);
- template <class T> void registerPacketType(Net::Packet::Type type) {
- requestHandlerFactories.insert(std::make_pair(type, new SpecificRequestHandlerFactory<T>()));
- }
-
- void unregisterPacketType(Net::Packet::Type type);
-
template <class T> void registerPacketType(const std::string &type) {
xmlRequestHandlerFactories.insert(std::make_pair(type, new SpecificXmlRequestHandlerFactory<T>()));
}
void unregisterPacketType(const std::string &type);
- bool sendRequest(Net::Connection *connection, std::auto_ptr<RequestBase> request);
bool sendRequest(Net::Connection *connection, std::auto_ptr<XmlRequest> request);
virtual ~RequestManager();
diff --git a/src/Common/XmlPacket.cpp b/src/Common/XmlPacket.cpp
index 87045a8..73dd87d 100644
--- a/src/Common/XmlPacket.cpp
+++ b/src/Common/XmlPacket.cpp
@@ -294,7 +294,7 @@ Net::Packet XmlPacket::encode(uint16_t requestId) const {
xmlDocDumpMemory(doc, &buf, &length);
- Net::Packet packet(Net::Packet::XML, requestId, buf, length);
+ Net::Packet packet(requestId, buf, length);
xmlFree(buf);
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index 7f8d9a9..9b6b87b 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -124,7 +124,7 @@ void Connection::packetHeaderReceiveHandler(const void *data, unsigned long leng
header = *(const Packet::Data*)data;
if(header.length == 0) {
- signal(this, Packet((Packet::Type)ntohs(header.type), ntohs(header.requestId)));
+ signal(this, Packet(ntohs(header.requestId)));
enterReceiveLoop();
}
@@ -144,7 +144,7 @@ void Connection::packetDataReceiveHandler(const void *data, unsigned long length
return;
}
- signal(this, Packet((Packet::Type)ntohs(header.type), ntohs(header.requestId), data, length));
+ signal(this, Packet(ntohs(header.requestId), data, length));
enterReceiveLoop();
}
diff --git a/src/Net/Packet.cpp b/src/Net/Packet.cpp
index 976fd65..a4e1b89 100644
--- a/src/Net/Packet.cpp
+++ b/src/Net/Packet.cpp
@@ -22,12 +22,10 @@
namespace Mad {
namespace Net {
-Packet::Packet(Type type, uint16_t requestId, const void *data, uint16_t length) {
+Packet::Packet(uint16_t requestId, const void *data, uint16_t length) {
rawData = (Data*)std::malloc(sizeof(Data)+length);
- rawData->type = htons(type);
rawData->requestId = htons(requestId);
- rawData->reserved = 0;
rawData->length = htons(length);
if(length)
@@ -46,29 +44,5 @@ 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 34f3428..48804de 100644
--- a/src/Net/Packet.h
+++ b/src/Net/Packet.h
@@ -30,16 +30,8 @@ namespace Net {
class Packet {
public:
- enum Type {
- OK = 0x0000, ERROR = 0x0001,
- GSSAPI_AUTH = 0x0010,
- XML = 0xFFFF
- };
-
struct Data {
- uint16_t type;
uint16_t requestId;
- uint16_t reserved;
uint16_t length;
uint8_t data[0];
};
@@ -47,14 +39,8 @@ class Packet {
protected:
Data *rawData;
- void setLength(uint16_t length) {
- rawData->length = htons(length);
-
- rawData = (Data*)std::realloc(rawData, getRawDataLength());
- }
-
public:
- Packet(Type type, uint16_t requestId, const void *data = 0, uint16_t length = 0);
+ Packet(uint16_t requestId, const void *data = 0, uint16_t length = 0);
Packet(const Packet &p) {
rawData = (Data*)std::malloc(p.getRawDataLength());
@@ -67,10 +53,6 @@ class Packet {
Packet& operator=(const Packet &p);
- Type getType() const {
- return (Type)ntohs(rawData->type);
- }
-
uint16_t getRequestId() const {
return ntohs(rawData->requestId);
}
@@ -90,10 +72,6 @@ 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/mad.cpp b/src/mad.cpp
index 4a9904a..bc218f6 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -24,7 +24,6 @@
#include "Common/LogManager.h"
#include "Common/Logger.h"
#include "Common/ModuleManager.h"
-#include "Common/Request.h"
#include "Common/RequestManager.h"
#include "Common/RequestHandlers/FSInfoRequestHandler.h"
#include "Common/RequestHandlers/StatusRequestHandler.h"