Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / nametokva.c
blob74fb2b5dda0a14988a29becc84c67b50a3d086e2
1 /* $NetBSD$ */
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 */
11 #include "ipf.h"
13 #include <sys/ioctl.h>
14 #include <fcntl.h>
16 ipfunc_t nametokva(name, iocfunc)
17 char *name;
18 ioctlfunc_t iocfunc;
20 ipfunc_resolve_t res;
21 int fd;
23 strncpy(res.ipfu_name, name, sizeof(res.ipfu_name));
24 res.ipfu_addr = NULL;
25 fd = -1;
27 if ((opts & OPT_DONOTHING) == 0) {
28 fd = open(IPL_NAME, O_RDONLY);
29 if (fd == -1)
30 return NULL;
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;