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:00:19 +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:00:19 +0000
commit877fab32b43e91b0a55b655a7b7d6ac0844918fd (patch)
treec7345c2720ad5cf6ffb5ebe4bf5bc985b609ec51 /ip6tables.c
parent138ab553e6e7e928ff163bdae0ddd0d403c62d56 (diff)
[PATCH] reduce service_to_port duplication (Phil Oester <kernel@linuxace.com>)
The service_to_port function is used in a number of places, and could benefit from some centralization instead of being duplicated everywhere.
Diffstat (limited to 'ip6tables.c')
-rw-r--r--ip6tables.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ip6tables.c b/ip6tables.c
index 82e9595..6dc7aa2 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -245,6 +245,17 @@ proto_to_name(u_int8_t proto, int nolookup)
return NULL;
}
+int
+service_to_port(const char *name, const char *proto)
+{
+ struct servent *service;
+
+ if ((service = getservbyname(name, proto)) != NULL)
+ return ntohs((unsigned short) service->s_port);
+
+ return -1;
+}
+
static void
in6addrcpy(struct in6_addr *dst, struct in6_addr *src)
{