summaryrefslogtreecommitdiffstats
path: root/ip6tables.c
diff options
context:
space:
mode:
author/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=kaber/emailAddress=kaber@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=kaber/emailAddress=kaber@netfilter.org>2006-07-20 17:01:54 +0000
committer/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=kaber/emailAddress=kaber@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=kaber/emailAddress=kaber@netfilter.org>2006-07-20 17:01:54 +0000
commit18c7ec36ac949aaaf28aa25d11c0289a88d35592 (patch)
treef12056e44275c023cef77e131ef9038e9efc3915 /ip6tables.c
parent877fab32b43e91b0a55b655a7b7d6ac0844918fd (diff)
[PATCH] 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 'ip6tables.c')
-rw-r--r--ip6tables.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ip6tables.c b/ip6tables.c
index 6dc7aa2..ef7e365 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)
{