From e6459a06dbc4057ec1680c76075bc12c1774d385 Mon Sep 17 00:00:00 2001 From: laforge Date: Sun, 20 Nov 2005 13:20:57 +0000 Subject: use bitmask instead of enum for input/output data type --- configure.in | 3 +++ include/ulogd/ulogd.h | 20 ++++++++++---------- src/ulogd.c | 9 +++++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/configure.in b/configure.in index e3b73fd..f586426 100644 --- a/configure.in +++ b/configure.in @@ -28,6 +28,9 @@ dnl Checks for library functions. AC_FUNC_VPRINTF AC_CHECK_FUNCS(socket strerror) +AC_CHECK_HEADER([libnetfilter_log/linux_nfnetlink_log.h], [AC_MSG_RESULT([found])], + [AC_MSG_ERROR([libnetfilter_log Version 0.0.11 or later needed])]) + DATABASE_DIR="" DATABASE_LIB="" DATABASE_LIB_DIR="" diff --git a/include/ulogd/ulogd.h b/include/ulogd/ulogd.h index 16a2f7a..6ca6a6e 100644 --- a/include/ulogd/ulogd.h +++ b/include/ulogd/ulogd.h @@ -71,12 +71,12 @@ /* ulogd data type */ enum ulogd_dtype { - ULOGD_DTYPE_NULL, - ULOGD_DTYPE_SOURCE, /* source of data, no input keys */ - ULOGD_DTYPE_RAW, /* raw packet data */ - ULOGD_DTYPE_PACKET, /* packet metadata */ - ULOGD_DTYPE_FLOW, /* flow metadata */ - ULOGD_DTYPE_SINK, /* sink of data, no output keys */ + ULOGD_DTYPE_NULL = 0x0000, + ULOGD_DTYPE_SOURCE = 0x0001, /* source of data, no input keys */ + ULOGD_DTYPE_RAW, = 0x0002, /* raw packet data */ + ULOGD_DTYPE_PACKET = 0x0004, /* packet metadata */ + ULOGD_DTYPE_FLOW = 0x0008, /* flow metadata */ + ULOGD_DTYPE_SINK = 0x0010, /* sink of data, no output keys */ }; /* structure describing an input / output parameter of a plugin */ @@ -129,16 +129,16 @@ struct ulogd_plugin { struct ulogd_key *keys; /* number of input keys */ unsigned int num_keys; - /* type */ - enum ulogd_dtype type; + /* bitmask of possible types */ + unsigned int type; } input; struct { /* possible input keys of this interpreter */ struct ulogd_key *keys; /* number of keys this interpreter has */ unsigned int num_keys; - /* type */ - enum ulogd_dtype type; + /* bitmask of possible types */ + unsigned int type; } output; /* function to call for each packet */ diff --git a/src/ulogd.c b/src/ulogd.c index 4ae6470..614d965 100644 --- a/src/ulogd.c +++ b/src/ulogd.c @@ -415,7 +415,7 @@ create_stack_resolve_keys(struct ulogd_pluginstance_stack *stack) if (i == 1) { /* first round: output plugin */ - if (pi_cur->plugin->output.type != ULOGD_DTYPE_SINK) { + if (!(pi_cur->plugin->output.type & ULOGD_DTYPE_SINK)) { ulogd_log(ULOGD_ERROR, "last plugin in stack " "has to be output plugin\n"); return -EINVAL; @@ -425,7 +425,8 @@ create_stack_resolve_keys(struct ulogd_pluginstance_stack *stack) if (&pi_prev->list == &stack->list) { /* this is the last one in the stack */ - if (pi_cur->plugin->input.type != ULOGD_DTYPE_SOURCE) { + if (!(pi_cur->plugin->input.type + & ULOGD_DTYPE_SOURCE)) { ulogd_log(ULOGD_ERROR, "first plugin in stack " "has to be source plugin\n"); return -EINVAL; @@ -435,8 +436,8 @@ create_stack_resolve_keys(struct ulogd_pluginstance_stack *stack) int j; /* not the last one in the stack */ - if (pi_cur->plugin->input.type != - pi_prev->plugin->output.type) { + if (!(pi_cur->plugin->input.type & + pi_prev->plugin->output.type)) { ulogd_log(ULOGD_ERROR, "type mismatch between " "%s and %s in stack\n", pi_cur->plugin->name, -- cgit v1.2.3