]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ipfilter/lib/kvatoname.c
This commit was generated by cvs2svn to compensate for changes in r155094,
[FreeBSD/FreeBSD.git] / contrib / ipfilter / lib / kvatoname.c
1 /*      $FreeBSD$       */
2
3 #include "ipf.h"
4
5 #include <fcntl.h>
6 #include <sys/ioctl.h>
7
8 char *kvatoname(func, iocfunc)
9 ipfunc_t func;
10 ioctlfunc_t iocfunc;
11 {
12         static char funcname[40];
13         ipfunc_resolve_t res;
14         int fd;
15
16         res.ipfu_addr = func;
17         res.ipfu_name[0] = '\0';
18         fd = -1;
19
20         if ((opts & OPT_DONOTHING) == 0) {
21                 fd = open(IPL_NAME, O_RDONLY);
22                 if (fd == -1)
23                         return NULL;
24         }
25         (void) (*iocfunc)(fd, SIOCFUNCL, &res);
26         if (fd >= 0)
27                 close(fd);
28         strncpy(funcname, res.ipfu_name, sizeof(funcname));
29         funcname[sizeof(funcname) - 1] = '\0';
30         return funcname;
31 }