]> granicus.if.org Git - ipset/blob - lib/ipset_hash_ipportip.c
Userspace revision handling is reworked
[ipset] / lib / ipset_hash_ipportip.c
1 /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation.
6  */
7 #include <libipset/data.h>                      /* IPSET_OPT_* */
8 #include <libipset/parse.h>                     /* parser functions */
9 #include <libipset/print.h>                     /* printing functions */
10 #include <libipset/ui.h>                        /* ipset_port_usage */
11 #include <libipset/types.h>                     /* prototypes */
12
13 /* SCTP and UDPLITE support */
14 static struct ipset_type ipset_hash_ipportip1 = {
15         .name = "hash:ip,port,ip",
16         .alias = { "ipportiphash", NULL },
17         .revision = 1,
18         .family = NFPROTO_IPSET_IPV46,
19         .dimension = IPSET_DIM_THREE,
20         .elem = {
21                 [IPSET_DIM_ONE - 1] = {
22                         .parse = ipset_parse_ip4_single6,
23                         .print = ipset_print_ip,
24                         .opt = IPSET_OPT_IP
25                 },
26                 [IPSET_DIM_TWO - 1] = {
27                         .parse = ipset_parse_proto_port,
28                         .print = ipset_print_proto_port,
29                         .opt = IPSET_OPT_PORT
30                 },
31                 [IPSET_DIM_THREE - 1] = {
32                         .parse = ipset_parse_single_ip,
33                         .print = ipset_print_ip,
34                         .opt = IPSET_OPT_IP2
35                 },
36         },
37         .cmd = {
38                 [IPSET_CREATE] = {
39                         .args = {
40                                 IPSET_ARG_FAMILY,
41                                 /* Aliases */
42                                 IPSET_ARG_INET,
43                                 IPSET_ARG_INET6,
44                                 IPSET_ARG_HASHSIZE,
45                                 IPSET_ARG_MAXELEM,
46                                 IPSET_ARG_TIMEOUT,
47                                 /* Ignored options: backward compatibilty */
48                                 IPSET_ARG_PROBES,
49                                 IPSET_ARG_RESIZE,
50                                 IPSET_ARG_IGNORED_FROM,
51                                 IPSET_ARG_IGNORED_TO,
52                                 IPSET_ARG_IGNORED_NETWORK,
53                                 IPSET_ARG_NONE,
54                         },
55                         .need = 0,
56                         .full = 0,
57                         .help = "",
58                 },
59                 [IPSET_ADD] = {
60                         .args = {
61                                 IPSET_ARG_TIMEOUT,
62                                 IPSET_ARG_NONE,
63                         },
64                         .need = IPSET_FLAG(IPSET_OPT_IP)
65                                 | IPSET_FLAG(IPSET_OPT_PROTO)
66                                 | IPSET_FLAG(IPSET_OPT_PORT)
67                                 | IPSET_FLAG(IPSET_OPT_IP2),
68                         .full = IPSET_FLAG(IPSET_OPT_IP)
69                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
70                                 | IPSET_FLAG(IPSET_OPT_PROTO)
71                                 | IPSET_FLAG(IPSET_OPT_PORT)
72                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
73                                 | IPSET_FLAG(IPSET_OPT_IP2),
74                         .help = "IP,[PROTO:]PORT,IP",
75                 },
76                 [IPSET_DEL] = {
77                         .args = {
78                                 IPSET_ARG_NONE,
79                         },
80                         .need = IPSET_FLAG(IPSET_OPT_IP)
81                                 | IPSET_FLAG(IPSET_OPT_PROTO)
82                                 | IPSET_FLAG(IPSET_OPT_PORT)
83                                 | IPSET_FLAG(IPSET_OPT_IP2),
84                         .full = IPSET_FLAG(IPSET_OPT_IP)
85                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
86                                 | IPSET_FLAG(IPSET_OPT_PROTO)
87                                 | IPSET_FLAG(IPSET_OPT_PORT)
88                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
89                                 | IPSET_FLAG(IPSET_OPT_IP2),
90                         .help = "IP,[PROTO:]PORT,IP",
91                 },
92                 [IPSET_TEST] = {
93                         .args = {
94                                 IPSET_ARG_NONE,
95                         },
96                         .need = IPSET_FLAG(IPSET_OPT_IP)
97                                 | IPSET_FLAG(IPSET_OPT_PROTO)
98                                 | IPSET_FLAG(IPSET_OPT_PORT)
99                                 | IPSET_FLAG(IPSET_OPT_IP2),
100                         .full = IPSET_FLAG(IPSET_OPT_IP)
101                                 | IPSET_FLAG(IPSET_OPT_PROTO)
102                                 | IPSET_FLAG(IPSET_OPT_PORT)
103                                 | IPSET_FLAG(IPSET_OPT_IP2),
104                         .help = "IP,[PROTO:]PORT,IP",
105                 },
106         },
107         .usage = "where depending on the INET family\n"
108                  "      IP is a valid IPv4 or IPv6 address (or hostname).\n"
109                  "      Adding/deleting multiple elements in IP/CIDR or FROM-TO form\n"
110                  "      in the first IP component is supported for IPv4.\n"
111                  "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
112                  "      port range is supported both for IPv4 and IPv6.",
113         .usagefn = ipset_port_usage,
114         .description = "SCTP and UDPLITE support",
115 };
116
117 /* counters support */
118 static struct ipset_type ipset_hash_ipportip2 = {
119         .name = "hash:ip,port,ip",
120         .alias = { "ipportiphash", NULL },
121         .revision = 2,
122         .family = NFPROTO_IPSET_IPV46,
123         .dimension = IPSET_DIM_THREE,
124         .elem = {
125                 [IPSET_DIM_ONE - 1] = {
126                         .parse = ipset_parse_ip4_single6,
127                         .print = ipset_print_ip,
128                         .opt = IPSET_OPT_IP
129                 },
130                 [IPSET_DIM_TWO - 1] = {
131                         .parse = ipset_parse_proto_port,
132                         .print = ipset_print_proto_port,
133                         .opt = IPSET_OPT_PORT
134                 },
135                 [IPSET_DIM_THREE - 1] = {
136                         .parse = ipset_parse_single_ip,
137                         .print = ipset_print_ip,
138                         .opt = IPSET_OPT_IP2
139                 },
140         },
141         .cmd = {
142                 [IPSET_CREATE] = {
143                         .args = {
144                                 IPSET_ARG_FAMILY,
145                                 /* Aliases */
146                                 IPSET_ARG_INET,
147                                 IPSET_ARG_INET6,
148                                 IPSET_ARG_HASHSIZE,
149                                 IPSET_ARG_MAXELEM,
150                                 IPSET_ARG_TIMEOUT,
151                                 IPSET_ARG_COUNTERS,
152                                 /* Ignored options: backward compatibilty */
153                                 IPSET_ARG_PROBES,
154                                 IPSET_ARG_RESIZE,
155                                 IPSET_ARG_IGNORED_FROM,
156                                 IPSET_ARG_IGNORED_TO,
157                                 IPSET_ARG_IGNORED_NETWORK,
158                                 IPSET_ARG_NONE,
159                         },
160                         .need = 0,
161                         .full = 0,
162                         .help = "",
163                 },
164                 [IPSET_ADD] = {
165                         .args = {
166                                 IPSET_ARG_TIMEOUT,
167                                 IPSET_ARG_PACKETS,
168                                 IPSET_ARG_BYTES,
169                                 IPSET_ARG_NONE,
170                         },
171                         .need = IPSET_FLAG(IPSET_OPT_IP)
172                                 | IPSET_FLAG(IPSET_OPT_PROTO)
173                                 | IPSET_FLAG(IPSET_OPT_PORT)
174                                 | IPSET_FLAG(IPSET_OPT_IP2),
175                         .full = IPSET_FLAG(IPSET_OPT_IP)
176                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
177                                 | IPSET_FLAG(IPSET_OPT_PROTO)
178                                 | IPSET_FLAG(IPSET_OPT_PORT)
179                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
180                                 | IPSET_FLAG(IPSET_OPT_IP2),
181                         .help = "IP,[PROTO:]PORT,IP",
182                 },
183                 [IPSET_DEL] = {
184                         .args = {
185                                 IPSET_ARG_NONE,
186                         },
187                         .need = IPSET_FLAG(IPSET_OPT_IP)
188                                 | IPSET_FLAG(IPSET_OPT_PROTO)
189                                 | IPSET_FLAG(IPSET_OPT_PORT)
190                                 | IPSET_FLAG(IPSET_OPT_IP2),
191                         .full = IPSET_FLAG(IPSET_OPT_IP)
192                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
193                                 | IPSET_FLAG(IPSET_OPT_PROTO)
194                                 | IPSET_FLAG(IPSET_OPT_PORT)
195                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
196                                 | IPSET_FLAG(IPSET_OPT_IP2),
197                         .help = "IP,[PROTO:]PORT,IP",
198                 },
199                 [IPSET_TEST] = {
200                         .args = {
201                                 IPSET_ARG_NONE,
202                         },
203                         .need = IPSET_FLAG(IPSET_OPT_IP)
204                                 | IPSET_FLAG(IPSET_OPT_PROTO)
205                                 | IPSET_FLAG(IPSET_OPT_PORT)
206                                 | IPSET_FLAG(IPSET_OPT_IP2),
207                         .full = IPSET_FLAG(IPSET_OPT_IP)
208                                 | IPSET_FLAG(IPSET_OPT_PROTO)
209                                 | IPSET_FLAG(IPSET_OPT_PORT)
210                                 | IPSET_FLAG(IPSET_OPT_IP2),
211                         .help = "IP,[PROTO:]PORT,IP",
212                 },
213         },
214         .usage = "where depending on the INET family\n"
215                  "      IP is a valid IPv4 or IPv6 address (or hostname).\n"
216                  "      Adding/deleting multiple elements in IP/CIDR or FROM-TO form\n"
217                  "      in the first IP component is supported for IPv4.\n"
218                  "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
219                  "      port range is supported both for IPv4 and IPv6.",
220         .usagefn = ipset_port_usage,
221         .description = "counters support",
222 };
223
224 /* comment support */
225 static struct ipset_type ipset_hash_ipportip3 = {
226         .name = "hash:ip,port,ip",
227         .alias = { "ipportiphash", NULL },
228         .revision = 3,
229         .family = NFPROTO_IPSET_IPV46,
230         .dimension = IPSET_DIM_THREE,
231         .elem = {
232                 [IPSET_DIM_ONE - 1] = {
233                         .parse = ipset_parse_ip4_single6,
234                         .print = ipset_print_ip,
235                         .opt = IPSET_OPT_IP
236                 },
237                 [IPSET_DIM_TWO - 1] = {
238                         .parse = ipset_parse_proto_port,
239                         .print = ipset_print_proto_port,
240                         .opt = IPSET_OPT_PORT
241                 },
242                 [IPSET_DIM_THREE - 1] = {
243                         .parse = ipset_parse_single_ip,
244                         .print = ipset_print_ip,
245                         .opt = IPSET_OPT_IP2
246                 },
247         },
248         .cmd = {
249                 [IPSET_CREATE] = {
250                         .args = {
251                                 IPSET_ARG_FAMILY,
252                                 /* Aliases */
253                                 IPSET_ARG_INET,
254                                 IPSET_ARG_INET6,
255                                 IPSET_ARG_HASHSIZE,
256                                 IPSET_ARG_MAXELEM,
257                                 IPSET_ARG_TIMEOUT,
258                                 IPSET_ARG_COUNTERS,
259                                 IPSET_ARG_COMMENT,
260                                 /* Ignored options: backward compatibilty */
261                                 IPSET_ARG_PROBES,
262                                 IPSET_ARG_RESIZE,
263                                 IPSET_ARG_IGNORED_FROM,
264                                 IPSET_ARG_IGNORED_TO,
265                                 IPSET_ARG_IGNORED_NETWORK,
266                                 IPSET_ARG_NONE,
267                         },
268                         .need = 0,
269                         .full = 0,
270                         .help = "",
271                 },
272                 [IPSET_ADD] = {
273                         .args = {
274                                 IPSET_ARG_TIMEOUT,
275                                 IPSET_ARG_PACKETS,
276                                 IPSET_ARG_BYTES,
277                                 IPSET_ARG_ADT_COMMENT,
278                                 IPSET_ARG_NONE,
279                         },
280                         .need = IPSET_FLAG(IPSET_OPT_IP)
281                                 | IPSET_FLAG(IPSET_OPT_PROTO)
282                                 | IPSET_FLAG(IPSET_OPT_PORT)
283                                 | IPSET_FLAG(IPSET_OPT_IP2),
284                         .full = IPSET_FLAG(IPSET_OPT_IP)
285                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
286                                 | IPSET_FLAG(IPSET_OPT_PROTO)
287                                 | IPSET_FLAG(IPSET_OPT_PORT)
288                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
289                                 | IPSET_FLAG(IPSET_OPT_IP2),
290                         .help = "IP,[PROTO:]PORT,IP",
291                 },
292                 [IPSET_DEL] = {
293                         .args = {
294                                 IPSET_ARG_NONE,
295                         },
296                         .need = IPSET_FLAG(IPSET_OPT_IP)
297                                 | IPSET_FLAG(IPSET_OPT_PROTO)
298                                 | IPSET_FLAG(IPSET_OPT_PORT)
299                                 | IPSET_FLAG(IPSET_OPT_IP2),
300                         .full = IPSET_FLAG(IPSET_OPT_IP)
301                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
302                                 | IPSET_FLAG(IPSET_OPT_PROTO)
303                                 | IPSET_FLAG(IPSET_OPT_PORT)
304                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
305                                 | IPSET_FLAG(IPSET_OPT_IP2),
306                         .help = "IP,[PROTO:]PORT,IP",
307                 },
308                 [IPSET_TEST] = {
309                         .args = {
310                                 IPSET_ARG_NONE,
311                         },
312                         .need = IPSET_FLAG(IPSET_OPT_IP)
313                                 | IPSET_FLAG(IPSET_OPT_PROTO)
314                                 | IPSET_FLAG(IPSET_OPT_PORT)
315                                 | IPSET_FLAG(IPSET_OPT_IP2),
316                         .full = IPSET_FLAG(IPSET_OPT_IP)
317                                 | IPSET_FLAG(IPSET_OPT_PROTO)
318                                 | IPSET_FLAG(IPSET_OPT_PORT)
319                                 | IPSET_FLAG(IPSET_OPT_IP2),
320                         .help = "IP,[PROTO:]PORT,IP",
321                 },
322         },
323         .usage = "where depending on the INET family\n"
324                  "      IP is a valid IPv4 or IPv6 address (or hostname).\n"
325                  "      Adding/deleting multiple elements in IP/CIDR or FROM-TO form\n"
326                  "      in the first IP component is supported for IPv4.\n"
327                  "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
328                  "      port range is supported both for IPv4 and IPv6.",
329         .usagefn = ipset_port_usage,
330         .description = "comment support",
331 };
332
333 /* forceadd support */
334 static struct ipset_type ipset_hash_ipportip4 = {
335         .name = "hash:ip,port,ip",
336         .alias = { "ipportiphash", NULL },
337         .revision = 4,
338         .family = NFPROTO_IPSET_IPV46,
339         .dimension = IPSET_DIM_THREE,
340         .elem = {
341                 [IPSET_DIM_ONE - 1] = {
342                         .parse = ipset_parse_ip4_single6,
343                         .print = ipset_print_ip,
344                         .opt = IPSET_OPT_IP
345                 },
346                 [IPSET_DIM_TWO - 1] = {
347                         .parse = ipset_parse_proto_port,
348                         .print = ipset_print_proto_port,
349                         .opt = IPSET_OPT_PORT
350                 },
351                 [IPSET_DIM_THREE - 1] = {
352                         .parse = ipset_parse_single_ip,
353                         .print = ipset_print_ip,
354                         .opt = IPSET_OPT_IP2
355                 },
356         },
357         .cmd = {
358                 [IPSET_CREATE] = {
359                         .args = {
360                                 IPSET_ARG_FAMILY,
361                                 /* Aliases */
362                                 IPSET_ARG_INET,
363                                 IPSET_ARG_INET6,
364                                 IPSET_ARG_HASHSIZE,
365                                 IPSET_ARG_MAXELEM,
366                                 IPSET_ARG_TIMEOUT,
367                                 IPSET_ARG_COUNTERS,
368                                 IPSET_ARG_COMMENT,
369                                 IPSET_ARG_FORCEADD,
370                                 /* Ignored options: backward compatibilty */
371                                 IPSET_ARG_PROBES,
372                                 IPSET_ARG_RESIZE,
373                                 IPSET_ARG_IGNORED_FROM,
374                                 IPSET_ARG_IGNORED_TO,
375                                 IPSET_ARG_IGNORED_NETWORK,
376                                 IPSET_ARG_NONE,
377                         },
378                         .need = 0,
379                         .full = 0,
380                         .help = "",
381                 },
382                 [IPSET_ADD] = {
383                         .args = {
384                                 IPSET_ARG_TIMEOUT,
385                                 IPSET_ARG_PACKETS,
386                                 IPSET_ARG_BYTES,
387                                 IPSET_ARG_ADT_COMMENT,
388                                 IPSET_ARG_NONE,
389                         },
390                         .need = IPSET_FLAG(IPSET_OPT_IP)
391                                 | IPSET_FLAG(IPSET_OPT_PROTO)
392                                 | IPSET_FLAG(IPSET_OPT_PORT)
393                                 | IPSET_FLAG(IPSET_OPT_IP2),
394                         .full = IPSET_FLAG(IPSET_OPT_IP)
395                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
396                                 | IPSET_FLAG(IPSET_OPT_PROTO)
397                                 | IPSET_FLAG(IPSET_OPT_PORT)
398                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
399                                 | IPSET_FLAG(IPSET_OPT_IP2),
400                         .help = "IP,[PROTO:]PORT,IP",
401                 },
402                 [IPSET_DEL] = {
403                         .args = {
404                                 IPSET_ARG_NONE,
405                         },
406                         .need = IPSET_FLAG(IPSET_OPT_IP)
407                                 | IPSET_FLAG(IPSET_OPT_PROTO)
408                                 | IPSET_FLAG(IPSET_OPT_PORT)
409                                 | IPSET_FLAG(IPSET_OPT_IP2),
410                         .full = IPSET_FLAG(IPSET_OPT_IP)
411                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
412                                 | IPSET_FLAG(IPSET_OPT_PROTO)
413                                 | IPSET_FLAG(IPSET_OPT_PORT)
414                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
415                                 | IPSET_FLAG(IPSET_OPT_IP2),
416                         .help = "IP,[PROTO:]PORT,IP",
417                 },
418                 [IPSET_TEST] = {
419                         .args = {
420                                 IPSET_ARG_NONE,
421                         },
422                         .need = IPSET_FLAG(IPSET_OPT_IP)
423                                 | IPSET_FLAG(IPSET_OPT_PROTO)
424                                 | IPSET_FLAG(IPSET_OPT_PORT)
425                                 | IPSET_FLAG(IPSET_OPT_IP2),
426                         .full = IPSET_FLAG(IPSET_OPT_IP)
427                                 | IPSET_FLAG(IPSET_OPT_PROTO)
428                                 | IPSET_FLAG(IPSET_OPT_PORT)
429                                 | IPSET_FLAG(IPSET_OPT_IP2),
430                         .help = "IP,[PROTO:]PORT,IP",
431                 },
432         },
433         .usage = "where depending on the INET family\n"
434                  "      IP is a valid IPv4 or IPv6 address (or hostname).\n"
435                  "      Adding/deleting multiple elements in IP/CIDR or FROM-TO form\n"
436                  "      in the first IP component is supported for IPv4.\n"
437                  "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
438                  "      port range is supported both for IPv4 and IPv6.",
439         .usagefn = ipset_port_usage,
440         .description = "forceadd support",
441 };
442
443 /* skbinfo support */
444 static struct ipset_type ipset_hash_ipportip5 = {
445         .name = "hash:ip,port,ip",
446         .alias = { "ipportiphash", NULL },
447         .revision = 5,
448         .family = NFPROTO_IPSET_IPV46,
449         .dimension = IPSET_DIM_THREE,
450         .elem = {
451                 [IPSET_DIM_ONE - 1] = {
452                         .parse = ipset_parse_ip4_single6,
453                         .print = ipset_print_ip,
454                         .opt = IPSET_OPT_IP
455                 },
456                 [IPSET_DIM_TWO - 1] = {
457                         .parse = ipset_parse_proto_port,
458                         .print = ipset_print_proto_port,
459                         .opt = IPSET_OPT_PORT
460                 },
461                 [IPSET_DIM_THREE - 1] = {
462                         .parse = ipset_parse_single_ip,
463                         .print = ipset_print_ip,
464                         .opt = IPSET_OPT_IP2
465                 },
466         },
467         .cmd = {
468                 [IPSET_CREATE] = {
469                         .args = {
470                                 IPSET_ARG_FAMILY,
471                                 /* Aliases */
472                                 IPSET_ARG_INET,
473                                 IPSET_ARG_INET6,
474                                 IPSET_ARG_HASHSIZE,
475                                 IPSET_ARG_MAXELEM,
476                                 IPSET_ARG_TIMEOUT,
477                                 IPSET_ARG_COUNTERS,
478                                 IPSET_ARG_COMMENT,
479                                 IPSET_ARG_FORCEADD,
480                                 IPSET_ARG_SKBINFO,
481                                 /* Ignored options: backward compatibilty */
482                                 IPSET_ARG_PROBES,
483                                 IPSET_ARG_RESIZE,
484                                 IPSET_ARG_IGNORED_FROM,
485                                 IPSET_ARG_IGNORED_TO,
486                                 IPSET_ARG_IGNORED_NETWORK,
487                                 IPSET_ARG_NONE,
488                         },
489                         .need = 0,
490                         .full = 0,
491                         .help = "",
492                 },
493                 [IPSET_ADD] = {
494                         .args = {
495                                 IPSET_ARG_TIMEOUT,
496                                 IPSET_ARG_PACKETS,
497                                 IPSET_ARG_BYTES,
498                                 IPSET_ARG_ADT_COMMENT,
499                                 IPSET_ARG_SKBMARK,
500                                 IPSET_ARG_SKBPRIO,
501                                 IPSET_ARG_SKBQUEUE,
502                                 IPSET_ARG_NONE,
503                         },
504                         .need = IPSET_FLAG(IPSET_OPT_IP)
505                                 | IPSET_FLAG(IPSET_OPT_PROTO)
506                                 | IPSET_FLAG(IPSET_OPT_PORT)
507                                 | IPSET_FLAG(IPSET_OPT_IP2),
508                         .full = IPSET_FLAG(IPSET_OPT_IP)
509                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
510                                 | IPSET_FLAG(IPSET_OPT_PROTO)
511                                 | IPSET_FLAG(IPSET_OPT_PORT)
512                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
513                                 | IPSET_FLAG(IPSET_OPT_IP2),
514                         .help = "IP,[PROTO:]PORT,IP",
515                 },
516                 [IPSET_DEL] = {
517                         .args = {
518                                 IPSET_ARG_NONE,
519                         },
520                         .need = IPSET_FLAG(IPSET_OPT_IP)
521                                 | IPSET_FLAG(IPSET_OPT_PROTO)
522                                 | IPSET_FLAG(IPSET_OPT_PORT)
523                                 | IPSET_FLAG(IPSET_OPT_IP2),
524                         .full = IPSET_FLAG(IPSET_OPT_IP)
525                                 | IPSET_FLAG(IPSET_OPT_IP_TO)
526                                 | IPSET_FLAG(IPSET_OPT_PROTO)
527                                 | IPSET_FLAG(IPSET_OPT_PORT)
528                                 | IPSET_FLAG(IPSET_OPT_PORT_TO)
529                                 | IPSET_FLAG(IPSET_OPT_IP2),
530                         .help = "IP,[PROTO:]PORT,IP",
531                 },
532                 [IPSET_TEST] = {
533                         .args = {
534                                 IPSET_ARG_NONE,
535                         },
536                         .need = IPSET_FLAG(IPSET_OPT_IP)
537                                 | IPSET_FLAG(IPSET_OPT_PROTO)
538                                 | IPSET_FLAG(IPSET_OPT_PORT)
539                                 | IPSET_FLAG(IPSET_OPT_IP2),
540                         .full = IPSET_FLAG(IPSET_OPT_IP)
541                                 | IPSET_FLAG(IPSET_OPT_PROTO)
542                                 | IPSET_FLAG(IPSET_OPT_PORT)
543                                 | IPSET_FLAG(IPSET_OPT_IP2),
544                         .help = "IP,[PROTO:]PORT,IP",
545                 },
546         },
547         .usage = "where depending on the INET family\n"
548                  "      IP is a valid IPv4 or IPv6 address (or hostname).\n"
549                  "      Adding/deleting multiple elements in IP/CIDR or FROM-TO form\n"
550                  "      in the first IP component is supported for IPv4.\n"
551                  "      Adding/deleting multiple elements with TCP/SCTP/UDP/UDPLITE\n"
552                  "      port range is supported both for IPv4 and IPv6.",
553         .usagefn = ipset_port_usage,
554         .description = "skbinfo support",
555 };
556
557 void _init(void);
558 void _init(void)
559 {
560         ipset_type_add(&ipset_hash_ipportip1);
561         ipset_type_add(&ipset_hash_ipportip2);
562         ipset_type_add(&ipset_hash_ipportip3);
563         ipset_type_add(&ipset_hash_ipportip4);
564         ipset_type_add(&ipset_hash_ipportip5);
565 }