static inline struct block *gen_true(void);
static inline struct block *gen_false(void);
static struct block *gen_ether_linktype(int);
+static struct block *gen_ipnet_linktype(int);
static struct block *gen_linux_sll_linktype(int);
static struct slist *gen_load_prism_llprefixlen(void);
static struct slist *gen_load_avs_llprefixlen(void);
off_nl = -1;
off_nl_nosnap = -1;
return;
+
+ case DLT_IPNET:
+ off_linktype = 1;
+ off_macpl = 24; /* ipnet header length */
+ off_nl = 0;
+ off_nl_nosnap = -1;
+ return;
}
bpf_error("unknown data link type %d", linktype);
/* NOTREACHED */
}
}
+/*
+ * "proto" is an Ethernet type value and for IPNET, if it is not IPv4
+ * or IPv6 then we have an error.
+ */
+static struct block *
+gen_ipnet_linktype(proto)
+ register int proto;
+{
+ struct block *b0, *b1;
+
+ switch (proto) {
+ case ETHERTYPE_IP:
+ return gen_cmp(OR_LINK, off_linktype, BPF_B,
+ (bpf_int32)AF_INET);
+ /* NOTREACHED */
+
+ case ETHERTYPE_IPV6:
+ return gen_cmp(OR_LINK, off_linktype, BPF_B,
+ (bpf_int32)AF_INET6);
+ /* NOTREACHED */
+ default :
+ break;
+ }
+
+ return gen_false();
+}
+
/*
* Generate code to match a particular packet type.
*
*/
return gen_mcmp(OR_LINK, 0, BPF_W, 0x4d474300, 0xffffff00); /* compare the magic number */
+ case DLT_IPNET:
+ return gen_ipnet_linktype(proto);
+
case DLT_LINUX_IRDA:
bpf_error("IrDA link-layer type filtering not implemented");
dir);
break;
+#ifdef DL_IPNET
+ case DLT_IPNET:
+ if (dir) {
+ /* match outgoing packets */
+ b0 = gen_cmp(OR_LINK, 2, BPF_H, IPNET_OUTBOUND);
+ } else {
+ /* match incoming packets */
+ b0 = gen_cmp(OR_LINK, 2, BPF_H, IPNET_INBOUND);
+ }
+ break;
+#endif
+
case DLT_LINUX_SLL:
if (dir) {
/*
#include <sys/ioccom.h>
#endif
#include <sys/utsname.h>
+#include <fcntl.h>
#ifdef HAVE_ZEROCOPY_BPF
#include <machine/atomic.h>
if (v == DLT_EN10MB) {
is_ethernet = 1;
for (i = 0; i < bdlp->bfl_len; i++) {
- if (bdlp->bfl_list[i] != DLT_EN10MB) {
+ if (bdlp->bfl_list[i] != DLT_EN10MB &&
+ bdlp->bfl_list[i] != DLT_IPNET) {
is_ethernet = 0;
break;
}
*/
#define DLT_CAN_SOCKETCAN 227
+#define DLT_IPNET 226 /* Assigned by tcpdump.org */
+#define DLT_IPOIB 162 /* Private until we know what it is */
+
+/*
+ * IPNET
+ */
+#define IPNET_OUTBOUND 1
+#define IPNET_INBOUND 2
+
/*
* DLT and savefile link type values are split into a class and
*/
#define LINKTYPE_CAN_SOCKETCAN 227
+#define LINKTYPE_IPNET 226
+
static struct linktype_map {
int dlt;
/* CAN frames with SocketCAN headers */
{ DLT_CAN_SOCKETCAN, LINKTYPE_CAN_SOCKETCAN },
+ /* Solaris IPNET */
+ { DLT_IPNET, LINKTYPE_IPNET },
+
{ -1, -1 }
};