From e138a2ac1e0e0be8421b21d1c461cbfb0733731e Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Thu, 12 Feb 2015 21:15:27 +0100 Subject: [PATCH] decode: introduce PacketCallocExtPkt function In flow timeout handling we need a function that allocate and blank a place that will be used to put constructed packet data. This new function has no other goal. --- src/decode.c | 12 ++++++++++++ src/decode.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/decode.c b/src/decode.c index 87aa831b24..c2c31cf14a 100644 --- a/src/decode.c +++ b/src/decode.c @@ -171,6 +171,18 @@ Packet *PacketGetFromQueueOrAlloc(void) return p; } +inline int PacketCallocExtPkt(Packet *p, int datalen) +{ + if (! p->ext_pkt) { + p->ext_pkt = SCCalloc(1, datalen); + if (unlikely(p->ext_pkt == NULL)) { + SET_PKT_LEN(p, 0); + return -1; + } + } + return 0; +} + /** * \brief Copy data to Packet payload at given offset * diff --git a/src/decode.h b/src/decode.h index 921aac3652..2af5494e29 100644 --- a/src/decode.h +++ b/src/decode.h @@ -835,6 +835,7 @@ Packet *PacketGetFromAlloc(void); void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p); void PacketFree(Packet *p); void PacketFreeOrRelease(Packet *p); +int PacketCallocExtPkt(Packet *p, int datalen); int PacketCopyData(Packet *p, uint8_t *pktdata, int pktlen); int PacketSetData(Packet *p, uint8_t *pktdata, int pktlen); int PacketCopyDataOffset(Packet *p, int offset, uint8_t *data, int datalen);