summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/lib/poolio.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ipfilter/lib/poolio.c')
-rw-r--r--contrib/ipfilter/lib/poolio.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/contrib/ipfilter/lib/poolio.c b/contrib/ipfilter/lib/poolio.c
new file mode 100644
index 0000000..18cf698
--- /dev/null
+++ b/contrib/ipfilter/lib/poolio.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 by Darren Reed.
+ *
+ * See the IPFILTER.LICENCE file for details on licencing.
+ *
+ * $Id: poolio.c,v 1.1.2.3 2012/07/22 08:04:24 darren_r Exp $
+ */
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include "ipf.h"
+#include "netinet/ip_lookup.h"
+#include "netinet/ip_pool.h"
+
+static int poolfd = -1;
+
+
+int
+pool_open()
+{
+
+ if ((opts & OPT_DONTOPEN) != 0)
+ return 0;
+
+ if (poolfd == -1)
+ poolfd = open(IPLOOKUP_NAME, O_RDWR);
+ return poolfd;
+}
+
+int
+pool_ioctl(iocfunc, cmd, ptr)
+ ioctlfunc_t iocfunc;
+ ioctlcmd_t cmd;
+ void *ptr;
+{
+ return (*iocfunc)(poolfd, cmd, ptr);
+}
+
+
+void
+pool_close()
+{
+ if (poolfd != -1) {
+ close(poolfd);
+ poolfd = -1;
+ }
+}
+
+int
+pool_fd()
+{
+ return poolfd;
+}
OpenPOWER on IntegriCloud