Try to fixup the mess of mdoc(7)/man(7) mixture as created by the merge.
[netbsd-mini2440.git] / dist / ipf / lib / remove_pool.c
blob677e4e08761afba3f195a1f12fa34e1b130e1d7e
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2003 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: remove_pool.c,v 1.1.4.1 2006/06/16 17:21:16 darrenr Exp
9 */
11 #include <fcntl.h>
12 #include <sys/ioctl.h>
13 #include "ipf.h"
14 #include "netinet/ip_lookup.h"
15 #include "netinet/ip_htable.h"
17 static int poolfd = -1;
20 int remove_pool(poolp, iocfunc)
21 ip_pool_t *poolp;
22 ioctlfunc_t iocfunc;
24 iplookupop_t op;
25 ip_pool_t pool;
27 if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0))
28 poolfd = open(IPLOOKUP_NAME, O_RDWR);
29 if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0))
30 return -1;
32 op.iplo_type = IPLT_POOL;
33 op.iplo_unit = poolp->ipo_unit;
34 strncpy(op.iplo_name, poolp->ipo_name, sizeof(op.iplo_name));
35 op.iplo_size = sizeof(pool);
36 op.iplo_struct = &pool;
38 bzero((char *)&pool, sizeof(pool));
39 pool.ipo_unit = poolp->ipo_unit;
40 strncpy(pool.ipo_name, poolp->ipo_name, sizeof(pool.ipo_name));
41 pool.ipo_flags = poolp->ipo_flags;
43 if ((*iocfunc)(poolfd, SIOCLOOKUPDELTABLE, &op))
44 if ((opts & OPT_DONOTHING) == 0) {
45 perror("remove_pool:SIOCLOOKUPDELTABLE");
46 return -1;
49 return 0;