Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / remove_hash.c
blobb2ee5e172f90073e030f1bf013d85bd84db673b0
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2003 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: remove_hash.c,v 1.1.4.1 2006/06/16 17:21:16 darrenr Exp
9 */
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"
17 static int hashfd = -1;
20 int remove_hash(iphp, iocfunc)
21 iphtable_t *iphp;
22 ioctlfunc_t iocfunc;
24 iplookupop_t op;
25 iphtable_t iph;
27 if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0))
28 hashfd = open(IPLOOKUP_NAME, O_RDWR);
29 if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0))
30 return -1;
32 op.iplo_type = IPLT_HASH;
33 op.iplo_unit = iphp->iph_unit;
34 strncpy(op.iplo_name, iphp->iph_name, sizeof(op.iplo_name));
35 if (*op.iplo_name == '\0')
36 op.iplo_arg = IPHASH_ANON;
37 op.iplo_size = sizeof(iph);
38 op.iplo_struct = &iph;
40 bzero((char *)&iph, sizeof(iph));
41 iph.iph_unit = iphp->iph_unit;
42 iph.iph_type = iphp->iph_type;
43 strncpy(iph.iph_name, iphp->iph_name, sizeof(iph.iph_name));
44 iph.iph_flags = iphp->iph_flags;
46 if ((*iocfunc)(hashfd, SIOCLOOKUPDELTABLE, &op))
47 if ((opts & OPT_DONOTHING) == 0) {
48 perror("remove_hash:SIOCLOOKUPDELTABLE");
49 return -1;
52 return 0;