Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / remove_poolnode.c
blobbb8d8e1d2da26f5c4844fc152cc9314836b14ac1
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2003 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: remove_poolnode.c,v 1.3.2.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_pool.h"
17 static int poolfd = -1;
20 int remove_poolnode(unit, name, node, iocfunc)
21 int unit;
22 char *name;
23 ip_pool_node_t *node;
24 ioctlfunc_t iocfunc;
26 ip_pool_node_t pn;
27 iplookupop_t op;
29 if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0))
30 poolfd = open(IPLOOKUP_NAME, O_RDWR);
31 if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0))
32 return -1;
34 op.iplo_unit = unit;
35 op.iplo_type = IPLT_POOL;
36 op.iplo_arg = 0;
37 strncpy(op.iplo_name, name, sizeof(op.iplo_name));
38 op.iplo_struct = &pn;
39 op.iplo_size = sizeof(pn);
41 bzero((char *)&pn, sizeof(pn));
42 bcopy((char *)&node->ipn_addr, (char *)&pn.ipn_addr,
43 sizeof(pn.ipn_addr));
44 bcopy((char *)&node->ipn_mask, (char *)&pn.ipn_mask,
45 sizeof(pn.ipn_mask));
46 pn.ipn_info = node->ipn_info;
47 strncpy(pn.ipn_name, node->ipn_name, sizeof(pn.ipn_name));
49 if ((*iocfunc)(poolfd, SIOCLOOKUPDELNODE, &op)) {
50 if ((opts & OPT_DONOTHING) == 0) {
51 perror("remove_pool:SIOCLOOKUPDELNODE");
52 return -1;
56 return 0;