Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / cmd / ipf / lib / common / nametokva.c
blob9250d7ce689734b239da7c4d2ff5c696a788f1ef
1 #include "ipf.h"
3 #include <sys/ioctl.h>
4 #include <fcntl.h>
6 ipfunc_t nametokva(name, iocfunc)
7 char *name;
8 ioctlfunc_t iocfunc;
10 ipfunc_resolve_t res;
11 int fd;
13 strncpy(res.ipfu_name, name, sizeof(res.ipfu_name));
14 res.ipfu_addr = NULL;
15 fd = -1;
17 if ((opts & OPT_DONOTHING) == 0) {
18 fd = open(IPL_NAME, O_RDONLY);
19 if (fd == -1)
20 return NULL;
22 (void) (*iocfunc)(fd, SIOCFUNCL, &res);
23 if (fd >= 0)
24 close(fd);
25 if (res.ipfu_addr == NULL)
26 res.ipfu_addr = (ipfunc_t)-1;
27 return res.ipfu_addr;