]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* IP tables module for matching the routing realm |
1da177e4 LT |
2 | * |
3 | * (C) 2003 by Sampsa Ranta <[email protected]> | |
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 | #include <linux/module.h> | |
11 | #include <linux/skbuff.h> | |
12 | #include <linux/netdevice.h> | |
13 | #include <net/route.h> | |
14 | ||
2e4e6a17 HW |
15 | #include <linux/netfilter_ipv4.h> |
16 | #include <linux/netfilter/xt_realm.h> | |
17 | #include <linux/netfilter/x_tables.h> | |
1da177e4 LT |
18 | |
19 | MODULE_AUTHOR("Sampsa Ranta <[email protected]>"); | |
20 | MODULE_LICENSE("GPL"); | |
2e4e6a17 HW |
21 | MODULE_DESCRIPTION("X_tables realm match"); |
22 | MODULE_ALIAS("ipt_realm"); | |
1da177e4 | 23 | |
1d93a9cb | 24 | static bool |
1da177e4 LT |
25 | match(const struct sk_buff *skb, |
26 | const struct net_device *in, | |
27 | const struct net_device *out, | |
c4986734 | 28 | const struct xt_match *match, |
1da177e4 LT |
29 | const void *matchinfo, |
30 | int offset, | |
2e4e6a17 | 31 | unsigned int protoff, |
cff533ac | 32 | bool *hotdrop) |
1da177e4 | 33 | { |
2e4e6a17 | 34 | const struct xt_realm_info *info = matchinfo; |
a47362a2 | 35 | const struct dst_entry *dst = skb->dst; |
601e68e1 | 36 | |
1da177e4 LT |
37 | return (info->id == (dst->tclassid & info->mask)) ^ info->invert; |
38 | } | |
39 | ||
9f15c530 | 40 | static struct xt_match realm_match __read_mostly = { |
1da177e4 | 41 | .name = "realm", |
5d04bff0 PM |
42 | .match = match, |
43 | .matchsize = sizeof(struct xt_realm_info), | |
44 | .hooks = (1 << NF_IP_POST_ROUTING) | (1 << NF_IP_FORWARD) | | |
45 | (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_LOCAL_IN), | |
a45049c5 | 46 | .family = AF_INET, |
1da177e4 LT |
47 | .me = THIS_MODULE |
48 | }; | |
49 | ||
65b4b4e8 | 50 | static int __init xt_realm_init(void) |
1da177e4 | 51 | { |
a45049c5 | 52 | return xt_register_match(&realm_match); |
1da177e4 LT |
53 | } |
54 | ||
65b4b4e8 | 55 | static void __exit xt_realm_fini(void) |
1da177e4 | 56 | { |
a45049c5 | 57 | xt_unregister_match(&realm_match); |
1da177e4 LT |
58 | } |
59 | ||
65b4b4e8 AM |
60 | module_init(xt_realm_init); |
61 | module_exit(xt_realm_fini); |