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 | 22 | static unsigned int |
4b560b44 | 23 | ebt_nflog_tg(struct sk_buff *skb, const struct xt_action_param *par) |
e7bfd0a1 | 24 | { |
7eb35586 | 25 | const struct ebt_nflog_info *info = par->targinfo; |
e7bfd0a1 | 26 | struct nf_loginfo li; |
686c9b50 | 27 | struct net *net = par->net; |
e7bfd0a1 PW |
28 | |
29 | li.type = NF_LOG_TYPE_ULOG; | |
30 | li.u.ulog.copy_len = info->len; | |
31 | li.u.ulog.group = info->group; | |
32 | li.u.ulog.qthreshold = info->threshold; | |
33 | ||
30e0c6a6 G |
34 | nf_log_packet(net, PF_BRIDGE, par->hooknum, skb, par->in, |
35 | par->out, &li, "%s", info->prefix); | |
0ac6ab1f | 36 | return EBT_CONTINUE; |
e7bfd0a1 PW |
37 | } |
38 | ||
135367b8 | 39 | static int ebt_nflog_tg_check(const struct xt_tgchk_param *par) |
e7bfd0a1 | 40 | { |
af5d6dc2 | 41 | struct ebt_nflog_info *info = par->targinfo; |
e7bfd0a1 | 42 | |
e7bfd0a1 | 43 | if (info->flags & ~EBT_NFLOG_MASK) |
d6b00a53 | 44 | return -EINVAL; |
e7bfd0a1 | 45 | info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0'; |
d6b00a53 | 46 | return 0; |
e7bfd0a1 PW |
47 | } |
48 | ||
043ef46c JE |
49 | static struct xt_target ebt_nflog_tg_reg __read_mostly = { |
50 | .name = "nflog", | |
51 | .revision = 0, | |
52 | .family = NFPROTO_BRIDGE, | |
53 | .target = ebt_nflog_tg, | |
2d06d4a5 | 54 | .checkentry = ebt_nflog_tg_check, |
fc0e3df4 | 55 | .targetsize = sizeof(struct ebt_nflog_info), |
043ef46c | 56 | .me = THIS_MODULE, |
e7bfd0a1 PW |
57 | }; |
58 | ||
59 | static int __init ebt_nflog_init(void) | |
60 | { | |
043ef46c | 61 | return xt_register_target(&ebt_nflog_tg_reg); |
e7bfd0a1 PW |
62 | } |
63 | ||
64 | static void __exit ebt_nflog_fini(void) | |
65 | { | |
043ef46c | 66 | xt_unregister_target(&ebt_nflog_tg_reg); |
e7bfd0a1 PW |
67 | } |
68 | ||
69 | module_init(ebt_nflog_init); | |
70 | module_exit(ebt_nflog_fini); | |
71 | MODULE_LICENSE("GPL"); | |
72 | MODULE_AUTHOR("Peter Warasin <peter@endian.com>"); | |
73 | MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module"); |