2005-04-25 18:20:15 +00:00
|
|
|
/* $FreeBSD$ */
|
2005-04-25 17:31:50 +00:00
|
|
|
|
|
|
|
/*
|
2013-08-11 14:28:45 +00:00
|
|
|
* Copyright (C) 2012 by Darren Reed.
|
2005-04-25 17:31:50 +00:00
|
|
|
*
|
|
|
|
* See the IPFILTER.LICENCE file for details on licencing.
|
|
|
|
*
|
2013-08-11 14:28:45 +00:00
|
|
|
* $Id$
|
2005-04-25 17:31:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include "ipf.h"
|
|
|
|
#include "netinet/ip_lookup.h"
|
|
|
|
#include "netinet/ip_htable.h"
|
|
|
|
|
|
|
|
|
2013-08-11 14:28:45 +00:00
|
|
|
int
|
2021-12-20 09:07:20 -08:00
|
|
|
remove_pool(ip_pool_t *poolp, ioctlfunc_t iocfunc)
|
2005-04-25 17:31:50 +00:00
|
|
|
{
|
|
|
|
iplookupop_t op;
|
|
|
|
ip_pool_t pool;
|
|
|
|
|
2013-08-11 14:28:45 +00:00
|
|
|
if (pool_open() == -1)
|
2022-01-03 18:49:18 -08:00
|
|
|
return (-1);
|
2005-04-25 17:31:50 +00:00
|
|
|
|
|
|
|
op.iplo_type = IPLT_POOL;
|
|
|
|
op.iplo_unit = poolp->ipo_unit;
|
|
|
|
strncpy(op.iplo_name, poolp->ipo_name, sizeof(op.iplo_name));
|
|
|
|
op.iplo_size = sizeof(pool);
|
|
|
|
op.iplo_struct = &pool;
|
|
|
|
|
|
|
|
bzero((char *)&pool, sizeof(pool));
|
|
|
|
pool.ipo_unit = poolp->ipo_unit;
|
|
|
|
strncpy(pool.ipo_name, poolp->ipo_name, sizeof(pool.ipo_name));
|
|
|
|
pool.ipo_flags = poolp->ipo_flags;
|
|
|
|
|
2013-08-11 14:28:45 +00:00
|
|
|
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op)) {
|
2005-04-25 17:31:50 +00:00
|
|
|
if ((opts & OPT_DONOTHING) == 0) {
|
2022-01-03 18:49:18 -08:00
|
|
|
return (ipf_perror_fd(pool_fd(), iocfunc,
|
2021-12-21 18:37:19 -08:00
|
|
|
"delete lookup pool"));
|
2005-04-25 17:31:50 +00:00
|
|
|
}
|
2013-08-11 14:28:45 +00:00
|
|
|
}
|
2022-01-03 18:49:18 -08:00
|
|
|
return (0);
|
2005-04-25 17:31:50 +00:00
|
|
|
}
|