Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / ipv4 / netfilter / ipt_mark.c
blob8955728127b9528e720fdba0259da1f9d216f261
1 /* Kernel module to match NFMARK values. */
3 /* (C) 1999-2001 Marc Boucher <marc@mbsi.ca>
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 */
10 #include <linux/module.h>
11 #include <linux/skbuff.h>
13 #include <linux/netfilter_ipv4/ipt_mark.h>
14 #include <linux/netfilter_ipv4/ip_tables.h>
16 MODULE_LICENSE("GPL");
17 MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
18 MODULE_DESCRIPTION("iptables mark matching module");
20 static int
21 match(const struct sk_buff *skb,
22 const struct net_device *in,
23 const struct net_device *out,
24 const void *matchinfo,
25 int offset,
26 int *hotdrop)
28 const struct ipt_mark_info *info = matchinfo;
30 return ((skb->nfmark & info->mask) == info->mark) ^ info->invert;
33 static int
34 checkentry(const char *tablename,
35 const struct ipt_ip *ip,
36 void *matchinfo,
37 unsigned int matchsize,
38 unsigned int hook_mask)
40 if (matchsize != IPT_ALIGN(sizeof(struct ipt_mark_info)))
41 return 0;
43 return 1;
46 static struct ipt_match mark_match = {
47 .name = "mark",
48 .match = &match,
49 .checkentry = &checkentry,
50 .me = THIS_MODULE,
53 static int __init init(void)
55 return ipt_register_match(&mark_match);
58 static void __exit fini(void)
60 ipt_unregister_match(&mark_match);
63 module_init(init);
64 module_exit(fini);