Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 1 | /* Shared library add-on to iptables to add multiple TCP port support. */ |
| 2 | #include <stdio.h> |
| 3 | #include <netdb.h> |
| 4 | #include <string.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <getopt.h> |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 7 | |
| 8 | #include <xtables.h> |
| 9 | #include <libiptc/libiptc.h> |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 10 | #include <libiptc/libip6tc.h> |
Jan Engelhardt | a2a7f2b | 2008-09-01 14:20:13 +0200 | [diff] [blame] | 11 | #include <linux/netfilter/xt_multiport.h> |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 12 | |
| 13 | /* Function which prints out usage message. */ |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 14 | static void multiport_help(void) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 15 | { |
| 16 | printf( |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 17 | "multiport match options:\n" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 18 | " --source-ports port[,port,port...]\n" |
| 19 | " --sports ...\n" |
| 20 | " match source port(s)\n" |
| 21 | " --destination-ports port[,port,port...]\n" |
| 22 | " --dports ...\n" |
| 23 | " match destination port(s)\n" |
| 24 | " --ports port[,port,port]\n" |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 25 | " match both source and destination port(s)\n" |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 26 | " NOTE: this kernel does not support port ranges in multiport.\n"); |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 27 | } |
| 28 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 29 | static void multiport_help_v1(void) |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 30 | { |
| 31 | printf( |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 32 | "multiport match options:\n" |
Jan Engelhardt | 9672792 | 2008-08-13 14:42:41 +0200 | [diff] [blame] | 33 | "[!] --source-ports port[,port:port,port...]\n" |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 34 | " --sports ...\n" |
| 35 | " match source port(s)\n" |
Jan Engelhardt | 9672792 | 2008-08-13 14:42:41 +0200 | [diff] [blame] | 36 | "[!] --destination-ports port[,port:port,port...]\n" |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 37 | " --dports ...\n" |
| 38 | " match destination port(s)\n" |
Jan Engelhardt | 9672792 | 2008-08-13 14:42:41 +0200 | [diff] [blame] | 39 | "[!] --ports port[,port:port,port]\n" |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 40 | " match both source and destination port(s)\n"); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 43 | static const struct option multiport_opts[] = { |
Patrick McHardy | 500f483 | 2007-09-08 15:59:04 +0000 | [diff] [blame] | 44 | { "source-ports", 1, NULL, '1' }, |
| 45 | { "sports", 1, NULL, '1' }, /* synonym */ |
| 46 | { "destination-ports", 1, NULL, '2' }, |
| 47 | { "dports", 1, NULL, '2' }, /* synonym */ |
| 48 | { "ports", 1, NULL, '3' }, |
Max Kellermann | 9ee386a | 2008-01-29 13:48:05 +0000 | [diff] [blame] | 49 | { .name = NULL } |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
Patrick McHardyJesper Brouer | c1eae41 | 2006-07-25 01:50:48 +0000 | [diff] [blame] | 52 | static char * |
| 53 | proto_to_name(u_int8_t proto) |
| 54 | { |
| 55 | switch (proto) { |
| 56 | case IPPROTO_TCP: |
| 57 | return "tcp"; |
| 58 | case IPPROTO_UDP: |
| 59 | return "udp"; |
Patrick McHardy | 9561606 | 2007-01-11 09:08:22 +0000 | [diff] [blame] | 60 | case IPPROTO_UDPLITE: |
| 61 | return "udplite"; |
Patrick McHardyJesper Brouer | c1eae41 | 2006-07-25 01:50:48 +0000 | [diff] [blame] | 62 | case IPPROTO_SCTP: |
| 63 | return "sctp"; |
| 64 | case IPPROTO_DCCP: |
| 65 | return "dccp"; |
| 66 | default: |
| 67 | return NULL; |
| 68 | } |
| 69 | } |
| 70 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 71 | static unsigned int |
| 72 | parse_multi_ports(const char *portstring, u_int16_t *ports, const char *proto) |
| 73 | { |
| 74 | char *buffer, *cp, *next; |
| 75 | unsigned int i; |
| 76 | |
| 77 | buffer = strdup(portstring); |
| 78 | if (!buffer) exit_error(OTHER_PROBLEM, "strdup failed"); |
| 79 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 80 | for (cp=buffer, i=0; cp && i<XT_MULTI_PORTS; cp=next,i++) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 81 | { |
| 82 | next=strchr(cp, ','); |
| 83 | if (next) *next++='\0'; |
| 84 | ports[i] = parse_port(cp, proto); |
| 85 | } |
| 86 | if (cp) exit_error(PARAMETER_PROBLEM, "too many ports specified"); |
| 87 | free(buffer); |
| 88 | return i; |
| 89 | } |
| 90 | |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 91 | static void |
| 92 | parse_multi_ports_v1(const char *portstring, |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 93 | struct xt_multiport_v1 *multiinfo, |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 94 | const char *proto) |
| 95 | { |
| 96 | char *buffer, *cp, *next, *range; |
| 97 | unsigned int i; |
| 98 | u_int16_t m; |
| 99 | |
| 100 | buffer = strdup(portstring); |
| 101 | if (!buffer) exit_error(OTHER_PROBLEM, "strdup failed"); |
| 102 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 103 | for (i=0; i<XT_MULTI_PORTS; i++) |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 104 | multiinfo->pflags[i] = 0; |
| 105 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 106 | for (cp=buffer, i=0; cp && i<XT_MULTI_PORTS; cp=next, i++) { |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 107 | next=strchr(cp, ','); |
| 108 | if (next) *next++='\0'; |
| 109 | range = strchr(cp, ':'); |
| 110 | if (range) { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 111 | if (i == XT_MULTI_PORTS-1) |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 112 | exit_error(PARAMETER_PROBLEM, |
| 113 | "too many ports specified"); |
| 114 | *range++ = '\0'; |
| 115 | } |
| 116 | multiinfo->ports[i] = parse_port(cp, proto); |
| 117 | if (range) { |
| 118 | multiinfo->pflags[i] = 1; |
| 119 | multiinfo->ports[++i] = parse_port(range, proto); |
| 120 | if (multiinfo->ports[i-1] >= multiinfo->ports[i]) |
| 121 | exit_error(PARAMETER_PROBLEM, |
| 122 | "invalid portrange specified"); |
| 123 | m <<= 1; |
| 124 | } |
| 125 | } |
| 126 | multiinfo->count = i; |
| 127 | if (cp) exit_error(PARAMETER_PROBLEM, "too many ports specified"); |
| 128 | free(buffer); |
| 129 | } |
| 130 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 131 | static const char * |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 132 | check_proto(u_int16_t pnum, u_int8_t invflags) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 133 | { |
Patrick McHardy | 2452baf | 2006-04-28 08:10:08 +0000 | [diff] [blame] | 134 | char *proto; |
| 135 | |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 136 | if (invflags & XT_INV_PROTO) |
Rusty Russell | 225f462 | 2005-01-03 09:51:58 +0000 | [diff] [blame] | 137 | exit_error(PARAMETER_PROBLEM, |
Patrick McHardy | 9561606 | 2007-01-11 09:08:22 +0000 | [diff] [blame] | 138 | "multiport only works with TCP, UDP, UDPLITE, SCTP and DCCP"); |
Rusty Russell | 225f462 | 2005-01-03 09:51:58 +0000 | [diff] [blame] | 139 | |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 140 | if ((proto = proto_to_name(pnum)) != NULL) |
Patrick McHardy | 2452baf | 2006-04-28 08:10:08 +0000 | [diff] [blame] | 141 | return proto; |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 142 | else if (!pnum) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 143 | exit_error(PARAMETER_PROBLEM, |
Patrick McHardy | 9561606 | 2007-01-11 09:08:22 +0000 | [diff] [blame] | 144 | "multiport needs `-p tcp', `-p udp', `-p udplite', " |
| 145 | "`-p sctp' or `-p dccp'"); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 146 | else |
| 147 | exit_error(PARAMETER_PROBLEM, |
Patrick McHardy | 9561606 | 2007-01-11 09:08:22 +0000 | [diff] [blame] | 148 | "multiport only works with TCP, UDP, UDPLITE, SCTP and DCCP"); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | /* Function which parses command options; returns true if it |
| 152 | ate an option */ |
| 153 | static int |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 154 | __multiport_parse(int c, char **argv, int invert, unsigned int *flags, |
| 155 | struct xt_entry_match **match, u_int16_t pnum, |
| 156 | u_int8_t invflags) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 157 | { |
| 158 | const char *proto; |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 159 | struct xt_multiport *multiinfo |
| 160 | = (struct xt_multiport *)(*match)->data; |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 161 | |
| 162 | switch (c) { |
| 163 | case '1': |
Patrick McHardy | d0a2e8a | 2004-09-18 17:43:36 +0000 | [diff] [blame] | 164 | check_inverse(argv[optind-1], &invert, &optind, 0); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 165 | proto = check_proto(pnum, invflags); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 166 | multiinfo->count = parse_multi_ports(argv[optind-1], |
| 167 | multiinfo->ports, proto); |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 168 | multiinfo->flags = XT_MULTIPORT_SOURCE; |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 169 | break; |
| 170 | |
| 171 | case '2': |
Patrick McHardy | d0a2e8a | 2004-09-18 17:43:36 +0000 | [diff] [blame] | 172 | check_inverse(argv[optind-1], &invert, &optind, 0); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 173 | proto = check_proto(pnum, invflags); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 174 | multiinfo->count = parse_multi_ports(argv[optind-1], |
| 175 | multiinfo->ports, proto); |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 176 | multiinfo->flags = XT_MULTIPORT_DESTINATION; |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 177 | break; |
| 178 | |
| 179 | case '3': |
Patrick McHardy | d0a2e8a | 2004-09-18 17:43:36 +0000 | [diff] [blame] | 180 | check_inverse(argv[optind-1], &invert, &optind, 0); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 181 | proto = check_proto(pnum, invflags); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 182 | multiinfo->count = parse_multi_ports(argv[optind-1], |
| 183 | multiinfo->ports, proto); |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 184 | multiinfo->flags = XT_MULTIPORT_EITHER; |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 185 | break; |
| 186 | |
| 187 | default: |
| 188 | return 0; |
| 189 | } |
| 190 | |
Patrick McHardy | d0a2e8a | 2004-09-18 17:43:36 +0000 | [diff] [blame] | 191 | if (invert) |
| 192 | exit_error(PARAMETER_PROBLEM, |
| 193 | "multiport does not support invert"); |
| 194 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 195 | if (*flags) |
| 196 | exit_error(PARAMETER_PROBLEM, |
| 197 | "multiport can only have one option"); |
| 198 | *flags = 1; |
| 199 | return 1; |
| 200 | } |
| 201 | |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 202 | static int |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 203 | multiport_parse(int c, char **argv, int invert, unsigned int *flags, |
| 204 | const void *e, struct xt_entry_match **match) |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 205 | { |
Yasuyuki KOZAKAI | ac8b271 | 2007-07-24 06:06:59 +0000 | [diff] [blame] | 206 | const struct ipt_entry *entry = e; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 207 | return __multiport_parse(c, argv, invert, flags, match, |
| 208 | entry->ip.proto, entry->ip.invflags); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | static int |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 212 | multiport_parse6(int c, char **argv, int invert, unsigned int *flags, |
| 213 | const void *e, struct xt_entry_match **match) |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 214 | { |
| 215 | const struct ip6t_entry *entry = (const struct ip6t_entry *)e; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 216 | return __multiport_parse(c, argv, invert, flags, match, |
| 217 | entry->ipv6.proto, entry->ipv6.invflags); |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | static int |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 221 | __multiport_parse_v1(int c, char **argv, int invert, unsigned int *flags, |
| 222 | struct xt_entry_match **match, u_int16_t pnum, |
| 223 | u_int8_t invflags) |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 224 | { |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 225 | const char *proto; |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 226 | struct xt_multiport_v1 *multiinfo |
| 227 | = (struct xt_multiport_v1 *)(*match)->data; |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 228 | |
| 229 | switch (c) { |
| 230 | case '1': |
| 231 | check_inverse(argv[optind-1], &invert, &optind, 0); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 232 | proto = check_proto(pnum, invflags); |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 233 | parse_multi_ports_v1(argv[optind-1], multiinfo, proto); |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 234 | multiinfo->flags = XT_MULTIPORT_SOURCE; |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 235 | break; |
| 236 | |
| 237 | case '2': |
| 238 | check_inverse(argv[optind-1], &invert, &optind, 0); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 239 | proto = check_proto(pnum, invflags); |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 240 | parse_multi_ports_v1(argv[optind-1], multiinfo, proto); |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 241 | multiinfo->flags = XT_MULTIPORT_DESTINATION; |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 242 | break; |
| 243 | |
| 244 | case '3': |
| 245 | check_inverse(argv[optind-1], &invert, &optind, 0); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 246 | proto = check_proto(pnum, invflags); |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 247 | parse_multi_ports_v1(argv[optind-1], multiinfo, proto); |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 248 | multiinfo->flags = XT_MULTIPORT_EITHER; |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 249 | break; |
| 250 | |
| 251 | default: |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | if (invert) |
Phil Oester | b2eedcd | 2005-02-02 19:20:15 +0000 | [diff] [blame] | 256 | multiinfo->invert = 1; |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 257 | |
| 258 | if (*flags) |
| 259 | exit_error(PARAMETER_PROBLEM, |
| 260 | "multiport can only have one option"); |
| 261 | *flags = 1; |
| 262 | return 1; |
| 263 | } |
| 264 | |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 265 | static int |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 266 | multiport_parse_v1(int c, char **argv, int invert, unsigned int *flags, |
| 267 | const void *e, struct xt_entry_match **match) |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 268 | { |
| 269 | const struct ipt_entry *entry = e; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 270 | return __multiport_parse_v1(c, argv, invert, flags, match, |
| 271 | entry->ip.proto, entry->ip.invflags); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 272 | } |
| 273 | |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 274 | static int |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 275 | multiport_parse6_v1(int c, char **argv, int invert, unsigned int *flags, |
| 276 | const void *e, struct xt_entry_match **match) |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 277 | { |
| 278 | const struct ip6t_entry *entry = (const struct ip6t_entry *)e; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 279 | return __multiport_parse_v1(c, argv, invert, flags, match, |
| 280 | entry->ipv6.proto, entry->ipv6.invflags); |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 283 | /* Final check; must specify something. */ |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 284 | static void multiport_check(unsigned int flags) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 285 | { |
| 286 | if (!flags) |
| 287 | exit_error(PARAMETER_PROBLEM, "multiport expection an option"); |
| 288 | } |
| 289 | |
| 290 | static char * |
| 291 | port_to_service(int port, u_int8_t proto) |
| 292 | { |
| 293 | struct servent *service; |
| 294 | |
Patrick McHardyJesper Brouer | c1eae41 | 2006-07-25 01:50:48 +0000 | [diff] [blame] | 295 | if ((service = getservbyport(htons(port), proto_to_name(proto)))) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 296 | return service->s_name; |
| 297 | |
| 298 | return NULL; |
| 299 | } |
| 300 | |
| 301 | static void |
| 302 | print_port(u_int16_t port, u_int8_t protocol, int numeric) |
| 303 | { |
| 304 | char *service; |
| 305 | |
| 306 | if (numeric || (service = port_to_service(port, protocol)) == NULL) |
| 307 | printf("%u", port); |
| 308 | else |
| 309 | printf("%s", service); |
| 310 | } |
| 311 | |
| 312 | /* Prints out the matchinfo. */ |
| 313 | static void |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 314 | __multiport_print(const struct xt_entry_match *match, int numeric, |
| 315 | u_int16_t proto) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 316 | { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 317 | const struct xt_multiport *multiinfo |
| 318 | = (const struct xt_multiport *)match->data; |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 319 | unsigned int i; |
| 320 | |
| 321 | printf("multiport "); |
| 322 | |
| 323 | switch (multiinfo->flags) { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 324 | case XT_MULTIPORT_SOURCE: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 325 | printf("sports "); |
| 326 | break; |
| 327 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 328 | case XT_MULTIPORT_DESTINATION: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 329 | printf("dports "); |
| 330 | break; |
| 331 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 332 | case XT_MULTIPORT_EITHER: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 333 | printf("ports "); |
| 334 | break; |
| 335 | |
| 336 | default: |
| 337 | printf("ERROR "); |
| 338 | break; |
| 339 | } |
| 340 | |
| 341 | for (i=0; i < multiinfo->count; i++) { |
| 342 | printf("%s", i ? "," : ""); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 343 | print_port(multiinfo->ports[i], proto, numeric); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 344 | } |
| 345 | printf(" "); |
| 346 | } |
| 347 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 348 | static void multiport_print(const void *ip_void, |
| 349 | const struct xt_entry_match *match, int numeric) |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 350 | { |
Yasuyuki KOZAKAI | ac8b271 | 2007-07-24 06:06:59 +0000 | [diff] [blame] | 351 | const struct ipt_ip *ip = ip_void; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 352 | __multiport_print(match, numeric, ip->proto); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 353 | } |
| 354 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 355 | static void multiport_print6(const void *ip_void, |
| 356 | const struct xt_entry_match *match, int numeric) |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 357 | { |
| 358 | const struct ip6t_ip6 *ip = (const struct ip6t_ip6 *)ip_void; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 359 | __multiport_print(match, numeric, ip->proto); |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 360 | } |
| 361 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 362 | static void __multiport_print_v1(const struct xt_entry_match *match, |
| 363 | int numeric, u_int16_t proto) |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 364 | { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 365 | const struct xt_multiport_v1 *multiinfo |
| 366 | = (const struct xt_multiport_v1 *)match->data; |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 367 | unsigned int i; |
| 368 | |
| 369 | printf("multiport "); |
| 370 | |
| 371 | switch (multiinfo->flags) { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 372 | case XT_MULTIPORT_SOURCE: |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 373 | printf("sports "); |
| 374 | break; |
| 375 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 376 | case XT_MULTIPORT_DESTINATION: |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 377 | printf("dports "); |
| 378 | break; |
| 379 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 380 | case XT_MULTIPORT_EITHER: |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 381 | printf("ports "); |
| 382 | break; |
| 383 | |
| 384 | default: |
| 385 | printf("ERROR "); |
| 386 | break; |
| 387 | } |
| 388 | |
Phil Oester | b2eedcd | 2005-02-02 19:20:15 +0000 | [diff] [blame] | 389 | if (multiinfo->invert) |
| 390 | printf("! "); |
| 391 | |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 392 | for (i=0; i < multiinfo->count; i++) { |
| 393 | printf("%s", i ? "," : ""); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 394 | print_port(multiinfo->ports[i], proto, numeric); |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 395 | if (multiinfo->pflags[i]) { |
| 396 | printf(":"); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 397 | print_port(multiinfo->ports[++i], proto, numeric); |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 398 | } |
| 399 | } |
| 400 | printf(" "); |
| 401 | } |
| 402 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 403 | static void multiport_print_v1(const void *ip_void, |
| 404 | const struct xt_entry_match *match, int numeric) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 405 | { |
Yasuyuki KOZAKAI | ac8b271 | 2007-07-24 06:06:59 +0000 | [diff] [blame] | 406 | const struct ipt_ip *ip = ip_void; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 407 | __multiport_print_v1(match, numeric, ip->proto); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 410 | static void multiport_print6_v1(const void *ip_void, |
| 411 | const struct xt_entry_match *match, int numeric) |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 412 | { |
| 413 | const struct ip6t_ip6 *ip = (const struct ip6t_ip6 *)ip_void; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 414 | __multiport_print_v1(match, numeric, ip->proto); |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 415 | } |
| 416 | |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 417 | /* Saves the union ipt_matchinfo in parsable form to stdout. */ |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 418 | static void __multiport_save(const struct xt_entry_match *match, |
| 419 | u_int16_t proto) |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 420 | { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 421 | const struct xt_multiport *multiinfo |
| 422 | = (const struct xt_multiport *)match->data; |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 423 | unsigned int i; |
| 424 | |
| 425 | switch (multiinfo->flags) { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 426 | case XT_MULTIPORT_SOURCE: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 427 | printf("--sports "); |
| 428 | break; |
| 429 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 430 | case XT_MULTIPORT_DESTINATION: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 431 | printf("--dports "); |
| 432 | break; |
| 433 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 434 | case XT_MULTIPORT_EITHER: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 435 | printf("--ports "); |
| 436 | break; |
| 437 | } |
| 438 | |
| 439 | for (i=0; i < multiinfo->count; i++) { |
| 440 | printf("%s", i ? "," : ""); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 441 | print_port(multiinfo->ports[i], proto, 1); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 442 | } |
| 443 | printf(" "); |
| 444 | } |
| 445 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 446 | static void multiport_save(const void *ip_void, |
| 447 | const struct xt_entry_match *match) |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 448 | { |
Yasuyuki KOZAKAI | ac8b271 | 2007-07-24 06:06:59 +0000 | [diff] [blame] | 449 | const struct ipt_ip *ip = ip_void; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 450 | __multiport_save(match, ip->proto); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 453 | static void multiport_save6(const void *ip_void, |
| 454 | const struct xt_entry_match *match) |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 455 | { |
| 456 | const struct ip6t_ip6 *ip = (const struct ip6t_ip6 *)ip_void; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 457 | __multiport_save(match, ip->proto); |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 458 | } |
| 459 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 460 | static void __multiport_save_v1(const struct xt_entry_match *match, |
| 461 | u_int16_t proto) |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 462 | { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 463 | const struct xt_multiport_v1 *multiinfo |
| 464 | = (const struct xt_multiport_v1 *)match->data; |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 465 | unsigned int i; |
| 466 | |
Jan Engelhardt | cea9f71 | 2008-12-09 15:06:20 +0100 | [diff] [blame] | 467 | if (multiinfo->invert) |
| 468 | printf("! "); |
| 469 | |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 470 | switch (multiinfo->flags) { |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 471 | case XT_MULTIPORT_SOURCE: |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 472 | printf("--sports "); |
| 473 | break; |
| 474 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 475 | case XT_MULTIPORT_DESTINATION: |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 476 | printf("--dports "); |
| 477 | break; |
| 478 | |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 479 | case XT_MULTIPORT_EITHER: |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 480 | printf("--ports "); |
| 481 | break; |
| 482 | } |
| 483 | |
| 484 | for (i=0; i < multiinfo->count; i++) { |
| 485 | printf("%s", i ? "," : ""); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 486 | print_port(multiinfo->ports[i], proto, 1); |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 487 | if (multiinfo->pflags[i]) { |
| 488 | printf(":"); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 489 | print_port(multiinfo->ports[++i], proto, 1); |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | printf(" "); |
| 493 | } |
| 494 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 495 | static void multiport_save_v1(const void *ip_void, |
| 496 | const struct xt_entry_match *match) |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 497 | { |
| 498 | const struct ipt_ip *ip = ip_void; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 499 | __multiport_save_v1(match, ip->proto); |
Yasuyuki KOZAKAI | f451b57 | 2007-07-24 06:46:08 +0000 | [diff] [blame] | 500 | } |
| 501 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 502 | static void multiport_save6_v1(const void *ip_void, |
| 503 | const struct xt_entry_match *match) |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 504 | { |
| 505 | const struct ip6t_ip6 *ip = (const struct ip6t_ip6 *)ip_void; |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 506 | __multiport_save_v1(match, ip->proto); |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 507 | } |
| 508 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 509 | static struct xtables_match multiport_match = { |
Jan Engelhardt | 03d9948 | 2008-11-18 12:27:54 +0100 | [diff] [blame] | 510 | .family = NFPROTO_IPV4, |
Pablo Neira | 8caee8b | 2004-12-28 13:11:59 +0000 | [diff] [blame] | 511 | .name = "multiport", |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 512 | .revision = 0, |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 513 | .version = XTABLES_VERSION, |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 514 | .size = XT_ALIGN(sizeof(struct xt_multiport)), |
| 515 | .userspacesize = XT_ALIGN(sizeof(struct xt_multiport)), |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 516 | .help = multiport_help, |
| 517 | .parse = multiport_parse, |
| 518 | .final_check = multiport_check, |
| 519 | .print = multiport_print, |
| 520 | .save = multiport_save, |
| 521 | .extra_opts = multiport_opts, |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 522 | }; |
| 523 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 524 | static struct xtables_match multiport_match6 = { |
Jan Engelhardt | 03d9948 | 2008-11-18 12:27:54 +0100 | [diff] [blame] | 525 | .family = NFPROTO_IPV6, |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 526 | .name = "multiport", |
| 527 | .revision = 0, |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 528 | .version = XTABLES_VERSION, |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 529 | .size = XT_ALIGN(sizeof(struct xt_multiport)), |
| 530 | .userspacesize = XT_ALIGN(sizeof(struct xt_multiport)), |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 531 | .help = multiport_help, |
| 532 | .parse = multiport_parse6, |
| 533 | .final_check = multiport_check, |
| 534 | .print = multiport_print6, |
| 535 | .save = multiport_save6, |
| 536 | .extra_opts = multiport_opts, |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 537 | }; |
| 538 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 539 | static struct xtables_match multiport_match_v1 = { |
Jan Engelhardt | 03d9948 | 2008-11-18 12:27:54 +0100 | [diff] [blame] | 540 | .family = NFPROTO_IPV4, |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 541 | .name = "multiport", |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 542 | .version = XTABLES_VERSION, |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 543 | .revision = 1, |
Yasuyuki KOZAKAI | eb6e65e | 2007-07-24 06:45:03 +0000 | [diff] [blame] | 544 | .size = XT_ALIGN(sizeof(struct xt_multiport_v1)), |
| 545 | .userspacesize = XT_ALIGN(sizeof(struct xt_multiport_v1)), |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 546 | .help = multiport_help_v1, |
| 547 | .parse = multiport_parse_v1, |
| 548 | .final_check = multiport_check, |
| 549 | .print = multiport_print_v1, |
| 550 | .save = multiport_save_v1, |
| 551 | .extra_opts = multiport_opts, |
Pablo Neira | 5df9547 | 2005-01-03 09:37:07 +0000 | [diff] [blame] | 552 | }; |
| 553 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 554 | static struct xtables_match multiport_match6_v1 = { |
Jan Engelhardt | 03d9948 | 2008-11-18 12:27:54 +0100 | [diff] [blame] | 555 | .family = NFPROTO_IPV6, |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 556 | .name = "multiport", |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 557 | .version = XTABLES_VERSION, |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 558 | .revision = 1, |
| 559 | .size = XT_ALIGN(sizeof(struct xt_multiport_v1)), |
| 560 | .userspacesize = XT_ALIGN(sizeof(struct xt_multiport_v1)), |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 561 | .help = multiport_help_v1, |
| 562 | .parse = multiport_parse6_v1, |
| 563 | .final_check = multiport_check, |
| 564 | .print = multiport_print6_v1, |
| 565 | .save = multiport_save6_v1, |
| 566 | .extra_opts = multiport_opts, |
Yasuyuki KOZAKAI | df2cf4f | 2007-07-24 06:49:15 +0000 | [diff] [blame] | 567 | }; |
| 568 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 569 | void |
| 570 | _init(void) |
| 571 | { |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 572 | xtables_register_match(&multiport_match); |
| 573 | xtables_register_match(&multiport_match6); |
| 574 | xtables_register_match(&multiport_match_v1); |
| 575 | xtables_register_match(&multiport_match6_v1); |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 576 | } |