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");
25 match(const struct sk_buff
*skb
,
26 const struct net_device
*in
,
27 const struct net_device
*out
,
28 const void *matchinfo
,
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
,
41 unsigned int matchsize
,
42 unsigned int 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");
51 if (matchsize
!= IPT_ALIGN(sizeof(struct ipt_realm_info
))) {
52 printk("ipt_realm: invalid matchsize.\n");
58 static struct ipt_match realm_match
= {
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
);