Move /var/svc/log to /var/log/svc
[unleashed/lotheac.git] / usr / src / cmd / ipf / lib / common / remove_hashnode.c
blobafa0dbc554d8e5c52fc460ceea6518bde6851a77
1 /*
2 * Copyright (C) 2002 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: remove_hashnode.c,v 1.1 2003/04/13 06:40:14 darrenr Exp $
7 */
9 #include <fcntl.h>
10 #include <sys/ioctl.h>
11 #include "ipf.h"
12 #include "netinet/ip_lookup.h"
13 #include "netinet/ip_htable.h"
15 static int hashfd = -1;
18 int remove_hashnode(unit, name, node, iocfunc)
19 int unit;
20 char *name;
21 iphtent_t *node;
22 ioctlfunc_t iocfunc;
24 iplookupop_t op;
25 iphtent_t ipe;
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 = unit;
34 op.iplo_size = sizeof(ipe);
35 op.iplo_struct = &ipe;
36 op.iplo_arg = 0;
37 strncpy(op.iplo_name, name, sizeof(op.iplo_name));
39 bzero((char *)&ipe, sizeof(ipe));
40 bcopy((char *)&node->ipe_addr, (char *)&ipe.ipe_addr,
41 sizeof(ipe.ipe_addr));
42 bcopy((char *)&node->ipe_mask, (char *)&ipe.ipe_mask,
43 sizeof(ipe.ipe_mask));
45 if (opts & OPT_DEBUG) {
46 printf("\t%s - ", inet_ntoa(ipe.ipe_addr.in4));
47 printf("%s\n", inet_ntoa(ipe.ipe_mask.in4));
50 if ((*iocfunc)(hashfd, SIOCLOOKUPDELNODE, &op))
51 if (!(opts & OPT_DONOTHING)) {
52 perror("remove_hash:SIOCLOOKUPDELNODE");
53 return -1;
55 return 0;