Blame SOURCES/ebtables-2.0.0-audit.patch

8c7451
--- ebtables2.orig/extensions/ebt_AUDIT.c	1970-01-01 01:00:00.000000000 +0100
8c7451
+++ ebtables2.orig/extensions/ebt_AUDIT.c	2011-01-07 10:53:46.680329228 +0100
8c7451
@@ -0,0 +1,110 @@ 
8c7451
+
8c7451
+#include <stdio.h>
8c7451
+#include <stdlib.h>
8c7451
+#include <string.h>
8c7451
+#include <getopt.h>
8c7451
+#include "../include/ebtables_u.h"
8c7451
+#include <linux/netfilter/xt_AUDIT.h>
8c7451
+
8c7451
+#define AUDIT_TYPE  '1'
8c7451
+static struct option opts[] =
8c7451
+{
8c7451
+	{ "audit-type" , required_argument, 0, AUDIT_TYPE },
8c7451
+	{ 0 }
8c7451
+};
8c7451
+
8c7451
+static void print_help()
8c7451
+{
8c7451
+	printf(
8c7451
+	"AUDIT target options:\n"
8c7451
+	" --audit-type TYPE          : Set action type to record.\n");
8c7451
+}
8c7451
+
8c7451
+static void init(struct ebt_entry_target *target)
8c7451
+{
8c7451
+	struct xt_AUDIT_info *info = (struct xt_AUDIT_info *) target->data;
8c7451
+
8c7451
+	info->type = 0;
8c7451
+}
8c7451
+
8c7451
+static int parse(int c, char **argv, int argc,
8c7451
+   const struct ebt_u_entry *entry, unsigned int *flags,
8c7451
+   struct ebt_entry_target **target)
8c7451
+{
8c7451
+	struct xt_AUDIT_info *info = (struct xt_AUDIT_info *) (*target)->data;
8c7451
+
8c7451
+	switch (c) {
8c7451
+	case AUDIT_TYPE:
8c7451
+		ebt_check_option2(flags, AUDIT_TYPE);
8c7451
+
8c7451
+		if (!strcasecmp(optarg, "accept"))
8c7451
+			info->type = XT_AUDIT_TYPE_ACCEPT;
8c7451
+		else if (!strcasecmp(optarg, "drop"))
8c7451
+			info->type = XT_AUDIT_TYPE_DROP;
8c7451
+		else if (!strcasecmp(optarg, "reject"))
8c7451
+			info->type = XT_AUDIT_TYPE_REJECT;
8c7451
+		else
8c7451
+			ebt_print_error2("Bad action type value `%s'", optarg);
8c7451
+
8c7451
+		break;
8c7451
+	 default:
8c7451
+		return 0;
8c7451
+	}
8c7451
+	return 1;
8c7451
+}
8c7451
+
8c7451
+static void final_check(const struct ebt_u_entry *entry,
8c7451
+   const struct ebt_entry_match *match, const char *name,
8c7451
+   unsigned int hookmask, unsigned int time)
8c7451
+{
8c7451
+}
8c7451
+
8c7451
+static void print(const struct ebt_u_entry *entry,
8c7451
+   const struct ebt_entry_target *target)
8c7451
+{
8c7451
+	const struct xt_AUDIT_info *info =
8c7451
+		(const struct xt_AUDIT_info *) target->data;
8c7451
+
8c7451
+	printf("--audit-type ");
8c7451
+
8c7451
+	switch(info->type) {
8c7451
+	case XT_AUDIT_TYPE_ACCEPT:
8c7451
+		printf("accept");
8c7451
+		break;
8c7451
+	case XT_AUDIT_TYPE_DROP:
8c7451
+		printf("drop");
8c7451
+		break;
8c7451
+	case XT_AUDIT_TYPE_REJECT:
8c7451
+		printf("reject");
8c7451
+		break;
8c7451
+	}
8c7451
+}
8c7451
+
8c7451
+static int compare(const struct ebt_entry_target *t1,
8c7451
+   const struct ebt_entry_target *t2)
8c7451
+{
8c7451
+	const struct xt_AUDIT_info *info1 =
8c7451
+		(const struct xt_AUDIT_info *) t1->data;
8c7451
+	const struct xt_AUDIT_info *info2 =
8c7451
+		(const struct xt_AUDIT_info *) t2->data;
8c7451
+
8c7451
+	return info1->type == info2->type;
8c7451
+}
8c7451
+
8c7451
+static struct ebt_u_target AUDIT_target =
8c7451
+{
8c7451
+	.name		= "AUDIT",
8c7451
+	.size		= sizeof(struct xt_AUDIT_info),
8c7451
+	.help		= print_help,
8c7451
+	.init		= init,
8c7451
+	.parse		= parse,
8c7451
+	.final_check	= final_check,
8c7451
+	.print		= print,
8c7451
+	.compare	= compare,
8c7451
+	.extra_ops	= opts,
8c7451
+};
8c7451
+
8c7451
+void _init(void)
8c7451
+{
8c7451
+	ebt_register_target(&AUDIT_target);
8c7451
+}
8c7451
--- ebtables2.orig/extensions/Makefile	2011-01-07 10:55:28.077246240 +0100
8c7451
+++ ebtables2.orig/extensions/Makefile	2011-01-07 10:53:46.686329230 +0100
8c7451
@@ -1,7 +1,7 @@ 
8c7451
 #! /usr/bin/make
8c7451
 
8c7451
 EXT_FUNC+=802_3 nat arp arpreply ip ip6 standard log redirect vlan mark_m mark \
8c7451
-          pkttype stp among limit ulog nflog
8c7451
+          pkttype stp among limit ulog nflog AUDIT
8c7451
 EXT_TABLES+=filter nat broute
8c7451
 EXT_OBJS+=$(foreach T,$(EXT_FUNC), extensions/ebt_$(T).o)
8c7451
 EXT_OBJS+=$(foreach T,$(EXT_TABLES), extensions/ebtable_$(T).o)
8c7451
--- a/include/linux/netfilter/xt_AUDIT.h	
8c7451
+++ a/include/linux/netfilter/xt_AUDIT.h	
8c7451
@@ -0,0 +1,30 @@ 
8c7451
+/*
8c7451
+ * Header file for iptables xt_AUDIT target
8c7451
+ *
8c7451
+ * (C) 2010-2011 Thomas Graf <tgraf@redhat.com>
8c7451
+ * (C) 2010-2011 Red Hat, Inc.
8c7451
+ *
8c7451
+ * This program is free software; you can redistribute it and/or modify
8c7451
+ * it under the terms of the GNU General Public License version 2 as
8c7451
+ * published by the Free Software Foundation.
8c7451
+ */
8c7451
+
8c7451
+#ifndef _XT_AUDIT_TARGET_H
8c7451
+#define _XT_AUDIT_TARGET_H
8c7451
+
8c7451
+#include <linux/types.h>
8c7451
+
8c7451
+enum {
8c7451
+	XT_AUDIT_TYPE_ACCEPT = 0,
8c7451
+	XT_AUDIT_TYPE_DROP,
8c7451
+	XT_AUDIT_TYPE_REJECT,
8c7451
+	__XT_AUDIT_TYPE_MAX,
8c7451
+};
8c7451
+
8c7451
+#define XT_AUDIT_TYPE_MAX (__XT_AUDIT_TYPE_MAX - 1)
8c7451
+
8c7451
+struct xt_AUDIT_info {
8c7451
+	__u8 type; /* XT_AUDIT_TYPE_* */
8c7451
+};
8c7451
+
8c7451
+#endif /* _XT_AUDIT_TARGET_H */