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 */
12
/* Parse commandline arguments */
13
static const struct ipset_arg bitmap_ipmac_create_args[] = {
14
{ .name = { "range", NULL },
15
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_IP,
16
.parse = ipset_parse_netrange, .print = ipset_print_ip,
18
{ .name = { "timeout", NULL },
19
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_TIMEOUT,
20
.parse = ipset_parse_uint32, .print = ipset_print_number,
22
/* Backward compatibility */
23
{ .name = { "from", NULL },
24
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_IP,
25
.parse = ipset_parse_single_ip,
27
{ .name = { "to", NULL },
28
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_IP_TO,
29
.parse = ipset_parse_single_ip,
31
{ .name = { "network", NULL },
32
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_IP,
33
.parse = ipset_parse_net,
38
static const struct ipset_arg bitmap_ipmac_add_args[] = {
39
{ .name = { "timeout", NULL },
40
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_TIMEOUT,
41
.parse = ipset_parse_uint32, .print = ipset_print_number,
46
static const char bitmap_ipmac_usage[] =
47
"create SETNAME bitmap:ip,mac range IP/CIDR|FROM-TO\n"
48
" [matchunset] [timeout VALUE]\n"
49
"add SETNAME IP[,MAC] [timeout VALUE]\n"
50
"del SETNAME IP[,MAC]\n"
51
"test SETNAME IP[,MAC]\n\n"
52
"where IP, FROM and TO are IPv4 addresses (or hostnames),\n"
53
" CIDR is a valid IPv4 CIDR prefix,\n"
54
" MAC is a valid MAC address.\n";
56
struct ipset_type ipset_bitmap_ipmac0 = {
57
.name = "bitmap:ip,mac",
58
.alias = { "macipmap", NULL },
61
.dimension = IPSET_DIM_TWO,
62
.last_elem_optional = true,
65
.parse = ipset_parse_single_ip,
66
.print = ipset_print_ip,
70
.parse = ipset_parse_ether,
71
.print = ipset_print_ether,
72
.opt = IPSET_OPT_ETHER
76
[IPSET_CREATE] = bitmap_ipmac_create_args,
77
[IPSET_ADD] = bitmap_ipmac_add_args,
80
[IPSET_CREATE] = IPSET_FLAG(IPSET_OPT_IP)
81
| IPSET_FLAG(IPSET_OPT_IP_TO),
82
[IPSET_ADD] = IPSET_FLAG(IPSET_OPT_IP),
83
[IPSET_DEL] = IPSET_FLAG(IPSET_OPT_IP),
84
[IPSET_TEST] = IPSET_FLAG(IPSET_OPT_IP),
87
[IPSET_CREATE] = IPSET_FLAG(IPSET_OPT_IP)
88
| IPSET_FLAG(IPSET_OPT_IP_TO)
89
| IPSET_FLAG(IPSET_OPT_TIMEOUT),
90
[IPSET_ADD] = IPSET_FLAG(IPSET_OPT_IP)
91
| IPSET_FLAG(IPSET_OPT_ETHER)
92
| IPSET_FLAG(IPSET_OPT_TIMEOUT),
93
[IPSET_DEL] = IPSET_FLAG(IPSET_OPT_IP)
94
| IPSET_FLAG(IPSET_OPT_ETHER),
95
[IPSET_TEST] = IPSET_FLAG(IPSET_OPT_IP)
96
| IPSET_FLAG(IPSET_OPT_ETHER),
99
.usage = bitmap_ipmac_usage,