1254219Scy/* 2254219Scy * Copyright (C) 2012 by Darren Reed. 3254219Scy * 4254219Scy * See the IPFILTER.LICENCE file for details on licencing. 5254219Scy * 6254219Scy * $Id: poolio.c,v 1.1.2.3 2012/07/22 08:04:24 darren_r Exp $ 7254219Scy */ 8254219Scy 9254219Scy#include <fcntl.h> 10254219Scy#include <sys/ioctl.h> 11254219Scy#include "ipf.h" 12254219Scy#include "netinet/ip_lookup.h" 13254219Scy#include "netinet/ip_pool.h" 14254219Scy 15254219Scystatic int poolfd = -1; 16254219Scy 17254219Scy 18254219Scyint 19254219Scypool_open() 20254219Scy{ 21254219Scy 22254219Scy if ((opts & OPT_DONTOPEN) != 0) 23254219Scy return 0; 24254219Scy 25254219Scy if (poolfd == -1) 26254219Scy poolfd = open(IPLOOKUP_NAME, O_RDWR); 27254219Scy return poolfd; 28254219Scy} 29254219Scy 30254219Scyint 31254219Scypool_ioctl(iocfunc, cmd, ptr) 32254219Scy ioctlfunc_t iocfunc; 33254219Scy ioctlcmd_t cmd; 34254219Scy void *ptr; 35254219Scy{ 36254219Scy return (*iocfunc)(poolfd, cmd, ptr); 37254219Scy} 38254219Scy 39254219Scy 40254219Scyvoid 41254219Scypool_close() 42254219Scy{ 43254219Scy if (poolfd != -1) { 44254219Scy close(poolfd); 45254219Scy poolfd = -1; 46254219Scy } 47254219Scy} 48254219Scy 49254219Scyint 50254219Scypool_fd() 51254219Scy{ 52254219Scy return poolfd; 53254219Scy} 54