1145519Sdarrenr/* $FreeBSD$ */ 2145510Sdarrenr 3145510Sdarrenr/* 4255332Scy * Copyright (C) 2012 by Darren Reed. 5145510Sdarrenr * 6145510Sdarrenr * See the IPFILTER.LICENCE file for details on licencing. 7145510Sdarrenr * 8255332Scy * $Id$ 9145510Sdarrenr */ 10145510Sdarrenr 11145510Sdarrenr#include <fcntl.h> 12145510Sdarrenr#include <sys/ioctl.h> 13145510Sdarrenr#include "ipf.h" 14145510Sdarrenr#include "netinet/ip_lookup.h" 15145510Sdarrenr#include "netinet/ip_htable.h" 16145510Sdarrenr 17145510Sdarrenr 18255332Scyint 19255332Scyremove_pool(poolp, iocfunc) 20255332Scy ip_pool_t *poolp; 21255332Scy ioctlfunc_t iocfunc; 22145510Sdarrenr{ 23145510Sdarrenr iplookupop_t op; 24145510Sdarrenr ip_pool_t pool; 25145510Sdarrenr 26255332Scy if (pool_open() == -1) 27145510Sdarrenr return -1; 28145510Sdarrenr 29145510Sdarrenr op.iplo_type = IPLT_POOL; 30145510Sdarrenr op.iplo_unit = poolp->ipo_unit; 31145510Sdarrenr strncpy(op.iplo_name, poolp->ipo_name, sizeof(op.iplo_name)); 32145510Sdarrenr op.iplo_size = sizeof(pool); 33145510Sdarrenr op.iplo_struct = &pool; 34145510Sdarrenr 35145510Sdarrenr bzero((char *)&pool, sizeof(pool)); 36145510Sdarrenr pool.ipo_unit = poolp->ipo_unit; 37145510Sdarrenr strncpy(pool.ipo_name, poolp->ipo_name, sizeof(pool.ipo_name)); 38145510Sdarrenr pool.ipo_flags = poolp->ipo_flags; 39145510Sdarrenr 40255332Scy if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op)) { 41145510Sdarrenr if ((opts & OPT_DONOTHING) == 0) { 42255332Scy return ipf_perror_fd(pool_fd(), iocfunc, 43255332Scy "delete lookup pool"); 44145510Sdarrenr } 45255332Scy } 46145510Sdarrenr return 0; 47145510Sdarrenr} 48