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_ipmac0 = {
14 .name = "bitmap:ip,mac",
15 .alias = { "macipmap", NULL },
17 .family = NFPROTO_IPV4,
18 .dimension = IPSET_DIM_TWO,
19 .last_elem_optional = true,
21 [IPSET_DIM_ONE - 1] = {
22 .parse = ipset_parse_single_ip,
23 .print = ipset_print_ip,
26 [IPSET_DIM_TWO - 1] = {
27 .parse = ipset_parse_ether,
28 .print = ipset_print_ether,
29 .opt = IPSET_OPT_ETHER
37 /* Backward compatibility */
43 .need = IPSET_FLAG(IPSET_OPT_IP)
44 | IPSET_FLAG(IPSET_OPT_IP_TO),
45 .full = IPSET_FLAG(IPSET_OPT_IP)
46 | IPSET_FLAG(IPSET_OPT_IP_TO),
47 .help = "range IP/CIDR|FROM-TO",
54 .need = IPSET_FLAG(IPSET_OPT_IP),
55 .full = IPSET_FLAG(IPSET_OPT_IP)
56 | IPSET_FLAG(IPSET_OPT_ETHER),
63 .need = IPSET_FLAG(IPSET_OPT_IP),
64 .full = IPSET_FLAG(IPSET_OPT_IP)
65 | IPSET_FLAG(IPSET_OPT_ETHER),
72 .need = IPSET_FLAG(IPSET_OPT_IP),
73 .full = IPSET_FLAG(IPSET_OPT_IP)
74 | IPSET_FLAG(IPSET_OPT_ETHER),
78 .usage = "where IP, FROM and TO are IPv4 addresses (or hostnames),\n"
79 " CIDR is a valid IPv4 CIDR prefix.\n"
80 " MAC is a valid MAC address.",
81 .description = "Initial revision",
84 /* Counters support */
85 static struct ipset_type ipset_bitmap_ipmac1 = {
86 .name = "bitmap:ip,mac",
87 .alias = { "macipmap", NULL },
89 .family = NFPROTO_IPV4,
90 .dimension = IPSET_DIM_TWO,
91 .last_elem_optional = true,
93 [IPSET_DIM_ONE - 1] = {
94 .parse = ipset_parse_single_ip,
95 .print = ipset_print_ip,
98 [IPSET_DIM_TWO - 1] = {
99 .parse = ipset_parse_ether,
100 .print = ipset_print_ether,
101 .opt = IPSET_OPT_ETHER
110 /* Backward compatibility */
116 .need = IPSET_FLAG(IPSET_OPT_IP)
117 | IPSET_FLAG(IPSET_OPT_IP_TO),
118 .full = IPSET_FLAG(IPSET_OPT_IP)
119 | IPSET_FLAG(IPSET_OPT_IP_TO),
120 .help = "range IP/CIDR|FROM-TO",
129 .need = IPSET_FLAG(IPSET_OPT_IP),
130 .full = IPSET_FLAG(IPSET_OPT_IP)
131 | IPSET_FLAG(IPSET_OPT_ETHER),
138 .need = IPSET_FLAG(IPSET_OPT_IP),
139 .full = IPSET_FLAG(IPSET_OPT_IP)
140 | IPSET_FLAG(IPSET_OPT_ETHER),
147 .need = IPSET_FLAG(IPSET_OPT_IP),
148 .full = IPSET_FLAG(IPSET_OPT_IP)
149 | IPSET_FLAG(IPSET_OPT_ETHER),
153 .usage = "where IP, FROM and TO are IPv4 addresses (or hostnames),\n"
154 " CIDR is a valid IPv4 CIDR prefix.\n"
155 " MAC is a valid MAC address.",
156 .description = "counters support",
159 /* Comment support */
160 static struct ipset_type ipset_bitmap_ipmac2 = {
161 .name = "bitmap:ip,mac",
162 .alias = { "macipmap", NULL },
164 .family = NFPROTO_IPV4,
165 .dimension = IPSET_DIM_TWO,
166 .last_elem_optional = true,
168 [IPSET_DIM_ONE - 1] = {
169 .parse = ipset_parse_single_ip,
170 .print = ipset_print_ip,
173 [IPSET_DIM_TWO - 1] = {
174 .parse = ipset_parse_ether,
175 .print = ipset_print_ether,
176 .opt = IPSET_OPT_ETHER
186 /* Backward compatibility */
192 .need = IPSET_FLAG(IPSET_OPT_IP)
193 | IPSET_FLAG(IPSET_OPT_IP_TO),
194 .full = IPSET_FLAG(IPSET_OPT_IP)
195 | IPSET_FLAG(IPSET_OPT_IP_TO),
196 .help = "range IP/CIDR|FROM-TO",
203 IPSET_ARG_ADT_COMMENT,
206 .need = IPSET_FLAG(IPSET_OPT_IP),
207 .full = IPSET_FLAG(IPSET_OPT_IP)
208 | IPSET_FLAG(IPSET_OPT_ETHER),
215 .need = IPSET_FLAG(IPSET_OPT_IP),
216 .full = IPSET_FLAG(IPSET_OPT_IP)
217 | IPSET_FLAG(IPSET_OPT_ETHER),
224 .need = IPSET_FLAG(IPSET_OPT_IP),
225 .full = IPSET_FLAG(IPSET_OPT_IP)
226 | IPSET_FLAG(IPSET_OPT_ETHER),
230 .usage = "where IP, FROM and TO are IPv4 addresses (or hostnames),\n"
231 " CIDR is a valid IPv4 CIDR prefix.\n"
232 " MAC is a valid MAC address.",
233 .description = "comment support",
236 /* skbinfo support */
237 static struct ipset_type ipset_bitmap_ipmac3 = {
238 .name = "bitmap:ip,mac",
239 .alias = { "macipmap", NULL },
241 .family = NFPROTO_IPV4,
242 .dimension = IPSET_DIM_TWO,
243 .last_elem_optional = true,
245 [IPSET_DIM_ONE - 1] = {
246 .parse = ipset_parse_single_ip,
247 .print = ipset_print_ip,
250 [IPSET_DIM_TWO - 1] = {
251 .parse = ipset_parse_ether,
252 .print = ipset_print_ether,
253 .opt = IPSET_OPT_ETHER
264 /* Backward compatibility */
270 .need = IPSET_FLAG(IPSET_OPT_IP)
271 | IPSET_FLAG(IPSET_OPT_IP_TO),
272 .full = IPSET_FLAG(IPSET_OPT_IP)
273 | IPSET_FLAG(IPSET_OPT_IP_TO),
274 .help = "range IP/CIDR|FROM-TO",
281 IPSET_ARG_ADT_COMMENT,
287 .need = IPSET_FLAG(IPSET_OPT_IP),
288 .full = IPSET_FLAG(IPSET_OPT_IP)
289 | IPSET_FLAG(IPSET_OPT_ETHER),
296 .need = IPSET_FLAG(IPSET_OPT_IP),
297 .full = IPSET_FLAG(IPSET_OPT_IP)
298 | IPSET_FLAG(IPSET_OPT_ETHER),
305 .need = IPSET_FLAG(IPSET_OPT_IP),
306 .full = IPSET_FLAG(IPSET_OPT_IP)
307 | IPSET_FLAG(IPSET_OPT_ETHER),
311 .usage = "where IP, FROM and TO are IPv4 addresses (or hostnames),\n"
312 " CIDR is a valid IPv4 CIDR prefix.\n"
313 " MAC is a valid MAC address.",
314 .description = "skbinfo support",
320 ipset_type_add(&ipset_bitmap_ipmac0);
321 ipset_type_add(&ipset_bitmap_ipmac1);
322 ipset_type_add(&ipset_bitmap_ipmac2);
323 ipset_type_add(&ipset_bitmap_ipmac3);