reduce parse_*_port duplication (Phil Oester <kernel@linuxace.com>)
The below patch (dependent upon my 'reduce service_to_port duplication' patch)
centralizes the parse_*_port functions into parse_port.
diff --git a/ip6tables.c b/ip6tables.c
index 6dc7aa2..ef7e365 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -256,6 +256,19 @@
return -1;
}
+u_int16_t
+parse_port(const char *port, const char *proto)
+{
+ unsigned int portnum;
+
+ if ((string_to_number(port, 0, 65535, &portnum)) != -1 ||
+ (portnum = service_to_port(port, proto)) != -1)
+ return (u_int16_t)portnum;
+
+ exit_error(PARAMETER_PROBLEM,
+ "invalid port/service `%s' specified", port);
+}
+
static void
in6addrcpy(struct in6_addr *dst, struct in6_addr *src)
{