NetBSD/dist/ipf/lib/kvatoname.c
darrenr abd0900a99 Import IPFilter 4.1.34 into NetBSD
4.1.34 - Release 11 March 2010
2964907 uninitialised use compile error
2959506 ipfstat does not display rules with compat
2949139 FR_T_BUILTIN masked out incorrectly
2937422 packets filtered with pools should not be cached
2935529 use of rules with tags leads to deadlock
2917501 whitespace cleanup required
2881514 in/out object functions not wired for compatibility
2841771 ipf/ippool rule maintenace bugs: memory leak, ref-counter bug
2839698 H.323 proxy does not clear fin_state/fin_nat
2010-04-17 20:44:16 +00:00

40 lines
779 B
C

/* $NetBSD: kvatoname.c,v 1.1.1.3 2010/04/17 20:45:49 darrenr Exp $ */
/*
* Copyright (C) 2002 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* Id: kvatoname.c,v 1.1.4.2 2009/12/27 06:58:06 darrenr Exp
*/
#include "ipf.h"
#include <fcntl.h>
#include <sys/ioctl.h>
char *kvatoname(func, iocfunc)
ipfunc_t func;
ioctlfunc_t iocfunc;
{
static char funcname[40];
ipfunc_resolve_t res;
int fd;
res.ipfu_addr = func;
res.ipfu_name[0] = '\0';
fd = -1;
if ((opts & OPT_DONOTHING) == 0) {
fd = open(IPL_NAME, O_RDONLY);
if (fd == -1)
return NULL;
}
(void) (*iocfunc)(fd, SIOCFUNCL, &res);
if (fd >= 0)
close(fd);
strncpy(funcname, res.ipfu_name, sizeof(funcname));
funcname[sizeof(funcname) - 1] = '\0';
return funcname;
}