summaryrefslogtreecommitdiff
path: root/contrib/ipfilter
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2019-09-27 00:29:12 +0000
committerCy Schubert <cy@FreeBSD.org>2019-09-27 00:29:12 +0000
commita97e8d2fe49304de1d9ea3c866dfbf6cce5aaa4b (patch)
treed07cc1bf429cce5f9989c8d442b5cde379f2a731 /contrib/ipfilter
parente7257e14993e23e57f113efa21e5f3507ac2d1b5 (diff)
downloadsrc-test2-a97e8d2fe49304de1d9ea3c866dfbf6cce5aaa4b.tar.gz
src-test2-a97e8d2fe49304de1d9ea3c866dfbf6cce5aaa4b.zip
Notes
Diffstat (limited to 'contrib/ipfilter')
-rw-r--r--contrib/ipfilter/man/ippool.82
-rw-r--r--contrib/ipfilter/tools/ippool.c33
2 files changed, 27 insertions, 8 deletions
diff --git a/contrib/ipfilter/man/ippool.8 b/contrib/ipfilter/man/ippool.8
index 09ff80cc9a2f..ea9664c37d6c 100644
--- a/contrib/ipfilter/man/ippool.8
+++ b/contrib/ipfilter/man/ippool.8
@@ -9,7 +9,7 @@ ippool \- user interface to the IPFilter pools
-a [-dnv] [-m <name>] [-o <role>] [-t <type>] [-T ttl] -i <ipaddr>[/<netmask>]
.br
.B ippool
--A [-dnv] [-m <name>] [-o <role>] [-S <seed>] [-t <type>]
+-A [-dnv] [-m <name>] [-o <role>] [-S <seed>] -t <type>
.br
.B ippool
-f <file> [-dnuv]
diff --git a/contrib/ipfilter/tools/ippool.c b/contrib/ipfilter/tools/ippool.c
index 8a1564ea59e6..4785d65c8db4 100644
--- a/contrib/ipfilter/tools/ippool.c
+++ b/contrib/ipfilter/tools/ippool.c
@@ -257,7 +257,7 @@ poolcommand(remove, argc, argv)
char *argv[];
{
int type, role, c, err;
- char *poolname;
+ char *poolname, *typearg = NULL;
iphtable_t iph;
ip_pool_t pool;
@@ -269,7 +269,7 @@ poolcommand(remove, argc, argv)
bzero((char *)&iph, sizeof(iph));
bzero((char *)&pool, sizeof(pool));
- while ((c = getopt(argc, argv, "dm:no:S:v")) != -1)
+ while ((c = getopt(argc, argv, "dm:no:S:vt:")) != -1)
switch (c)
{
case 'd' :
@@ -295,6 +295,10 @@ poolcommand(remove, argc, argv)
else
usage(argv[0]);
break;
+ case 't' :
+ type = gettype(optarg, &iph.iph_type);
+ typearg = optarg;
+ break;
case 'v' :
opts |= OPT_VERBOSE;
break;
@@ -314,17 +318,22 @@ poolcommand(remove, argc, argv)
return -1;
}
- type = gettype(argv[optind], &iph.iph_type);
- if (type == IPLT_NONE) {
- fprintf(stderr, "unknown type '%s'\n", argv[optind]);
+ if (type == IPLT_NONE && remove == 0) {
+ if (typearg == NULL) {
+ fprintf(stderr, "type must be specified\n");
+ usage(argv[0]);
+ } else {
+ fprintf(stderr, "unknown type '%s'\n", typearg);
+ }
return -1;
}
- if (type == IPLT_HASH) {
+ if (type == IPLT_HASH || (type == IPLT_NONE && remove == 1)) {
strncpy(iph.iph_name, poolname, sizeof(iph.iph_name));
iph.iph_name[sizeof(iph.iph_name) - 1] = '\0';
iph.iph_unit = role;
- } else if (type == IPLT_POOL) {
+ }
+ if (type == IPLT_POOL || (type == IPLT_NONE && remove == 1)) {
strncpy(pool.ipo_name, poolname, sizeof(pool.ipo_name));
pool.ipo_name[sizeof(pool.ipo_name) - 1] = '\0';
pool.ipo_unit = role;
@@ -349,6 +358,16 @@ poolcommand(remove, argc, argv)
case IPLT_POOL :
err = remove_pool(&pool, ioctl);
break;
+ case IPLT_NONE :
+ err = 1;
+ {
+ int err_h, err_p;
+ err_h = remove_hash(&iph, ioctl);
+ err_p = remove_pool(&pool, ioctl);
+ if (err_h == 0 || err_p == 0)
+ err = 0;
+ }
+ break;
}
}
return err;