From dbac8ad71c3c418fd8a62c08211885a38177b725 Mon Sep 17 00:00:00 2001 From: Phil Oester Date: Thu, 20 Jul 2006 17:01:54 +0000 Subject: reduce parse_*_port duplication (Phil Oester ) The below patch (dependent upon my 'reduce service_to_port duplication' patch) centralizes the parse_*_port functions into parse_port. --- ip6tables.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ip6tables.c') diff --git a/ip6tables.c b/ip6tables.c index 6dc7aa2d..ef7e3653 100644 --- a/ip6tables.c +++ b/ip6tables.c @@ -256,6 +256,19 @@ service_to_port(const char *name, const char *proto) 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) { -- cgit v1.2.3