1 /* $FreeBSD$ */ 2 3 /* 4 * Copyright (C) 2012 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * $Id$ 9 */ 10 11 #include "ipf.h" 12 13 #include <fcntl.h> 14 #include <sys/ioctl.h> 15 16 char *kvatoname(func, iocfunc) 17 ipfunc_t func; 18 ioctlfunc_t iocfunc; 19 { 20 static char funcname[40]; 21 ipfunc_resolve_t res; 22 int fd; 23 24 res.ipfu_addr = func; 25 res.ipfu_name[0] = '\0'; 26 fd = -1; 27 28 if ((opts & OPT_DONTOPEN) == 0) { 29 fd = open(IPL_NAME, O_RDONLY); 30 if (fd == -1) 31 return NULL; 32 } 33 (void) (*iocfunc)(fd, SIOCFUNCL, &res); 34 if (fd >= 0) 35 close(fd); 36 strncpy(funcname, res.ipfu_name, sizeof(funcname)); 37 funcname[sizeof(funcname) - 1] = '\0'; 38 return funcname; 39 } 40