~ubuntu-branches/ubuntu/quantal/xtables-addons/quantal

« back to all changes in this revision

Viewing changes to extensions/ipset-5/src/ipset_bitmap_ipmac.c

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2011-01-13 14:21:34 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110113142134-l7au0iehf1q1wq7k
Tags: 1.32-1
* Imported Upstream version 1.32 (Closes: #593521)
  - Build on recent kernels (Closes: #590140)
* Add temporary hack to fix configure with --without-kbuild flag
* Fix clean target

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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/types.h>                     /* prototypes */
 
11
 
 
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,
 
17
        },
 
18
        { .name = { "timeout", NULL },
 
19
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_TIMEOUT,
 
20
          .parse = ipset_parse_uint32,          .print = ipset_print_number,
 
21
        },
 
22
        /* Backward compatibility */
 
23
        { .name = { "from", NULL },
 
24
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_IP,
 
25
          .parse = ipset_parse_single_ip,
 
26
        },
 
27
        { .name = { "to", NULL },
 
28
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_IP_TO,
 
29
          .parse = ipset_parse_single_ip,
 
30
        },
 
31
        { .name = { "network", NULL },
 
32
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_IP,
 
33
          .parse = ipset_parse_net,
 
34
        },
 
35
        { },
 
36
}; 
 
37
 
 
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,
 
42
        },
 
43
        { },
 
44
}; 
 
45
 
 
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";
 
55
 
 
56
struct ipset_type ipset_bitmap_ipmac0 = {
 
57
        .name = "bitmap:ip,mac",
 
58
        .alias = { "macipmap", NULL },
 
59
        .revision = 0,
 
60
        .family = AF_INET,
 
61
        .dimension = IPSET_DIM_TWO,
 
62
        .last_elem_optional = true,
 
63
        .elem = { 
 
64
                [IPSET_DIM_ONE] = { 
 
65
                        .parse = ipset_parse_single_ip,
 
66
                        .print = ipset_print_ip,
 
67
                        .opt = IPSET_OPT_IP
 
68
                },
 
69
                [IPSET_DIM_TWO] = { 
 
70
                        .parse = ipset_parse_ether,
 
71
                        .print = ipset_print_ether,
 
72
                        .opt = IPSET_OPT_ETHER
 
73
                },
 
74
        },
 
75
        .args = {
 
76
                [IPSET_CREATE] = bitmap_ipmac_create_args,
 
77
                [IPSET_ADD] = bitmap_ipmac_add_args,
 
78
        },
 
79
        .mandatory = {
 
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),
 
85
        },
 
86
        .full = {
 
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),
 
97
        },
 
98
 
 
99
        .usage = bitmap_ipmac_usage,
 
100
};