4 * Copyright (C) 2012 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
16 * Given a pointer to an interface in the kernel, return a pointer to a
17 * string which is the interface name.
23 #if SOLARIS || defined(__hpux)
25 # include <sys/mutex.h>
26 # include <sys/condvar.h>
28 # include "../pfil/qif.h"
32 if ((void *)ptr == (void *)-1)
37 if (kmemcpy((char *)&qif, (u_long)ptr, sizeof(qif)) == -1)
39 ifname = strdup(qif.qf_name);
40 if ((ifname != NULL) && (*ifname == '\0')) {
46 # if defined(NetBSD) && (NetBSD >= 199905) && (NetBSD < 1991011) || \
47 defined(__OpenBSD__) || \
48 (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
55 if ((void *)ptr == (void *)-1)
60 if (kmemcpy((char *)&netif, (u_long)ptr, sizeof(netif)) == -1)
62 # if defined(NetBSD) && (NetBSD >= 199905) && (NetBSD < 1991011) || \
63 defined(__OpenBSD__) || defined(linux) || \
64 (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
65 return strdup(netif.if_xname);
67 if (kstrncpy(buf, (u_long)netif.if_name, sizeof(buf)) == -1)
69 if (netif.if_unit < 10)
71 else if (netif.if_unit < 1000)
73 else if (netif.if_unit < 10000)
77 buf[sizeof(buf) - len] = '\0';
78 sprintf(buf + strlen(buf), "%d", netif.if_unit % 10000);