summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2012-11-05 17:01:41 +0100
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2012-11-05 17:01:41 +0100
commit355e5495bc3d0d6c90a2dde2f61f35e1a9125a3a (patch)
tree33524eabe9eca5f088fb63cc6e738896c34fbb0a
parent95bc8577e79773847bdd7fe74ae1d25a281a218a (diff)
Support protocol numbers as well, not only protocol names
-rw-r--r--lib/parse.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/parse.c b/lib/parse.c
index 65fddd4..af2168e 100644
--- a/lib/parse.c
+++ b/lib/parse.c
@@ -440,9 +440,15 @@ ipset_parse_proto(struct ipset_session *session,
protoent = getprotobyname(strcasecmp(str, "icmpv6") == 0
? "ipv6-icmp" : str);
- if (protoent == NULL)
- return syntax_err("cannot parse '%s' "
- "as a protocol name", str);
+ if (protoent == NULL) {
+ uint8_t protonum;
+ int err;
+
+ if (!((err = string_to_u8(session, str, &protonum) == 0) &&
+ (protoent = getprotobynumber(protonum)) != NULL))
+ return syntax_err("cannot parse '%s' "
+ "as a protocol", str);
+ }
proto = protoent->p_proto;
if (!proto)
return syntax_err("Unsupported protocol '%s'", str);