]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ipfilter/lib/kvatoname.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ipfilter / lib / kvatoname.c
1 /*      $FreeBSD$       */
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.1 2006/06/16 17:21:05 darrenr Exp $ 
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_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 }