summaryrefslogtreecommitdiffstats
path: root/src/Net
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/Net
parentd88e4d0da7ff801b0c58b5043ade0743547cfb90 (diff)
downloadmad-c316a3115bf790fb623f0765dd6b04f781af5b51.tar
mad-c316a3115bf790fb623f0765dd6b04f781af5b51.zip
Alte Request-Klassen entfernt
Diffstat (limited to 'src/Net')
-rw-r--r--src/Net/Connection.cpp4
-rw-r--r--src/Net/Packet.cpp28
-rw-r--r--src/Net/Packet.h24
3 files changed, 4 insertions, 52 deletions
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);
};
}