Repository : ssh://git@open-mesh.org/alfred
On branch : master
commit 31c2c5751d41b2a58d418d4c178bc965abd5d195 Author: Sven Eckelmann sven@narfation.org Date: Sun May 31 13:35:55 2015 +0200
alfred: Reduce MAX_PAYLOAD by the size of the UDP header
The len field in the UDP header is 16 bit long. It can therefore store a value of up to (2 ** 16 - 1). This value is currently used for MAX_PAYLOAD. But the UDP len field not only stores the payload length but also the udp header itself. Thus the length of MAX_PAYLOAD has to be reduced by the size of udphdr to make sure that the payload can still be sent.
Reported-by: Hans-Werner Hilse hwhilse@gmail.com Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
31c2c5751d41b2a58d418d4c178bc965abd5d195 alfred.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/alfred.h b/alfred.h index 8fc8ab1..7c308e5 100644 --- a/alfred.h +++ b/alfred.h @@ -25,6 +25,7 @@
#include <net/ethernet.h> #include <netinet/in.h> +#include <netinet/udp.h> #include <stdint.h> #include <time.h> #include <sys/select.h> @@ -137,7 +138,7 @@ struct globals { #define debugMalloc(size, num) malloc(size) #define debugFree(ptr, num) free(ptr)
-#define MAX_PAYLOAD ((1 << 16) - 1) +#define MAX_PAYLOAD ((1 << 16) - 1 - sizeof(struct udphdr))
extern const struct in6_addr in6addr_localmcast;