if_plip.c (43999) | if_plip.c (48645) |
---|---|
1/*- 2 * Copyright (c) 1997 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp | 1/*- 2 * Copyright (c) 1997 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp |
27 * $Id: if_plip.c,v 1.11 1999/02/14 11:59:59 nsouch Exp $ | 27 * $Id: if_plip.c,v 1.12 1999/02/14 16:19:16 nsouch Exp $ |
28 */ 29 30/* 31 * Parallel port TCP/IP interfaces added. I looked at the driver from 32 * MACH but this is a complete rewrite, and btw. incompatible, and it 33 * should perform better too. I have never run the MACH driver though. 34 * 35 * This driver sends two bytes (0x08, 0x00) in front of each packet, --- 52 unchanged lines hidden (view full) --- 88 89#include <net/if.h> 90#include <net/if_types.h> 91#include <net/netisr.h> 92 93#include <netinet/in.h> 94#include <netinet/in_var.h> 95 | 28 */ 29 30/* 31 * Parallel port TCP/IP interfaces added. I looked at the driver from 32 * MACH but this is a complete rewrite, and btw. incompatible, and it 33 * should perform better too. I have never run the MACH driver though. 34 * 35 * This driver sends two bytes (0x08, 0x00) in front of each packet, --- 52 unchanged lines hidden (view full) --- 88 89#include <net/if.h> 90#include <net/if_types.h> 91#include <net/netisr.h> 92 93#include <netinet/in.h> 94#include <netinet/in_var.h> 95 |
96#include "bpfilter.h" 97#if NBPFILTER > 0 | 96#include "bpf.h" 97#if NBPF > 0 |
98#include <net/bpf.h> 99#endif 100 101#include <dev/ppbus/ppbconf.h> 102 103#include "opt_plip.h" 104 105#ifndef LPMTU /* MTU for the lp# interfaces */ --- 145 unchanged lines hidden (view full) --- 251 ifp->if_ioctl = lpioctl; 252 ifp->if_output = lpoutput; 253 ifp->if_type = IFT_PARA; 254 ifp->if_hdrlen = 0; 255 ifp->if_addrlen = 0; 256 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; 257 if_attach(ifp); 258 | 98#include <net/bpf.h> 99#endif 100 101#include <dev/ppbus/ppbconf.h> 102 103#include "opt_plip.h" 104 105#ifndef LPMTU /* MTU for the lp# interfaces */ --- 145 unchanged lines hidden (view full) --- 251 ifp->if_ioctl = lpioctl; 252 ifp->if_output = lpoutput; 253 ifp->if_type = IFT_PARA; 254 ifp->if_hdrlen = 0; 255 ifp->if_addrlen = 0; 256 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; 257 if_attach(ifp); 258 |
259#if NBPFILTER > 0 | 259#if NBPF > 0 |
260 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); 261#endif 262 263 return (1); 264} 265/* 266 * Build the translation tables for the LPIP (BSD unix) protocol. 267 * We don't want to calculate these nasties in our tight loop, so we --- 173 unchanged lines hidden (view full) --- 441 return -1; 442 } 443 c = ppb_rstr(dev); 444 ppb_wdtr(dev, 0x00); 445 446 return (ctrecvl[cl] | ctrecvh[c]); 447} 448 | 260 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); 261#endif 262 263 return (1); 264} 265/* 266 * Build the translation tables for the LPIP (BSD unix) protocol. 267 * We don't want to calculate these nasties in our tight loop, so we --- 173 unchanged lines hidden (view full) --- 441 return -1; 442 } 443 c = ppb_rstr(dev); 444 ppb_wdtr(dev, 0x00); 445 446 return (ctrecvl[cl] | ctrecvh[c]); 447} 448 |
449#if NBPFILTER > 0 | 449#if NBPF > 0 |
450static void 451lptap(struct ifnet *ifp, struct mbuf *m) 452{ 453 /* 454 * Send a packet through bpf. We need to prepend the address family 455 * as a four byte field. Cons up a dummy header to pacify bpf. This 456 * is safe because bpf will only read from the mbuf (i.e., it won't 457 * try to free it or keep a pointer to it). --- 62 unchanged lines hidden (view full) --- 520 IF_DROP(&ipintrq); 521 goto done; 522 } 523 len -= CLPIPHDRLEN; 524 sc->sc_if.if_ipackets++; 525 sc->sc_if.if_ibytes += len; 526 top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0); 527 if (top) { | 450static void 451lptap(struct ifnet *ifp, struct mbuf *m) 452{ 453 /* 454 * Send a packet through bpf. We need to prepend the address family 455 * as a four byte field. Cons up a dummy header to pacify bpf. This 456 * is safe because bpf will only read from the mbuf (i.e., it won't 457 * try to free it or keep a pointer to it). --- 62 unchanged lines hidden (view full) --- 520 IF_DROP(&ipintrq); 521 goto done; 522 } 523 len -= CLPIPHDRLEN; 524 sc->sc_if.if_ipackets++; 525 sc->sc_if.if_ibytes += len; 526 top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0); 527 if (top) { |
528#if NBPFILTER > 0 | 528#if NBPF > 0 |
529 if (sc->sc_if.if_bpf) 530 lptap(&sc->sc_if, top); 531#endif 532 IF_ENQUEUE(&ipintrq, top); 533 schednetisr(NETISR_IP); 534 } 535 goto done; 536 } --- 36 unchanged lines hidden (view full) --- 573 IF_DROP(&ipintrq); 574 goto done; 575 } 576 len -= LPIPHDRLEN; 577 sc->sc_if.if_ipackets++; 578 sc->sc_if.if_ibytes += len; 579 top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0); 580 if (top) { | 529 if (sc->sc_if.if_bpf) 530 lptap(&sc->sc_if, top); 531#endif 532 IF_ENQUEUE(&ipintrq, top); 533 schednetisr(NETISR_IP); 534 } 535 goto done; 536 } --- 36 unchanged lines hidden (view full) --- 573 IF_DROP(&ipintrq); 574 goto done; 575 } 576 len -= LPIPHDRLEN; 577 sc->sc_if.if_ipackets++; 578 sc->sc_if.if_ibytes += len; 579 top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0); 580 if (top) { |
581#if NBPFILTER > 0 | 581#if NBPF > 0 |
582 if (sc->sc_if.if_bpf) 583 lptap(&sc->sc_if, top); 584#endif 585 IF_ENQUEUE(&ipintrq, top); 586 schednetisr(NETISR_IP); 587 } 588 } 589 goto done; --- 120 unchanged lines hidden (view full) --- 710 711 nend: 712 if (err) { /* if we didn't timeout... */ 713 ifp->if_oerrors++; 714 lprintf("X"); 715 } else { 716 ifp->if_opackets++; 717 ifp->if_obytes += m->m_pkthdr.len; | 582 if (sc->sc_if.if_bpf) 583 lptap(&sc->sc_if, top); 584#endif 585 IF_ENQUEUE(&ipintrq, top); 586 schednetisr(NETISR_IP); 587 } 588 } 589 goto done; --- 120 unchanged lines hidden (view full) --- 710 711 nend: 712 if (err) { /* if we didn't timeout... */ 713 ifp->if_oerrors++; 714 lprintf("X"); 715 } else { 716 ifp->if_opackets++; 717 ifp->if_obytes += m->m_pkthdr.len; |
718#if NBPFILTER > 0 | 718#if NBPF > 0 |
719 if (ifp->if_bpf) 720 lptap(ifp, m); 721#endif 722 } 723 724 m_freem(m); 725 726 if (!(ppb_rstr(&sc->lp_dev) & CLPIP_SHAKE)) { --- 30 unchanged lines hidden (view full) --- 757 ppb_wdtr(&sc->lp_dev, txmitl[*cp] ^ 0x17); 758 759 if (err) { /* if we didn't timeout... */ 760 ifp->if_oerrors++; 761 lprintf("X"); 762 } else { 763 ifp->if_opackets++; 764 ifp->if_obytes += m->m_pkthdr.len; | 719 if (ifp->if_bpf) 720 lptap(ifp, m); 721#endif 722 } 723 724 m_freem(m); 725 726 if (!(ppb_rstr(&sc->lp_dev) & CLPIP_SHAKE)) { --- 30 unchanged lines hidden (view full) --- 757 ppb_wdtr(&sc->lp_dev, txmitl[*cp] ^ 0x17); 758 759 if (err) { /* if we didn't timeout... */ 760 ifp->if_oerrors++; 761 lprintf("X"); 762 } else { 763 ifp->if_opackets++; 764 ifp->if_obytes += m->m_pkthdr.len; |
765#if NBPFILTER > 0 | 765#if NBPF > 0 |
766 if (ifp->if_bpf) 767 lptap(ifp, m); 768#endif 769 } 770 771 m_freem(m); 772 773 if (ppb_rstr(&sc->lp_dev) & LPIP_SHAKE) { 774 lprintf("^"); 775 lpintr(ifp->if_unit); 776 } 777 778 (void) splx(s); 779 return 0; 780} | 766 if (ifp->if_bpf) 767 lptap(ifp, m); 768#endif 769 } 770 771 m_freem(m); 772 773 if (ppb_rstr(&sc->lp_dev) & LPIP_SHAKE) { 774 lprintf("^"); 775 lpintr(ifp->if_unit); 776 } 777 778 (void) splx(s); 779 return 0; 780} |