141edb306SCy Schubert /* 241edb306SCy Schubert * Copyright (C) 2012 by Darren Reed. 341edb306SCy Schubert * 441edb306SCy Schubert * See the IPFILTER.LICENCE file for details on licencing. 541edb306SCy Schubert * 641edb306SCy Schubert * $Id: poolio.c,v 1.1.2.3 2012/07/22 08:04:24 darren_r Exp $ 741edb306SCy Schubert */ 841edb306SCy Schubert 941edb306SCy Schubert #include <fcntl.h> 1041edb306SCy Schubert #include <sys/ioctl.h> 1141edb306SCy Schubert #include "ipf.h" 1241edb306SCy Schubert #include "netinet/ip_lookup.h" 1341edb306SCy Schubert #include "netinet/ip_pool.h" 1441edb306SCy Schubert 1541edb306SCy Schubert static int poolfd = -1; 1641edb306SCy Schubert 1741edb306SCy Schubert 1841edb306SCy Schubert int pool_open(void)19efeb8bffSCy Schubertpool_open(void) 2041edb306SCy Schubert { 2141edb306SCy Schubert 2241edb306SCy Schubert if ((opts & OPT_DONTOPEN) != 0) 232582ae57SCy Schubert return (0); 2441edb306SCy Schubert 2541edb306SCy Schubert if (poolfd == -1) 2641edb306SCy Schubert poolfd = open(IPLOOKUP_NAME, O_RDWR); 272582ae57SCy Schubert return (poolfd); 2841edb306SCy Schubert } 2941edb306SCy Schubert 3041edb306SCy Schubert int pool_ioctl(ioctlfunc_t iocfunc,ioctlcmd_t cmd,void * ptr)31*2ac057ddSJohn Baldwinpool_ioctl(ioctlfunc_t iocfunc, ioctlcmd_t cmd, void *ptr) 3241edb306SCy Schubert { 3341edb306SCy Schubert return (*iocfunc)(poolfd, cmd, ptr); 3441edb306SCy Schubert } 3541edb306SCy Schubert 3641edb306SCy Schubert 3741edb306SCy Schubert void pool_close(void)38efeb8bffSCy Schubertpool_close(void) 3941edb306SCy Schubert { 4041edb306SCy Schubert if (poolfd != -1) { 4141edb306SCy Schubert close(poolfd); 4241edb306SCy Schubert poolfd = -1; 4341edb306SCy Schubert } 4441edb306SCy Schubert } 4541edb306SCy Schubert 4641edb306SCy Schubert int pool_fd(void)47efeb8bffSCy Schubertpool_fd(void) 4841edb306SCy Schubert { 492582ae57SCy Schubert return (poolfd); 5041edb306SCy Schubert } 51