1145519Sdarrenr/* $FreeBSD$ */ 2145510Sdarrenr 3145510Sdarrenr/* 4255332Scy * Copyright (C) 2012 by Darren Reed. 5145510Sdarrenr * 6145510Sdarrenr * See the IPFILTER.LICENCE file for details on licencing. 7145510Sdarrenr * 8255332Scy * $Id$ 9145510Sdarrenr */ 10145510Sdarrenr 11145510Sdarrenr#include <fcntl.h> 12145510Sdarrenr#include <sys/ioctl.h> 13145510Sdarrenr#include "ipf.h" 14145510Sdarrenr#include "netinet/ip_lookup.h" 15145510Sdarrenr#include "netinet/ip_htable.h" 16145510Sdarrenr 17145510Sdarrenr 18255332Scyint 19255332Scyremove_hashnode(unit, name, node, iocfunc) 20255332Scy int unit; 21255332Scy char *name; 22255332Scy iphtent_t *node; 23255332Scy ioctlfunc_t iocfunc; 24145510Sdarrenr{ 25145510Sdarrenr iplookupop_t op; 26145510Sdarrenr iphtent_t ipe; 27145510Sdarrenr 28255332Scy if (pool_open() == -1) 29145510Sdarrenr return -1; 30145510Sdarrenr 31145510Sdarrenr op.iplo_type = IPLT_HASH; 32145510Sdarrenr op.iplo_unit = unit; 33145510Sdarrenr op.iplo_size = sizeof(ipe); 34145510Sdarrenr op.iplo_struct = &ipe; 35145510Sdarrenr op.iplo_arg = 0; 36145510Sdarrenr strncpy(op.iplo_name, name, sizeof(op.iplo_name)); 37145510Sdarrenr 38145510Sdarrenr bzero((char *)&ipe, sizeof(ipe)); 39145510Sdarrenr bcopy((char *)&node->ipe_addr, (char *)&ipe.ipe_addr, 40145510Sdarrenr sizeof(ipe.ipe_addr)); 41145510Sdarrenr bcopy((char *)&node->ipe_mask, (char *)&ipe.ipe_mask, 42145510Sdarrenr sizeof(ipe.ipe_mask)); 43145510Sdarrenr 44145510Sdarrenr if (opts & OPT_DEBUG) { 45145510Sdarrenr printf("\t%s - ", inet_ntoa(ipe.ipe_addr.in4)); 46145510Sdarrenr printf("%s\n", inet_ntoa(ipe.ipe_mask.in4)); 47145510Sdarrenr } 48145510Sdarrenr 49255332Scy if (pool_ioctl(iocfunc, SIOCLOOKUPDELNODE, &op)) { 50145510Sdarrenr if (!(opts & OPT_DONOTHING)) { 51255332Scy return ipf_perror_fd(pool_fd(), iocfunc, 52255332Scy "remove lookup hash node"); 53145510Sdarrenr } 54255332Scy } 55145510Sdarrenr return 0; 56145510Sdarrenr} 57