xref: /titanic_50/usr/src/cmd/ipf/lib/common/nametokva.c (revision 25cf1a301a396c38e8adf52c15f537b80d2483f7)
1 #include "ipf.h"
2 
3 #include <sys/ioctl.h>
4 #include <fcntl.h>
5 
6 ipfunc_t nametokva(name, iocfunc)
7 char *name;
8 ioctlfunc_t iocfunc;
9 {
10 	ipfunc_resolve_t res;
11 	int fd;
12 
13 	strncpy(res.ipfu_name, name, sizeof(res.ipfu_name));
14 	res.ipfu_addr = NULL;
15 	fd = -1;
16 
17 	if ((opts & OPT_DONOTHING) == 0) {
18 		fd = open(IPL_NAME, O_RDONLY);
19 		if (fd == -1)
20 			return NULL;
21 	}
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;
28 }
29