Date: Sun, 7 Feb 1999 15:44:01 PST From: Bill Fenner <fenner@parc.xerox.com> To: Dag-Erling Smorgrav <des@flood.ping.uio.no> Cc: wpaul@FreeBSD.ORG, nsouch@FreeBSD.ORG, hackers@FreeBSD.ORG Subject: Re: Regarding tcpdump and plip Message-ID: <199902072344.PAA06579@mango.parc.xerox.com> In-Reply-To: Your message of "Sun, 07 Feb 1999 15:16:13 PST." <86n22pg5z6.fsf@niobe.ewox.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Here are some diffs that I wrote ages ago for lpt.c, but never committed because nobody volunteered to test them. They at least demonstrate what tcpdump wants (an int, in host byte order, with AF_INET in it). You could also look at if_sl.c, if_loop.c, etc. Bill Index: lpt.c =================================================================== RCS file: /home/ncvs/src/sys/i386/isa/lpt.c,v retrieving revision 1.72 diff -u -r1.72 lpt.c --- lpt.c 1998/12/10 01:42:32 1.72 +++ lpt.c 1999/02/07 23:39:10 @@ -876,7 +876,7 @@ printf("lp%d: TCP/IP capable interface\n", unit); #if NBPFILTER > 0 - bpfattach(ifp, DLT_NULL, LPIPHDRLEN); + bpfattach(ifp, DLT_NULL, sizeof(u_int)); #endif } /* @@ -1098,6 +1098,25 @@ sc->sc_if.if_ibytes += len; top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0); if (top) { +#if NBPFILTER > 0 + if (sc->sc_if.if_bpf) { + /* + * We need to prepend the address family as + * a four byte field. Cons up a dummy header + * to pacify bpf. This is safe because bpf + * will only read from the mbuf (i.e., it won't + * try to free it or keep a pointer to it). + */ + struct mbuf m0; + u_int af = AF_INET; + + m0.m_next = top; + m0.m_len = 4; + m0.m_data = (char *)⁡ + + bpf_mtap(ifp, &m0); + } +#endif IF_ENQUEUE(&ipintrq, top); schednetisr(NETISR_IP); } @@ -1142,16 +1161,30 @@ IF_DROP(&ipintrq); goto done; } -#if NBPFILTER > 0 - if (sc->sc_if.if_bpf) { - bpf_tap(&sc->sc_if, sc->sc_ifbuf, len); - } -#endif len -= LPIPHDRLEN; sc->sc_if.if_ipackets++; sc->sc_if.if_ibytes += len; top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0); if (top) { +#if NBPFILTER > 0 + if (sc->sc_if.if_bpf) { + /* + * We need to prepend the address family as + * a four byte field. Cons up a dummy header + * to pacify bpf. This is safe because bpf + * will only read from the mbuf (i.e., it won't + * try to free it or keep a pointer to it). + */ + struct mbuf m0; + u_int af = AF_INET; + + m0.m_next = top; + m0.m_len = 4; + m0.m_data = (char *)⁡ + + bpf_mtap(ifp, &m0); + } +#endif IF_ENQUEUE(&ipintrq, top); schednetisr(NETISR_IP); } @@ -1221,6 +1254,26 @@ /* Suspend (on laptops) or receive-errors might have taken us offline */ outb(lpt_ctrl_port, LPC_ENA); +#if NBPFILTER > 0 + if (ifp->if_bpf) { + /* + * We need to prepend the address family as + * a four byte field. Cons up a dummy header + * to pacify bpf. This is safe because bpf + * will only read from the mbuf (i.e., it won't + * try to free it or keep a pointer to it). + */ + struct mbuf m0; + u_int af = AF_INET; + + m0.m_next = m; + m0.m_len = 4; + m0.m_data = (char *)⁡ + + bpf_mtap(ifp, &m0); + } +#endif + if (ifp->if_flags & IFF_LINK0) { if (!(inb(lpt_stat_port) & CLPIP_SHAKE)) { @@ -1330,25 +1383,6 @@ } else { ifp->if_opackets++; ifp->if_obytes += m->m_pkthdr.len; -#if NBPFILTER > 0 - if (ifp->if_bpf) { - /* - * We need to prepend the packet type as - * a two byte field. Cons up a dummy header - * to pacify bpf. This is safe because bpf - * will only read from the mbuf (i.e., it won't - * try to free it or keep a pointer to it). - */ - struct mbuf m0; - u_short hdr = 0x800; - - m0.m_next = m; - m0.m_len = 2; - m0.m_data = (char *)&hdr; - - bpf_mtap(ifp, &m0); - } -#endif } m_freem(m); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902072344.PAA06579>