Commit | Line | Data |
---|---|---|
e7bfd0a1 PW |
1 | /* |
2 | * ebt_nflog | |
3 | * | |
4 | * Author: | |
5 | * Peter Warasin <peter@endian.com> | |
6 | * | |
7 | * February, 2008 | |
8 | * | |
9 | * Based on: | |
10 | * xt_NFLOG.c, (C) 2006 by Patrick McHardy <kaber@trash.net> | |
11 | * ebt_ulog.c, (C) 2004 by Bart De Schuymer <bdschuym@pandora.be> | |
12 | * | |
13 | */ | |
14 | ||
15 | #include <linux/module.h> | |
16 | #include <linux/spinlock.h> | |
18219d3f | 17 | #include <linux/netfilter/x_tables.h> |
e7bfd0a1 PW |
18 | #include <linux/netfilter_bridge/ebtables.h> |
19 | #include <linux/netfilter_bridge/ebt_nflog.h> | |
20 | #include <net/netfilter/nf_log.h> | |
21 | ||
2d06d4a5 JE |
22 | static unsigned int |
23 | ebt_nflog_tg(struct sk_buff *skb, const struct net_device *in, | |
24 | const struct net_device *out, unsigned int hooknr, | |
25 | const struct xt_target *target, const void *data) | |
e7bfd0a1 PW |
26 | { |
27 | struct ebt_nflog_info *info = (struct ebt_nflog_info *)data; | |
28 | struct nf_loginfo li; | |
29 | ||
30 | li.type = NF_LOG_TYPE_ULOG; | |
31 | li.u.ulog.copy_len = info->len; | |
32 | li.u.ulog.group = info->group; | |
33 | li.u.ulog.qthreshold = info->threshold; | |
34 | ||
35 | nf_log_packet(PF_BRIDGE, hooknr, skb, in, out, &li, "%s", info->prefix); | |
0ac6ab1f | 36 | return EBT_CONTINUE; |
e7bfd0a1 PW |
37 | } |
38 | ||
2d06d4a5 JE |
39 | static bool |
40 | ebt_nflog_tg_check(const char *table, const void *e, | |
41 | const struct xt_target *target, void *data, | |
42 | unsigned int hookmask) | |
e7bfd0a1 PW |
43 | { |
44 | struct ebt_nflog_info *info = (struct ebt_nflog_info *)data; | |
45 | ||
e7bfd0a1 | 46 | if (info->flags & ~EBT_NFLOG_MASK) |
19eda879 | 47 | return false; |
e7bfd0a1 | 48 | info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0'; |
19eda879 | 49 | return true; |
e7bfd0a1 PW |
50 | } |
51 | ||
043ef46c JE |
52 | static struct xt_target ebt_nflog_tg_reg __read_mostly = { |
53 | .name = "nflog", | |
54 | .revision = 0, | |
55 | .family = NFPROTO_BRIDGE, | |
56 | .target = ebt_nflog_tg, | |
2d06d4a5 | 57 | .checkentry = ebt_nflog_tg_check, |
18219d3f | 58 | .targetsize = XT_ALIGN(sizeof(struct ebt_nflog_info)), |
043ef46c | 59 | .me = THIS_MODULE, |
e7bfd0a1 PW |
60 | }; |
61 | ||
62 | static int __init ebt_nflog_init(void) | |
63 | { | |
043ef46c | 64 | return xt_register_target(&ebt_nflog_tg_reg); |
e7bfd0a1 PW |
65 | } |
66 | ||
67 | static void __exit ebt_nflog_fini(void) | |
68 | { | |
043ef46c | 69 | xt_unregister_target(&ebt_nflog_tg_reg); |
e7bfd0a1 PW |
70 | } |
71 | ||
72 | module_init(ebt_nflog_init); | |
73 | module_exit(ebt_nflog_fini); | |
74 | MODULE_LICENSE("GPL"); | |
75 | MODULE_AUTHOR("Peter Warasin <peter@endian.com>"); | |
76 | MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module"); |