From e099bddc24fad6c628e29284a585bd50404768b6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 21 Mar 2013 02:01:41 +0100 Subject: Add alloca_packet() macro --- src/packet.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/packet.h') diff --git a/src/packet.h b/src/packet.h index 286192e..07c0f3b 100644 --- a/src/packet.h +++ b/src/packet.h @@ -29,6 +29,8 @@ #include "types.h" +#include + #include @@ -41,6 +43,13 @@ struct __attribute__((packed)) gp_babel_packet { uint8_t tlv[]; }; +#define alloca_packet(size) ({ \ + gp_babel_packet_t *__packet = alloca(sizeof(gp_babel_packet_t)+size); \ + __packet->version = htons(GP_BABEL_VERSION); \ + __packet->len = 0; \ + __packet; \ + }) + static inline size_t gp_babel_packet_size(const gp_babel_packet_t *packet) { return sizeof(gp_babel_packet_t)+ntohs(packet->len); } -- cgit v1.2.3