diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-03-21 02:01:41 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-03-21 02:01:41 +0100 |
commit | e099bddc24fad6c628e29284a585bd50404768b6 (patch) | |
tree | 350e9c44bb5680505d71d961a70f374e03c17023 /src/packet.h | |
parent | de428f0b8f3a959038d06d00fcf2fb4d2ce156d2 (diff) | |
download | babel-e099bddc24fad6c628e29284a585bd50404768b6.tar babel-e099bddc24fad6c628e29284a585bd50404768b6.zip |
Add alloca_packet() macro
Diffstat (limited to 'src/packet.h')
-rw-r--r-- | src/packet.h | 9 |
1 files changed, 9 insertions, 0 deletions
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 <alloca.h> + #include <arpa/inet.h> @@ -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); } |