1/* $NetBSD: nametokva.c,v 1.1.1.3 2010/04/17 20:45:56 darrenr Exp $ */ 2 3/* 4 * Copyright (C) 2002 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * Id: nametokva.c,v 1.1.4.2 2009/12/27 06:58:06 darrenr Exp 9 */ 10 11#include "ipf.h" 12 13#include <sys/ioctl.h> 14#include <fcntl.h> 15 16ipfunc_t nametokva(name, iocfunc) 17char *name; 18ioctlfunc_t iocfunc; 19{ 20 ipfunc_resolve_t res; 21 int fd; 22 23 strncpy(res.ipfu_name, name, sizeof(res.ipfu_name)); 24 res.ipfu_addr = NULL; 25 fd = -1; 26 27 if ((opts & OPT_DONOTHING) == 0) { 28 fd = open(IPL_NAME, O_RDONLY); 29 if (fd == -1) 30 return NULL; 31 } 32 (void) (*iocfunc)(fd, SIOCFUNCL, &res); 33 if (fd >= 0) 34 close(fd); 35 if (res.ipfu_addr == NULL) 36 res.ipfu_addr = (ipfunc_t)-1; 37 return res.ipfu_addr; 38} 39