summaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
author/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>2006-05-23 08:57:18 +0000
committer/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>2006-05-23 08:57:18 +0000
commit62defdbdb365c325795b83845f266410cf7c1076 (patch)
tree30ec9bd4ba364b5058ad7b782140e908654a46a0 /filter
parent5f738b5660fc5abf6e21b527bb6f946bbaaa31db (diff)
Move the printpkt functionality out of SYSLOG and LOGEMU, and into
a separate PRINTPKT plugin. This reduces code duplication, and also makes the SYSLOG and LOGEMU plugins more general. (Philip Craig)
Diffstat (limited to 'filter')
-rw-r--r--filter/Makefile.am6
-rw-r--r--filter/ulogd_filter_PRINTPKT.c66
2 files changed, 71 insertions, 1 deletions
diff --git a/filter/Makefile.am b/filter/Makefile.am
index 55d14c0..8c2a37d 100644
--- a/filter/Makefile.am
+++ b/filter/Makefile.am
@@ -4,10 +4,14 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
noinst_HEADERS = rtnl.h iftable.h
-pkglib_LTLIBRARIES = ulogd_filter_IFINDEX.la ulogd_filter_PWSNIFF.la
+pkglib_LTLIBRARIES = ulogd_filter_IFINDEX.la ulogd_filter_PWSNIFF.la \
+ ulogd_filter_PRINTPKT.la
ulogd_filter_IFINDEX_la_SOURCES = ulogd_filter_IFINDEX.c rtnl.c iftable.c
ulogd_filter_IFINDEX_la_LDFLAGS = -module
ulogd_filter_PWSNIFF_la_SOURCES = ulogd_filter_PWSNIFF.c
ulogd_filter_PWSNIFF_la_LDFLAGS = -module
+
+ulogd_filter_PRINTPKT_la_SOURCES = ulogd_filter_PRINTPKT.c ../util/printpkt.c
+ulogd_filter_PRINTPKT_la_LDFLAGS = -module
diff --git a/filter/ulogd_filter_PRINTPKT.c b/filter/ulogd_filter_PRINTPKT.c
new file mode 100644
index 0000000..09f0fdf
--- /dev/null
+++ b/filter/ulogd_filter_PRINTPKT.c
@@ -0,0 +1,66 @@
+/* ulogd_filter_PRINTPKT.c, Version $Revision: 1.1 $
+ *
+ * This target produces entries identical to the LOG target.
+ *
+ * (C) 2006 by Philip Craig <philipc@snapgear.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <ulogd/ulogd.h>
+#include <ulogd/printpkt.h>
+
+static struct ulogd_key printpkt_outp[] = {
+ {
+ .type = ULOGD_RET_STRING,
+ .flags = ULOGD_RETF_NONE,
+ .name = "print",
+ },
+};
+
+static int printpkt_interp(struct ulogd_pluginstance *upi)
+{
+ struct ulogd_key *inp = upi->input.keys;
+ struct ulogd_key *ret = upi->output.keys;
+ static char buf[4096];
+
+ printpkt_print(inp, buf);
+ ret[0].u.value.ptr = buf;
+ ret[0].flags |= ULOGD_RETF_VALID;
+ return 0;
+}
+
+static struct ulogd_plugin printpkt_plugin = {
+ .name = "PRINTPKT",
+ .input = {
+ .keys = printpkt_keys,
+ .num_keys = ARRAY_SIZE(printpkt_keys),
+ .type = ULOGD_DTYPE_PACKET,
+ },
+ .output = {
+ .keys = printpkt_outp,
+ .num_keys = ARRAY_SIZE(printpkt_outp),
+ .type = ULOGD_DTYPE_PACKET,
+ },
+ .interp = &printpkt_interp,
+ .version = ULOGD_VERSION,
+};
+
+void __attribute__ ((constructor)) init(void);
+
+void init(void)
+{
+ ulogd_register_plugin(&printpkt_plugin);
+}