summaryrefslogtreecommitdiffstats
path: root/src/Net/Packet.h
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-09-11 15:04:47 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-09-11 15:04:47 +0200
commitc18004e67869a9de88d9f8038a7a1957f20f63fc (patch)
tree67e1ae2e3886dfe4d8421fe0faf1e461dea14e04 /src/Net/Packet.h
parent36a3a590ffa4133f7f2d980a57d48ef95c680b71 (diff)
downloadmad-c18004e67869a9de88d9f8038a7a1957f20f63fc.tar
mad-c18004e67869a9de88d9f8038a7a1957f20f63fc.zip
Net: Add support for packets >64K
Need too secure this against DoS...
Diffstat (limited to 'src/Net/Packet.h')
-rw-r--r--src/Net/Packet.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Net/Packet.h b/src/Net/Packet.h
index 567c9c3..3844bad 100644
--- a/src/Net/Packet.h
+++ b/src/Net/Packet.h
@@ -38,15 +38,16 @@ namespace Net {
class MAD_NET_EXPORT Packet {
public:
struct Header {
+ boost::uint32_t length;
boost::uint16_t requestId;
- boost::uint16_t length;
+ boost::uint16_t reserved;
};
protected:
Header *rawData;
public:
- Packet(boost::uint16_t requestId, const void *data = 0, boost::uint16_t length = 0);
+ Packet(boost::uint16_t requestId, const void *data = 0, boost::uint32_t length = 0);
Packet(const Packet &p) {
rawData = reinterpret_cast<Header*>(std::malloc(p.getRawDataLength()));
@@ -63,8 +64,8 @@ class MAD_NET_EXPORT Packet {
return ntohs(rawData->requestId);
}
- boost::uint16_t getLength() const {
- return ntohs(rawData->length);
+ boost::uint32_t getLength() const {
+ return ntohl(rawData->length);
}
const boost::uint8_t* getData() const {
@@ -76,7 +77,7 @@ class MAD_NET_EXPORT Packet {
}
unsigned long getRawDataLength() const {
- return sizeof(Header) + ntohs(rawData->length);
+ return sizeof(Header) + getLength();
}
};