1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright (C) 2002 by Darren Reed. 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 5*0Sstevel@tonic-gate * 6*0Sstevel@tonic-gate * $Id: remove_hash.c,v 1.1 2003/04/13 06:40:14 darrenr Exp $ 7*0Sstevel@tonic-gate */ 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gate #include <fcntl.h> 10*0Sstevel@tonic-gate #include <sys/ioctl.h> 11*0Sstevel@tonic-gate #include "ipf.h" 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate #if SOLARIS2 >= 10 14*0Sstevel@tonic-gate #include "ip_lookup.h" 15*0Sstevel@tonic-gate #include "ip_htable.h" 16*0Sstevel@tonic-gate #else 17*0Sstevel@tonic-gate #include "netinet/ip_lookup.h" 18*0Sstevel@tonic-gate #include "netinet/ip_htable.h" 19*0Sstevel@tonic-gate #endif 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gate static int hashfd = -1; 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gate int remove_hash(iphp, iocfunc) 25*0Sstevel@tonic-gate iphtable_t *iphp; 26*0Sstevel@tonic-gate ioctlfunc_t iocfunc; 27*0Sstevel@tonic-gate { 28*0Sstevel@tonic-gate iplookupop_t op; 29*0Sstevel@tonic-gate iphtable_t iph; 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0)) 32*0Sstevel@tonic-gate hashfd = open(IPLOOKUP_NAME, O_RDWR); 33*0Sstevel@tonic-gate if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0)) 34*0Sstevel@tonic-gate return -1; 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate op.iplo_type = IPLT_HASH; 37*0Sstevel@tonic-gate op.iplo_unit = iphp->iph_unit; 38*0Sstevel@tonic-gate strncpy(op.iplo_name, iphp->iph_name, sizeof(op.iplo_name)); 39*0Sstevel@tonic-gate if (*op.iplo_name == '\0') 40*0Sstevel@tonic-gate op.iplo_arg = IPHASH_ANON; 41*0Sstevel@tonic-gate op.iplo_size = sizeof(iph); 42*0Sstevel@tonic-gate op.iplo_struct = &iph; 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate bzero((char *)&iph, sizeof(iph)); 45*0Sstevel@tonic-gate iph.iph_unit = iphp->iph_unit; 46*0Sstevel@tonic-gate iph.iph_type = iphp->iph_type; 47*0Sstevel@tonic-gate strncpy(iph.iph_name, iphp->iph_name, sizeof(iph.iph_name)); 48*0Sstevel@tonic-gate iph.iph_flags = iphp->iph_flags; 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate if ((*iocfunc)(hashfd, SIOCLOOKUPDELTABLE, &op)) 51*0Sstevel@tonic-gate if ((opts & OPT_DONOTHING) == 0) { 52*0Sstevel@tonic-gate perror("remove_hash:SIOCLOOKUPDELTABLE"); 53*0Sstevel@tonic-gate return -1; 54*0Sstevel@tonic-gate } 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate return 0; 57*0Sstevel@tonic-gate } 58