diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2004-12-22 04:26:53 +0000 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2004-12-22 04:26:53 +0000 |
commit | 70f758db30e46d084397d89bfb670274b0288ac8 (patch) | |
tree | e1ee3d921beaabea1741da3e8750cb88feb640ec /extensions | |
parent | 8beb0492c84dbec73febce36559ff244f77ec08e (diff) |
Use string_to_number. Don't check for no optarg: we set has_arg to 1 in option array, so getopt does that for us.
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/libipt_ttl.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/extensions/libipt_ttl.c b/extensions/libipt_ttl.c index 523c8550..ce87368b 100644 --- a/extensions/libipt_ttl.c +++ b/extensions/libipt_ttl.c @@ -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,v 1.6 2002/05/29 13:08:16 laforge Exp $ + * $Id$ * * This program is released under the terms of GNU GPL */ @@ -35,14 +35,14 @@ 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; - u_int8_t value; + int value; check_inverse(optarg, &invert, &optind, 0); - value = atoi(argv[optind-1]); - if (!optarg) + if (string_to_number(optarg, 0, 255, &value) == -1) exit_error(PARAMETER_PROBLEM, - "ttl: You must specify a value"); + "ttl: Expected value between 0 and 255"); + switch (c) { case '2': if (invert) |