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