From ea3922117076b01f10f19fdc10e6d9f2bfb54e0a Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Thu, 24 May 2007 10:57:18 +0000 Subject: fixed some compression stuff --- src/packet.h | 84 ++++++++++++++++++++++++++---------------------------------- 1 file changed, 37 insertions(+), 47 deletions(-) (limited to 'src/packet.h') diff --git a/src/packet.h b/src/packet.h index 62784044..ebc5e41e 100644 --- a/src/packet.h +++ b/src/packet.h @@ -18,7 +18,7 @@ protected: unsigned seq; }; - unsigned char packet_data[MAX_PACKET_SIZE-sizeof(header)]; + unsigned char packet_data[MAX_PACKET_SIZE]; unsigned char *current; // these are used to prepend data in the packet @@ -26,8 +26,6 @@ protected: // pack and unpack the same way enum { - DEBUG_TYPE_SHIFT=24, - DEBUG_SIZE_MASK=0xffff, DEBUG_TYPE_INT=0x1, DEBUG_TYPE_STR=0x2, DEBUG_TYPE_RAW=0x3, @@ -36,19 +34,29 @@ protected: // writes an int to the packet void write_int_raw(int i) { - // TODO: byteorder fix, should make sure that it writes big endian // TODO: check for overflow *(int*)current = i; current += sizeof(int); } // reads an int from the packet - void read_int_raw(int *i) + int read_int_raw() { - // TODO: byteorder fix, should make sure that it reads big endian // TODO: check for overflow - *i = *(int*)current; + int i = *(int*)current; current += sizeof(int); + return i; + } + + void debug_insert_mark(int type, int size) + { + write_int_raw((type<<16)|size); + } + + void debug_verify_mark(int type, int size) + { + if(read_int_raw() == ((type<<16) | size)) + dbg_assert(0, "error during packet disassembly"); } public: @@ -68,69 +76,52 @@ public: // writes an int to the packet void write_int(int i) { - write_int_raw((DEBUG_TYPE_INT<msg(), p->size(), seq); p->set_header(ack, seq); socket->send(&address(), p->data(), p->size()); counter_sent_bytes += p->size(); -- cgit 1.4.1