GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / net / netfilter / xt_ethport.c
blob8c4a8ddd637e5340ba0e8766798bc87e53d1df74
1 /*
2 * IP tables module for matching the value of the incoming ether port
3 * for Ralink SoC platform.
5 * (C) 2009 by Y.Y. Huang <yy_huang@ralinktech.com.tw>
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/ip.h>
15 #include <linux/ipv6.h>
17 #include <linux/netfilter/xt_ethport.h>
18 #include <linux/netfilter/x_tables.h>
20 MODULE_AUTHOR("Y.Y. Huang <yy_huang@ralinktech.com.tw>");
21 MODULE_DESCRIPTION("x_tables Ra SoC Ethernet incoming port matching module");
22 MODULE_LICENSE("GPL");
23 MODULE_ALIAS("ipt_ethport");
24 MODULE_ALIAS("ip6t_ethport");
26 static bool match(const struct sk_buff *skb, struct xt_action_param *par)
28 const struct xt_ethport_info *info = par->matchinfo;
29 u_int8_t portnum = skb->priority;
31 return (portnum == info->portnum) ^ !!info->invert;
34 static bool match6(const struct sk_buff *skb, struct xt_action_param *par)
36 const struct xt_ethport_info *info = par->matchinfo;
37 u_int8_t portnum = skb->priority;
39 return (portnum == info->portnum) ^ !!info->invert;
42 static int checkentry(const struct xt_mtchk_param *par)
44 const u_int8_t portnum = ((struct xt_ethport_info *)(par->matchinfo))->portnum;
46 if (portnum > XT_ETHPORT_MAX) {
47 printk(KERN_ERR "xt_ethport: port number %x is out of range(%x)\n", portnum, XT_ETHPORT_MAX);
48 return -EINVAL;
51 return 0;
54 static struct xt_match xt_ethport_match[] = {
56 .name = "ethport",
57 .family = AF_INET,
58 .checkentry = checkentry,
59 .match = match,
60 .matchsize = sizeof(struct xt_ethport_info),
61 .me = THIS_MODULE,
64 .name = "ethport",
65 .family = AF_INET6,
66 .checkentry = checkentry,
67 .match = match6,
68 .matchsize = sizeof(struct xt_ethport_info),
69 .me = THIS_MODULE,
73 static int __init xt_ethport_match_init(void)
75 return xt_register_matches(xt_ethport_match, ARRAY_SIZE(xt_ethport_match));
78 static void __exit xt_ethport_match_fini(void)
80 xt_unregister_matches(xt_ethport_match, ARRAY_SIZE(xt_ethport_match));
83 module_init(xt_ethport_match_init);
84 module_exit(xt_ethport_match_fini);