From e917bca09924435f3fca23c01042543b1826c81e Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 27 Jan 2009 18:14:21 +0100 Subject: extensions: use UINT_MAX constants over open-coded numbers (2/2) Use the handy constants for ranges. Signed-off-by: Jan Engelhardt --- extensions/libxt_TOS.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'extensions/libxt_TOS.c') 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; -- cgit v1.2.3 From 5f2922cfc0bbfbeb878f5c12e9fb3eb602ae5507 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 27 Jan 2009 18:43:01 +0100 Subject: libxtables: prefix/order - strtoui This commit also throws out the redundant string_to_number_*. Signed-off-by: Jan Engelhardt --- extensions/libxt_TOS.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'extensions/libxt_TOS.c') diff --git a/extensions/libxt_TOS.c b/extensions/libxt_TOS.c index a04f7414..96eb4201 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, UINT8_MAX)) + if (!xtables_strtoui(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, UINT8_MAX)) + if (!xtables_strtoui(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, UINT8_MAX)) + if (!xtables_strtoui(optarg, NULL, &bits, 0, UINT8_MAX)) param_act(P_BAD_VALUE, "TOS", "--xor-tos", optarg); info->tos_value = bits; info->tos_mask = 0; -- cgit v1.2.3 From a41545ca7cde43e0ba53260ba74bd9bf74025a68 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 27 Jan 2009 21:27:19 +0100 Subject: libxtables: prefix/order - param_act Changes: exittype -> xtables_exittype P_* -> XTF_* flags Signed-off-by: Jan Engelhardt --- extensions/libxt_TOS.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'extensions/libxt_TOS.c') diff --git a/extensions/libxt_TOS.c b/extensions/libxt_TOS.c index 96eb4201..7b1f7f83 100644 --- a/extensions/libxt_TOS.c +++ b/extensions/libxt_TOS.c @@ -82,10 +82,10 @@ static int tos_tg_parse_v0(int c, char **argv, int invert, unsigned int *flags, switch (c) { case '=': - param_act(P_ONLY_ONCE, "TOS", "--set-tos", *flags & FLAG_TOS); - param_act(P_NO_INVERT, "TOS", "--set-tos", invert); + xtables_param_act(XTF_ONLY_ONCE, "TOS", "--set-tos", *flags & FLAG_TOS); + xtables_param_act(XTF_NO_INVERT, "TOS", "--set-tos", invert); if (!tos_parse_symbolic(optarg, &tvm, 0xFF)) - param_act(P_BAD_VALUE, "TOS", "--set-tos", optarg); + xtables_param_act(XTF_BAD_VALUE, "TOS", "--set-tos", optarg); if (tvm.mask != 0xFF) exit_error(PARAMETER_PROBLEM, "tos match: Your kernel " "is too old to support anything besides " @@ -107,37 +107,37 @@ static int tos_tg_parse(int c, char **argv, int invert, unsigned int *flags, switch (c) { case '=': /* --set-tos */ - param_act(P_ONLY_ONCE, "TOS", "--set-tos", *flags & FLAG_TOS); - param_act(P_NO_INVERT, "TOS", "--set-tos", invert); + xtables_param_act(XTF_ONLY_ONCE, "TOS", "--set-tos", *flags & FLAG_TOS); + xtables_param_act(XTF_NO_INVERT, "TOS", "--set-tos", invert); if (!tos_parse_symbolic(optarg, &tvm, 0x3F)) - param_act(P_BAD_VALUE, "TOS", "--set-tos", optarg); + xtables_param_act(XTF_BAD_VALUE, "TOS", "--set-tos", optarg); info->tos_value = tvm.value; info->tos_mask = tvm.mask; break; case '&': /* --and-tos */ - param_act(P_ONLY_ONCE, "TOS", "--and-tos", *flags & FLAG_TOS); - param_act(P_NO_INVERT, "TOS", "--and-tos", invert); + xtables_param_act(XTF_ONLY_ONCE, "TOS", "--and-tos", *flags & FLAG_TOS); + xtables_param_act(XTF_NO_INVERT, "TOS", "--and-tos", invert); if (!xtables_strtoui(optarg, NULL, &bits, 0, UINT8_MAX)) - param_act(P_BAD_VALUE, "TOS", "--and-tos", optarg); + xtables_param_act(XTF_BAD_VALUE, "TOS", "--and-tos", optarg); info->tos_value = 0; info->tos_mask = ~bits; break; case '|': /* --or-tos */ - param_act(P_ONLY_ONCE, "TOS", "--or-tos", *flags & FLAG_TOS); - param_act(P_NO_INVERT, "TOS", "--or-tos", invert); + xtables_param_act(XTF_ONLY_ONCE, "TOS", "--or-tos", *flags & FLAG_TOS); + xtables_param_act(XTF_NO_INVERT, "TOS", "--or-tos", invert); if (!xtables_strtoui(optarg, NULL, &bits, 0, UINT8_MAX)) - param_act(P_BAD_VALUE, "TOS", "--or-tos", optarg); + xtables_param_act(XTF_BAD_VALUE, "TOS", "--or-tos", optarg); info->tos_value = bits; info->tos_mask = bits; break; case '^': /* --xor-tos */ - param_act(P_ONLY_ONCE, "TOS", "--xor-tos", *flags & FLAG_TOS); - param_act(P_NO_INVERT, "TOS", "--xor-tos", invert); + xtables_param_act(XTF_ONLY_ONCE, "TOS", "--xor-tos", *flags & FLAG_TOS); + xtables_param_act(XTF_NO_INVERT, "TOS", "--xor-tos", invert); if (!xtables_strtoui(optarg, NULL, &bits, 0, UINT8_MAX)) - param_act(P_BAD_VALUE, "TOS", "--xor-tos", optarg); + xtables_param_act(XTF_BAD_VALUE, "TOS", "--xor-tos", optarg); info->tos_value = bits; info->tos_mask = 0; break; -- cgit v1.2.3