From dbac8ad71c3c418fd8a62c08211885a38177b725 Mon Sep 17 00:00:00 2001 From: Phil Oester Date: Thu, 20 Jul 2006 17:01:54 +0000 Subject: reduce parse_*_port duplication (Phil Oester ) The below patch (dependent upon my 'reduce service_to_port duplication' patch) centralizes the parse_*_port functions into parse_port. --- extensions/libipt_dccp.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'extensions/libipt_dccp.c') diff --git a/extensions/libipt_dccp.c b/extensions/libipt_dccp.c index 603be1de..e5782a85 100644 --- a/extensions/libipt_dccp.c +++ b/extensions/libipt_dccp.c @@ -56,20 +56,6 @@ static struct option opts[] = { { .name = 0 } }; -static u_int16_t -parse_dccp_port(const char *port) -{ - unsigned int portnum; - - DEBUGP("%s\n", port); - if (string_to_number(port, 0, 65535, &portnum) != -1 || - (portnum = service_to_port(port, "dccp")) != -1) - return (u_int16_t)portnum; - - exit_error(PARAMETER_PROBLEM, - "invalid DCCP port/service `%s' specified", port); -} - static void parse_dccp_ports(const char *portstring, u_int16_t *ports) @@ -80,14 +66,14 @@ parse_dccp_ports(const char *portstring, buffer = strdup(portstring); DEBUGP("%s\n", portstring); if ((cp = strchr(buffer, ':')) == NULL) { - ports[0] = ports[1] = parse_dccp_port(buffer); + ports[0] = ports[1] = parse_port(buffer, "dccp"); } else { *cp = '\0'; cp++; - ports[0] = buffer[0] ? parse_dccp_port(buffer) : 0; - ports[1] = cp[0] ? parse_dccp_port(cp) : 0xFFFF; + ports[0] = buffer[0] ? parse_port(buffer, "dccp") : 0; + ports[1] = cp[0] ? parse_port(cp, "dccp") : 0xFFFF; if (ports[0] > ports[1]) exit_error(PARAMETER_PROBLEM, -- cgit v1.2.3