linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / net / netfilter / xt_tcpmss.c
index cf7d335..acf7f53 100644 (file)
@@ -81,7 +81,6 @@ static int
 match(const struct sk_buff *skb,
       const struct net_device *in,
       const struct net_device *out,
-      const struct xt_match *match,
       const void *matchinfo,
       int offset,
       unsigned int protoff,
@@ -93,44 +92,81 @@ match(const struct sk_buff *skb,
                               info->invert, hotdrop);
 }
 
+static int
+checkentry(const char *tablename,
+           const void *ipinfo,
+           void *matchinfo,
+           unsigned int matchsize,
+           unsigned int hook_mask)
+{
+       const struct ipt_ip *ip = ipinfo;
+       if (matchsize != XT_ALIGN(sizeof(struct xt_tcpmss_match_info)))
+               return 0;
+
+       /* Must specify -p tcp */
+       if (ip->proto != IPPROTO_TCP || (ip->invflags & IPT_INV_PROTO)) {
+               printk("tcpmss: Only works on TCP packets\n");
+               return 0;
+       }
+
+       return 1;
+}
+
+static int
+checkentry6(const char *tablename,
+          const void *ipinfo,
+           void *matchinfo,
+           unsigned int matchsize,
+           unsigned int hook_mask)
+{
+       const struct ip6t_ip6 *ip = ipinfo;
+
+       if (matchsize != XT_ALIGN(sizeof(struct xt_tcpmss_match_info)))
+               return 0;
+
+       /* Must specify -p tcp */
+       if (ip->proto != IPPROTO_TCP || (ip->invflags & XT_INV_PROTO)) {
+               printk("tcpmss: Only works on TCP packets\n");
+               return 0;
+       }
+
+       return 1;
+}
+
 static struct xt_match tcpmss_match = {
        .name           = "tcpmss",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_tcpmss_match_info),
-       .proto          = IPPROTO_TCP,
-       .family         = AF_INET,
+       .match          = &match,
+       .checkentry     = &checkentry,
        .me             = THIS_MODULE,
 };
 
 static struct xt_match tcpmss6_match = {
        .name           = "tcpmss",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_tcpmss_match_info),
-       .proto          = IPPROTO_TCP,
-       .family         = AF_INET6,
+       .match          = &match,
+       .checkentry     = &checkentry6,
        .me             = THIS_MODULE,
 };
 
 
-static int __init xt_tcpmss_init(void)
+static int __init init(void)
 {
        int ret;
-       ret = xt_register_match(&tcpmss_match);
+       ret = xt_register_match(AF_INET, &tcpmss_match);
        if (ret)
                return ret;
 
-       ret = xt_register_match(&tcpmss6_match);
+       ret = xt_register_match(AF_INET6, &tcpmss6_match);
        if (ret)
-               xt_unregister_match(&tcpmss_match);
+               xt_unregister_match(AF_INET, &tcpmss_match);
 
        return ret;
 }
 
-static void __exit xt_tcpmss_fini(void)
+static void __exit fini(void)
 {
-       xt_unregister_match(&tcpmss6_match);
-       xt_unregister_match(&tcpmss_match);
+       xt_unregister_match(AF_INET6, &tcpmss6_match);
+       xt_unregister_match(AF_INET, &tcpmss_match);
 }
 
-module_init(xt_tcpmss_init);
-module_exit(xt_tcpmss_fini);
+module_init(init);
+module_exit(fini);