aboutsummaryrefslogtreecommitdiff
path: root/lib/load_hashnode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/load_hashnode.c')
-rw-r--r--lib/load_hashnode.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/lib/load_hashnode.c b/lib/load_hashnode.c
index 8ff907abe9bf..802833372363 100644
--- a/lib/load_hashnode.c
+++ b/lib/load_hashnode.c
@@ -1,9 +1,9 @@
/*
- * Copyright (C) 2003-2005 by Darren Reed.
+ * Copyright (C) 2012 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
- * $Id: load_hashnode.c,v 1.2.4.2 2006/06/16 17:21:05 darrenr Exp $
+ * $Id$
*/
#include <fcntl.h>
@@ -12,22 +12,21 @@
#include "netinet/ip_lookup.h"
#include "netinet/ip_htable.h"
-static int hashfd = -1;
-
-int load_hashnode(unit, name, node, iocfunc)
-int unit;
-char *name;
-iphtent_t *node;
-ioctlfunc_t iocfunc;
+int
+load_hashnode(unit, name, node, ttl, iocfunc)
+ int unit;
+ char *name;
+ iphtent_t *node;
+ int ttl;
+ ioctlfunc_t iocfunc;
{
iplookupop_t op;
iphtent_t ipe;
+ char *what;
int err;
- if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0))
- hashfd = open(IPLOOKUP_NAME, O_RDWR);
- if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0))
+ if (pool_open() == -1)
return -1;
op.iplo_type = IPLT_HASH;
@@ -38,6 +37,8 @@ ioctlfunc_t iocfunc;
strncpy(op.iplo_name, name, sizeof(op.iplo_name));
bzero((char *)&ipe, sizeof(ipe));
+ ipe.ipe_family = node->ipe_family;
+ ipe.ipe_die = ttl;
bcopy((char *)&node->ipe_addr, (char *)&ipe.ipe_addr,
sizeof(ipe.ipe_addr));
bcopy((char *)&node->ipe_mask, (char *)&ipe.ipe_mask,
@@ -45,15 +46,20 @@ ioctlfunc_t iocfunc;
bcopy((char *)&node->ipe_group, (char *)&ipe.ipe_group,
sizeof(ipe.ipe_group));
- if ((opts & OPT_REMOVE) == 0)
- err = (*iocfunc)(hashfd, SIOCLOOKUPADDNODE, &op);
- else
- err = (*iocfunc)(hashfd, SIOCLOOKUPDELNODE, &op);
+ if ((opts & OPT_REMOVE) == 0) {
+ what = "add";
+ err = pool_ioctl(iocfunc, SIOCLOOKUPADDNODE, &op);
+ } else {
+ what = "delete";
+ err = pool_ioctl(iocfunc, SIOCLOOKUPDELNODE, &op);
+ }
if (err != 0)
if (!(opts & OPT_DONOTHING)) {
- perror("load_hash:SIOCLOOKUP*NODE");
- return -1;
+ char msg[80];
+
+ sprintf(msg, "%s node from lookup hash table", what);
+ return ipf_perror_fd(pool_fd(), iocfunc, msg);
}
return 0;
}