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