2 * Copyright (C) 2003-2005 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: load_hashnode.c,v 1.2.4.2 2006/06/16 17:21:05 darrenr Exp $
10 #include <sys/ioctl.h>
12 #include "netinet/ip_lookup.h"
13 #include "netinet/ip_htable.h"
15 static int hashfd = -1;
18 int load_hashnode(unit, name, node, iocfunc)
28 if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0))
29 hashfd = open(IPLOOKUP_NAME, O_RDWR);
30 if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0))
33 op.iplo_type = IPLT_HASH;
36 op.iplo_size = sizeof(ipe);
37 op.iplo_struct = &ipe;
38 strncpy(op.iplo_name, name, sizeof(op.iplo_name));
40 bzero((char *)&ipe, sizeof(ipe));
41 bcopy((char *)&node->ipe_addr, (char *)&ipe.ipe_addr,
42 sizeof(ipe.ipe_addr));
43 bcopy((char *)&node->ipe_mask, (char *)&ipe.ipe_mask,
44 sizeof(ipe.ipe_mask));
45 bcopy((char *)&node->ipe_group, (char *)&ipe.ipe_group,
46 sizeof(ipe.ipe_group));
48 if ((opts & OPT_REMOVE) == 0)
49 err = (*iocfunc)(hashfd, SIOCLOOKUPADDNODE, &op);
51 err = (*iocfunc)(hashfd, SIOCLOOKUPDELNODE, &op);
54 if (!(opts & OPT_DONOTHING)) {
55 perror("load_hash:SIOCLOOKUP*NODE");