Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / ipv4 / netfilter / ipt_realm.c
blob54a6897ebaa682499434a080966b3b2fd3856771
1 /* IP tables module for matching the routing realm
3 * $Id: ipt_realm.c,v 1.3 2004/03/05 13:25:40 laforge Exp $
5 * (C) 2003 by Sampsa Ranta <sampsa@netsonic.fi>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/module.h>
13 #include <linux/skbuff.h>
14 #include <linux/netdevice.h>
15 #include <net/route.h>
17 #include <linux/netfilter_ipv4/ipt_realm.h>
18 #include <linux/netfilter_ipv4/ip_tables.h>
20 MODULE_AUTHOR("Sampsa Ranta <sampsa@netsonic.fi>");
21 MODULE_LICENSE("GPL");
22 MODULE_DESCRIPTION("iptables realm match");
24 static int
25 match(const struct sk_buff *skb,
26 const struct net_device *in,
27 const struct net_device *out,
28 const void *matchinfo,
29 int offset,
30 int *hotdrop)
32 const struct ipt_realm_info *info = matchinfo;
33 struct dst_entry *dst = skb->dst;
35 return (info->id == (dst->tclassid & info->mask)) ^ info->invert;
38 static int check(const char *tablename,
39 const struct ipt_ip *ip,
40 void *matchinfo,
41 unsigned int matchsize,
42 unsigned int hook_mask)
44 if (hook_mask
45 & ~((1 << NF_IP_POST_ROUTING) | (1 << NF_IP_FORWARD) |
46 (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_LOCAL_IN))) {
47 printk("ipt_realm: only valid for POST_ROUTING, LOCAL_OUT, "
48 "LOCAL_IN or FORWARD.\n");
49 return 0;
51 if (matchsize != IPT_ALIGN(sizeof(struct ipt_realm_info))) {
52 printk("ipt_realm: invalid matchsize.\n");
53 return 0;
55 return 1;
58 static struct ipt_match realm_match = {
59 .name = "realm",
60 .match = match,
61 .checkentry = check,
62 .me = THIS_MODULE
65 static int __init init(void)
67 return ipt_register_match(&realm_match);
70 static void __exit fini(void)
72 ipt_unregister_match(&realm_match);
75 module_init(init);
76 module_exit(fini);