]> granicus.if.org Git - ipset/commitdiff
Support protocol numbers as well, not only protocol names
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 5 Nov 2012 16:01:41 +0000 (17:01 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 5 Nov 2012 16:01:41 +0000 (17:01 +0100)
lib/parse.c

index 65fddd4cb99e6f5f0e6e6414e4f86c247ea753c9..af2168eb365735d57710c27a9cbb00cd5c38c50a 100644 (file)
@@ -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);