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_htable.h" 16 17 18 int 19 remove_hash(iphp, iocfunc) 20 iphtable_t *iphp; 21 ioctlfunc_t iocfunc; 22 { 23 iplookupop_t op; 24 iphtable_t iph; 25 26 if (pool_open() == -1) 27 return -1; 28 29 op.iplo_type = IPLT_HASH; 30 op.iplo_unit = iphp->iph_unit; 31 strncpy(op.iplo_name, iphp->iph_name, sizeof(op.iplo_name)); 32 if (*op.iplo_name == '\0') 33 op.iplo_arg = IPHASH_ANON; 34 op.iplo_size = sizeof(iph); 35 op.iplo_struct = &iph; 36 37 bzero((char *)&iph, sizeof(iph)); 38 iph.iph_unit = iphp->iph_unit; 39 iph.iph_type = iphp->iph_type; 40 strncpy(iph.iph_name, iphp->iph_name, sizeof(iph.iph_name)); 41 iph.iph_flags = iphp->iph_flags; 42 43 if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op)) { 44 if ((opts & OPT_DONOTHING) == 0) { 45 return ipf_perror_fd(pool_fd(), iocfunc, 46 "remove lookup hash table"); 47 } 48 } 49 return 0; 50 } 51