diff options
Diffstat (limited to 'src/packet.h')
-rw-r--r-- | src/packet.h | 14 |
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) { |