summaryrefslogtreecommitdiffstats
path: root/xtoptions.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2011-05-12 14:03:36 +0200
committerJan Engelhardt <jengelh@medozas.de>2011-05-12 14:03:37 +0200
commit85f423addb46736e414f70b59c9f885e99aeb488 (patch)
tree6bb9fd45a3d0f891e95ad8c818ccdcf4e3ea40a7 /xtoptions.c
parentcdc8e0b252c14a17b47e1c89a2fa4dbac2002473 (diff)
libxtables: collapse double protocol parsing
Un-dent xtables_parse_protocol, and make xtopt_parse_protocol make use of it. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'xtoptions.c')
-rw-r--r--xtoptions.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/xtoptions.c b/xtoptions.c
index 9e19250b..eb9e4e6b 100644
--- a/xtoptions.c
+++ b/xtoptions.c
@@ -498,19 +498,7 @@ static int xtables_getportbyname(const char *name)
*/
static void xtopt_parse_protocol(struct xt_option_call *cb)
{
- const struct protoent *entry;
- unsigned int value = -1;
-
- if (xtables_strtoui(cb->arg, NULL, &value, 0, UINT8_MAX)) {
- cb->val.protocol = value;
- return;
- }
- entry = getprotobyname(cb->arg);
- if (entry == NULL)
- xt_params->exit_err(PARAMETER_PROBLEM,
- "Protocol \"%s\" does not resolve to anything.\n",
- cb->arg);
- cb->val.protocol = entry->p_proto;
+ cb->val.protocol = xtables_parse_protocol(cb->arg);
if (cb->entry->flags & XTOPT_PUT)
*(uint8_t *)XTOPT_MKPTR(cb) = cb->val.protocol;
}