]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ipfilter/lib/poolio.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ipfilter / lib / poolio.c
1 /*
2  * Copyright (C) 2012 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * $Id: poolio.c,v 1.1.2.3 2012/07/22 08:04:24 darren_r Exp $
7  */
8
9 #include <fcntl.h>
10 #include <sys/ioctl.h>
11 #include "ipf.h"
12 #include "netinet/ip_lookup.h"
13 #include "netinet/ip_pool.h"
14
15 static int poolfd = -1;
16
17
18 int
19 pool_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
30 int
31 pool_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
40 void
41 pool_close()
42 {
43         if (poolfd != -1) {
44                 close(poolfd);
45                 poolfd = -1;
46         }
47 }
48
49 int
50 pool_fd()
51 {
52         return poolfd;
53 }