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