summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ip6tables.c100
-rw-r--r--iptables.c109
2 files changed, 91 insertions, 118 deletions
diff --git a/ip6tables.c b/ip6tables.c
index 3330420f..c475bf26 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -1247,71 +1247,59 @@ static void command_default(struct iptables_command_state *cs)
if (cs->target == NULL || cs->target->parse == NULL ||
cs->c < cs->target->option_offset ||
- cs->c >= cs->target->option_offset + XT_OPTION_OFFSET_SCALE ||
- !cs->target->parse(cs->c - cs->target->option_offset,
- cs->argv, cs->invert,
- &cs->target->tflags,
- &cs->fw6, &cs->target->t)) {
- for (matchp = cs->matches; matchp; matchp = matchp->next) {
- if (matchp->completed ||
- matchp->match->parse == NULL)
- continue;
- if (cs->c < matchp->match->option_offset ||
- cs->c >= matchp->match->option_offset + XT_OPTION_OFFSET_SCALE)
- continue;
- if (matchp->match->parse(cs->c - matchp->match->option_offset,
- cs->argv, cs->invert,
- &matchp->match->mflags,
- &cs->fw6,
- &matchp->match->m))
- break;
- }
- m = matchp ? matchp->match : NULL;
+ cs->c >= cs->target->option_offset + XT_OPTION_OFFSET_SCALE) {
+ cs->target->parse(cs->c - cs->target->option_offset, cs->argv,
+ cs->invert, &cs->target->tflags, &cs->fw6,
+ &cs->target->t);
+ return;
+ }
- if (m == NULL && (m = load_proto(cs)) != NULL) {
- /* Try loading protocol */
- size_t size;
+ for (matchp = cs->matches; matchp; matchp = matchp->next) {
+ m = matchp->match;
- cs->proto_used = 1;
+ if (matchp->completed || m->parse == NULL)
+ continue;
+ if (cs->c < matchp->match->option_offset ||
+ cs->c >= matchp->match->option_offset + XT_OPTION_OFFSET_SCALE)
+ continue;
+ m->parse(cs->c - m->option_offset, cs->argv, cs->invert,
+ &m->mflags, &cs->fw6, &m->m);
+ return;
+ }
- size = IP6T_ALIGN(sizeof(struct ip6t_entry_match))
- + m->size;
+ /* Try loading protocol */
+ m = load_proto(cs);
+ if (m != NULL) {
+ size_t size;
- m->m = xtables_calloc(1, size);
- m->m->u.match_size = size;
- strcpy(m->m->u.user.name, m->name);
- m->m->u.user.revision = m->revision;
- if (m->init != NULL)
- m->init(m->m);
+ cs->proto_used = 1;
- opts = xtables_merge_options(ip6tables_globals.orig_opts, opts,
- m->extra_opts, &m->option_offset);
+ size = IP6T_ALIGN(sizeof(struct ip6t_entry_match)) + m->size;
- optind--;
- return;
- }
+ m->m = xtables_calloc(1, size);
+ m->m->u.match_size = size;
+ strcpy(m->m->u.user.name, m->name);
+ m->m->u.user.revision = m->revision;
+ if (m->init != NULL)
+ m->init(m->m);
- if (!m) {
- if (cs->c == '?') {
- if (optopt) {
- xtables_error(
- PARAMETER_PROBLEM,
- "option `%s' "
- "requires an "
- "argument",
- cs->argv[optind-1]);
- } else {
- xtables_error(
- PARAMETER_PROBLEM,
- "unknown option "
- "`%s'",
- cs->argv[optind-1]);
- }
- }
+ opts = xtables_merge_options(ip6tables_globals.orig_opts, opts,
+ m->extra_opts, &m->option_offset);
+
+ optind--;
+ return;
+ }
+
+ if (cs->c == '?') {
+ if (optopt)
xtables_error(PARAMETER_PROBLEM,
- "Unknown arg `%s'", optarg);
- }
+ "option \"%s\" requires an argument",
+ cs->argv[optind-1]);
+ else
+ xtables_error(PARAMETER_PROBLEM,
+ "unknown option \"%s\"", cs->argv[optind-1]);
}
+ xtables_error(PARAMETER_PROBLEM, "Unknown arg \"%s\"", optarg);
}
int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **handle)
diff --git a/iptables.c b/iptables.c
index bae14afc..96732b40 100644
--- a/iptables.c
+++ b/iptables.c
@@ -1271,76 +1271,61 @@ static void command_default(struct iptables_command_state *cs)
if (cs->target == NULL || cs->target->parse == NULL ||
cs->c < cs->target->option_offset ||
- cs->c >= cs->target->option_offset + XT_OPTION_OFFSET_SCALE ||
- !cs->target->parse(cs->c - cs->target->option_offset,
- cs->argv, cs->invert,
- &cs->target->tflags,
- &cs->fw, &cs->target->t)) {
- for (matchp = cs->matches; matchp; matchp = matchp->next) {
- if (matchp->completed ||
- matchp->match->parse == NULL)
- continue;
- if (cs->c < matchp->match->option_offset ||
- cs->c >= matchp->match->option_offset + XT_OPTION_OFFSET_SCALE)
- continue;
- if (matchp->match->parse(cs->c - matchp->match->option_offset,
- cs->argv, cs->invert,
- &matchp->match->mflags,
- &cs->fw,
- &matchp->match->m))
- break;
- }
- m = matchp ? matchp->match : NULL;
+ cs->c >= cs->target->option_offset + XT_OPTION_OFFSET_SCALE) {
+ cs->target->parse(cs->c - cs->target->option_offset, cs->argv,
+ cs->invert, &cs->target->tflags, &cs->fw,
+ &cs->target->t);
+ return;
+ }
- if (m == NULL && (m = load_proto(cs)) != NULL) {
- /* Try loading protocol */
- size_t size;
+ for (matchp = cs->matches; matchp; matchp = matchp->next) {
+ m = matchp->match;
- cs->proto_used = 1;
+ if (matchp->completed || m->parse == NULL)
+ continue;
+ if (cs->c < m->option_offset ||
+ cs->c >= m->option_offset + XT_OPTION_OFFSET_SCALE)
+ continue;
+ m->parse(cs->c - m->option_offset, cs->argv, cs->invert,
+ &m->mflags, &cs->fw, &m->m);
+ return;
+ }
- size = IPT_ALIGN(sizeof(struct ipt_entry_match))
- + m->size;
+ /* Try loading protocol */
+ m = load_proto(cs);
+ if (m != NULL) {
+ size_t size;
- m->m = xtables_calloc(1, size);
- m->m->u.match_size = size;
- strcpy(m->m->u.user.name, m->name);
- m->m->u.user.revision = m->revision;
- if (m->init != NULL)
- m->init(m->m);
+ cs->proto_used = 1;
- opts = xtables_merge_options(
- iptables_globals.orig_opts,
- opts,
- m->extra_opts,
- &m->option_offset);
- if (opts == NULL)
- xtables_error(OTHER_PROBLEM,
- "can't alloc memory!");
+ size = IPT_ALIGN(sizeof(struct ipt_entry_match)) + m->size;
- optind--;
- return;
- }
- if (!m) {
- if (cs->c == '?') {
- if (optopt) {
- xtables_error(
- PARAMETER_PROBLEM,
- "option `%s' "
- "requires an "
- "argument",
- cs->argv[optind-1]);
- } else {
- xtables_error(
- PARAMETER_PROBLEM,
- "unknown option "
- "`%s'",
- cs->argv[optind-1]);
- }
- }
+ m->m = xtables_calloc(1, size);
+ m->m->u.match_size = size;
+ strcpy(m->m->u.user.name, m->name);
+ m->m->u.user.revision = m->revision;
+ if (m->init != NULL)
+ m->init(m->m);
+
+ opts = xtables_merge_options(iptables_globals.orig_opts, opts,
+ m->extra_opts, &m->option_offset);
+ if (opts == NULL)
+ xtables_error(OTHER_PROBLEM, "can't alloc memory!");
+
+ optind--;
+ return;
+ }
+
+ if (cs->c == '?') {
+ if (optopt)
xtables_error(PARAMETER_PROBLEM,
- "Unknown arg `%s'", optarg);
- }
+ "option \"%s\" requires an argument",
+ cs->argv[optind-1]);
+ else
+ xtables_error(PARAMETER_PROBLEM,
+ "unknown option \"%s\"", cs->argv[optind-1]);
}
+ xtables_error(PARAMETER_PROBLEM, "Unknown arg \"%s\"", optarg);
}
int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle)