From 58179b1d0d1722ea16028aa2ea9d74afc86dd5dc Mon Sep 17 00:00:00 2001 From: Phil Oester Date: Thu, 20 Jul 2006 17:00:19 +0000 Subject: 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_dccp.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'extensions/libipt_dccp.c') diff --git a/extensions/libipt_dccp.c b/extensions/libipt_dccp.c index af1d20e2..603be1de 100644 --- a/extensions/libipt_dccp.c +++ b/extensions/libipt_dccp.c @@ -56,17 +56,6 @@ static struct option opts[] = { { .name = 0 } }; -static int -service_to_port(const char *name) -{ - struct servent *service; - - if ((service = getservbyname(name, "dccp")) != NULL) - return ntohs((unsigned short) service->s_port); - - return -1; -} - static u_int16_t parse_dccp_port(const char *port) { @@ -74,7 +63,7 @@ parse_dccp_port(const char *port) DEBUGP("%s\n", port); if (string_to_number(port, 0, 65535, &portnum) != -1 || - (portnum = service_to_port(port)) != -1) + (portnum = service_to_port(port, "dccp")) != -1) return (u_int16_t)portnum; exit_error(PARAMETER_PROBLEM, -- cgit v1.2.3