xref: /titanic_52/usr/src/cmd/ipf/lib/common/remove_pool.c (revision f841f6ad96ea6675d6c6b35c749eaac601799fdf)
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 
13 #if SOLARIS2 >= 10
14 #include "ip_lookup.h"
15 #include "ip_htable.h"
16 #else
17 #include "netinet/ip_lookup.h"
18 #include "netinet/ip_htable.h"
19 #endif
20 
21 static int poolfd = -1;
22 
23 
24 int remove_pool(poolp, iocfunc)
25 ip_pool_t *poolp;
26 ioctlfunc_t iocfunc;
27 {
28 	iplookupop_t op;
29 	ip_pool_t pool;
30 
31 	if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0))
32 		poolfd = open(IPLOOKUP_NAME, O_RDWR);
33 	if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0))
34 		return -1;
35 
36 	op.iplo_type = IPLT_POOL;
37 	op.iplo_unit = poolp->ipo_unit;
38 	strncpy(op.iplo_name, poolp->ipo_name, sizeof(op.iplo_name));
39 	op.iplo_size = sizeof(pool);
40 	op.iplo_struct = &pool;
41 
42 	bzero((char *)&pool, sizeof(pool));
43 	pool.ipo_unit = poolp->ipo_unit;
44 	strncpy(pool.ipo_name, poolp->ipo_name, sizeof(pool.ipo_name));
45 	pool.ipo_flags = poolp->ipo_flags;
46 
47 	if ((*iocfunc)(poolfd, SIOCLOOKUPDELTABLE, &op))
48 		if ((opts & OPT_DONOTHING) == 0) {
49 			perror("remove_pool:SIOCLOOKUPDELTABLE");
50 			return -1;
51 		}
52 
53 	return 0;
54 }
55