blob: 22e2ad5f23e888ec9dd82a2615e0808c247f12c6 [file] [log] [blame]
Peter Warasine7bfd0a2008-04-14 11:15:54 +02001/*
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>
Jan Engelhardt18219d32008-10-08 11:35:13 +020017#include <linux/netfilter/x_tables.h>
Peter Warasine7bfd0a2008-04-14 11:15:54 +020018#include <linux/netfilter_bridge/ebtables.h>
19#include <linux/netfilter_bridge/ebt_nflog.h>
20#include <net/netfilter/nf_log.h>
21
Jan Engelhardt2d06d4a2008-10-08 11:35:15 +020022static unsigned int
Jan Engelhardt7eb35582008-10-08 11:35:19 +020023ebt_nflog_tg(struct sk_buff *skb, const struct xt_target_param *par)
Peter Warasine7bfd0a2008-04-14 11:15:54 +020024{
Jan Engelhardt7eb35582008-10-08 11:35:19 +020025 const struct ebt_nflog_info *info = par->targinfo;
Peter Warasine7bfd0a2008-04-14 11:15:54 +020026 struct nf_loginfo li;
27
28 li.type = NF_LOG_TYPE_ULOG;
29 li.u.ulog.copy_len = info->len;
30 li.u.ulog.group = info->group;
31 li.u.ulog.qthreshold = info->threshold;
32
Jan Engelhardt7eb35582008-10-08 11:35:19 +020033 nf_log_packet(PF_BRIDGE, par->hooknum, skb, par->in, par->out,
34 &li, "%s", info->prefix);
Jan Engelhardt0ac6ab12008-10-08 11:35:13 +020035 return EBT_CONTINUE;
Peter Warasine7bfd0a2008-04-14 11:15:54 +020036}
37
Jan Engelhardt135367b2010-03-19 17:16:42 +010038static int ebt_nflog_tg_check(const struct xt_tgchk_param *par)
Peter Warasine7bfd0a2008-04-14 11:15:54 +020039{
Jan Engelhardtaf5d6dc2008-10-08 11:35:19 +020040 struct ebt_nflog_info *info = par->targinfo;
Peter Warasine7bfd0a2008-04-14 11:15:54 +020041
Peter Warasine7bfd0a2008-04-14 11:15:54 +020042 if (info->flags & ~EBT_NFLOG_MASK)
Jan Engelhardtd6b00a52010-03-25 16:34:45 +010043 return -EINVAL;
Peter Warasine7bfd0a2008-04-14 11:15:54 +020044 info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0';
Jan Engelhardtd6b00a52010-03-25 16:34:45 +010045 return 0;
Peter Warasine7bfd0a2008-04-14 11:15:54 +020046}
47
Jan Engelhardt043ef462008-10-08 11:35:15 +020048static struct xt_target ebt_nflog_tg_reg __read_mostly = {
49 .name = "nflog",
50 .revision = 0,
51 .family = NFPROTO_BRIDGE,
52 .target = ebt_nflog_tg,
Jan Engelhardt2d06d4a2008-10-08 11:35:15 +020053 .checkentry = ebt_nflog_tg_check,
Florian Westphalfc0e3df2010-02-15 18:16:26 +010054 .targetsize = sizeof(struct ebt_nflog_info),
Jan Engelhardt043ef462008-10-08 11:35:15 +020055 .me = THIS_MODULE,
Peter Warasine7bfd0a2008-04-14 11:15:54 +020056};
57
58static int __init ebt_nflog_init(void)
59{
Jan Engelhardt043ef462008-10-08 11:35:15 +020060 return xt_register_target(&ebt_nflog_tg_reg);
Peter Warasine7bfd0a2008-04-14 11:15:54 +020061}
62
63static void __exit ebt_nflog_fini(void)
64{
Jan Engelhardt043ef462008-10-08 11:35:15 +020065 xt_unregister_target(&ebt_nflog_tg_reg);
Peter Warasine7bfd0a2008-04-14 11:15:54 +020066}
67
68module_init(ebt_nflog_init);
69module_exit(ebt_nflog_fini);
70MODULE_LICENSE("GPL");
71MODULE_AUTHOR("Peter Warasin <peter@endian.com>");
72MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module");