summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-10-04 01:03:50 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-10-04 01:03:50 +0000
commite32185cccad9cb68578ab027b032e3c98a9dbeef (patch)
treea71a368917101f049834078af81268d3e87339f2
parent59a71a41359e40800cdf80819c92ca27972ef070 (diff)
bpf support for atm cards; from jason@ackley.net
none of us can test this, but that does not mean it has to sit in the pr database
-rw-r--r--sys/dev/ic/midway.c43
-rw-r--r--sys/net/bpf.c14
2 files changed, 54 insertions, 3 deletions
diff --git a/sys/dev/ic/midway.c b/sys/dev/ic/midway.c
index 5c14ca04ddd..0d7a0ae6874 100644
--- a/sys/dev/ic/midway.c
+++ b/sys/dev/ic/midway.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midway.c,v 1.30 2002/03/14 01:26:54 millert Exp $ */
+/* $OpenBSD: midway.c,v 1.31 2003/10/04 01:03:48 deraadt Exp $ */
/* (sync'd to midway.c 1.68) */
/*
@@ -108,6 +108,8 @@
#define INLINE inline
#endif /* EN_DEBUG */
+#include "bpfilter.h"
+
#ifdef __FreeBSD__
#include "en.h"
#endif
@@ -175,6 +177,12 @@
#endif /* __FreeBSD__ */
+#define BPF_MTAP(ifp, m) bpf_mtap((ifp)->if_bpf, (m))
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#endif
+
/*
* params
*/
@@ -834,6 +842,11 @@ done_probe:
if_attach(ifp);
atm_ifattach(ifp);
+
+#if NBPFILTER > 0
+ bpfattach(&ifp->if_bpf, ifp, DLT_ATM_RFC1483, sizeof(struct atmllc));
+#endif
+
}
@@ -1912,6 +1925,29 @@ again:
launch.pdu1 = MID_PDU_MK1(0, 0, datalen); /* host byte order */
}
+#if NBPFILTER > 0
+ if (sc->enif.if_bpf != NULL) {
+ /*
+ * adjust the top of the mbuf to skip the TBD if present
+ * before passing the packet to bpf.
+ * Also remove padding and the PDU trailer. Assume both of
+ * them to be in the same mbuf. pktlen, m_len and m_data
+ * are not needed anymore so we can change them.
+ */
+ int size = sizeof(struct atm_pseudohdr);
+ if (launch.atm_flags & EN_OBHDR)
+ size += MID_TBD_SIZE;
+
+ launch.t->m_data += size;
+ launch.t->m_len -= size;
+
+ BPF_MTAP(&sc->enif, launch.t);
+
+ launch.t->m_data -= size;
+ launch.t->m_len += size;
+ }
+#endif
+
en_txlaunch(sc, chan, &launch);
/*
@@ -2476,6 +2512,11 @@ void *arg;
#endif
sc->enif.if_ipackets++;
+#if NBPFILTER > 0
+ if (sc->enif.if_bpf)
+ BPF_MTAP(&sc->enif, m);
+#endif
+
atm_input(&sc->enif, &ah, m, sc->rxslot[slot].rxhand);
}
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 7e42edc8e62..425a2d41b75 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.38 2003/09/23 16:51:13 millert Exp $ */
+/* $OpenBSD: bpf.c,v 1.39 2003/10/04 01:03:49 deraadt Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -59,7 +59,7 @@
#include <netinet/if_arc.h>
#include <netinet/if_ether.h>
-#define BPF_BUFSIZE 8192 /* 4096 too small for FDDI frames */
+#define BPF_BUFSIZE 9216 /* 8192 too small for ATM frames */
#define PRINET 26 /* interruptible */
@@ -150,6 +150,16 @@ bpf_movein(uio, linktype, mp, sockp)
hlen = 0;
break;
+ case DLT_ATM_RFC1483:
+ /*
+ * en atm driver requires 4-byte atm pseudo header.
+ * though it isn't standard, vpi:vci needs to be
+ * specified anyway.
+ */
+ sockp->sa_family = AF_UNSPEC;
+ hlen = 12; /* XXX 4(ATM_PH) + 3(LLC) + 5(SNAP) */
+ break;
+
default:
return (EIO);
}