Merge to iptables-1.3.5
[iptables.git] / extensions / libipt_ttl.c
index 2391986..c7503fe 100644 (file)
@@ -1,7 +1,7 @@
 /* Shared library add-on to iptables to add TTL matching support 
  * (C) 2000 by Harald Welte <laforge@gnumonks.org>
  *
- * $Id: libipt_ttl.c 3687 2005-02-14 13:13:04Z /C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=kaber/emailAddress=kaber@netfilter.org $
+ * $Id: libipt_ttl.c,v 1.1.1.3 2006/07/28 14:34:27 mlhuang Exp $
  *
  * This program is released under the terms of GNU GPL */
 
@@ -29,16 +29,16 @@ static int parse(int c, char **argv, int invert, unsigned int *flags,
                struct ipt_entry_match **match)
 {
        struct ipt_ttl_info *info = (struct ipt_ttl_info *) (*match)->data;
-       int value;
+       unsigned int value;
 
        check_inverse(optarg, &invert, &optind, 0);
 
-       if (string_to_number(optarg, 0, 255, &value) == -1)
-               exit_error(PARAMETER_PROBLEM,
-                          "ttl: Expected value between 0 and 255");
-
        switch (c) {
                case '2':
+                       if (string_to_number(optarg, 0, 255, &value) == -1)
+                               exit_error(PARAMETER_PROBLEM,
+                                          "ttl: Expected value between 0 and 255");
+
                        if (invert)
                                info->mode = IPT_TTL_NE;
                        else
@@ -48,6 +48,10 @@ static int parse(int c, char **argv, int invert, unsigned int *flags,
                        info->ttl = value;
                        break;
                case '3':
+                       if (string_to_number(optarg, 0, 255, &value) == -1)
+                               exit_error(PARAMETER_PROBLEM,
+                                          "ttl: Expected value between 0 and 255");
+
                        if (invert) 
                                exit_error(PARAMETER_PROBLEM,
                                                "ttl: unexpected `!'");
@@ -56,6 +60,10 @@ static int parse(int c, char **argv, int invert, unsigned int *flags,
                        info->ttl = value;
                        break;
                case '4':
+                       if (string_to_number(optarg, 0, 255, &value) == -1)
+                               exit_error(PARAMETER_PROBLEM,
+                                          "ttl: Expected value between 0 and 255");
+
                        if (invert)
                                exit_error(PARAMETER_PROBLEM,
                                                "ttl: unexpected `!'");