~ubuntu-branches/ubuntu/trusty/xtables-addons/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2011-05-09 21:42:42 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110509214242-x3qc2okkyupvefoy
Tags: 1.35-1
* Imported Upstream version 1.35
* Update version numbers for DKMS package (Closes: #620662)
* Bump Standards Version to 3.9.2

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/ui.h>                        /* ipset_port_usage */
11
 
#include <libipset/types.h>                     /* prototypes */
12
 
 
13
 
/* Parse commandline arguments */
14
 
static const struct ipset_arg hash_ipportip_create_args[] = {
15
 
        { .name = { "family", NULL },
16
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_FAMILY,
17
 
          .parse = ipset_parse_family,          .print = ipset_print_family,
18
 
        },
19
 
        /* Alias: family inet */
20
 
        { .name = { "-4", NULL },
21
 
          .has_arg = IPSET_NO_ARG,              .opt = IPSET_OPT_FAMILY,
22
 
          .parse = ipset_parse_family,
23
 
        },
24
 
        /* Alias: family inet6 */
25
 
        { .name = { "-6", NULL },
26
 
          .has_arg = IPSET_NO_ARG,              .opt = IPSET_OPT_FAMILY,
27
 
          .parse = ipset_parse_family,
28
 
        },
29
 
        { .name = { "hashsize", NULL },
30
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_HASHSIZE,
31
 
          .parse = ipset_parse_uint32,          .print = ipset_print_number,
32
 
        },
33
 
        { .name = { "maxelem", NULL },
34
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_MAXELEM,
35
 
          .parse = ipset_parse_uint32,          .print = ipset_print_number,
36
 
        },
37
 
        { .name = { "timeout", NULL },
38
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_TIMEOUT,
39
 
          .parse = ipset_parse_uint32,          .print = ipset_print_number,
40
 
        },
41
 
        /* Backward compatibility */
42
 
        { .name = { "probes", NULL },
43
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_PROBES,
44
 
          .parse = ipset_parse_ignored,         .print = ipset_print_number,
45
 
        },
46
 
        { .name = { "resize", NULL },
47
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_RESIZE,
48
 
          .parse = ipset_parse_ignored,         .print = ipset_print_number,
49
 
        },
50
 
        { .name = { "from", NULL },
51
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_IP,
52
 
          .parse = ipset_parse_ignored,
53
 
        },
54
 
        { .name = { "to", NULL },
55
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_IP_TO,
56
 
          .parse = ipset_parse_ignored,
57
 
        },
58
 
        { .name = { "network", NULL },
59
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_IP,
60
 
          .parse = ipset_parse_ignored,
61
 
        },
62
 
        { },
63
 
}; 
64
 
 
65
 
static const struct ipset_arg hash_ipportip_add_args[] = {
66
 
        { .name = { "timeout", NULL },
67
 
          .has_arg = IPSET_MANDATORY_ARG,       .opt = IPSET_OPT_TIMEOUT,
68
 
          .parse = ipset_parse_uint32,          .print = ipset_print_number,
69
 
        },
70
 
        { },
71
 
}; 
72
 
 
73
 
static const char hash_ipportip_usage[] =
74
 
"create SETNAME hash:ip,port,ip\n"
75
 
"               [family inet|inet6]\n"
76
 
"               [hashsize VALUE] [maxelem VALUE]\n"
77
 
"               [timeout VALUE]\n"
78
 
"add    SETNAME IP,PROTO:PORT,IP [timeout VALUE]\n"
79
 
"del    SETNAME IP,PROTO:PORT,IP\n"
80
 
"test   SETNAME IP,PROTO:PORT,IP\n\n"
81
 
"where depending on the INET family\n"
82
 
"      IP is a valid IPv4 or IPv6 address (or hostname).\n"
83
 
"      Adding/deleting multiple elements in IP/CIDR or FROM-TO form\n"
84
 
"      in the first IP component is supported for IPv4.\n"
85
 
"      Adding/deleting multiple elements with TCP/UDP port range\n"
86
 
"      is supported both for IPv4 and IPv6.\n";
87
 
 
88
 
struct ipset_type ipset_hash_ipportip0 = {
89
 
        .name = "hash:ip,port,ip",
90
 
        .alias = { "ipportiphash", NULL },
91
 
        .revision = 0,
92
 
        .family = AF_INET46,
93
 
        .dimension = IPSET_DIM_THREE,
94
 
        .elem = { 
95
 
                [IPSET_DIM_ONE] = { 
96
 
                        .parse = ipset_parse_ip4_single6,
97
 
                        .print = ipset_print_ip,
98
 
                        .opt = IPSET_OPT_IP
99
 
                },
100
 
                [IPSET_DIM_TWO] = { 
101
 
                        .parse = ipset_parse_proto_port,
102
 
                        .print = ipset_print_proto_port,
103
 
                        .opt = IPSET_OPT_PORT
104
 
                },
105
 
                [IPSET_DIM_THREE] = { 
106
 
                        .parse = ipset_parse_single_ip,
107
 
                        .print = ipset_print_ip,
108
 
                        .opt = IPSET_OPT_IP2
109
 
                },
110
 
        },
111
 
        .args = {
112
 
                [IPSET_CREATE] = hash_ipportip_create_args,
113
 
                [IPSET_ADD] = hash_ipportip_add_args,
114
 
        },
115
 
        .mandatory = {
116
 
                [IPSET_CREATE] = 0,
117
 
                [IPSET_ADD] = IPSET_FLAG(IPSET_OPT_IP)
118
 
                        | IPSET_FLAG(IPSET_OPT_PORT)
119
 
                        | IPSET_FLAG(IPSET_OPT_PROTO)
120
 
                        | IPSET_FLAG(IPSET_OPT_IP2),
121
 
                [IPSET_DEL] = IPSET_FLAG(IPSET_OPT_IP)
122
 
                        | IPSET_FLAG(IPSET_OPT_PORT)
123
 
                        | IPSET_FLAG(IPSET_OPT_PROTO)
124
 
                        | IPSET_FLAG(IPSET_OPT_IP2),
125
 
                [IPSET_TEST] = IPSET_FLAG(IPSET_OPT_IP)
126
 
                        | IPSET_FLAG(IPSET_OPT_PORT)
127
 
                        | IPSET_FLAG(IPSET_OPT_PROTO)
128
 
                        | IPSET_FLAG(IPSET_OPT_IP2),
129
 
        },
130
 
        .full = {
131
 
                [IPSET_CREATE] = IPSET_FLAG(IPSET_OPT_HASHSIZE)
132
 
                        | IPSET_FLAG(IPSET_OPT_MAXELEM)
133
 
                        | IPSET_FLAG(IPSET_OPT_TIMEOUT),
134
 
                [IPSET_ADD] = IPSET_FLAG(IPSET_OPT_IP)
135
 
                        | IPSET_FLAG(IPSET_OPT_IP_TO)
136
 
                        | IPSET_FLAG(IPSET_OPT_PORT)
137
 
                        | IPSET_FLAG(IPSET_OPT_PORT_TO)
138
 
                        | IPSET_FLAG(IPSET_OPT_PROTO)
139
 
                        | IPSET_FLAG(IPSET_OPT_IP2)
140
 
                        | IPSET_FLAG(IPSET_OPT_TIMEOUT),
141
 
                [IPSET_DEL] = IPSET_FLAG(IPSET_OPT_IP)
142
 
                        | IPSET_FLAG(IPSET_OPT_IP_TO)
143
 
                        | IPSET_FLAG(IPSET_OPT_PORT)
144
 
                        | IPSET_FLAG(IPSET_OPT_PORT_TO)
145
 
                        | IPSET_FLAG(IPSET_OPT_PROTO)
146
 
                        | IPSET_FLAG(IPSET_OPT_IP2),
147
 
                [IPSET_TEST] = IPSET_FLAG(IPSET_OPT_IP)
148
 
                        | IPSET_FLAG(IPSET_OPT_PORT)
149
 
                        | IPSET_FLAG(IPSET_OPT_PROTO)
150
 
                        | IPSET_FLAG(IPSET_OPT_IP2),
151
 
        },
152
 
 
153
 
        .usage = hash_ipportip_usage,
154
 
        .usagefn = ipset_port_usage,
155
 
};