From 09e209b04940f682d8989c789058c71114fcc695 Mon Sep 17 00:00:00 2001 From: laforge Date: Mon, 3 Oct 2005 16:01:37 +0000 Subject: add skeleton of ifindex->interfacename plugin --- filter/Makefile.am | 7 ++++ filter/ulogd_filter_IFINDEX.c | 75 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 filter/ulogd_filter_IFINDEX.c diff --git a/filter/Makefile.am b/filter/Makefile.am index 25f2516..6d0cd43 100644 --- a/filter/Makefile.am +++ b/filter/Makefile.am @@ -1 +1,8 @@ SUBDIRS = raw2packet packet2flow + +INCLUDES = $(all_includes) -I$(top_srcdir)/include + +pkglib_LTLIBRARIES = ulogd_filter_IFINDEX.la + +ulogd_filter_IFINDEX_la_SOURCES = ulogd_filter_IFINDEX.c +ulogd_filter_IFINDEX_la_LDFLAGS = -module diff --git a/filter/ulogd_filter_IFINDEX.c b/filter/ulogd_filter_IFINDEX.c new file mode 100644 index 0000000..783fe54 --- /dev/null +++ b/filter/ulogd_filter_IFINDEX.c @@ -0,0 +1,75 @@ +#include +#include +#include + +static struct ulogd_key ifindex_keys[] = { + { + .type = ULOGD_RET_STRING, + .flags = ULOGD_RETF_NONE, + .name = "oob.in", + }, + { + .type = ULOGD_RET_STRING, + .flags = ULOGD_RETF_NONE, + .name = "oob.out", + }, +}; + +static struct ulogd_key ifindex_inp[] = { + { + .type = ULOGD_RET_UINT32, + .name = "oob.ifindex_in", + }, + { + .type = ULOGD_RET_UINT32, + .name = "oob.ifindex_out", + }, +}; + +static int interp_ifindex(struct ulogd_pluginstance *pi) +{ + struct ulogd_key *ret = pi->output; + + ret[0].u.value.ptr = "eth_in_FIXME"; + ret[0].flags |= ULOGD_RETF_VALID; + ret[1].u.value.ptr = "eth_out_FIXME"; + ret[1].flags |= ULOGD_RETF_VALID; + + return 0; +} + + +static int ifindex_start(struct ulogd_pluginstance *upi) +{ + return 0; +} + +static int ifindex_fini(struct ulogd_pluginstance *upi) +{ + return 0; +} + +static struct ulogd_plugin ifindex_plugin = { + .name = "IFINDEX", + .input = { + .keys = ifindex_inp, + .num_keys = ARRAY_SIZE(ifindex_inp), + .type = ULOGD_DTYPE_RAW, + }, + .output = { + .keys = ifindex_keys, + .num_keys = ARRAY_SIZE(ifindex_keys), + .type = ULOGD_DTYPE_PACKET, + }, + .interp = &interp_ifindex, + + .start = &ifindex_start, + .stop = &ifindex_fini, +}; + +void __attribute__ ((constructor)) init(void); + +void init(void) +{ + ulogd_register_plugin(&ifindex_plugin); +} -- cgit v1.2.3