diff options
author | Phil Oester <kernel@linuxace.com> | 2006-07-20 17:01:54 +0000 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2006-07-20 17:01:54 +0000 |
commit | dbac8ad71c3c418fd8a62c08211885a38177b725 (patch) | |
tree | f12056e44275c023cef77e131ef9038e9efc3915 /iptables.c | |
parent | 58179b1d0d1722ea16028aa2ea9d74afc86dd5dc (diff) |
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.
Diffstat (limited to 'iptables.c')
-rw-r--r-- | iptables.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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) { |