diff options
author | Patrick McHardy <kaber@trash.net> | 2006-04-28 08:10:08 +0000 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2006-04-28 08:10:08 +0000 |
commit | 2452bafd9810e8560717f10af8e26f8a3ac4f4cf (patch) | |
tree | 58c83b1bb3fdcf05cdfc672b70d9a56a00241d51 /extensions/libipt_multiport.c | |
parent | f8ec61f6c8253e2269fe858b27126af07b652d54 (diff) |
Add DCCP/SCTP support to multiport. Patch for kernel will go in 2.6.18.
Diffstat (limited to 'extensions/libipt_multiport.c')
-rw-r--r-- | extensions/libipt_multiport.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/extensions/libipt_multiport.c b/extensions/libipt_multiport.c index 9f5193fa..97e14765 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 int service_to_port(const char *name, const char *proto) { @@ -144,20 +161,20 @@ init(struct ipt_entry_match *m, unsigned int *nfcache) static const char * check_proto(const struct ipt_entry *entry) { + char *proto; + if (entry->ip.invflags & IPT_INV_PROTO) exit_error(PARAMETER_PROBLEM, "multiport only works with TCP or UDP"); - if (entry->ip.proto == IPPROTO_TCP) - return "tcp"; - else if (entry->ip.proto == IPPROTO_UDP) - return "udp"; + if ((proto = proto_to_name(entry->ip.proto)) != NULL) + return proto; else if (!entry->ip.proto) exit_error(PARAMETER_PROBLEM, - "multiport needs `-p tcp' or `-p udp'"); + "multiport needs `-p tcp', `-p udp', `-p sctp' or `-p dccp'"); else exit_error(PARAMETER_PROBLEM, - "multiport only works with TCP or UDP"); + "multiport only works with TCP, UDP, SCTP and DCCP"); } /* Function which parses command options; returns true if it @@ -271,8 +288,7 @@ port_to_service(int port, u_int8_t proto) { struct servent *service; - if ((service = getservbyport(htons(port), - proto == IPPROTO_TCP ? "tcp" : "udp"))) + if ((service = getservbyport(htons(port), proto_to_name(proto)))) return service->s_name; return NULL; |