summaryrefslogtreecommitdiffstats
path: root/iptables.c
diff options
context:
space:
mode:
Diffstat (limited to 'iptables.c')
-rw-r--r--iptables.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/iptables.c b/iptables.c
index 56921db7..28917cf1 100644
--- a/iptables.c
+++ b/iptables.c
@@ -260,6 +260,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);
+}
+
struct in_addr *
dotted_to_addr(const char *dotted)
{