From owner-freebsd-hackers Sun Feb 7 15:44:19 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA05589 for freebsd-hackers-outgoing; Sun, 7 Feb 1999 15:44:19 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id PAA05581; Sun, 7 Feb 1999 15:44:11 -0800 (PST) (envelope-from fenner@parc.xerox.com) Received: from mango.parc.xerox.com ([13.1.102.232]) by alpha.xerox.com with SMTP id <52197(1)>; Sun, 7 Feb 1999 15:44:06 PST Received: from mango.parc.xerox.com (localhost.parc.xerox.com [127.0.0.1]) by mango.parc.xerox.com (8.8.8/8.8.8) with ESMTP id PAA06579; Sun, 7 Feb 1999 15:44:01 -0800 (PST) (envelope-from fenner@mango.parc.xerox.com) Message-Id: <199902072344.PAA06579@mango.parc.xerox.com> To: Dag-Erling Smorgrav cc: wpaul@FreeBSD.ORG, nsouch@FreeBSD.ORG, hackers@FreeBSD.ORG Subject: Re: Regarding tcpdump and plip In-reply-to: Your message of "Sun, 07 Feb 1999 15:16:13 PST." <86n22pg5z6.fsf@niobe.ewox.org> Date: Sun, 7 Feb 1999 15:44:01 PST From: Bill Fenner Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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