summaryrefslogtreecommitdiffstats
path: root/src/ipset_hash_ipportnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipset_hash_ipportnet.c')
-rw-r--r--src/ipset_hash_ipportnet.c83
1 files changed, 42 insertions, 41 deletions
diff --git a/src/ipset_hash_ipportnet.c b/src/ipset_hash_ipportnet.c
index 769304d..13a0487 100644
--- a/src/ipset_hash_ipportnet.c
+++ b/src/ipset_hash_ipportnet.c
@@ -11,48 +11,58 @@
/* Parse commandline arguments */
static const struct ipset_arg hash_ipportnet_create_args[] = {
- { .name = { "range", "--range", NULL },
- .has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_IP,
- .parse = ipset_parse_netrange, .print = ipset_print_ip,
+ { .name = { "family", NULL },
+ .has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_FAMILY,
+ .parse = ipset_parse_family, .print = ipset_print_family,
+ },
+ /* Alias: family inet */
+ { .name = { "-4", NULL },
+ .has_arg = IPSET_NO_ARG, .opt = IPSET_OPT_FAMILY,
+ .parse = ipset_parse_family,
+ },
+ /* Alias: family inet6 */
+ { .name = { "-6", NULL },
+ .has_arg = IPSET_NO_ARG, .opt = IPSET_OPT_FAMILY,
+ .parse = ipset_parse_family,
},
- { .name = { "hashsize", "--hashsize", NULL },
+ { .name = { "hashsize", NULL },
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_HASHSIZE,
.parse = ipset_parse_uint32, .print = ipset_print_number,
},
- { .name = { "maxelem", "--maxleme", NULL },
+ { .name = { "maxelem", NULL },
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_MAXELEM,
.parse = ipset_parse_uint32, .print = ipset_print_number,
},
- { .name = { "probes", "--probes", NULL },
- .has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_PROBES,
- .parse = ipset_parse_uint8, .print = ipset_print_number,
- },
- { .name = { "resize", "--resize", NULL },
- .has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_RESIZE,
- .parse = ipset_parse_uint8, .print = ipset_print_number,
- },
- { .name = { "timeout", "--timeout", NULL },
+ { .name = { "timeout", NULL },
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_TIMEOUT,
.parse = ipset_parse_uint32, .print = ipset_print_number,
},
/* Backward compatibility */
- { .name = { "--from", NULL },
+ { .name = { "probes", NULL },
+ .has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_PROBES,
+ .parse = ipset_parse_ignored, .print = ipset_print_number,
+ },
+ { .name = { "resize", NULL },
+ .has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_RESIZE,
+ .parse = ipset_parse_ignored, .print = ipset_print_number,
+ },
+ { .name = { "from", NULL },
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_IP,
- .parse = ipset_parse_single_ip,
+ .parse = ipset_parse_ignored,
},
- { .name = { "--to", NULL },
+ { .name = { "to", NULL },
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_IP_TO,
- .parse = ipset_parse_single_ip,
+ .parse = ipset_parse_ignored,
},
- { .name = { "--network", NULL },
+ { .name = { "network", NULL },
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_IP,
- .parse = ipset_parse_net,
+ .parse = ipset_parse_ignored,
},
{ },
};
static const struct ipset_arg hash_ipportnet_add_args[] = {
- { .name = { "timeout", "--timeout", NULL },
+ { .name = { "timeout", NULL },
.has_arg = IPSET_MANDATORY_ARG, .opt = IPSET_OPT_TIMEOUT,
.parse = ipset_parse_uint32, .print = ipset_print_number,
},
@@ -60,18 +70,17 @@ static const struct ipset_arg hash_ipportnet_add_args[] = {
};
static const char hash_ipportnet_usage[] =
-"create SETNAME hash:ip,port,net range IP/CIDR|FROM-TO\n"
+"create SETNAME hash:ip,port,net\n"
" [family inet|inet6]\n"
" [hashsize VALUE] [maxelem VALUE]\n"
-" [probes VALUE] [resize VALUE]\n"
" [timeout VALUE]\n"
-"add SETNAME IP,PORT,IP/CIDR [timeout VALUE]\n"
-"del SETNAME IP,PORT,IP/CIDR\n"
-"test SETNAME IP,PORT,IP/CIDR\n";
+"add SETNAME IP,PORT,IP[/CIDR] [timeout VALUE]\n"
+"del SETNAME IP,PORT,IP[/CIDR]\n"
+"test SETNAME IP,PORT,IP[/CIDR]\n";
struct ipset_type ipset_hash_ipportnet0 = {
.name = "hash:ip,port,net",
- .alias = "ipportnethash",
+ .alias = { "ipportnethash", NULL },
.revision = 0,
.family = AF_INET46,
.dimension = IPSET_DIM_THREE,
@@ -87,7 +96,7 @@ struct ipset_type ipset_hash_ipportnet0 = {
.opt = IPSET_OPT_PORT
},
[IPSET_DIM_THREE] = {
- .parse = ipset_parse_net,
+ .parse = ipset_parse_ipnet,
.print = ipset_print_ip,
.opt = IPSET_OPT_IP2
},
@@ -97,28 +106,20 @@ struct ipset_type ipset_hash_ipportnet0 = {
[IPSET_ADD] = hash_ipportnet_add_args,
},
.mandatory = {
- [IPSET_CREATE] = IPSET_FLAG(IPSET_OPT_IP)
- | IPSET_FLAG(IPSET_OPT_IP_TO),
+ [IPSET_CREATE] = 0,
[IPSET_ADD] = IPSET_FLAG(IPSET_OPT_IP)
| IPSET_FLAG(IPSET_OPT_PORT)
- | IPSET_FLAG(IPSET_OPT_IP2)
- | IPSET_FLAG(IPSET_OPT_CIDR2),
+ | IPSET_FLAG(IPSET_OPT_IP2),
[IPSET_DEL] = IPSET_FLAG(IPSET_OPT_IP)
| IPSET_FLAG(IPSET_OPT_PORT)
- | IPSET_FLAG(IPSET_OPT_IP2)
- | IPSET_FLAG(IPSET_OPT_CIDR2),
+ | IPSET_FLAG(IPSET_OPT_IP2),
[IPSET_TEST] = IPSET_FLAG(IPSET_OPT_IP)
| IPSET_FLAG(IPSET_OPT_PORT)
- | IPSET_FLAG(IPSET_OPT_IP2)
- | IPSET_FLAG(IPSET_OPT_CIDR2),
+ | IPSET_FLAG(IPSET_OPT_IP2),
},
.full = {
- [IPSET_CREATE] = IPSET_FLAG(IPSET_OPT_IP)
- | IPSET_FLAG(IPSET_OPT_IP_TO)
- | IPSET_FLAG(IPSET_OPT_HASHSIZE)
+ [IPSET_CREATE] = IPSET_FLAG(IPSET_OPT_HASHSIZE)
| IPSET_FLAG(IPSET_OPT_MAXELEM)
- | IPSET_FLAG(IPSET_OPT_PROBES)
- | IPSET_FLAG(IPSET_OPT_RESIZE)
| IPSET_FLAG(IPSET_OPT_TIMEOUT),
[IPSET_ADD] = IPSET_FLAG(IPSET_OPT_IP)
| IPSET_FLAG(IPSET_OPT_PORT)