1 /* $FreeBSD$ */ 2 3 /* 4 * Copyright (C) 2012 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * $Id$ 9 */ 10 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" 16 17 18 int 19 remove_poolnode(int unit, char *name, ip_pool_node_t *node, 20 ioctlfunc_t iocfunc) 21 { 22 ip_pool_node_t pn; 23 iplookupop_t op; 24 25 if (pool_open() == -1) 26 return (-1); 27 28 op.iplo_unit = unit; 29 op.iplo_type = IPLT_POOL; 30 op.iplo_arg = 0; 31 strncpy(op.iplo_name, name, sizeof(op.iplo_name)); 32 op.iplo_struct = &pn; 33 op.iplo_size = sizeof(pn); 34 35 bzero((char *)&pn, sizeof(pn)); 36 bcopy((char *)&node->ipn_addr, (char *)&pn.ipn_addr, 37 sizeof(pn.ipn_addr)); 38 bcopy((char *)&node->ipn_mask, (char *)&pn.ipn_mask, 39 sizeof(pn.ipn_mask)); 40 pn.ipn_info = node->ipn_info; 41 strncpy(pn.ipn_name, node->ipn_name, sizeof(pn.ipn_name)); 42 43 if (pool_ioctl(iocfunc, SIOCLOOKUPDELNODE, &op)) { 44 if ((opts & OPT_DONOTHING) == 0) { 45 return (ipf_perror_fd(pool_fd(), iocfunc, 46 "remove lookup pool node")); 47 } 48 } 49 50 return (0); 51 } 52