]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
length2: guard off IPv6-only functions
authorJan Engelhardt <jengelh@medozas.de>
Tue, 23 Feb 2010 23:29:55 +0000 (00:29 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Tue, 23 Feb 2010 23:29:55 +0000 (00:29 +0100)
extensions/xt_length2.c

index a329cbdb2b67e938bd73f5babd78f7802b30059b..8de6ca50babfd10637567a1b981c98bc925b3431 100644 (file)
@@ -136,6 +136,30 @@ static bool xtlength_layer7(unsigned int *length, const struct sk_buff *skb,
        }
 }
 
+static bool
+length2_mt(const struct sk_buff *skb, const struct xt_match_param *par)
+{
+       const struct xt_length_mtinfo2 *info = par->matchinfo;
+       const struct iphdr *iph = ip_hdr(skb);
+       unsigned int len = 0;
+       bool hit = true;
+
+       if (info->flags & XT_LENGTH_LAYER3)
+               len = ntohs(iph->tot_len);
+       else if (info->flags & XT_LENGTH_LAYER4)
+               len = ntohs(iph->tot_len) - par->thoff;
+       else if (info->flags & XT_LENGTH_LAYER5)
+               hit = xtlength_layer5(&len, skb, iph->protocol, par->thoff);
+       else if (info->flags & XT_LENGTH_LAYER7)
+               hit = xtlength_layer7(&len, skb, iph->protocol, par->thoff);
+       if (!hit)
+               return false;
+
+       return (len >= info->min && len <= info->max) ^
+              !!(info->flags & XT_LENGTH_INVERT);
+}
+
+#ifdef WITH_IPV6
 /**
  * llayer4_proto - figure out the L4 protocol in an IPv6 packet
  * @skb:       skb pointer
@@ -173,30 +197,6 @@ llayer4_proto(const struct sk_buff *skb, unsigned int *offset, bool *hotdrop)
        return NEXTHDR_MAX;
 }
 
-static bool
-length2_mt(const struct sk_buff *skb, const struct xt_match_param *par)
-{
-       const struct xt_length_mtinfo2 *info = par->matchinfo;
-       const struct iphdr *iph = ip_hdr(skb);
-       unsigned int len = 0;
-       bool hit = true;
-
-       if (info->flags & XT_LENGTH_LAYER3)
-               len = ntohs(iph->tot_len);
-       else if (info->flags & XT_LENGTH_LAYER4)
-               len = ntohs(iph->tot_len) - par->thoff;
-       else if (info->flags & XT_LENGTH_LAYER5)
-               hit = xtlength_layer5(&len, skb, iph->protocol, par->thoff);
-       else if (info->flags & XT_LENGTH_LAYER7)
-               hit = xtlength_layer7(&len, skb, iph->protocol, par->thoff);
-       if (!hit)
-               return false;
-
-       return (len >= info->min && len <= info->max) ^
-              !!(info->flags & XT_LENGTH_INVERT);
-}
-
-#ifdef WITH_IPV6
 static bool
 length2_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
 {