1/*	$NetBSD: kvatoname.c,v 1.2 2012/02/15 17:55:06 riz Exp $	*/
2
3/*
4 * Copyright (C) 2002 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 *
8 * Id: kvatoname.c,v 1.1.4.2 2009/12/27 06:58:06 darrenr Exp
9 */
10
11#include "ipf.h"
12
13#include <fcntl.h>
14#include <sys/ioctl.h>
15
16char *kvatoname(func, iocfunc)
17ipfunc_t func;
18ioctlfunc_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_DONOTHING) == 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