]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ipfilter/lib/nametokva.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ipfilter / lib / nametokva.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: nametokva.c,v 1.1.4.1 2006/06/16 17:21:07 darrenr Exp $ 
9  */     
10
11 #include "ipf.h"
12
13 #include <sys/ioctl.h>
14 #include <fcntl.h>
15
16 ipfunc_t nametokva(name, iocfunc)
17 char *name;
18 ioctlfunc_t iocfunc;
19 {
20         ipfunc_resolve_t res;
21         int fd;
22
23         strncpy(res.ipfu_name, name, sizeof(res.ipfu_name));
24         res.ipfu_addr = NULL;
25         fd = -1;
26
27         if ((opts & OPT_DONOTHING) == 0) {
28                 fd = open(IPL_NAME, O_RDONLY);
29                 if (fd == -1)
30                         return NULL;
31         }
32         (void) (*iocfunc)(fd, SIOCFUNCL, &res);
33         if (fd >= 0)
34                 close(fd);
35         if (res.ipfu_addr == NULL)
36                 res.ipfu_addr = (ipfunc_t)-1;
37         return res.ipfu_addr;
38 }