summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-07-17 05:14:31 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-07-17 05:14:31 +0200
commit9f96fb364bea47ec76dea57fc14e03e0e42fa5e3 (patch)
tree32801f7f7c25be3f427b20ae78e40d17b060d84e
parent2ec96d979cb67399ca2c0d59f772cedf98fe8276 (diff)
downloadmad-9f96fb364bea47ec76dea57fc14e03e0e42fa5e3.tar
mad-9f96fb364bea47ec76dea57fc14e03e0e42fa5e3.zip
Nur 2 Bytes f?r das Gr??enfeld in Paketen verwenden, um Angriffe zu verhindern
-rw-r--r--Konzept/Netzwerk.txt10
-rw-r--r--src/Net/Makefile.am2
-rw-r--r--src/Net/Makefile.in5
-rw-r--r--src/Net/Packet.cpp28
-rw-r--r--src/Net/Packet.h8
5 files changed, 13 insertions, 40 deletions
diff --git a/Konzept/Netzwerk.txt b/Konzept/Netzwerk.txt
index 52434dc..39ea274 100644
--- a/Konzept/Netzwerk.txt
+++ b/Konzept/Netzwerk.txt
@@ -23,11 +23,11 @@ Server -> Client/Dämon
Datenpakete:
-+-------------------+----------+-------------------+-----
-| 1 - 2 | 3 - 4 | 5 - 8 | 9 - ...
-+-------------------+----------+-------------------+-----
-|Typ des Datenpakets|Request-ID|Größe der Nutzdaten|Nutzdaten
-+-------------------+----------+-------------------+-----
++-------------------+----------+-------+-------------------+-----
+| 1 - 2 | 3 - 4 | 5 - 6 | 7 - 8 | 9 - ...
++-------------------+----------+-------+-------------------+-----
+|Typ des Datenpakets|Request-ID| 0 |Größe der Nutzdaten|Nutzdaten
++-------------------+----------+-------+-------------------+-----
Jeder Client/Dämon und der Kern verwalten ihre eigenen Request-IDs, und insgesamt wird ein Request durch Quelle und ID identifiziert.
Damit es nicht zu Konflikten zwischen vom Kern und von Clients/Dämonen generierten IDs kommt, ist bei Client/Dämon-IDs das letzte Bit gesetzt, bei Kern-IDs nicht.
diff --git a/src/Net/Makefile.am b/src/Net/Makefile.am
index 8e49695..c7f58da 100644
--- a/src/Net/Makefile.am
+++ b/src/Net/Makefile.am
@@ -1,6 +1,6 @@
noinst_LTLIBRARIES = libnet.la
-libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp Packet.cpp
+libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp
noinst_HEADERS = ClientConnection.h ServerConnection.h Connection.h Exception.h ConnectionException.h \
InvalidAddressException.h IPAddress.h Listener.h Packet.h
diff --git a/src/Net/Makefile.in b/src/Net/Makefile.in
index e99597e..9ce9a8e 100644
--- a/src/Net/Makefile.in
+++ b/src/Net/Makefile.in
@@ -46,7 +46,7 @@ CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libnet_la_LIBADD =
am_libnet_la_OBJECTS = ClientConnection.lo ServerConnection.lo \
- Connection.lo Listener.lo Packet.lo
+ Connection.lo Listener.lo
libnet_la_OBJECTS = $(am_libnet_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -181,7 +181,7 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = libnet.la
-libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp Packet.cpp
+libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp
noinst_HEADERS = ClientConnection.h ServerConnection.h Connection.h Exception.h ConnectionException.h \
InvalidAddressException.h IPAddress.h Listener.h Packet.h
@@ -239,7 +239,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClientConnection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Connection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Listener.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Packet.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerConnection.Plo@am__quote@
.cpp.o:
diff --git a/src/Net/Packet.cpp b/src/Net/Packet.cpp
deleted file mode 100644
index 9c90db7..0000000
--- a/src/Net/Packet.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Packet.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 "Packet.h"
-
-namespace Mad {
-namespace Net {
-
-
-
-}
-}
diff --git a/src/Net/Packet.h b/src/Net/Packet.h
index 7ef5cb0..c867ffa 100644
--- a/src/Net/Packet.h
+++ b/src/Net/Packet.h
@@ -36,7 +36,8 @@ class Packet {
struct Data {
unsigned short type;
unsigned short requestId;
- unsigned long length;
+ unsigned short reserved;
+ unsigned short length;
unsigned char data[0];
};
@@ -44,11 +45,12 @@ class Packet {
Data *rawData;
public:
- Packet(Type type, unsigned short requestId, const void *data = NULL, unsigned long length = 0) {
+ Packet(Type type, unsigned short requestId, const void *data = NULL, unsigned short length = 0) {
rawData = (Data*)std::malloc(sizeof(Data)+length);
rawData->type = type;
rawData->requestId = requestId;
+ rawData->reserved = 0;
rawData->length = length;
if(length)
@@ -84,7 +86,7 @@ class Packet {
return rawData->requestId;
}
- unsigned long getLength() const {
+ unsigned short getLength() const {
return rawData->length;
}