]> err.no Git - linux-2.6/blob - net/bridge/netfilter/ebt_nflog.c
mac80211: automatic IBSS channel selection
[linux-2.6] / net / bridge / netfilter / ebt_nflog.c
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>
17 #include <linux/netfilter_bridge/ebtables.h>
18 #include <linux/netfilter_bridge/ebt_nflog.h>
19 #include <net/netfilter/nf_log.h>
20
21 static void ebt_nflog(const struct sk_buff *skb,
22                       unsigned int hooknr,
23                       const struct net_device *in,
24                       const struct net_device *out,
25                       const void *data, unsigned int datalen)
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);
36 }
37
38 static int ebt_nflog_check(const char *tablename,
39                            unsigned int hookmask,
40                            const struct ebt_entry *e,
41                            void *data, unsigned int datalen)
42 {
43         struct ebt_nflog_info *info = (struct ebt_nflog_info *)data;
44
45         if (datalen != EBT_ALIGN(sizeof(struct ebt_nflog_info)))
46                 return -EINVAL;
47         if (info->flags & ~EBT_NFLOG_MASK)
48                 return -EINVAL;
49         info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0';
50         return 0;
51 }
52
53 static struct ebt_watcher nflog __read_mostly = {
54         .name = EBT_NFLOG_WATCHER,
55         .watcher = ebt_nflog,
56         .check = ebt_nflog_check,
57         .me = THIS_MODULE,
58 };
59
60 static int __init ebt_nflog_init(void)
61 {
62         return ebt_register_watcher(&nflog);
63 }
64
65 static void __exit ebt_nflog_fini(void)
66 {
67         ebt_unregister_watcher(&nflog);
68 }
69
70 module_init(ebt_nflog_init);
71 module_exit(ebt_nflog_fini);
72 MODULE_LICENSE("GPL");
73 MODULE_AUTHOR("Peter Warasin <peter@endian.com>");
74 MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module");