diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2009-01-27 18:14:21 +0100 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2009-01-27 23:14:29 +0100 |
commit | e917bca09924435f3fca23c01042543b1826c81e (patch) | |
tree | 4af388f40ddf885f17fa3e8fe791b3f9affd2a14 /extensions | |
parent | a80975497968e69b23f56bf15d346c65bec381f2 (diff) |
extensions: use UINT_MAX constants over open-coded numbers (2/2)
Use the handy constants for ranges.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/libip6t_HL.c | 2 | ||||
-rw-r--r-- | extensions/libip6t_icmp6.c | 4 | ||||
-rw-r--r-- | extensions/libip6t_mh.c | 2 | ||||
-rw-r--r-- | extensions/libipt_TTL.c | 2 | ||||
-rw-r--r-- | extensions/libipt_icmp.c | 4 | ||||
-rw-r--r-- | extensions/libipt_ttl.c | 6 | ||||
-rw-r--r-- | extensions/libxt_DSCP.c | 2 | ||||
-rw-r--r-- | extensions/libxt_NFQUEUE.c | 2 | ||||
-rw-r--r-- | extensions/libxt_TCPMSS.c | 2 | ||||
-rw-r--r-- | extensions/libxt_TCPOPTSTRIP.c | 2 | ||||
-rw-r--r-- | extensions/libxt_TOS.c | 6 | ||||
-rw-r--r-- | extensions/libxt_TPROXY.c | 2 | ||||
-rw-r--r-- | extensions/libxt_dccp.c | 2 | ||||
-rw-r--r-- | extensions/libxt_dscp.c | 2 | ||||
-rw-r--r-- | extensions/libxt_hashlimit.c | 16 | ||||
-rw-r--r-- | extensions/libxt_length.c | 2 | ||||
-rw-r--r-- | extensions/libxt_statistic.c | 4 | ||||
-rw-r--r-- | extensions/libxt_tcp.c | 2 | ||||
-rw-r--r-- | extensions/libxt_tcpmss.c | 2 | ||||
-rw-r--r-- | extensions/tos_values.c | 2 |
20 files changed, 34 insertions, 34 deletions
diff --git a/extensions/libip6t_HL.c b/extensions/libip6t_HL.c index 92266e49..8f555722 100644 --- a/extensions/libip6t_HL.c +++ b/extensions/libip6t_HL.c @@ -44,7 +44,7 @@ static int HL_parse(int c, char **argv, int invert, unsigned int *flags, exit_error(PARAMETER_PROBLEM, "HL: unexpected `!'"); - if (string_to_number(optarg, 0, 255, &value) == -1) + if (string_to_number(optarg, 0, UINT8_MAX, &value) == -1) exit_error(PARAMETER_PROBLEM, "HL: Expected value between 0 and 255"); diff --git a/extensions/libip6t_icmp6.c b/extensions/libip6t_icmp6.c index b87538f9..17567dfb 100644 --- a/extensions/libip6t_icmp6.c +++ b/extensions/libip6t_icmp6.c @@ -123,12 +123,12 @@ parse_icmpv6(const char *icmpv6type, u_int8_t *type, u_int8_t code[]) if (slash) *slash = '\0'; - if (string_to_number(buffer, 0, 255, &number) == -1) + if (string_to_number(buffer, 0, UINT8_MAX, &number) == -1) exit_error(PARAMETER_PROBLEM, "Invalid ICMPv6 type `%s'\n", buffer); *type = number; if (slash) { - if (string_to_number(slash+1, 0, 255, &number) == -1) + if (string_to_number(slash+1, 0, UINT8_MAX, &number) == -1) exit_error(PARAMETER_PROBLEM, "Invalid ICMPv6 code `%s'\n", slash+1); diff --git a/extensions/libip6t_mh.c b/extensions/libip6t_mh.c index e76d7c36..8b58bcdf 100644 --- a/extensions/libip6t_mh.c +++ b/extensions/libip6t_mh.c @@ -93,7 +93,7 @@ static unsigned int name_to_type(const char *name) } else { unsigned int number; - if (string_to_number(name, 0, 255, &number) == -1) + if (string_to_number(name, 0, UINT8_MAX, &number) == -1) exit_error(PARAMETER_PROBLEM, "Invalid MH type `%s'\n", name); return number; diff --git a/extensions/libipt_TTL.c b/extensions/libipt_TTL.c index 7647f2f7..e124381e 100644 --- a/extensions/libipt_TTL.c +++ b/extensions/libipt_TTL.c @@ -44,7 +44,7 @@ static int TTL_parse(int c, char **argv, int invert, unsigned int *flags, exit_error(PARAMETER_PROBLEM, "TTL: unexpected `!'"); - if (string_to_number(optarg, 0, 255, &value) == -1) + if (string_to_number(optarg, 0, UINT8_MAX, &value) == -1) exit_error(PARAMETER_PROBLEM, "TTL: Expected value between 0 and 255"); diff --git a/extensions/libipt_icmp.c b/extensions/libipt_icmp.c index fa5a5409..7aff9caa 100644 --- a/extensions/libipt_icmp.c +++ b/extensions/libipt_icmp.c @@ -147,12 +147,12 @@ parse_icmp(const char *icmptype, u_int8_t *type, u_int8_t code[]) if (slash) *slash = '\0'; - if (string_to_number(buffer, 0, 255, &number) == -1) + if (string_to_number(buffer, 0, UINT8_MAX, &number) == -1) exit_error(PARAMETER_PROBLEM, "Invalid ICMP type `%s'\n", buffer); *type = number; if (slash) { - if (string_to_number(slash+1, 0, 255, &number) == -1) + if (string_to_number(slash+1, 0, UINT8_MAX, &number) == -1) exit_error(PARAMETER_PROBLEM, "Invalid ICMP code `%s'\n", slash+1); diff --git a/extensions/libipt_ttl.c b/extensions/libipt_ttl.c index 055c92ee..a8455e1d 100644 --- a/extensions/libipt_ttl.c +++ b/extensions/libipt_ttl.c @@ -33,7 +33,7 @@ static int ttl_parse(int c, char **argv, int invert, unsigned int *flags, switch (c) { case '2': - if (string_to_number(optarg, 0, 255, &value) == -1) + if (string_to_number(optarg, 0, UINT8_MAX, &value) == -1) exit_error(PARAMETER_PROBLEM, "ttl: Expected value between 0 and 255"); @@ -46,7 +46,7 @@ static int ttl_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) + if (string_to_number(optarg, 0, UINT8_MAX, &value) == -1) exit_error(PARAMETER_PROBLEM, "ttl: Expected value between 0 and 255"); @@ -58,7 +58,7 @@ static int ttl_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) + if (string_to_number(optarg, 0, UINT8_MAX, &value) == -1) exit_error(PARAMETER_PROBLEM, "ttl: Expected value between 0 and 255"); diff --git a/extensions/libxt_DSCP.c b/extensions/libxt_DSCP.c index 409fa196..92a6de5b 100644 --- a/extensions/libxt_DSCP.c +++ b/extensions/libxt_DSCP.c @@ -48,7 +48,7 @@ parse_dscp(const char *s, struct xt_DSCP_info *dinfo) { unsigned int dscp; - if (string_to_number(s, 0, 255, &dscp) == -1) + if (string_to_number(s, 0, UINT8_MAX, &dscp) == -1) exit_error(PARAMETER_PROBLEM, "Invalid dscp `%s'\n", s); diff --git a/extensions/libxt_NFQUEUE.c b/extensions/libxt_NFQUEUE.c index 58807853..1a58760b 100644 --- a/extensions/libxt_NFQUEUE.c +++ b/extensions/libxt_NFQUEUE.c @@ -33,7 +33,7 @@ parse_num(const char *s, struct xt_NFQ_info *tinfo) { unsigned int num; - if (string_to_number(s, 0, 65535, &num) == -1) + if (string_to_number(s, 0, UINT16_MAX, &num) == -1) exit_error(PARAMETER_PROBLEM, "Invalid queue number `%s'\n", s); diff --git a/extensions/libxt_TCPMSS.c b/extensions/libxt_TCPMSS.c index 2227eb48..9b62a56b 100644 --- a/extensions/libxt_TCPMSS.c +++ b/extensions/libxt_TCPMSS.c @@ -55,7 +55,7 @@ static int __TCPMSS_parse(int c, char **argv, int invert, unsigned int *flags, if (*flags) exit_error(PARAMETER_PROBLEM, "TCPMSS target: Only one option may be specified"); - if (string_to_number(optarg, 0, 65535 - hdrsize, &mssval) == -1) + if (string_to_number(optarg, 0, UINT16_MAX - hdrsize, &mssval) == -1) exit_error(PARAMETER_PROBLEM, "Bad TCPMSS value `%s'", optarg); mssinfo->mss = mssval; diff --git a/extensions/libxt_TCPOPTSTRIP.c b/extensions/libxt_TCPOPTSTRIP.c index 758f8476..7211288e 100644 --- a/extensions/libxt_TCPOPTSTRIP.c +++ b/extensions/libxt_TCPOPTSTRIP.c @@ -82,7 +82,7 @@ static void parse_list(struct xt_tcpoptstrip_target_info *info, char *arg) break; } - if (option == 0 && string_to_number(arg, 0, 255, &option) == -1) + if (option == 0 && string_to_number(arg, 0, UINT8_MAX, &option) == -1) exit_error(PARAMETER_PROBLEM, "Bad TCP option value \"%s\"", arg); diff --git a/extensions/libxt_TOS.c b/extensions/libxt_TOS.c index c1856817..a04f7414 100644 --- a/extensions/libxt_TOS.c +++ b/extensions/libxt_TOS.c @@ -118,7 +118,7 @@ static int tos_tg_parse(int c, char **argv, int invert, unsigned int *flags, case '&': /* --and-tos */ param_act(P_ONLY_ONCE, "TOS", "--and-tos", *flags & FLAG_TOS); param_act(P_NO_INVERT, "TOS", "--and-tos", invert); - if (!strtonum(optarg, NULL, &bits, 0, 0xFF)) + if (!strtonum(optarg, NULL, &bits, 0, UINT8_MAX)) param_act(P_BAD_VALUE, "TOS", "--and-tos", optarg); info->tos_value = 0; info->tos_mask = ~bits; @@ -127,7 +127,7 @@ static int tos_tg_parse(int c, char **argv, int invert, unsigned int *flags, case '|': /* --or-tos */ param_act(P_ONLY_ONCE, "TOS", "--or-tos", *flags & FLAG_TOS); param_act(P_NO_INVERT, "TOS", "--or-tos", invert); - if (!strtonum(optarg, NULL, &bits, 0, 0xFF)) + if (!strtonum(optarg, NULL, &bits, 0, UINT8_MAX)) param_act(P_BAD_VALUE, "TOS", "--or-tos", optarg); info->tos_value = bits; info->tos_mask = bits; @@ -136,7 +136,7 @@ static int tos_tg_parse(int c, char **argv, int invert, unsigned int *flags, case '^': /* --xor-tos */ param_act(P_ONLY_ONCE, "TOS", "--xor-tos", *flags & FLAG_TOS); param_act(P_NO_INVERT, "TOS", "--xor-tos", invert); - if (!strtonum(optarg, NULL, &bits, 0, 0xFF)) + if (!strtonum(optarg, NULL, &bits, 0, UINT8_MAX)) param_act(P_BAD_VALUE, "TOS", "--xor-tos", optarg); info->tos_value = bits; info->tos_mask = 0; diff --git a/extensions/libxt_TPROXY.c b/extensions/libxt_TPROXY.c index e9a41a15..41ca2436 100644 --- a/extensions/libxt_TPROXY.c +++ b/extensions/libxt_TPROXY.c @@ -40,7 +40,7 @@ static void parse_tproxy_lport(const char *s, struct xt_tproxy_target_info *info { unsigned int lport; - if (string_to_number(s, 0, 65535, &lport) != -1) + if (string_to_number(s, 0, UINT16_MAX, &lport) != -1) info->lport = htons(lport); else param_act(P_BAD_VALUE, "TPROXY", "--on-port", s); diff --git a/extensions/libxt_dccp.c b/extensions/libxt_dccp.c index b1ae62ee..0eb95cef 100644 --- a/extensions/libxt_dccp.c +++ b/extensions/libxt_dccp.c @@ -121,7 +121,7 @@ static u_int8_t parse_dccp_option(char *optstring) { unsigned int ret; - if (string_to_number(optstring, 1, 255, &ret) == -1) + if (string_to_number(optstring, 1, UINT8_MAX, &ret) == -1) exit_error(PARAMETER_PROBLEM, "Bad DCCP option `%s'", optstring); diff --git a/extensions/libxt_dscp.c b/extensions/libxt_dscp.c index 315e219a..ae5a6248 100644 --- a/extensions/libxt_dscp.c +++ b/extensions/libxt_dscp.c @@ -48,7 +48,7 @@ parse_dscp(const char *s, struct xt_dscp_info *dinfo) { unsigned int dscp; - if (string_to_number(s, 0, 255, &dscp) == -1) + if (string_to_number(s, 0, UINT8_MAX, &dscp) == -1) exit_error(PARAMETER_PROBLEM, "Invalid dscp `%s'\n", s); diff --git a/extensions/libxt_hashlimit.c b/extensions/libxt_hashlimit.c index 1c506852..278e098e 100644 --- a/extensions/libxt_hashlimit.c +++ b/extensions/libxt_hashlimit.c @@ -240,7 +240,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags, param_act(P_ONLY_ONCE, "hashlimit", "--hashlimit-htable-size", *flags & PARAM_SIZE); if (check_inverse(argv[optind-1], &invert, &optind, 0)) break; - if (string_to_number(optarg, 0, 0xffffffff, &num) == -1) + if (string_to_number(optarg, 0, UINT32_MAX, &num) == -1) exit_error(PARAMETER_PROBLEM, "bad --hashlimit-htable-size: `%s'", optarg); r->cfg.size = num; @@ -250,7 +250,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags, param_act(P_ONLY_ONCE, "hashlimit", "--hashlimit-htable-max", *flags & PARAM_MAX); if (check_inverse(argv[optind-1], &invert, &optind, 0)) break; - if (string_to_number(optarg, 0, 0xffffffff, &num) == -1) + if (string_to_number(optarg, 0, UINT32_MAX, &num) == -1) exit_error(PARAMETER_PROBLEM, "bad --hashlimit-htable-max: `%s'", optarg); r->cfg.max = num; @@ -261,7 +261,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags, "--hashlimit-htable-gcinterval", *flags & PARAM_GCINTERVAL); if (check_inverse(argv[optind-1], &invert, &optind, 0)) break; - if (string_to_number(optarg, 0, 0xffffffff, &num) == -1) + if (string_to_number(optarg, 0, UINT32_MAX, &num) == -1) exit_error(PARAMETER_PROBLEM, "bad --hashlimit-htable-gcinterval: `%s'", optarg); @@ -273,7 +273,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags, param_act(P_ONLY_ONCE, "hashlimit", "--hashlimit-htable-expire", *flags & PARAM_EXPIRE); if (check_inverse(argv[optind-1], &invert, &optind, 0)) break; - if (string_to_number(optarg, 0, 0xffffffff, &num) == -1) + if (string_to_number(optarg, 0, UINT32_MAX, &num) == -1) exit_error(PARAMETER_PROBLEM, "bad --hashlimit-htable-expire: `%s'", optarg); /* FIXME: not HZ dependent */ @@ -351,7 +351,7 @@ hashlimit_mt_parse(struct xt_hashlimit_mtinfo1 *info, unsigned int *flags, case '&': /* --hashlimit-htable-size */ param_act(P_ONLY_ONCE, "hashlimit", "--hashlimit-htable-size", *flags & PARAM_SIZE); - if (!strtonum(optarg, NULL, &num, 0, 0xffffffff)) + if (!strtonum(optarg, NULL, &num, 0, UINT32_MAX)) param_act(P_BAD_VALUE, "hashlimit", "--hashlimit-htable-size", optarg); info->cfg.size = num; @@ -361,7 +361,7 @@ hashlimit_mt_parse(struct xt_hashlimit_mtinfo1 *info, unsigned int *flags, case '*': /* --hashlimit-htable-max */ param_act(P_ONLY_ONCE, "hashlimit", "--hashlimit-htable-max", *flags & PARAM_MAX); - if (!strtonum(optarg, NULL, &num, 0, 0xffffffff)) + if (!strtonum(optarg, NULL, &num, 0, UINT32_MAX)) param_act(P_BAD_VALUE, "hashlimit", "--hashlimit-htable-max", optarg); info->cfg.max = num; @@ -372,7 +372,7 @@ hashlimit_mt_parse(struct xt_hashlimit_mtinfo1 *info, unsigned int *flags, param_act(P_ONLY_ONCE, "hashlimit", "--hashlimit-htable-gcinterval", *flags & PARAM_GCINTERVAL); - if (!strtonum(optarg, NULL, &num, 0, 0xffffffff)) + if (!strtonum(optarg, NULL, &num, 0, UINT32_MAX)) param_act(P_BAD_VALUE, "hashlimit", "--hashlimit-htable-gcinterval", optarg); /* FIXME: not HZ dependent!! */ @@ -383,7 +383,7 @@ hashlimit_mt_parse(struct xt_hashlimit_mtinfo1 *info, unsigned int *flags, case ')': /* --hashlimit-htable-expire */ param_act(P_ONLY_ONCE, "hashlimit", "--hashlimit-htable-expire", *flags & PARAM_EXPIRE); - if (!strtonum(optarg, NULL, &num, 0, 0xffffffff)) + if (!strtonum(optarg, NULL, &num, 0, UINT32_MAX)) param_act(P_BAD_VALUE, "hashlimit", "--hashlimit-htable-expire", optarg); /* FIXME: not HZ dependent */ diff --git a/extensions/libxt_length.c b/extensions/libxt_length.c index e350431c..0e196d78 100644 --- a/extensions/libxt_length.c +++ b/extensions/libxt_length.c @@ -26,7 +26,7 @@ parse_length(const char *s) { unsigned int len; - if (string_to_number(s, 0, 0xFFFF, &len) == -1) + if (string_to_number(s, 0, UINT16_MAX, &len) == -1) exit_error(PARAMETER_PROBLEM, "length invalid: `%s'\n", s); else return len; diff --git a/extensions/libxt_statistic.c b/extensions/libxt_statistic.c index d85aacbd..e43de7d2 100644 --- a/extensions/libxt_statistic.c +++ b/extensions/libxt_statistic.c @@ -70,7 +70,7 @@ statistic_parse(int c, char **argv, int invert, unsigned int *flags, case '3': if (*flags & 0x4) exit_error(PARAMETER_PROBLEM, "double --every"); - if (string_to_number(optarg, 0, 0xFFFFFFFF, + if (string_to_number(optarg, 0, UINT32_MAX, &info->u.nth.every) == -1) exit_error(PARAMETER_PROBLEM, "cannot parse --every `%s'", optarg); @@ -82,7 +82,7 @@ statistic_parse(int c, char **argv, int invert, unsigned int *flags, case '4': if (*flags & 0x8) exit_error(PARAMETER_PROBLEM, "double --packet"); - if (string_to_number(optarg, 0, 0xFFFFFFFF, + if (string_to_number(optarg, 0, UINT32_MAX, &info->u.nth.packet) == -1) exit_error(PARAMETER_PROBLEM, "cannot parse --packet `%s'", optarg); diff --git a/extensions/libxt_tcp.c b/extensions/libxt_tcp.c index a9039f0b..82954a4e 100644 --- a/extensions/libxt_tcp.c +++ b/extensions/libxt_tcp.c @@ -121,7 +121,7 @@ parse_tcp_option(const char *option, u_int8_t *result) { unsigned int ret; - if (string_to_number(option, 1, 255, &ret) == -1) + if (string_to_number(option, 1, UINT8_MAX, &ret) == -1) exit_error(PARAMETER_PROBLEM, "Bad TCP option `%s'", option); *result = ret; diff --git a/extensions/libxt_tcpmss.c b/extensions/libxt_tcpmss.c index a720c425..e64a1b33 100644 --- a/extensions/libxt_tcpmss.c +++ b/extensions/libxt_tcpmss.c @@ -26,7 +26,7 @@ parse_tcp_mssvalue(const char *mssvalue) { unsigned int mssvaluenum; - if (string_to_number(mssvalue, 0, 65535, &mssvaluenum) != -1) + if (string_to_number(mssvalue, 0, UINT16_MAX, &mssvaluenum) != -1) return mssvaluenum; exit_error(PARAMETER_PROBLEM, diff --git a/extensions/tos_values.c b/extensions/tos_values.c index 0ab784da..2d5b4312 100644 --- a/extensions/tos_values.c +++ b/extensions/tos_values.c @@ -55,7 +55,7 @@ static bool tos_parse_numeric(const char *str, struct tos_value_mask *tvm, static bool tos_parse_symbolic(const char *str, struct tos_value_mask *tvm, unsigned int def_mask) { - const unsigned int max = 255; + const unsigned int max = UINT8_MAX; const struct tos_symbol_info *symbol; char *tmp; |