ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / net / ipv6 / netfilter / ip6t_mark.c
1 /* Kernel module to match NFMARK values. */
2
3 /* (C) 1999-2001 Marc Boucher <marc@mbsi.ca>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  */
9
10
11 #include <linux/module.h>
12 #include <linux/skbuff.h>
13
14 #include <linux/netfilter_ipv6/ip6t_mark.h>
15 #include <linux/netfilter_ipv6/ip6_tables.h>
16
17 MODULE_LICENSE("GPL");
18 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
19 MODULE_DESCRIPTION("ip6tables mark match");
20
21 static int
22 match(const struct sk_buff *skb,
23       const struct net_device *in,
24       const struct net_device *out,
25       const void *matchinfo,
26       int offset,
27       const void *hdr,
28       u_int16_t datalen,
29       int *hotdrop)
30 {
31         const struct ip6t_mark_info *info = matchinfo;
32
33         return ((skb->nfmark & info->mask) == info->mark) ^ info->invert;
34 }
35
36 static int
37 checkentry(const char *tablename,
38            const struct ip6t_ip6 *ip,
39            void *matchinfo,
40            unsigned int matchsize,
41            unsigned int hook_mask)
42 {
43         if (matchsize != IP6T_ALIGN(sizeof(struct ip6t_mark_info)))
44                 return 0;
45
46         return 1;
47 }
48
49 static struct ip6t_match mark_match = {
50         .name           = "mark",
51         .match          = &match,
52         .checkentry     = &checkentry,
53         .me             = THIS_MODULE,
54 };
55
56 static int __init init(void)
57 {
58         return ip6t_register_match(&mark_match);
59 }
60
61 static void __exit fini(void)
62 {
63         ip6t_unregister_match(&mark_match);
64 }
65
66 module_init(init);
67 module_exit(fini);