xt_comment.c revision 5d04bff096180f032de8b9b12153a8a1b4009b8d
1/*
2 * Implements a dummy match to allow attaching comments to rules
3 *
4 * 2003-05-13 Brad Fisher (brad@info-link.net)
5 */
6
7#include <linux/module.h>
8#include <linux/skbuff.h>
9#include <linux/netfilter/x_tables.h>
10#include <linux/netfilter/xt_comment.h>
11
12MODULE_AUTHOR("Brad Fisher <brad@info-link.net>");
13MODULE_DESCRIPTION("iptables comment match module");
14MODULE_LICENSE("GPL");
15MODULE_ALIAS("ipt_comment");
16MODULE_ALIAS("ip6t_comment");
17
18static int
19match(const struct sk_buff *skb,
20      const struct net_device *in,
21      const struct net_device *out,
22      const void *matchinfo,
23      int offset,
24      unsigned int protooff,
25      int *hotdrop)
26{
27	/* We always match */
28	return 1;
29}
30
31static struct xt_match comment_match = {
32	.name		= "comment",
33	.match		= match,
34	.matchsize	= sizeof(struct xt_comment_info),
35	.me		= THIS_MODULE
36};
37
38static struct xt_match comment6_match = {
39	.name		= "comment",
40	.match		= match,
41	.matchsize	= sizeof(struct xt_comment_info),
42	.me		= THIS_MODULE
43};
44
45static int __init init(void)
46{
47	int ret;
48
49	ret = xt_register_match(AF_INET, &comment_match);
50	if (ret)
51		return ret;
52
53	ret = xt_register_match(AF_INET6, &comment6_match);
54	if (ret)
55		xt_unregister_match(AF_INET, &comment_match);
56
57	return ret;
58}
59
60static void __exit fini(void)
61{
62	xt_unregister_match(AF_INET, &comment_match);
63	xt_unregister_match(AF_INET6, &comment6_match);
64}
65
66module_init(init);
67module_exit(fini);
68