From c0c59fbd177d81845833342617ab2a5d8e4bbab4 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Mon, 24 Jun 2013 09:52:31 +0200 Subject: [PATCH] decode: factorize macro code PACKET_* are now wrapper to the newly introduced PACKET_SET_ACTION macro. --- src/decode.h | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/src/decode.h b/src/decode.h index b3f493bd8b..c747eb2914 100644 --- a/src/decode.h +++ b/src/decode.h @@ -706,47 +706,26 @@ typedef struct DecodeThreadVars_ /* macro's for setting the action * handle the case of a root packet * for tunnels */ -#define PACKET_ALERT(p) do { \ - ((p)->root ? \ - ((p)->root->action = ACTION_ALERT) : \ - ((p)->action = ACTION_ALERT)); \ -} while (0) -#define PACKET_ACCEPT(p) do { \ +#define PACKET_SET_ACTION(p, a) do { \ ((p)->root ? \ - ((p)->root->action = ACTION_ACCEPT) : \ - ((p)->action = ACTION_ACCEPT)); \ + ((p)->root->action = a) : \ + ((p)->action = a)); \ } while (0) -#define PACKET_DROP(p) do { \ - ((p)->root ? \ - ((p)->root->action = ACTION_DROP) : \ - ((p)->action = ACTION_DROP)); \ -} while (0) +#define PACKET_ALERT(p) PACKET_SET_ACTION(p, ACTION_ALERT) -#define PACKET_REJECT(p) do { \ - ((p)->root ? \ - ((p)->root->action = (ACTION_REJECT|ACTION_DROP)) : \ - ((p)->action = (ACTION_REJECT|ACTION_DROP))); \ -} while (0) +#define PACKET_ACCEPT(p) PACKET_SET_ACTION(p, ACTION_ACCEPT) -#define PACKET_REJECT_DST(p) do { \ - ((p)->root ? \ - ((p)->root->action = (ACTION_REJECT_DST|ACTION_DROP)) : \ - ((p)->action = (ACTION_REJECT_DST|ACTION_DROP))); \ -} while (0) +#define PACKET_DROP(p) PACKET_SET_ACTION(p, ACTION_DROP) -#define PACKET_REJECT_BOTH(p) do { \ - ((p)->root ? \ - ((p)->root->action = (ACTION_REJECT_BOTH|ACTION_DROP)) : \ - ((p)->action = (ACTION_REJECT_BOTH|ACTION_DROP))); \ -} while (0) +#define PACKET_REJECT(p) PACKET_SET_ACTION(p, (ACTION_REJECT|ACTION_DROP)) -#define PACKET_PASS(p) do { \ - ((p)->root ? \ - ((p)->root->action = ACTION_PASS) : \ - ((p)->action = ACTION_PASS)); \ -} while (0) +#define PACKET_REJECT_DST(p) PACKET_SET_ACTION(p, (ACTION_REJECT_DST|ACTION_DROP)) + +#define PACKET_REJECT_BOTH(p) PACKET_SET_ACTION(p, (ACTION_REJECT_BOTH|ACTION_DROP)) + +#define PACKET_PASS(p) PACKET_SET_ACTION(p, ACTION_PASS) #define PACKET_TEST_ACTION(p, a) \ ((p)->root ? \