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 | */ |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 8 | #include <stdint.h> |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 9 | #include <stdio.h> |
| 10 | #include <string.h> |
| 11 | #include <stdlib.h> |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 12 | #include <netdb.h> |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 13 | #include <arpa/inet.h> |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 14 | #include <xtables.h> |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 15 | #include <linux/dccp.h> |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 16 | #include <linux/netfilter/x_tables.h> |
| 17 | #include <linux/netfilter/xt_dccp.h> |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 18 | |
| 19 | #if 0 |
| 20 | #define DEBUGP(format, first...) printf(format, ##first) |
| 21 | #define static |
| 22 | #else |
| 23 | #define DEBUGP(format, fist...) |
| 24 | #endif |
| 25 | |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 26 | enum { |
| 27 | O_SOURCE_PORT = 0, |
| 28 | O_DEST_PORT, |
| 29 | O_DCCP_TYPES, |
| 30 | O_DCCP_OPTION, |
| 31 | }; |
| 32 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 33 | static void dccp_help(void) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 34 | { |
| 35 | printf( |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 36 | "dccp match options\n" |
Jan Engelhardt | 9672792 | 2008-08-13 14:42:41 +0200 | [diff] [blame] | 37 | "[!] --source-port port[:port] match source port(s)\n" |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 38 | " --sport ...\n" |
Jan Engelhardt | 9672792 | 2008-08-13 14:42:41 +0200 | [diff] [blame] | 39 | "[!] --destination-port port[:port] match destination port(s)\n" |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 40 | " --dport ...\n"); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 43 | #define s struct xt_dccp_info |
| 44 | static const struct xt_option_entry dccp_opts[] = { |
| 45 | {.name = "source-port", .id = O_SOURCE_PORT, .type = XTTYPE_PORTRC, |
| 46 | .flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, spts)}, |
| 47 | {.name = "sport", .id = O_SOURCE_PORT, .type = XTTYPE_PORTRC, |
| 48 | .flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, spts)}, |
| 49 | {.name = "destination-port", .id = O_DEST_PORT, .type = XTTYPE_PORTRC, |
| 50 | .flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, dpts)}, |
| 51 | {.name = "dport", .id = O_DEST_PORT, .type = XTTYPE_PORTRC, |
| 52 | .flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, dpts)}, |
| 53 | {.name = "dccp-types", .id = O_DCCP_TYPES, .type = XTTYPE_STRING}, |
| 54 | {.name = "dccp-option", .id = O_DCCP_OPTION, .type = XTTYPE_UINT8, |
| 55 | .min = 1, .max = UINT8_MAX, .flags = XTOPT_PUT, |
| 56 | XTOPT_POINTER(s, option)}, |
| 57 | XTOPT_TABLEEND, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 58 | }; |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 59 | #undef s |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 60 | |
Jan Engelhardt | 0e2abed | 2007-10-04 16:25:58 +0000 | [diff] [blame] | 61 | static const char *const dccp_pkt_types[] = { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 62 | [DCCP_PKT_REQUEST] = "REQUEST", |
| 63 | [DCCP_PKT_RESPONSE] = "RESPONSE", |
| 64 | [DCCP_PKT_DATA] = "DATA", |
| 65 | [DCCP_PKT_ACK] = "ACK", |
| 66 | [DCCP_PKT_DATAACK] = "DATAACK", |
| 67 | [DCCP_PKT_CLOSEREQ] = "CLOSEREQ", |
| 68 | [DCCP_PKT_CLOSE] = "CLOSE", |
| 69 | [DCCP_PKT_RESET] = "RESET", |
| 70 | [DCCP_PKT_SYNC] = "SYNC", |
| 71 | [DCCP_PKT_SYNCACK] = "SYNCACK", |
| 72 | [DCCP_PKT_INVALID] = "INVALID", |
| 73 | }; |
| 74 | |
Jan Engelhardt | 7ac4052 | 2011-01-07 12:34:04 +0100 | [diff] [blame] | 75 | static uint16_t |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 76 | parse_dccp_types(const char *typestring) |
| 77 | { |
Jan Engelhardt | 7ac4052 | 2011-01-07 12:34:04 +0100 | [diff] [blame] | 78 | uint16_t typemask = 0; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 79 | char *ptr, *buffer; |
| 80 | |
| 81 | buffer = strdup(typestring); |
| 82 | |
| 83 | for (ptr = strtok(buffer, ","); ptr; ptr = strtok(NULL, ",")) { |
| 84 | unsigned int i; |
Jan Engelhardt | 2c69b55 | 2009-04-30 19:32:02 +0200 | [diff] [blame] | 85 | for (i = 0; i < ARRAY_SIZE(dccp_pkt_types); ++i) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 86 | if (!strcasecmp(dccp_pkt_types[i], ptr)) { |
| 87 | typemask |= (1 << i); |
| 88 | break; |
| 89 | } |
Jan Engelhardt | 2c69b55 | 2009-04-30 19:32:02 +0200 | [diff] [blame] | 90 | if (i == ARRAY_SIZE(dccp_pkt_types)) |
Jan Engelhardt | 1829ed4 | 2009-02-21 03:29:44 +0100 | [diff] [blame] | 91 | xtables_error(PARAMETER_PROBLEM, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 92 | "Unknown DCCP type `%s'", ptr); |
| 93 | } |
| 94 | |
| 95 | free(buffer); |
| 96 | return typemask; |
| 97 | } |
| 98 | |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 99 | static void dccp_parse(struct xt_option_call *cb) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 100 | { |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 101 | struct xt_dccp_info *einfo = cb->data; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 102 | |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 103 | xtables_option_parse(cb); |
| 104 | switch (cb->entry->id) { |
| 105 | case O_SOURCE_PORT: |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 106 | einfo->flags |= XT_DCCP_SRC_PORTS; |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 107 | if (cb->invert) |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 108 | einfo->invflags |= XT_DCCP_SRC_PORTS; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 109 | break; |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 110 | case O_DEST_PORT: |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 111 | einfo->flags |= XT_DCCP_DEST_PORTS; |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 112 | if (cb->invert) |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 113 | einfo->invflags |= XT_DCCP_DEST_PORTS; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 114 | break; |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 115 | case O_DCCP_TYPES: |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 116 | einfo->flags |= XT_DCCP_TYPE; |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 117 | einfo->typemask = parse_dccp_types(cb->arg); |
| 118 | if (cb->invert) |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 119 | einfo->invflags |= XT_DCCP_TYPE; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 120 | break; |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 121 | case O_DCCP_OPTION: |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 122 | einfo->flags |= XT_DCCP_OPTION; |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 123 | if (cb->invert) |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 124 | einfo->invflags |= XT_DCCP_OPTION; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 125 | break; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 126 | } |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 129 | static char * |
| 130 | port_to_service(int port) |
| 131 | { |
| 132 | struct servent *service; |
| 133 | |
| 134 | if ((service = getservbyport(htons(port), "dccp"))) |
| 135 | return service->s_name; |
| 136 | |
| 137 | return NULL; |
| 138 | } |
| 139 | |
| 140 | static void |
Jan Engelhardt | 7ac4052 | 2011-01-07 12:34:04 +0100 | [diff] [blame] | 141 | print_port(uint16_t port, int numeric) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 142 | { |
| 143 | char *service; |
| 144 | |
| 145 | if (numeric || (service = port_to_service(port)) == NULL) |
| 146 | printf("%u", port); |
| 147 | else |
| 148 | printf("%s", service); |
| 149 | } |
| 150 | |
| 151 | static void |
Jan Engelhardt | 7ac4052 | 2011-01-07 12:34:04 +0100 | [diff] [blame] | 152 | print_ports(const char *name, uint16_t min, uint16_t max, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 153 | int invert, int numeric) |
| 154 | { |
| 155 | const char *inv = invert ? "!" : ""; |
| 156 | |
| 157 | if (min != 0 || max != 0xFFFF || invert) { |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 158 | printf(" %s", name); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 159 | if (min == max) { |
| 160 | printf(":%s", inv); |
| 161 | print_port(min, numeric); |
| 162 | } else { |
| 163 | printf("s:%s", inv); |
| 164 | print_port(min, numeric); |
| 165 | printf(":"); |
| 166 | print_port(max, numeric); |
| 167 | } |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
| 171 | static void |
Jan Engelhardt | 7ac4052 | 2011-01-07 12:34:04 +0100 | [diff] [blame] | 172 | print_types(uint16_t types, int inverted, int numeric) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 173 | { |
| 174 | int have_type = 0; |
| 175 | |
| 176 | if (inverted) |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 177 | printf(" !"); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 178 | |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 179 | printf(" "); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 180 | while (types) { |
| 181 | unsigned int i; |
| 182 | |
| 183 | for (i = 0; !(types & (1 << i)); i++); |
| 184 | |
| 185 | if (have_type) |
| 186 | printf(","); |
| 187 | else |
| 188 | have_type = 1; |
| 189 | |
| 190 | if (numeric) |
| 191 | printf("%u", i); |
| 192 | else |
| 193 | printf("%s", dccp_pkt_types[i]); |
| 194 | |
| 195 | types &= ~(1 << i); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | static void |
Jan Engelhardt | 7ac4052 | 2011-01-07 12:34:04 +0100 | [diff] [blame] | 200 | print_option(uint8_t option, int invert, int numeric) |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 201 | { |
| 202 | if (option || invert) |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 203 | printf(" option=%s%u", invert ? "!" : "", option); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 204 | } |
| 205 | |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 206 | static void |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 207 | 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] | 208 | { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 209 | const struct xt_dccp_info *einfo = |
| 210 | (const struct xt_dccp_info *)match->data; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 211 | |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 212 | printf(" dccp"); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 213 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 214 | if (einfo->flags & XT_DCCP_SRC_PORTS) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 215 | print_ports("spt", einfo->spts[0], einfo->spts[1], |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 216 | einfo->invflags & XT_DCCP_SRC_PORTS, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 217 | numeric); |
| 218 | } |
| 219 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 220 | if (einfo->flags & XT_DCCP_DEST_PORTS) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 221 | print_ports("dpt", einfo->dpts[0], einfo->dpts[1], |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 222 | einfo->invflags & XT_DCCP_DEST_PORTS, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 223 | numeric); |
| 224 | } |
| 225 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 226 | if (einfo->flags & XT_DCCP_TYPE) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 227 | print_types(einfo->typemask, |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 228 | einfo->invflags & XT_DCCP_TYPE, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 229 | numeric); |
| 230 | } |
| 231 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 232 | if (einfo->flags & XT_DCCP_OPTION) { |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 233 | print_option(einfo->option, |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 234 | einfo->invflags & XT_DCCP_OPTION, numeric); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 238 | 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] | 239 | { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 240 | const struct xt_dccp_info *einfo = |
| 241 | (const struct xt_dccp_info *)match->data; |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 242 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 243 | if (einfo->flags & XT_DCCP_SRC_PORTS) { |
| 244 | if (einfo->invflags & XT_DCCP_SRC_PORTS) |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 245 | printf(" !"); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 246 | if (einfo->spts[0] != einfo->spts[1]) |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 247 | printf(" --sport %u:%u", |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 248 | einfo->spts[0], einfo->spts[1]); |
| 249 | else |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 250 | printf(" --sport %u", einfo->spts[0]); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 251 | } |
| 252 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 253 | if (einfo->flags & XT_DCCP_DEST_PORTS) { |
| 254 | if (einfo->invflags & XT_DCCP_DEST_PORTS) |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 255 | printf(" !"); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 256 | if (einfo->dpts[0] != einfo->dpts[1]) |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 257 | printf(" --dport %u:%u", |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 258 | einfo->dpts[0], einfo->dpts[1]); |
| 259 | else |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 260 | printf(" --dport %u", einfo->dpts[0]); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 263 | if (einfo->flags & XT_DCCP_TYPE) { |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 264 | printf(" --dccp-type"); |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 265 | print_types(einfo->typemask, einfo->invflags & XT_DCCP_TYPE,0); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 266 | } |
| 267 | |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 268 | if (einfo->flags & XT_DCCP_OPTION) { |
Jan Engelhardt | 7386635 | 2010-12-18 02:04:59 +0100 | [diff] [blame] | 269 | printf(" --dccp-option %s%u", |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 270 | einfo->typemask & XT_DCCP_OPTION ? "! " : "", |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 271 | einfo->option); |
| 272 | } |
| 273 | } |
| 274 | |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 275 | static struct xtables_match dccp_match = { |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 276 | .name = "dccp", |
Jan Engelhardt | c5e8573 | 2009-06-12 20:55:44 +0200 | [diff] [blame] | 277 | .family = NFPROTO_UNSPEC, |
Jan Engelhardt | 8b7c64d | 2008-04-15 11:48:25 +0200 | [diff] [blame] | 278 | .version = XTABLES_VERSION, |
Yasuyuki KOZAKAI | 3c96c8e | 2007-07-24 07:19:41 +0000 | [diff] [blame] | 279 | .size = XT_ALIGN(sizeof(struct xt_dccp_info)), |
| 280 | .userspacesize = XT_ALIGN(sizeof(struct xt_dccp_info)), |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 281 | .help = dccp_help, |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 282 | .print = dccp_print, |
| 283 | .save = dccp_save, |
Jan Engelhardt | 753bbed | 2011-04-20 10:17:33 +0200 | [diff] [blame^] | 284 | .x6_parse = dccp_parse, |
| 285 | .x6_options = dccp_opts, |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | void _init(void) |
| 289 | { |
Jan Engelhardt | 181dead | 2007-10-04 16:27:07 +0000 | [diff] [blame] | 290 | xtables_register_match(&dccp_match); |
Harald Welte | e40b11d | 2005-08-06 21:13:04 +0000 | [diff] [blame] | 291 | } |