2 * Copyright (C) 2003 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
14 * Given a pointer to an interface in the kernel, return a pointer to a
15 * string which is the interface name.
17 * The same code is used to run in two different environments: in ipfstat
18 * and in ipftest. In ipftest, kmemcpy is wrapper for bcopy but in ipfstat,
19 * it is used as an interface to libkvm.
25 # include <sys/mutex.h>
26 # include <sys/condvar.h>
31 # if defined(NetBSD) && (NetBSD >= 199905) && (NetBSD < 1991011) || \
32 defined(__OpenBSD__) || \
33 (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
39 #define SOLARIS_PFHOOKS 1
40 # ifdef SOLARIS_PFHOOKS
41 if ((opts
& OPT_DONOTHING
) == 0)
45 if ((void *)ptr
== (void *)-1)
50 if (kmemcpy((char *)&netif
, (u_long
)ptr
, sizeof(netif
)) == -1)
52 # if defined(NetBSD) && (NetBSD >= 199905) && (NetBSD < 1991011) || \
53 defined(__OpenBSD__) || defined(linux) || \
54 (defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
55 return strdup(netif
.if_xname
);
57 if (kstrncpy(buf
, (u_long
)netif
.if_name
, sizeof(buf
)) == -1)
59 if (netif
.if_unit
< 10)
61 else if (netif
.if_unit
< 1000)
63 else if (netif
.if_unit
< 10000)
67 buf
[sizeof(buf
) - len
] = '\0';
68 sprintf(buf
+ strlen(buf
), "%d", netif
.if_unit
% 10000);