[Oisf-devel] [PATCH] convert action_type to enum

Eric Leblond eleblond at edenwall.com
Wed Jan 13 20:28:21 UTC 2010


This patch converts packet action type to an enum. This will
provide some facilities and ease bad value detection by gcc.
---
 src/action-globals.h |   14 ++++++++------
 src/decode.h         |    2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/action-globals.h b/src/action-globals.h
index be52791..5b2a0a5 100644
--- a/src/action-globals.h
+++ b/src/action-globals.h
@@ -2,11 +2,13 @@
 #ifndef __ACTION_GLOBALS_H__
 #define __ACTION_GLOBALS_H__
 
-#define ACTION_ALERT           0
-#define ACTION_DROP            1
-#define ACTION_REJECT          2
-#define ACTION_REJECT_DST      3
-#define ACTION_REJECT_BOTH     4
-#define ACTION_PASS            5
+typedef enum {
+    ACTION_ALERT,
+    ACTION_DROP,
+    ACTION_REJECT,
+    ACTION_REJECT_DST,
+    ACTION_REJECT_BOTH,
+    ACTION_PASS
+} ActionType;
 
 #endif /* __ACTION_GLOBALS_H__ */
diff --git a/src/decode.h b/src/decode.h
index 26418ee..8dceffa 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -300,7 +300,7 @@ typedef struct Packet_
     PacketAlerts alerts;
 
     /* IPS action to take */
-    int action;
+    ActionType action;
 
     /* double linked list ptrs */
     struct Packet_ *next;
-- 
1.6.6




More information about the Oisf-devel mailing list