summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/lib/kvatoname.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ipfilter/lib/kvatoname.c')
-rw-r--r--contrib/ipfilter/lib/kvatoname.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/contrib/ipfilter/lib/kvatoname.c b/contrib/ipfilter/lib/kvatoname.c
new file mode 100644
index 0000000..65b5240
--- /dev/null
+++ b/contrib/ipfilter/lib/kvatoname.c
@@ -0,0 +1,39 @@
+/* $FreeBSD$ */
+
+/*
+ * Copyright (C) 2012 by Darren Reed.
+ *
+ * See the IPFILTER.LICENCE file for details on licencing.
+ *
+ * $Id$
+ */
+
+#include "ipf.h"
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+char *kvatoname(func, iocfunc)
+ ipfunc_t func;
+ ioctlfunc_t iocfunc;
+{
+ static char funcname[40];
+ ipfunc_resolve_t res;
+ int fd;
+
+ res.ipfu_addr = func;
+ res.ipfu_name[0] = '\0';
+ fd = -1;
+
+ if ((opts & OPT_DONTOPEN) == 0) {
+ fd = open(IPL_NAME, O_RDONLY);
+ if (fd == -1)
+ return NULL;
+ }
+ (void) (*iocfunc)(fd, SIOCFUNCL, &res);
+ if (fd >= 0)
+ close(fd);
+ strncpy(funcname, res.ipfu_name, sizeof(funcname));
+ funcname[sizeof(funcname) - 1] = '\0';
+ return funcname;
+}
OpenPOWER on IntegriCloud