From 877fab32b43e91b0a55b655a7b7d6ac0844918fd Mon Sep 17 00:00:00 2001 From: "/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=kaber/emailAddress=kaber@netfilter.org" Date: Thu, 20 Jul 2006 17:00:19 +0000 Subject: [PATCH] reduce service_to_port duplication (Phil Oester ) The service_to_port function is used in a number of places, and could benefit from some centralization instead of being duplicated everywhere. --- extensions/libipt_udp.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'extensions/libipt_udp.c') diff --git a/extensions/libipt_udp.c b/extensions/libipt_udp.c index f45f364..a49e8f7 100644 --- a/extensions/libipt_udp.c +++ b/extensions/libipt_udp.c @@ -30,24 +30,13 @@ static struct option opts[] = { {0} }; -static int -service_to_port(const char *name) -{ - struct servent *service; - - if ((service = getservbyname(name, "udp")) != NULL) - return ntohs((unsigned short) service->s_port); - - return -1; -} - static u_int16_t parse_udp_port(const char *port) { unsigned int portnum; if (string_to_number(port, 0, 65535, &portnum) != -1 || - (portnum = service_to_port(port)) != -1) + (portnum = service_to_port(port, "udp")) != -1) return (u_int16_t)portnum; exit_error(PARAMETER_PROBLEM, -- cgit v1.2.3