add UNLEASHED_OBJ to unleashed.mk
[unleashed/tickless.git] / usr / src / cmd / ipf / lib / common / remove_poolnode.c
blob2c7f9d30280234316f7ac94c0921f15819f17d72
1 /*
2 * Copyright (C) 2002 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: remove_poolnode.c,v 1.3 2003/11/22 10:14:36 darrenr Exp $
7 */
9 #include <fcntl.h>
10 #include <sys/ioctl.h>
11 #include "ipf.h"
12 #include "netinet/ip_lookup.h"
13 #include "netinet/ip_pool.h"
15 static int poolfd = -1;
18 int remove_poolnode(unit, name, node, iocfunc)
19 int unit;
20 char *name;
21 ip_pool_node_t *node;
22 ioctlfunc_t iocfunc;
24 ip_pool_node_t pn;
25 iplookupop_t op;
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_unit = unit;
33 op.iplo_type = IPLT_POOL;
34 op.iplo_arg = 0;
35 strncpy(op.iplo_name, name, sizeof(op.iplo_name));
36 op.iplo_struct = &pn;
37 op.iplo_size = sizeof(pn);
39 bzero((char *)&pn, sizeof(pn));
40 bcopy((char *)&node->ipn_addr, (char *)&pn.ipn_addr,
41 sizeof(pn.ipn_addr));
42 bcopy((char *)&node->ipn_mask, (char *)&pn.ipn_mask,
43 sizeof(pn.ipn_mask));
44 pn.ipn_info = node->ipn_info;
45 strncpy(pn.ipn_name, node->ipn_name, sizeof(pn.ipn_name));
47 if ((*iocfunc)(poolfd, SIOCLOOKUPDELNODE, &op)) {
48 if ((opts & OPT_DONOTHING) == 0) {
49 perror("remove_pool:SIOCLOOKUPDELNODE");
50 return -1;
54 return 0;