summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/lib/nametokva.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ipfilter/lib/nametokva.c')
-rw-r--r--contrib/ipfilter/lib/nametokva.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/contrib/ipfilter/lib/nametokva.c b/contrib/ipfilter/lib/nametokva.c
new file mode 100644
index 0000000..50f3077
--- /dev/null
+++ b/contrib/ipfilter/lib/nametokva.c
@@ -0,0 +1,30 @@
+/* $NetBSD$ */
+
+#include "ipf.h"
+
+#include <sys/ioctl.h>
+#include <fcntl.h>
+
+ipfunc_t nametokva(name, iocfunc)
+char *name;
+ioctlfunc_t iocfunc;
+{
+ ipfunc_resolve_t res;
+ int fd;
+
+ strncpy(res.ipfu_name, name, sizeof(res.ipfu_name));
+ res.ipfu_addr = NULL;
+ fd = -1;
+
+ if ((opts & OPT_DONOTHING) == 0) {
+ fd = open(IPL_NAME, O_RDONLY);
+ if (fd == -1)
+ return NULL;
+ }
+ (void) (*iocfunc)(fd, SIOCFUNCL, &res);
+ if (fd >= 0)
+ close(fd);
+ if (res.ipfu_addr == NULL)
+ res.ipfu_addr = (ipfunc_t)-1;
+ return res.ipfu_addr;
+}
OpenPOWER on IntegriCloud