summaryrefslogtreecommitdiffstats
path: root/src/packet.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-03-21 20:34:51 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-03-21 20:34:51 +0100
commit8fe8ed1942b6d7ff029a5a02e3352009d31f2ee2 (patch)
treeb22a74225d4fee21d25b4709626ff54865cbe322 /src/packet.h
parentca758c85d216baa6c88b50a3170958d86deb05e0 (diff)
downloadbabel-8fe8ed1942b6d7ff029a5a02e3352009d31f2ee2.tar
babel-8fe8ed1942b6d7ff029a5a02e3352009d31f2ee2.zip
Save maximum length in packet buffers
Diffstat (limited to 'src/packet.h')
-rw-r--r--src/packet.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/packet.h b/src/packet.h
index df22dd6..09b6dc0 100644
--- a/src/packet.h
+++ b/src/packet.h
@@ -43,11 +43,17 @@ struct __attribute__((packed)) gp_babel_packet {
uint8_t tlv[];
};
+struct gp_babel_packet_buf {
+ size_t max_len;
+ gp_babel_packet_t packet;
+};
+
#define gp_babel_packet_alloca(size) ({ \
- gp_babel_packet_t *__packet = alloca(sizeof(gp_babel_packet_t)+size); \
- __packet->version = htons(GP_BABEL_VERSION); \
- __packet->len = 0; \
- __packet; \
+ gp_babel_packet_buf_t *__buf = alloca(sizeof(gp_babel_packet_buf_t) + size - sizeof(gp_babel_packet_t)); \
+ __buf->max_len = size - sizeof(gp_babel_packet_t); \
+ __buf->packet.version = htons(GP_BABEL_VERSION); \
+ __buf->packet.len = 0; \
+ __buf; \
})
static inline size_t gp_babel_packet_size(const gp_babel_packet_t *packet) {