1 /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
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.
7 #include <libipset/data.h> /* IPSET_OPT_* */
8 #include <libipset/parse.h> /* parser functions */
9 #include <libipset/print.h> /* printing functions */
10 #include <libipset/types.h> /* prototypes */
13 static struct ipset_type ipset_bitmap_port0 = {
14 .name = "bitmap:port",
15 .alias = { "portmap", NULL },
17 .family = NFPROTO_UNSPEC,
18 .dimension = IPSET_DIM_ONE,
20 [IPSET_DIM_ONE - 1] = {
21 .parse = ipset_parse_tcp_udp_port,
22 .print = ipset_print_port,
31 /* Backward compatibility */
36 .need = IPSET_FLAG(IPSET_OPT_PORT)
37 | IPSET_FLAG(IPSET_OPT_PORT_TO),
38 .full = IPSET_FLAG(IPSET_OPT_PORT)
39 | IPSET_FLAG(IPSET_OPT_PORT_TO),
40 .help = "range [PROTO:]FROM-TO",
47 .need = IPSET_FLAG(IPSET_OPT_PORT),
48 .full = IPSET_FLAG(IPSET_OPT_PORT)
49 | IPSET_FLAG(IPSET_OPT_PORT_TO),
50 .help = "[PROTO:]PORT|FROM-TO",
56 .need = IPSET_FLAG(IPSET_OPT_PORT),
57 .full = IPSET_FLAG(IPSET_OPT_PORT)
58 | IPSET_FLAG(IPSET_OPT_PORT_TO),
59 .help = "[PROTO:]PORT|FROM-TO",
65 .need = IPSET_FLAG(IPSET_OPT_PORT),
66 .full = IPSET_FLAG(IPSET_OPT_PORT),
67 .help = "[PROTO:]PORT",
70 .usage = "where PORT, FROM and TO are port numbers or port names from /etc/services.\n"
71 " PROTO is only needed if a service name is used and it does not exist\n"
72 " as a TCP service; it isn't used otherwise with the bitmap.",
73 .description = "Initial revision",
76 /* Counters support */
77 static struct ipset_type ipset_bitmap_port1 = {
78 .name = "bitmap:port",
79 .alias = { "portmap", NULL },
81 .family = NFPROTO_UNSPEC,
82 .dimension = IPSET_DIM_ONE,
84 [IPSET_DIM_ONE - 1] = {
85 .parse = ipset_parse_tcp_udp_port,
86 .print = ipset_print_port,
96 /* Backward compatibility */
101 .need = IPSET_FLAG(IPSET_OPT_PORT)
102 | IPSET_FLAG(IPSET_OPT_PORT_TO),
103 .full = IPSET_FLAG(IPSET_OPT_PORT)
104 | IPSET_FLAG(IPSET_OPT_PORT_TO),
105 .help = "range [PROTO:]FROM-TO",
114 .need = IPSET_FLAG(IPSET_OPT_PORT),
115 .full = IPSET_FLAG(IPSET_OPT_PORT)
116 | IPSET_FLAG(IPSET_OPT_PORT_TO),
117 .help = "[PROTO:]PORT|FROM-TO",
123 .need = IPSET_FLAG(IPSET_OPT_PORT),
124 .full = IPSET_FLAG(IPSET_OPT_PORT)
125 | IPSET_FLAG(IPSET_OPT_PORT_TO),
126 .help = "[PROTO:]PORT|FROM-TO",
132 .need = IPSET_FLAG(IPSET_OPT_PORT),
133 .full = IPSET_FLAG(IPSET_OPT_PORT),
134 .help = "[PROTO:]PORT",
137 .usage = "where PORT, FROM and TO are port numbers or port names from /etc/services.\n"
138 " PROTO is only needed if a service name is used and it does not exist\n"
139 " as a TCP service; it isn't used otherwise with the bitmap.",
140 .description = "counters support",
143 /* Comment support */
144 static struct ipset_type ipset_bitmap_port2 = {
145 .name = "bitmap:port",
146 .alias = { "portmap", NULL },
148 .family = NFPROTO_UNSPEC,
149 .dimension = IPSET_DIM_ONE,
151 [IPSET_DIM_ONE - 1] = {
152 .parse = ipset_parse_tcp_udp_port,
153 .print = ipset_print_port,
154 .opt = IPSET_OPT_PORT
164 /* Backward compatibility */
169 .need = IPSET_FLAG(IPSET_OPT_PORT)
170 | IPSET_FLAG(IPSET_OPT_PORT_TO),
171 .full = IPSET_FLAG(IPSET_OPT_PORT)
172 | IPSET_FLAG(IPSET_OPT_PORT_TO),
173 .help = "range [PROTO:]FROM-TO",
180 IPSET_ARG_ADT_COMMENT,
183 .need = IPSET_FLAG(IPSET_OPT_PORT),
184 .full = IPSET_FLAG(IPSET_OPT_PORT)
185 | IPSET_FLAG(IPSET_OPT_PORT_TO),
186 .help = "[PROTO:]PORT|FROM-TO",
192 .need = IPSET_FLAG(IPSET_OPT_PORT),
193 .full = IPSET_FLAG(IPSET_OPT_PORT)
194 | IPSET_FLAG(IPSET_OPT_PORT_TO),
195 .help = "[PROTO:]PORT|FROM-TO",
201 .need = IPSET_FLAG(IPSET_OPT_PORT),
202 .full = IPSET_FLAG(IPSET_OPT_PORT),
203 .help = "[PROTO:]PORT",
206 .usage = "where PORT, FROM and TO are port numbers or port names from /etc/services.\n"
207 " PROTO is only needed if a service name is used and it does not exist\n"
208 " as a TCP service; it isn't used otherwise with the bitmap.",
209 .description = "comment support",
212 /* skbinfo support */
213 static struct ipset_type ipset_bitmap_port3 = {
214 .name = "bitmap:port",
215 .alias = { "portmap", NULL },
217 .family = NFPROTO_UNSPEC,
218 .dimension = IPSET_DIM_ONE,
220 [IPSET_DIM_ONE - 1] = {
221 .parse = ipset_parse_tcp_udp_port,
222 .print = ipset_print_port,
223 .opt = IPSET_OPT_PORT
234 /* Backward compatibility */
239 .need = IPSET_FLAG(IPSET_OPT_PORT)
240 | IPSET_FLAG(IPSET_OPT_PORT_TO),
241 .full = IPSET_FLAG(IPSET_OPT_PORT)
242 | IPSET_FLAG(IPSET_OPT_PORT_TO),
243 .help = "range [PROTO:]FROM-TO",
250 IPSET_ARG_ADT_COMMENT,
256 .need = IPSET_FLAG(IPSET_OPT_PORT),
257 .full = IPSET_FLAG(IPSET_OPT_PORT)
258 | IPSET_FLAG(IPSET_OPT_PORT_TO),
259 .help = "[PROTO:]PORT|FROM-TO",
265 .need = IPSET_FLAG(IPSET_OPT_PORT),
266 .full = IPSET_FLAG(IPSET_OPT_PORT)
267 | IPSET_FLAG(IPSET_OPT_PORT_TO),
268 .help = "[PROTO:]PORT|FROM-TO",
274 .need = IPSET_FLAG(IPSET_OPT_PORT),
275 .full = IPSET_FLAG(IPSET_OPT_PORT),
276 .help = "[PROTO:]PORT",
279 .usage = "where PORT, FROM and TO are port numbers or port names from /etc/services.\n"
280 " PROTO is only needed if a service name is used and it does not exist\n"
281 " as a TCP service; it isn't used otherwise with the bitmap.",
282 .description = "skbinfo support",
288 ipset_type_add(&ipset_bitmap_port0);
289 ipset_type_add(&ipset_bitmap_port1);
290 ipset_type_add(&ipset_bitmap_port2);
291 ipset_type_add(&ipset_bitmap_port3);