poolio.c revision 254219
1289087Sbapt/*
2289087Sbapt * Copyright (C) 2012 by Darren Reed.
3289087Sbapt *
4289087Sbapt * See the IPFILTER.LICENCE file for details on licencing.
5289087Sbapt *
6289087Sbapt * $Id: poolio.c,v 1.1.2.3 2012/07/22 08:04:24 darren_r Exp $
7297327Skan */
8289087Sbapt
9289087Sbapt#include <fcntl.h>
10304588Sbapt#include <sys/ioctl.h>
11289087Sbapt#include "ipf.h"
12289087Sbapt#include "netinet/ip_lookup.h"
13289087Sbapt#include "netinet/ip_pool.h"
14298107Sgjb
15static int poolfd = -1;
16
17
18int
19pool_open()
20{
21
22	if ((opts & OPT_DONTOPEN) != 0)
23		return 0;
24
25	if (poolfd == -1)
26		poolfd = open(IPLOOKUP_NAME, O_RDWR);
27	return poolfd;
28}
29
30int
31pool_ioctl(iocfunc, cmd, ptr)
32	ioctlfunc_t iocfunc;
33	ioctlcmd_t cmd;
34	void *ptr;
35{
36	return (*iocfunc)(poolfd, cmd, ptr);
37}
38
39
40void
41pool_close()
42{
43	if (poolfd != -1) {
44		close(poolfd);
45		poolfd = -1;
46	}
47}
48
49int
50pool_fd()
51{
52	return poolfd;
53}
54