summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filter/ulogd_filter_PWSNIFF.c2
-rw-r--r--include/ulogd/plugin.h19
-rw-r--r--input/packet/ulogd_inppkt_ULOG.c10
-rw-r--r--output/pcap/ulogd_output_PCAP.c4
-rw-r--r--output/ulogd_output_ASTARO.c2
-rw-r--r--output/ulogd_output_IPFIX.c4
-rw-r--r--output/ulogd_output_LOGEMU.c4
-rw-r--r--output/ulogd_output_SYSLOG.c2
-rw-r--r--src/db.c2
-rw-r--r--src/plugin.c66
-rw-r--r--util/printflow.c4
-rw-r--r--util/printpkt.c5
12 files changed, 59 insertions, 65 deletions
diff --git a/filter/ulogd_filter_PWSNIFF.c b/filter/ulogd_filter_PWSNIFF.c
index 4812dbc..30a7a0f 100644
--- a/filter/ulogd_filter_PWSNIFF.c
+++ b/filter/ulogd_filter_PWSNIFF.c
@@ -127,7 +127,7 @@ static int interp_pwsniff(struct ulogd_pluginstance *pi, unsigned *flags)
return 0;
}
strncpy((char *)key_ptr(&ret[1]), (char *)pw_begp, pw_len);
- *(ret[1].u.val.str + pw_len + 1) = '\0';
+ *(ret[1].val.str + pw_len + 1) = '\0';
}
return 0;
diff --git a/include/ulogd/plugin.h b/include/ulogd/plugin.h
index f9f91e0..f35e353 100644
--- a/include/ulogd/plugin.h
+++ b/include/ulogd/plugin.h
@@ -90,13 +90,12 @@ struct db_column;
/* structure describing an input / output parameter of a plugin */
struct ulogd_key {
- union {
- struct ulogd_value val;
- struct ulogd_key *source;
- } u;
+ struct ulogd_key *source;
uint16_t flags;
+ struct ulogd_value val;
+
/*
* Map to database column
*/
@@ -127,13 +126,13 @@ struct ulogd_keyset {
/* key initializers */
#define KEY(t, n) \
{ \
- .u.val.type = ULOGD_RET_ ## t, \
+ .val.type = ULOGD_RET_ ## t, \
.name = (n), \
}
#define KEY_FLAGS(t, n, fl) \
{ \
.flags = (fl), \
- .u.val.type = ULOGD_RET_ ## t, \
+ .val.type = ULOGD_RET_ ## t, \
.name = (n), \
}
#define IPFIX(v, f) \
@@ -143,14 +142,14 @@ struct ulogd_keyset {
}
#define KEY_IPFIX(t, n, v, f) \
{ \
- .u.val.type = ULOGD_RET_ ## t, \
+ .val.type = ULOGD_RET_ ## t, \
.name = (n), \
.ipfix = IPFIX(v, f), \
}
#define KEY_IPFIX_FLAGS(t, n, v, f, fl) \
{ \
.flags = (fl), \
- .u.val.type = ULOGD_RET_ ## t, \
+ .val.type = ULOGD_RET_ ## t, \
.name = (n), \
.ipfix = IPFIX(v, f), \
}
@@ -205,13 +204,13 @@ void key_reset(struct ulogd_key *key);
static inline struct ulogd_key *
key_src(const struct ulogd_key *key)
{
- return key->u.source;
+ return key->source;
}
static inline void
key_set_src(struct ulogd_key *key, struct ulogd_key *src_key)
{
- key->u.source = src_key;
+ key->source = src_key;
}
static inline bool
diff --git a/input/packet/ulogd_inppkt_ULOG.c b/input/packet/ulogd_inppkt_ULOG.c
index 93a66ca..8f91d74 100644
--- a/input/packet/ulogd_inppkt_ULOG.c
+++ b/input/packet/ulogd_inppkt_ULOG.c
@@ -61,7 +61,7 @@ static const struct config_keyset libulog_kset = {
static struct ulogd_key output_keys[] = {
KEY_FLAGS(STRING, "raw.mac", ULOGD_RETF_FREE),
{
- .u.val.type = ULOGD_RET_RAW,
+ .val.type = ULOGD_RET_RAW,
.flags = ULOGD_RETF_FREE,
.name = "raw.pkt",
.ipfix = {
@@ -70,7 +70,7 @@ static struct ulogd_key output_keys[] = {
},
},
{
- .u.val.type = ULOGD_RET_UINT32,
+ .val.type = ULOGD_RET_UINT32,
.flags = ULOGD_RETF_NONE,
.name = "raw.pktlen",
.ipfix = {
@@ -79,7 +79,7 @@ static struct ulogd_key output_keys[] = {
},
},
{
- .u.val.type = ULOGD_RET_UINT32,
+ .val.type = ULOGD_RET_UINT32,
.flags = ULOGD_RETF_NONE,
.name = "raw.pktcount",
.ipfix = {
@@ -88,11 +88,11 @@ static struct ulogd_key output_keys[] = {
},
},
{
- .u.val.type = ULOGD_RET_STRING,
+ .val.type = ULOGD_RET_STRING,
.flags = ULOGD_RETF_NONE,
.name = "oob.prefix",
},
- { .u.val.type = ULOGD_RET_UINT32,
+ { .val.type = ULOGD_RET_UINT32,
.flags = ULOGD_RETF_NONE,
.name = "oob.time.sec",
.ipfix = {
diff --git a/output/pcap/ulogd_output_PCAP.c b/output/pcap/ulogd_output_PCAP.c
index a4b5f77..133c541 100644
--- a/output/pcap/ulogd_output_PCAP.c
+++ b/output/pcap/ulogd_output_PCAP.c
@@ -121,8 +121,8 @@ static struct ulogd_key pcap_keys[INTR_IDS] = {
{ .name = "oob.time.usec" },
};
-#define GET_VALUE(res, x) (res[x].u.source->u.val)
-#define GET_FLAGS(res, x) (res[x].u.source->flags)
+#define GET_VALUE(res, x) (res[x].source->val)
+#define GET_FLAGS(res, x) (res[x].source->flags)
static int interp_pcap(struct ulogd_pluginstance *upi, unsigned *flags)
{
diff --git a/output/ulogd_output_ASTARO.c b/output/ulogd_output_ASTARO.c
index 08e7789..d4dea45 100644
--- a/output/ulogd_output_ASTARO.c
+++ b/output/ulogd_output_ASTARO.c
@@ -319,7 +319,7 @@ print_key(char *buf, size_t len, const struct ulogd_key *key,
strcpy(pch, name), pch += strlen(name);
strcpy(pch, "=\""), pch += sizeof("=\"") - 1;
- pch += ulogd_value_to_ascii(&key_src(key)->u.val, pch, end - pch);
+ pch += ulogd_value_to_ascii(&key_src(key)->val, pch, end - pch);
strcpy(pch, "\" "), pch += sizeof("\" ") - 1;
return pch - buf;
diff --git a/output/ulogd_output_IPFIX.c b/output/ulogd_output_IPFIX.c
index adcb426..3e15cc1 100644
--- a/output/ulogd_output_IPFIX.c
+++ b/output/ulogd_output_IPFIX.c
@@ -237,7 +237,7 @@ build_template_for_bitmask(struct ulogd_pluginstance *upi,
struct ulogd_key *key = &upi->input.keys[i];
int length = ulogd_key_size(key);
- if (!(key->u.source->flags & ULOGD_RETF_VALID))
+ if (!(key->source->flags & ULOGD_RETF_VALID))
continue;
if (length < 0 || length > 0xfffe) {
@@ -310,7 +310,7 @@ static int output_ipfix(struct ulogd_pluginstance *upi, unsigned *flags)
bitmask_clear(ii->valid_bitmask);
for (i = 0; i < upi->input.num_keys; i++) {
- struct ulogd_key *key = upi->input.keys[i].u.source;
+ struct ulogd_key *key = upi->input.keys[i].source;
if (key->flags & ULOGD_RETF_VALID)
bitmask_set_bit(ii->valid_bitmask, i);
diff --git a/output/ulogd_output_LOGEMU.c b/output/ulogd_output_LOGEMU.c
index f82b10d..efcb5d3 100644
--- a/output/ulogd_output_LOGEMU.c
+++ b/output/ulogd_output_LOGEMU.c
@@ -78,12 +78,12 @@ static int _output_logemu(struct ulogd_pluginstance *upi, unsigned *flags)
struct logemu_instance *li = upi_priv(upi);
struct ulogd_key *res = upi->input.keys;
- if (res[0].u.source->flags & ULOGD_RETF_VALID) {
+ if (res[0].source->flags & ULOGD_RETF_VALID) {
char *timestr;
char *tmp;
time_t now;
- if (res[1].u.source && (res[1].u.source->flags & ULOGD_RETF_VALID))
+ if (res[1].source && (res[1].source->flags & ULOGD_RETF_VALID))
now = (time_t) key_src_u32(&res[1]);
else
now = time(NULL);
diff --git a/output/ulogd_output_SYSLOG.c b/output/ulogd_output_SYSLOG.c
index eed5b2f..591391b 100644
--- a/output/ulogd_output_SYSLOG.c
+++ b/output/ulogd_output_SYSLOG.c
@@ -51,7 +51,7 @@ static int syslog_interp(struct ulogd_pluginstance *upi, unsigned *flags)
struct syslog_instance *li = upi_priv(upi);
struct ulogd_key *res = upi->input.keys;
- if (res[0].u.source->flags & ULOGD_RETF_VALID)
+ if (res[0].source->flags & ULOGD_RETF_VALID)
syslog(li->level | li->facility, "%s", key_str(&res[0]));
return 0;
diff --git a/src/db.c b/src/db.c
index 7ea2308..e1b2483 100644
--- a/src/db.c
+++ b/src/db.c
@@ -700,7 +700,7 @@ ulogd_db_interp(struct ulogd_pluginstance *pi, unsigned *flags)
if (!key)
memset(&row->value[i], 0, sizeof(struct ulogd_value));
else
- memcpy(&row->value[i], &key->u.val, sizeof(struct ulogd_value));
+ memcpy(&row->value[i], &key->val, sizeof(struct ulogd_value));
}
/* reset key pointers */
diff --git a/src/plugin.c b/src/plugin.c
index 8f7d788..c546bc0 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -153,13 +153,7 @@ stack_resolve_keys(const struct ulogd_pluginstance_stack *stack)
if (ikey->flags & ULOGD_KEYF_INACTIVE)
continue;
- if (ikey->u.source) {
- ulogd_log(ULOGD_ERROR, "input key `%s' "
- "already has source\n",
- ikey->name);
-
- return -EINVAL;
- }
+ BUG_ON(ikey->source);
okey = find_okey_in_stack(ikey->name, pi_cur, &pi_src);
if (okey == NULL) {
@@ -179,7 +173,7 @@ stack_resolve_keys(const struct ulogd_pluginstance_stack *stack)
ulogd_log(ULOGD_DEBUG, " %s(%s) -> %s(%s)\n",
ikey->name, pi_cur->id, okey->name, pi_src->id);
- ikey->u.source = okey;
+ ikey->source = okey;
}
}
}
@@ -723,7 +717,7 @@ ulogd_upi_stop(struct ulogd_pluginstance *pi)
/* clear source links */
for (i = 0; i < pi->input.num_keys; i++)
- pi->input.keys[i].u.source = NULL;
+ pi->input.keys[i].source = NULL;
ulogd_upi_set_state(pi, PsInit);
@@ -897,7 +891,7 @@ key_set_i8(struct ulogd_key *key, int v)
{
__check_set(key, ULOGD_RET_INT8);
- key->u.val.i8 = v;
+ key->val.i8 = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -906,7 +900,7 @@ key_set_i16(struct ulogd_key *key, int v)
{
__check_set(key, ULOGD_RET_INT16);
- key->u.val.i16 = v;
+ key->val.i16 = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -915,7 +909,7 @@ key_set_i32(struct ulogd_key *key, int v)
{
__check_set(key, ULOGD_RET_INT32);
- key->u.val.i32 = v;
+ key->val.i32 = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -924,7 +918,7 @@ key_set_u8(struct ulogd_key *key, unsigned v)
{
__check_set(key, ULOGD_RET_UINT8);
- key->u.val.i8 = v;
+ key->val.i8 = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -933,7 +927,7 @@ key_set_u16(struct ulogd_key *key, unsigned v)
{
__check_set(key, ULOGD_RET_UINT16);
- key->u.val.ui16 = v;
+ key->val.ui16 = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -942,7 +936,7 @@ key_set_u32(struct ulogd_key *key, unsigned v)
{
__check_set(key, ULOGD_RET_UINT32 | ULOGD_RET_IPADDR);
- key->u.val.ui32 = v;
+ key->val.ui32 = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -951,7 +945,7 @@ key_set_i64(struct ulogd_key *key, int64_t v)
{
__check_set(key, ULOGD_RET_INT64);
- key->u.val.i64 = v;
+ key->val.i64 = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -960,7 +954,7 @@ key_set_u64(struct ulogd_key *key, uint64_t v)
{
__check_set(key, ULOGD_RET_UINT64);
- key->u.val.ui64 = v;
+ key->val.ui64 = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -969,7 +963,7 @@ key_set_bool(struct ulogd_key *key, bool v)
{
__check_set(key, ULOGD_RET_BOOL);
- key->u.val.b = v;
+ key->val.b = v;
key->flags |= ULOGD_RETF_VALID;
}
@@ -978,7 +972,7 @@ key_set_ptr(struct ulogd_key *key, void *ptr)
{
__check_set(key, ULOGD_RET_RAW);
- key->u.val.ptr = ptr;
+ key->val.ptr = ptr;
key->flags |= ULOGD_RETF_VALID;
}
@@ -987,7 +981,7 @@ key_set_str(struct ulogd_key *key, char *str)
{
__check_set(key, ULOGD_RET_STRING);
- key->u.val.str = str;
+ key->val.str = str;
key->flags |= ULOGD_RETF_VALID;
}
@@ -996,7 +990,7 @@ key_set_in6(struct ulogd_key *key, const struct in6_addr *addr)
{
__check_set(key, ULOGD_RET_IP6ADDR);
- memcpy(&key->u.val.in6, addr, sizeof(struct in6_addr));
+ memcpy(&key->val.in6, addr, sizeof(struct in6_addr));
key->flags |= ULOGD_RETF_VALID;
}
@@ -1018,7 +1012,7 @@ key_i8(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_INT8);
- return key->u.val.i8;
+ return key->val.i8;
}
int
@@ -1026,7 +1020,7 @@ key_i16(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_INT16);
- return key->u.val.i16;
+ return key->val.i16;
}
int
@@ -1034,7 +1028,7 @@ key_i32(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_INT32);
- return key->u.val.i32;
+ return key->val.i32;
}
unsigned
@@ -1042,7 +1036,7 @@ key_u8(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_UINT8);
- return key->u.val.i8;
+ return key->val.i8;
}
unsigned
@@ -1050,7 +1044,7 @@ key_u16(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_UINT16);
- return key->u.val.i16;
+ return key->val.i16;
}
unsigned
@@ -1060,7 +1054,7 @@ key_u32(const struct ulogd_key *key)
might require to add key_get_ipaddr() as well. */
__check_get(key, ULOGD_RET_UINT32 | ULOGD_RET_IPADDR);
- return key->u.val.i32;
+ return key->val.i32;
}
int64_t
@@ -1068,7 +1062,7 @@ key_i64(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_INT64);
- return key->u.val.i64;
+ return key->val.i64;
}
uint64_t
@@ -1076,7 +1070,7 @@ key_u64(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_UINT64);
- return key->u.val.i64;
+ return key->val.i64;
}
bool
@@ -1084,7 +1078,7 @@ key_bool(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_BOOL);
- return !!key->u.val.b;
+ return !!key->val.b;
}
void *
@@ -1092,7 +1086,7 @@ key_ptr(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_RAW);
- return key->u.val.ptr;
+ return key->val.ptr;
}
char *
@@ -1100,7 +1094,7 @@ key_str(const struct ulogd_key *key)
{
__check_get(key, ULOGD_RET_STRING);
- return key->u.val.str;
+ return key->val.str;
}
void
@@ -1108,7 +1102,7 @@ key_in6(const struct ulogd_key *key, struct in6_addr *addr)
{
__check_get(key, ULOGD_RET_IP6ADDR);
- memcpy(addr, &key->u.val.in6, sizeof(*addr));
+ memcpy(addr, &key->val.in6, sizeof(*addr));
}
int key_src_i8(const struct ulogd_key *key)
@@ -1185,15 +1179,15 @@ key_src_in6(const struct ulogd_key *key, struct in6_addr *addr)
enum ulogd_ktype
key_type(const struct ulogd_key *key)
{
- return key->u.val.type;
+ return key->val.type;
}
void
key_free(struct ulogd_key *key)
{
if (key->flags & ULOGD_RETF_FREE) {
- free(key->u.val.ptr);
- key->u.val.ptr = NULL;
+ free(key->val.ptr);
+ key->val.ptr = NULL;
}
}
diff --git a/util/printflow.c b/util/printflow.c
index 85a6570..8e10817 100644
--- a/util/printflow.c
+++ b/util/printflow.c
@@ -43,8 +43,8 @@ struct ulogd_key printflow_keys[] = {
};
int printflow_keys_num = sizeof(printflow_keys)/sizeof(*printflow_keys);
-#define GET_VALUE(res, x) (res[x].u.source->u.val)
-#define GET_FLAGS(res, x) (res[x].u.source->flags)
+#define GET_VALUE(res, x) (res[x].source->val)
+#define GET_FLAGS(res, x) (res[x].source->flags)
#define pp_is_valid(res, x) (GET_FLAGS(res, x) & ULOGD_RETF_VALID)
#define pp_print(buf_cur, label, res, x, type) \
diff --git a/util/printpkt.c b/util/printpkt.c
index ac373a4..487fce9 100644
--- a/util/printpkt.c
+++ b/util/printpkt.c
@@ -1,3 +1,4 @@
+
/* printpkt.c
*
* build something looking like a iptables LOG message
@@ -73,8 +74,8 @@ struct ulogd_key printpkt_keys[INTR_IDS] = {
{ .name = "ahesp.spi", },
};
-#define GET_VALUE(res, x) (res[x].u.source->u.val)
-#define GET_FLAGS(res, x) (res[x].u.source->flags)
+#define GET_VALUE(res, x) (res[x].source->val)
+#define GET_FLAGS(res, x) (res[x].source->flags)
#define pp_is_valid(res, x) (GET_FLAGS(res, x) & ULOGD_RETF_VALID)
int printpkt_print(struct ulogd_key *res, char *buf)