1 1.2 darrenr /* $NetBSD: remove_hash.c,v 1.2 2012/07/22 14:27:37 darrenr Exp $ */ 2 1.1 christos 3 1.1 christos /* 4 1.2 darrenr * Copyright (C) 2012 by Darren Reed. 5 1.1 christos * 6 1.1 christos * See the IPFILTER.LICENCE file for details on licencing. 7 1.1 christos * 8 1.2 darrenr * Id: remove_hash.c,v 1.1.1.2 2012/07/22 13:44:42 darrenr Exp $ 9 1.1 christos */ 10 1.1 christos 11 1.1 christos #include <fcntl.h> 12 1.1 christos #include <sys/ioctl.h> 13 1.1 christos #include "ipf.h" 14 1.1 christos #include "netinet/ip_lookup.h" 15 1.1 christos #include "netinet/ip_htable.h" 16 1.1 christos 17 1.1 christos 18 1.1 christos int 19 1.1 christos remove_hash(iphp, iocfunc) 20 1.1 christos iphtable_t *iphp; 21 1.1 christos ioctlfunc_t iocfunc; 22 1.1 christos { 23 1.1 christos iplookupop_t op; 24 1.1 christos iphtable_t iph; 25 1.1 christos 26 1.1 christos if (pool_open() == -1) 27 1.1 christos return -1; 28 1.1 christos 29 1.1 christos op.iplo_type = IPLT_HASH; 30 1.1 christos op.iplo_unit = iphp->iph_unit; 31 1.1 christos strncpy(op.iplo_name, iphp->iph_name, sizeof(op.iplo_name)); 32 1.1 christos if (*op.iplo_name == '\0') 33 1.1 christos op.iplo_arg = IPHASH_ANON; 34 1.1 christos op.iplo_size = sizeof(iph); 35 1.1 christos op.iplo_struct = &iph; 36 1.1 christos 37 1.1 christos bzero((char *)&iph, sizeof(iph)); 38 1.1 christos iph.iph_unit = iphp->iph_unit; 39 1.1 christos iph.iph_type = iphp->iph_type; 40 1.1 christos strncpy(iph.iph_name, iphp->iph_name, sizeof(iph.iph_name)); 41 1.1 christos iph.iph_flags = iphp->iph_flags; 42 1.1 christos 43 1.2 darrenr if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op)) { 44 1.1 christos if ((opts & OPT_DONOTHING) == 0) { 45 1.2 darrenr return ipf_perror_fd(pool_fd(), iocfunc, 46 1.2 darrenr "remove lookup hash table"); 47 1.1 christos } 48 1.2 darrenr } 49 1.1 christos return 0; 50 1.1 christos } 51