1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * Copyright (C) 2002 by Darren Reed.
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing.
5*0Sstevel@tonic-gate *
6*0Sstevel@tonic-gate * $Id: remove_pool.c,v 1.1 2003/04/13 06:40:14 darrenr Exp $
7*0Sstevel@tonic-gate */
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate #include <fcntl.h>
10*0Sstevel@tonic-gate #include <sys/ioctl.h>
11*0Sstevel@tonic-gate #include "ipf.h"
12*0Sstevel@tonic-gate #include "netinet/ip_lookup.h"
13*0Sstevel@tonic-gate #include "netinet/ip_htable.h"
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gate static int poolfd = -1;
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gate
remove_pool(poolp,iocfunc)18*0Sstevel@tonic-gate int remove_pool(poolp, iocfunc)
19*0Sstevel@tonic-gate ip_pool_t *poolp;
20*0Sstevel@tonic-gate ioctlfunc_t iocfunc;
21*0Sstevel@tonic-gate {
22*0Sstevel@tonic-gate iplookupop_t op;
23*0Sstevel@tonic-gate ip_pool_t pool;
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0))
26*0Sstevel@tonic-gate poolfd = open(IPLOOKUP_NAME, O_RDWR);
27*0Sstevel@tonic-gate if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0))
28*0Sstevel@tonic-gate return -1;
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate op.iplo_type = IPLT_POOL;
31*0Sstevel@tonic-gate op.iplo_unit = poolp->ipo_unit;
32*0Sstevel@tonic-gate strncpy(op.iplo_name, poolp->ipo_name, sizeof(op.iplo_name));
33*0Sstevel@tonic-gate op.iplo_size = sizeof(pool);
34*0Sstevel@tonic-gate op.iplo_struct = &pool;
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gate bzero((char *)&pool, sizeof(pool));
37*0Sstevel@tonic-gate pool.ipo_unit = poolp->ipo_unit;
38*0Sstevel@tonic-gate strncpy(pool.ipo_name, poolp->ipo_name, sizeof(pool.ipo_name));
39*0Sstevel@tonic-gate pool.ipo_flags = poolp->ipo_flags;
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate if ((*iocfunc)(poolfd, SIOCLOOKUPDELTABLE, &op))
42*0Sstevel@tonic-gate if ((opts & OPT_DONOTHING) == 0) {
43*0Sstevel@tonic-gate perror("remove_pool:SIOCLOOKUPDELTABLE");
44*0Sstevel@tonic-gate return -1;
45*0Sstevel@tonic-gate }
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gate return 0;
48*0Sstevel@tonic-gate }
49