From 85f423addb46736e414f70b59c9f885e99aeb488 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 12 May 2011 14:03:36 +0200 Subject: libxtables: collapse double protocol parsing Un-dent xtables_parse_protocol, and make xtopt_parse_protocol make use of it. Signed-off-by: Jan Engelhardt --- xtoptions.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'xtoptions.c') 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; } -- cgit v1.2.3