diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-11-23 23:59:44 +0100 |
---|---|---|
committer | Eric Leblond <eric@inl.fr> | 2008-12-09 01:19:25 +0100 |
commit | d4cf078cb71a943af0dcaa51ed5f950df0fdeca3 (patch) | |
tree | 7a732b2f7526343f76ab71092bd6b7dccc233497 /output/pcap | |
parent | 8aa47fcd3c013913b5e553053e0098b6765e5544 (diff) |
add ukey_* function for key assignation
This patch cleans up the current key assignation by introducing a
set of functions ukey_* to set the key value as Eric Leblond and
we discussed during the latest Netfilter Workshop. This patch is
based on an idea from Holger Eitzenberger.
Signed-off-by: Eric Leblond <eric@inl.fr>
Diffstat (limited to 'output/pcap')
-rw-r--r-- | output/pcap/ulogd_output_PCAP.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/output/pcap/ulogd_output_PCAP.c b/output/pcap/ulogd_output_PCAP.c index ce4393c..09120a1 100644 --- a/output/pcap/ulogd_output_PCAP.c +++ b/output/pcap/ulogd_output_PCAP.c @@ -126,7 +126,6 @@ static struct ulogd_key pcap_keys[INTR_IDS] = { { .name = "oob.time.usec" }, }; -#define GET_VALUE(res, x) (res[x].u.source->u.value) #define GET_FLAGS(res, x) (res[x].u.source->flags) static int interp_pcap(struct ulogd_pluginstance *upi) @@ -135,13 +134,13 @@ static int interp_pcap(struct ulogd_pluginstance *upi) struct ulogd_key *res = upi->input.keys; struct pcap_sf_pkthdr pchdr; - pchdr.caplen = GET_VALUE(res, 2).ui32; - pchdr.len = GET_VALUE(res, 2).ui32; + pchdr.caplen = ikey_get_u32(&res[2]); + pchdr.len = ikey_get_u32(&res[2]); if (GET_FLAGS(res, 3) & ULOGD_RETF_VALID && GET_FLAGS(res, 4) & ULOGD_RETF_VALID) { - pchdr.ts.tv_sec = GET_VALUE(res, 3).ui32; - pchdr.ts.tv_usec = GET_VALUE(res, 4).ui32; + pchdr.ts.tv_sec = ikey_get_u32(&res[3]); + pchdr.ts.tv_usec = ikey_get_u32(&res[4]); } else { /* use current system time */ struct timeval tv; @@ -156,7 +155,7 @@ static int interp_pcap(struct ulogd_pluginstance *upi) strerror(errno)); return ULOGD_IRET_ERR; } - if (fwrite(GET_VALUE(res, 0).ptr, pchdr.caplen, 1, pi->of) != 1) { + if (fwrite(ikey_get_ptr(&res[0]), pchdr.caplen, 1, pi->of) != 1) { ulogd_log(ULOGD_ERROR, "Error during write: %s\n", strerror(errno)); return ULOGD_IRET_ERR; |