From 3d22713b09f850b7be97dc0f24aa325b297819e7 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 21 May 2011 10:06:18 +0200 Subject: [PATCH] Convert Packet tunnel variables to bit flag checks. --- src/decode.h | 18 ++++++++++-------- src/tmqh-packetpool.c | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/decode.h b/src/decode.h index dcba6f691e..482dcf4869 100644 --- a/src/decode.h +++ b/src/decode.h @@ -388,9 +388,6 @@ typedef struct Packet_ SCMutex mutex_rtv_cnt; /* tunnel stuff */ uint8_t tunnel_proto; - /* tunnel XXX convert to bitfield*/ - char tunnel_pkt; - char tunnel_verdicted; /* decoder events */ PacketDecoderEvents events; @@ -586,8 +583,6 @@ typedef struct DecodeThreadVars_ SCMutexDestroy(&(p)->mutex_rtv_cnt); \ SCMutexInit(&(p)->mutex_rtv_cnt, NULL); \ (p)->tunnel_proto = 0; \ - (p)->tunnel_pkt = 0; \ - (p)->tunnel_verdicted = 0; \ (p)->events.cnt = 0; \ (p)->next = NULL; \ (p)->prev = NULL; \ @@ -700,9 +695,13 @@ typedef struct DecodeThreadVars_ #define TUNNEL_PKT_RTV(p) ((p)->root ? (p)->root->rtv_cnt : (p)->rtv_cnt) #define TUNNEL_PKT_TPR(p) ((p)->root ? (p)->root->tpr_cnt : (p)->tpr_cnt) -#define IS_TUNNEL_ROOT_PKT(p) (((p)->root == NULL && (p)->tunnel_pkt == 1)) -#define IS_TUNNEL_PKT(p) (((p)->tunnel_pkt == 1)) -#define SET_TUNNEL_PKT(p) ((p)->tunnel_pkt = 1) +//#define IS_TUNNEL_ROOT_PKT(p) (((p)->root == NULL && (p)->tunnel_pkt == 1)) +#define IS_TUNNEL_PKT(p) (((p)->flags & PKT_TUNNEL)) +#define SET_TUNNEL_PKT(p) ((p)->flags |= PKT_TUNNEL) +#define IS_TUNNEL_ROOT_PKT(p) (IS_TUNNEL_PKT(p) && (p)->root == NULL) + +#define IS_TUNNEL_PKT_VERDICTED(p) (((p)->flags & PKT_TUNNEL_VERDICTED)) +#define SET_TUNNEL_PKT_VERDICTED(p) ((p)->flags |= PKT_TUNNEL_VERDICTED) void DecodeRegisterPerfCounters(DecodeThreadVars *, ThreadVars *); @@ -822,6 +821,9 @@ void AddressDebugPrint(Address *); #define PKT_MARK_MODIFIED 0x0400 /**< Packet mark is modified */ #define PKT_STREAM_NOPCAPLOG 0x0800 /**< Exclude packet from pcap logging as it's part of a stream that has reassembly depth reached. */ +#define PKT_TUNNEL 0x1000 +#define PKT_TUNNEL_VERDICTED 0x2000 + /** \brief return 1 if the packet is a pseudo packet */ #define PKT_IS_PSEUDOPKT(p) ((p)->flags & PKT_PSEUDO_STREAM_END) diff --git a/src/tmqh-packetpool.c b/src/tmqh-packetpool.c index a90356bc05..d9e169efae 100644 --- a/src/tmqh-packetpool.c +++ b/src/tmqh-packetpool.c @@ -157,7 +157,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p) * packets, don't add this. It's still referenced * by the tunnel packets, and we will enqueue it * when we handle them */ - p->tunnel_verdicted = 1; + SET_TUNNEL_PKT_VERDICTED(p); SCMutexUnlock(m); SCReturn; } @@ -169,7 +169,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p) * p->root == NULL. So when we are here p->root can only be * non-NULL, right? CLANG thinks differently. May be a FP, but * better safe than sorry. VJ */ - if (p->root != NULL && p->root->tunnel_verdicted == 1 && + if (p->root != NULL && IS_TUNNEL_PKT_VERDICTED(p->root) && TUNNEL_PKT_TPR(p) == 1) { SCLogDebug("p->root->tunnel_verdicted == 1 && TUNNEL_PKT_TPR(p) == 1");