if_tap.c (166438) | if_tap.c (166443) |
---|---|
1/*- 2 * Copyright (C) 1999-2000 by Maksim Yevmenkin <m_evmenkin@yahoo.com> 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 --- 17 unchanged lines hidden (view full) --- 26 * BASED ON: 27 * ------------------------------------------------------------------------- 28 * 29 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk> 30 * Nottingham University 1987. 31 */ 32 33/* | 1/*- 2 * Copyright (C) 1999-2000 by Maksim Yevmenkin <m_evmenkin@yahoo.com> 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 --- 17 unchanged lines hidden (view full) --- 26 * BASED ON: 27 * ------------------------------------------------------------------------- 28 * 29 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk> 30 * Nottingham University 1987. 31 */ 32 33/* |
34 * $FreeBSD: head/sys/net/if_tap.c 166438 2007-02-02 22:27:45Z bms $ | 34 * $FreeBSD: head/sys/net/if_tap.c 166443 2007-02-03 02:57:45Z bms $ |
35 * $Id: if_tap.c,v 0.21 2000/07/23 21:46:02 max Exp $ 36 */ 37 38#include "opt_compat.h" 39#include "opt_inet.h" 40 41#include <sys/param.h> 42#include <sys/conf.h> --- 765 unchanged lines hidden (view full) --- 808/* 809 * tapwrite 810 * 811 * the cdevsw write interface - an atomic write is a packet - or else! 812 */ 813static int 814tapwrite(struct cdev *dev, struct uio *uio, int flag) 815{ | 35 * $Id: if_tap.c,v 0.21 2000/07/23 21:46:02 max Exp $ 36 */ 37 38#include "opt_compat.h" 39#include "opt_inet.h" 40 41#include <sys/param.h> 42#include <sys/conf.h> --- 765 unchanged lines hidden (view full) --- 808/* 809 * tapwrite 810 * 811 * the cdevsw write interface - an atomic write is a packet - or else! 812 */ 813static int 814tapwrite(struct cdev *dev, struct uio *uio, int flag) 815{ |
816 struct ether_header *eh; |
|
816 struct tap_softc *tp = dev->si_drv1; 817 struct ifnet *ifp = tp->tap_ifp; 818 struct mbuf *m; 819 820 TAPDEBUG("%s writting, minor = %#x\n", 821 ifp->if_xname, minor(dev)); 822 823 if (uio->uio_resid == 0) --- 9 unchanged lines hidden (view full) --- 833 if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, ETHER_ALIGN, 834 M_PKTHDR)) == NULL) { 835 ifp->if_ierrors ++; 836 return (ENOBUFS); 837 } 838 839 m->m_pkthdr.rcvif = ifp; 840 | 817 struct tap_softc *tp = dev->si_drv1; 818 struct ifnet *ifp = tp->tap_ifp; 819 struct mbuf *m; 820 821 TAPDEBUG("%s writting, minor = %#x\n", 822 ifp->if_xname, minor(dev)); 823 824 if (uio->uio_resid == 0) --- 9 unchanged lines hidden (view full) --- 834 if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, ETHER_ALIGN, 835 M_PKTHDR)) == NULL) { 836 ifp->if_ierrors ++; 837 return (ENOBUFS); 838 } 839 840 m->m_pkthdr.rcvif = ifp; 841 |
842 /* 843 * Only pass a unicast frame to ether_input(), if it would actually 844 * have been received by non-virtual hardware. 845 */ 846 if (m->m_len < sizeof(struct ether_header)) { 847 m_freem(m); 848 return (0); 849 } 850 eh = mtod(m, struct ether_header *); 851 852 if (eh && (ifp->if_flags & IFF_PROMISC) == 0 && 853 !ETHER_IS_MULTICAST(eh->ether_dhost) && 854 bcmp(eh->ether_dhost, IF_LLADDR(ifp), ETHER_ADDR_LEN) != 0) { 855 m_freem(m); 856 return (0); 857 } 858 |
|
841 /* Pass packet up to parent. */ 842 (*ifp->if_input)(ifp, m); 843 ifp->if_ipackets ++; /* ibytes are counted in parent */ 844 845 return (0); 846} /* tapwrite */ 847 848 --- 140 unchanged lines hidden --- | 859 /* Pass packet up to parent. */ 860 (*ifp->if_input)(ifp, m); 861 ifp->if_ipackets ++; /* ibytes are counted in parent */ 862 863 return (0); 864} /* tapwrite */ 865 866 --- 140 unchanged lines hidden --- |