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