summaryrefslogtreecommitdiffstats
path: root/iptables/xshared.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2023-11-29 00:30:02 +0100
committerPhil Sutter <phil@nwl.cc>2023-12-05 16:35:37 +0100
commit12d780775b5e34bcc2e0c34c550a6d5d96028628 (patch)
treebf178f48d2154ce67af2893d88a6f7adb07f6b4c /iptables/xshared.c
parentb6acee49227a0009cf22c3a3bfa29ea608896649 (diff)
xshared: Introduce option_test_and_reject()
Just a small helper eliminating the repetitive code there. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xshared.c')
-rw-r--r--iptables/xshared.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/iptables/xshared.c b/iptables/xshared.c
index 50f23757..ebe17222 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -1439,6 +1439,15 @@ static void parse_change_counters_rule(int argc, char **argv,
"Packet counter '%s' invalid", argv[optind - 1]);
}
+static void option_test_and_reject(struct xt_cmd_parse *p,
+ struct iptables_command_state *cs,
+ unsigned int option)
+{
+ if (cs->options & option)
+ xtables_error(PARAMETER_PROBLEM, "Can't use %s with %s",
+ p->ops->option_name(option), p->chain);
+}
+
void do_parse(int argc, char *argv[],
struct xt_cmd_parse *p, struct iptables_command_state *cs,
struct xtables_args *args)
@@ -1924,21 +1933,13 @@ void do_parse(int argc, char *argv[],
if (strcmp(p->chain, "PREROUTING") == 0
|| strcmp(p->chain, "INPUT") == 0) {
/* -o not valid with incoming packets. */
- if (cs->options & OPT_VIANAMEOUT)
- xtables_error(PARAMETER_PROBLEM,
- "Can't use %s with %s\n",
- p->ops->option_name(OPT_VIANAMEOUT),
- p->chain);
+ option_test_and_reject(p, cs, OPT_VIANAMEOUT);
}
if (strcmp(p->chain, "POSTROUTING") == 0
|| strcmp(p->chain, "OUTPUT") == 0) {
/* -i not valid with outgoing packets */
- if (cs->options & OPT_VIANAMEIN)
- xtables_error(PARAMETER_PROBLEM,
- "Can't use %s with %s\n",
- p->ops->option_name(OPT_VIANAMEIN),
- p->chain);
+ option_test_and_reject(p, cs, OPT_VIANAMEIN);
}
}
}