X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/86090d318af7775327fa0535cfe00da20ebbb66c..ed554bc5e4201344d7eaad78263566e79428759c:/usr/src/sys/pmax/dev/if_le.c diff --git a/usr/src/sys/pmax/dev/if_le.c b/usr/src/sys/pmax/dev/if_le.c index 75831ae9e0..8c3d3bde15 100644 --- a/usr/src/sys/pmax/dev/if_le.c +++ b/usr/src/sys/pmax/dev/if_le.c @@ -1,13 +1,39 @@ /*- - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell and Rick Macklem. * - * %sccs.include.redist.c% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * @(#)if_le.c 8.1 (Berkeley) %G% + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_le.c 8.2 (Berkeley) 11/16/93 */ #include @@ -475,16 +501,15 @@ lestart(ifp) IF_DEQUEUE(&le->sc_if.if_snd, m); if (m == 0) break; - len = leput(le, LER2_TBUFADDR(le->sc_r2, bix), m); #if NBPFILTER > 0 /* * If bpf is listening on this interface, let it * see the packet before we commit it to the wire. */ if (ifp->if_bpf) - bpf_tap(ifp->if_bpf, - LER2_TBUFADDR(le->sc_r2, le->sc_tmd), len); + bpf_mtap(ifp->if_bpf, m); #endif + len = leput(le, LER2_TBUFADDR(le->sc_r2, bix), m); LER2_tmd3(tmd, 0); LER2_tmd2(tmd, -len); LER2_tmd1(tmd, LE_OWN | LE_STP | LE_ENP); @@ -683,7 +708,7 @@ leread(unit, buf, len) { register struct le_softc *le = &le_softc[unit]; struct ether_header et; - struct mbuf *m, **hdrmp, **tailmp; + struct mbuf *m; int off, resid, flags; u_short sbuf[2], eth_type; extern struct mbuf *leget(); @@ -725,13 +750,22 @@ leread(unit, buf, len) if (et.ether_dhost[0] & 1) flags |= M_MCAST; + /* + * Pull packet off interface. Off is nonzero if packet + * has trailing header; leget will then force this header + * information to be at the front, but we still have to drop + * the type and length which are at the front of any trailer data. + */ + m = leget(le, buf, len, off, &le->sc_if); + if (m == 0) + return; #if NBPFILTER > 0 /* * Check if there's a bpf filter listening on this interface. * If so, hand off the raw packet to enet. */ if (le->sc_if.if_bpf) { - bpf_tap(le->sc_if.if_bpf, buf, len + sizeof(struct ether_header)); + bpf_mtap(le->sc_if.if_bpf, m); /* * Keep the packet if it's a broadcast or has our @@ -745,23 +779,12 @@ leread(unit, buf, len) (flags & M_BCAST) == 0 && #endif bcmp(et.ether_dhost, le->sc_addr, - sizeof(et.ether_dhost)) != 0) + sizeof(et.ether_dhost)) != 0) { + m_freem(m); return; + } } #endif - - /* - * Pull packet off interface. Off is nonzero if packet - * has trailing header; leget will then force this header - * information to be at the front, but we still have to drop - * the type and length which are at the front of any trailer data. - * The hdrmp and tailmp pointers are used by lebpf_tap() to - * temporarily reorder the mbuf list. See the comment at the beginning - * of lebpf_tap() for all the ugly details. - */ - m = leget(le, buf, len, off, &le->sc_if, &hdrmp, &tailmp); - if (m == 0) - return; m->m_flags |= flags; et.ether_type = eth_type; ether_input(&le->sc_if, &et, m); @@ -800,12 +823,11 @@ leput(le, lebuf, m) * Routine to copy from network buffer memory into mbufs. */ struct mbuf * -leget(le, lebuf, totlen, off, ifp, hdrmp, tailmp) +leget(le, lebuf, totlen, off, ifp) struct le_softc *le; volatile void *lebuf; int totlen, off; struct ifnet *ifp; - struct mbuf ***hdrmp, ***tailmp; { register struct mbuf *m; struct mbuf *top = 0, **mp = ⊤ @@ -860,10 +882,8 @@ leget(le, lebuf, totlen, off, ifp, hdrmp, tailmp) if (resid == 0) { boff = sizeof (struct ether_header); resid = totlen; - *hdrmp = mp; } } - *tailmp = mp; return (top); } @@ -1149,7 +1169,7 @@ copytobuf_gap2(from, lebuf, boff, len) bptr = ((volatile u_short *)lebuf) + boff; if ((unsigned)from & 0x1) { while (len > 1) { - *bptr = (from[1] << 8) | from[0]; + *bptr = (from[1] << 8) | (from[0] & 0xff); bptr += 2; from += 2; len -= 2;