poolio.c revision 1.1.1.1
1/* $NetBSD: poolio.c,v 1.1.1.1 2012/03/23 21:20:09 christos Exp $ */ 2 3/* 4 * Copyright (C) 2009 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * Id: poolio.c,v 1.1.2.1 2012/01/26 05:44:26 darren_r Exp 9 */ 10 11#include <fcntl.h> 12#include <sys/ioctl.h> 13#include "ipf.h" 14#include "netinet/ip_lookup.h" 15#include "netinet/ip_pool.h" 16 17static int poolfd = -1; 18 19 20int 21pool_open() 22{ 23 24 if ((opts & OPT_DONTOPEN) != 0) 25 return 0; 26 27 if (poolfd == -1) 28 poolfd = open(IPLOOKUP_NAME, O_RDWR); 29 return poolfd; 30} 31 32int 33pool_ioctl(iocfunc, cmd, ptr) 34 ioctlfunc_t iocfunc; 35 ioctlcmd_t cmd; 36 void *ptr; 37{ 38 return (*iocfunc)(poolfd, cmd, ptr); 39} 40 41 42void 43pool_close() 44{ 45 if (poolfd != -1) { 46 close(poolfd); 47 poolfd = -1; 48 } 49} 50