Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 1 | /* Shared library add-on to iptables for DCCP matching |
| 2 | * |
| 3 | * (C) 2005 by Harald Welte <laforge@netfilter.org> |
| 4 | * |
| 5 | * This program is distributed under the terms of GNU GPL v2, 1991 |
| 6 | * |
| 7 | */ |
| 8 | #include <stdio.h> |
| 9 | #include <string.h> |
| 10 | #include <stdlib.h> |
| 11 | #include <getopt.h> |
| 12 | #include <netdb.h> |
| 13 | #include <ctype.h> |
| 14 | |
Thomas Jarosch | ecae0c3 | 2008-10-23 15:41:27 +0200 | [diff] [blame] | 15 | #include <netinet/in.h> |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 16 | #include <xtables.h> |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 17 | #include <linux/dccp.h> |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 18 | #include <linux/netfilter/x_tables.h> |
| 19 | #include <linux/netfilter/xt_dccp.h> |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 20 | |
| 21 | #if 0 |
| 22 | #define DEBUGP(format, first...) printf(format, ##first) |
| 23 | #define static |
| 24 | #else |
| 25 | #define DEBUGP(format, fist...) |
| 26 | #endif |
| 27 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 28 | static void dccp_init(struct xt_entry_match *m) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 29 | { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 30 | struct xt_dccp_info *einfo = (struct xt_dccp_info *)m->data; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 31 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 32 | memset(einfo, 0, sizeof(struct xt_dccp_info)); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 35 | static void dccp_help(void) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 36 | { |
| 37 | printf( |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 38 | "dccp match options\n" |
Jan Engelhardt | 9672792 | 2008-08-13 14:42:41 +0200 | [diff] [blame] | 39 | "[!] --source-port port[:port] match source port(s)\n" |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 40 | " --sport ...\n" |
Jan Engelhardt | 9672792 | 2008-08-13 14:42:41 +0200 | [diff] [blame] | 41 | "[!] --destination-port port[:port] match destination port(s)\n" |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 42 | " --dport ...\n"); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 45 | static const struct option dccp_opts[] = { |
Patrick McHardy | 500f483 | 2007-09-08 15:59:04 +0000 | [diff] [blame] | 46 | { .name = "source-port", .has_arg = 1, .val = '1' }, |
| 47 | { .name = "sport", .has_arg = 1, .val = '1' }, |
| 48 | { .name = "destination-port", .has_arg = 1, .val = '2' }, |
| 49 | { .name = "dport", .has_arg = 1, .val = '2' }, |
| 50 | { .name = "dccp-types", .has_arg = 1, .val = '3' }, |
| 51 | { .name = "dccp-option", .has_arg = 1, .val = '4' }, |
Max Kellermann | 9ee386a | 2008-01-29 13:48:05 +0000 | [diff] [blame] | 52 | { .name = NULL } |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 55 | static void |
| 56 | parse_dccp_ports(const char *portstring, |
| 57 | u_int16_t *ports) |
| 58 | { |
| 59 | char *buffer; |
| 60 | char *cp; |
| 61 | |
| 62 | buffer = strdup(portstring); |
| 63 | DEBUGP("%s\n", portstring); |
| 64 | if ((cp = strchr(buffer, ':')) == NULL) { |
Phil Oester | dbac8ad | 2006-07-20 17:01:54 +0000 | [diff] [blame] | 65 | ports[0] = ports[1] = parse_port(buffer, "dccp"); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 66 | } |
| 67 | else { |
| 68 | *cp = '\0'; |
| 69 | cp++; |
| 70 | |
Phil Oester | dbac8ad | 2006-07-20 17:01:54 +0000 | [diff] [blame] | 71 | ports[0] = buffer[0] ? parse_port(buffer, "dccp") : 0; |
| 72 | ports[1] = cp[0] ? parse_port(cp, "dccp") : 0xFFFF; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 73 | |
| 74 | if (ports[0] > ports[1]) |
| 75 | exit_error(PARAMETER_PROBLEM, |
| 76 | "invalid portrange (min > max)"); |
| 77 | } |
| 78 | free(buffer); |
| 79 | } |
| 80 | |
Jan Engelhardt | 0e2abed | 2007-10-04 16:25:58 +0000 | [diff] [blame] | 81 | static const char *const dccp_pkt_types[] = { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 82 | [DCCP_PKT_REQUEST] = "REQUEST", |
| 83 | [DCCP_PKT_RESPONSE] = "RESPONSE", |
| 84 | [DCCP_PKT_DATA] = "DATA", |
| 85 | [DCCP_PKT_ACK] = "ACK", |
| 86 | [DCCP_PKT_DATAACK] = "DATAACK", |
| 87 | [DCCP_PKT_CLOSEREQ] = "CLOSEREQ", |
| 88 | [DCCP_PKT_CLOSE] = "CLOSE", |
| 89 | [DCCP_PKT_RESET] = "RESET", |
| 90 | [DCCP_PKT_SYNC] = "SYNC", |
| 91 | [DCCP_PKT_SYNCACK] = "SYNCACK", |
| 92 | [DCCP_PKT_INVALID] = "INVALID", |
| 93 | }; |
| 94 | |
| 95 | static u_int16_t |
| 96 | parse_dccp_types(const char *typestring) |
| 97 | { |
| 98 | u_int16_t typemask = 0; |
| 99 | char *ptr, *buffer; |
| 100 | |
| 101 | buffer = strdup(typestring); |
| 102 | |
| 103 | for (ptr = strtok(buffer, ","); ptr; ptr = strtok(NULL, ",")) { |
| 104 | unsigned int i; |
| 105 | for (i = 0; i < sizeof(dccp_pkt_types)/sizeof(char *); i++) { |
| 106 | if (!strcasecmp(dccp_pkt_types[i], ptr)) { |
| 107 | typemask |= (1 << i); |
| 108 | break; |
| 109 | } |
| 110 | } |
| 111 | if (i == sizeof(dccp_pkt_types)/sizeof(char *)) |
| 112 | exit_error(PARAMETER_PROBLEM, |
| 113 | "Unknown DCCP type `%s'", ptr); |
| 114 | } |
| 115 | |
| 116 | free(buffer); |
| 117 | return typemask; |
| 118 | } |
| 119 | |
| 120 | static u_int8_t parse_dccp_option(char *optstring) |
| 121 | { |
| 122 | unsigned int ret; |
| 123 | |
Jan Engelhardt | 5f2922c | 2009-01-27 18:43:01 +0100 | [diff] [blame] | 124 | if (!xtables_strtoui(optstring, NULL, &ret, 1, UINT8_MAX)) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 125 | exit_error(PARAMETER_PROBLEM, "Bad DCCP option `%s'", |
| 126 | optstring); |
| 127 | |
Jan Engelhardt | 213e185 | 2009-01-27 17:24:34 +0100 | [diff] [blame] | 128 | return ret; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | static int |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 132 | dccp_parse(int c, char **argv, int invert, unsigned int *flags, |
| 133 | const void *entry, struct xt_entry_match **match) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 134 | { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 135 | struct xt_dccp_info *einfo |
| 136 | = (struct xt_dccp_info *)(*match)->data; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 137 | |
| 138 | switch (c) { |
| 139 | case '1': |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 140 | if (*flags & XT_DCCP_SRC_PORTS) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 141 | exit_error(PARAMETER_PROBLEM, |
| 142 | "Only one `--source-port' allowed"); |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 143 | einfo->flags |= XT_DCCP_SRC_PORTS; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 144 | check_inverse(optarg, &invert, &optind, 0); |
| 145 | parse_dccp_ports(argv[optind-1], einfo->spts); |
| 146 | if (invert) |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 147 | einfo->invflags |= XT_DCCP_SRC_PORTS; |
| 148 | *flags |= XT_DCCP_SRC_PORTS; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 149 | break; |
| 150 | |
| 151 | case '2': |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 152 | if (*flags & XT_DCCP_DEST_PORTS) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 153 | exit_error(PARAMETER_PROBLEM, |
| 154 | "Only one `--destination-port' allowed"); |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 155 | einfo->flags |= XT_DCCP_DEST_PORTS; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 156 | check_inverse(optarg, &invert, &optind, 0); |
| 157 | parse_dccp_ports(argv[optind-1], einfo->dpts); |
| 158 | if (invert) |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 159 | einfo->invflags |= XT_DCCP_DEST_PORTS; |
| 160 | *flags |= XT_DCCP_DEST_PORTS; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 161 | break; |
| 162 | |
| 163 | case '3': |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 164 | if (*flags & XT_DCCP_TYPE) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 165 | exit_error(PARAMETER_PROBLEM, |
| 166 | "Only one `--dccp-types' allowed"); |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 167 | einfo->flags |= XT_DCCP_TYPE; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 168 | check_inverse(optarg, &invert, &optind, 0); |
| 169 | einfo->typemask = parse_dccp_types(argv[optind-1]); |
| 170 | if (invert) |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 171 | einfo->invflags |= XT_DCCP_TYPE; |
| 172 | *flags |= XT_DCCP_TYPE; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 173 | break; |
| 174 | |
| 175 | case '4': |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 176 | if (*flags & XT_DCCP_OPTION) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 177 | exit_error(PARAMETER_PROBLEM, |
| 178 | "Only one `--dccp-option' allowed"); |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 179 | einfo->flags |= XT_DCCP_OPTION; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 180 | check_inverse(optarg, &invert, &optind, 0); |
| 181 | einfo->option = parse_dccp_option(argv[optind-1]); |
| 182 | if (invert) |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 183 | einfo->invflags |= XT_DCCP_OPTION; |
| 184 | *flags |= XT_DCCP_OPTION; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 185 | break; |
| 186 | default: |
| 187 | return 0; |
| 188 | } |
| 189 | return 1; |
| 190 | } |
| 191 | |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 192 | static char * |
| 193 | port_to_service(int port) |
| 194 | { |
| 195 | struct servent *service; |
| 196 | |
| 197 | if ((service = getservbyport(htons(port), "dccp"))) |
| 198 | return service->s_name; |
| 199 | |
| 200 | return NULL; |
| 201 | } |
| 202 | |
| 203 | static void |
| 204 | print_port(u_int16_t port, int numeric) |
| 205 | { |
| 206 | char *service; |
| 207 | |
| 208 | if (numeric || (service = port_to_service(port)) == NULL) |
| 209 | printf("%u", port); |
| 210 | else |
| 211 | printf("%s", service); |
| 212 | } |
| 213 | |
| 214 | static void |
| 215 | print_ports(const char *name, u_int16_t min, u_int16_t max, |
| 216 | int invert, int numeric) |
| 217 | { |
| 218 | const char *inv = invert ? "!" : ""; |
| 219 | |
| 220 | if (min != 0 || max != 0xFFFF || invert) { |
| 221 | printf("%s", name); |
| 222 | if (min == max) { |
| 223 | printf(":%s", inv); |
| 224 | print_port(min, numeric); |
| 225 | } else { |
| 226 | printf("s:%s", inv); |
| 227 | print_port(min, numeric); |
| 228 | printf(":"); |
| 229 | print_port(max, numeric); |
| 230 | } |
| 231 | printf(" "); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | static void |
| 236 | print_types(u_int16_t types, int inverted, int numeric) |
| 237 | { |
| 238 | int have_type = 0; |
| 239 | |
| 240 | if (inverted) |
| 241 | printf("! "); |
| 242 | |
| 243 | while (types) { |
| 244 | unsigned int i; |
| 245 | |
| 246 | for (i = 0; !(types & (1 << i)); i++); |
| 247 | |
| 248 | if (have_type) |
| 249 | printf(","); |
| 250 | else |
| 251 | have_type = 1; |
| 252 | |
| 253 | if (numeric) |
| 254 | printf("%u", i); |
| 255 | else |
| 256 | printf("%s", dccp_pkt_types[i]); |
| 257 | |
| 258 | types &= ~(1 << i); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | static void |
| 263 | print_option(u_int8_t option, int invert, int numeric) |
| 264 | { |
| 265 | if (option || invert) |
| 266 | printf("option=%s%u ", invert ? "!" : "", option); |
| 267 | } |
| 268 | |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 269 | static void |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 270 | dccp_print(const void *ip, const struct xt_entry_match *match, int numeric) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 271 | { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 272 | const struct xt_dccp_info *einfo = |
| 273 | (const struct xt_dccp_info *)match->data; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 274 | |
| 275 | printf("dccp "); |
| 276 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 277 | if (einfo->flags & XT_DCCP_SRC_PORTS) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 278 | print_ports("spt", einfo->spts[0], einfo->spts[1], |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 279 | einfo->invflags & XT_DCCP_SRC_PORTS, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 280 | numeric); |
| 281 | } |
| 282 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 283 | if (einfo->flags & XT_DCCP_DEST_PORTS) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 284 | print_ports("dpt", einfo->dpts[0], einfo->dpts[1], |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 285 | einfo->invflags & XT_DCCP_DEST_PORTS, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 286 | numeric); |
| 287 | } |
| 288 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 289 | if (einfo->flags & XT_DCCP_TYPE) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 290 | print_types(einfo->typemask, |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 291 | einfo->invflags & XT_DCCP_TYPE, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 292 | numeric); |
| 293 | } |
| 294 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 295 | if (einfo->flags & XT_DCCP_OPTION) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 296 | print_option(einfo->option, |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 297 | einfo->invflags & XT_DCCP_OPTION, numeric); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 301 | static void dccp_save(const void *ip, const struct xt_entry_match *match) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 302 | { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 303 | const struct xt_dccp_info *einfo = |
| 304 | (const struct xt_dccp_info *)match->data; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 305 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 306 | if (einfo->flags & XT_DCCP_SRC_PORTS) { |
| 307 | if (einfo->invflags & XT_DCCP_SRC_PORTS) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 308 | printf("! "); |
| 309 | if (einfo->spts[0] != einfo->spts[1]) |
| 310 | printf("--sport %u:%u ", |
| 311 | einfo->spts[0], einfo->spts[1]); |
| 312 | else |
| 313 | printf("--sport %u ", einfo->spts[0]); |
| 314 | } |
| 315 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 316 | if (einfo->flags & XT_DCCP_DEST_PORTS) { |
| 317 | if (einfo->invflags & XT_DCCP_DEST_PORTS) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 318 | printf("! "); |
| 319 | if (einfo->dpts[0] != einfo->dpts[1]) |
| 320 | printf("--dport %u:%u ", |
| 321 | einfo->dpts[0], einfo->dpts[1]); |
| 322 | else |
| 323 | printf("--dport %u ", einfo->dpts[0]); |
| 324 | } |
| 325 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 326 | if (einfo->flags & XT_DCCP_TYPE) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 327 | printf("--dccp-type "); |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 328 | print_types(einfo->typemask, einfo->invflags & XT_DCCP_TYPE,0); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 329 | } |
| 330 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 331 | if (einfo->flags & XT_DCCP_OPTION) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 332 | printf("--dccp-option %s%u ", |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 333 | einfo->typemask & XT_DCCP_OPTION ? "! " : "", |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 334 | einfo->option); |
| 335 | } |
| 336 | } |
| 337 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 338 | static struct xtables_match dccp_match = { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 339 | .name = "dccp", |
Jan Engelhardt | 03d9948 | 2008-11-18 12:27:54 +0100 | [diff] [blame] | 340 | .family = NFPROTO_IPV4, |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 341 | .version = XTABLES_VERSION, |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 342 | .size = XT_ALIGN(sizeof(struct xt_dccp_info)), |
| 343 | .userspacesize = XT_ALIGN(sizeof(struct xt_dccp_info)), |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 344 | .help = dccp_help, |
| 345 | .init = dccp_init, |
| 346 | .parse = dccp_parse, |
| 347 | .print = dccp_print, |
| 348 | .save = dccp_save, |
| 349 | .extra_opts = dccp_opts, |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 350 | }; |
| 351 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 352 | static struct xtables_match dccp_match6 = { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 353 | .name = "dccp", |
Jan Engelhardt | 03d9948 | 2008-11-18 12:27:54 +0100 | [diff] [blame] | 354 | .family = NFPROTO_IPV6, |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 355 | .version = XTABLES_VERSION, |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 356 | .size = XT_ALIGN(sizeof(struct xt_dccp_info)), |
| 357 | .userspacesize = XT_ALIGN(sizeof(struct xt_dccp_info)), |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 358 | .help = dccp_help, |
| 359 | .init = dccp_init, |
| 360 | .parse = dccp_parse, |
| 361 | .print = dccp_print, |
| 362 | .save = dccp_save, |
| 363 | .extra_opts = dccp_opts, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 364 | }; |
| 365 | |
| 366 | void _init(void) |
| 367 | { |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 368 | xtables_register_match(&dccp_match); |
| 369 | xtables_register_match(&dccp_match6); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 370 | } |