summaryrefslogtreecommitdiffstats
path: root/extensions/libipt_multiport.c
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/libipt_multiport.c')
-rw-r--r--extensions/libipt_multiport.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/extensions/libipt_multiport.c b/extensions/libipt_multiport.c
index 28fd8503..2a10abd4 100644
--- a/extensions/libipt_multiport.c
+++ b/extensions/libipt_multiport.c
@@ -51,6 +51,23 @@ static struct option opts[] = {
{0}
};
+static char *
+proto_to_name(u_int8_t proto)
+{
+ switch (proto) {
+ case IPPROTO_TCP:
+ return "tcp";
+ case IPPROTO_UDP:
+ return "udp";
+ case IPPROTO_SCTP:
+ return "sctp";
+ case IPPROTO_DCCP:
+ return "dccp";
+ default:
+ return NULL;
+ }
+}
+
static unsigned int
parse_multi_ports(const char *portstring, u_int16_t *ports, const char *proto)
{
@@ -126,7 +143,7 @@ check_proto(const struct ipt_entry *entry)
exit_error(PARAMETER_PROBLEM,
"multiport only works with TCP or UDP");
- if ((proto = proto_to_name(entry->ip.proto, 1)) != NULL)
+ if ((proto = proto_to_name(entry->ip.proto)) != NULL)
return proto;
else if (!entry->ip.proto)
exit_error(PARAMETER_PROBLEM,
@@ -247,7 +264,7 @@ port_to_service(int port, u_int8_t proto)
{
struct servent *service;
- if ((service = getservbyport(htons(port), proto_to_name(proto, 1))))
+ if ((service = getservbyport(htons(port), proto_to_name(proto))))
return service->s_name;
return NULL;