/* $NetBSD: ether.c,v 1.24 2019/03/31 20:08:45 christos Exp $ */ /* * Copyright (c) 1992 Regents of the University of California. * All rights reserved. * * This software was developed by the Computer Systems Engineering group * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and * contributed to Berkeley. * * 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, Lawrence Berkeley Laboratory 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. * * 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. * * @(#) Header: net.c,v 1.9 93/08/06 19:32:15 leres Exp (LBL) */ #include #include #ifdef _STANDALONE #include #else #include #endif #include #include #include #include #include "stand.h" #include "net.h" /* Caller must leave room for ethernet header in front!! */ ssize_t sendether(struct iodesc *d, void *pkt, size_t len, u_char *dea, int etype) { ssize_t n; struct ether_header *eh; #ifdef ETHER_DEBUG if (debug) printf("%s: called\n", __func__); #endif eh = (struct ether_header *)pkt - 1; len += sizeof(*eh); MACPY(d->myea, eh->ether_shost); /* by byte */ MACPY(dea, eh->ether_dhost); /* by byte */ eh->ether_type = htons(etype); n = netif_put(d, eh, len); if (n == -1 || (size_t)n < sizeof(*eh)) return -1; n -= (ssize_t)sizeof(*eh); return n; } /* * Get a packet of any Ethernet type, with our address or * the broadcast address. Save the Ether type in arg 5. * NOTE: Caller must leave room for the Ether header. */ ssize_t readether(struct iodesc *d, void *pkt, size_t len, saseconds_t tleft, u_int16_t *etype) { ssize_t n; struct ether_header *eh; #ifdef ETHER_DEBUG if (debug) printf("%s: called\n", __func__); #endif eh = (struct ether_header *)pkt - 1; len += sizeof(*eh); n = netif_get(d, eh, len, tleft); if (n == -1 || (size_t)n < sizeof(*eh)) return -1; /* Validate Ethernet address. */ if (memcmp(d->myea, eh->ether_dhost, ETHER_ADDR_LEN) != 0 && memcmp(bcea, eh->ether_dhost, ETHER_ADDR_LEN) != 0) { #ifdef ETHER_DEBUG if (debug) printf("%s: not ours (ea=%s)\n", __func__, ether_sprintf(eh->ether_dhost)); #endif return -1; } *etype = ntohs(eh->ether_type); n -= (ssize_t)sizeof(*eh); return n; } bsd/commit/sys/dev/ic/rt2661.c?id=b29945ed814271d66b2366aad09b975c348f00ed'> bpf_mtap*() before ieee80211_encap() should be bpf_mtap() rather thanmsaitoh 2018-05-01GC private 802.11 rateset declarations, use the standard ones.maya 2017-10-23 If if_initialize() failed in the attach function, free resources and return.msaitoh 2017-05-23Apply deferred if_start to more driversozaki-r 2017-02-02wlan interfaces make interrupt routine running on softint context.nonaka 2016-06-10Introduce m_set_rcvif and m_reset_rcvifozaki-r 2016-05-26Introduce M_CLEARCTX and use it instead of open-coding rcvifozaki-r 2016-05-26Use M_GETCTXozaki-r 2015-01-07Pass a correct firmware size (instead of 0) to firmware_freeozaki-r 2012-02-18split device_t/softcdrochner 2010-04-05Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpfjoerg 2010-01-19Redefine bpf linkage through an always present op vector, i.e.pooka 2009-09-05Invert logic around nested pmf(9) registrations for readability.tsutsui 2008-11-07*** Summary ***dyoung 2008-04-29Pull in some more changes from OpenBSD:scw 2008-04-08use aprint_*_dev and device_xnamecegger 2008-03-17Merge some changes from OpenBSD:xtraeme 2007-12-09Merge jmcneill-pm branch.jmcneill 2007-10-21Fix a number of driver which doesn't check wep flag in *_tx_mgt.degroote 2007-10-19machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.had 2007-09-29- Fix bpf radiotap: s/NPBFILTER/NBPFILTER/scw 2007-09-01Change a bazillion occurrences of code resembling this,dyoung 2007-08-26Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier todyoung 2007-07-09Merge some of the less invasive changes from the vmlocking branch:ad 2007-03-04Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.christos 2006-11-16__unused removal on arguments; approved by core.christos 2006-10-12- sprinkle __unused on function decls.christos 2006-07-04Add missing semicolon.rpaulo 2006-07-04Coverity CID 3805: Close the firmware_handle on error and avoid leaks.rpaulo 2006-06-18Remove IF_PREPEND() to comply with altq. I think the logic is safe to justrpaulo 2006-06-18When calling IF_DEQUEUE() check if the dequeued mbuf is NULL to complyrpaulo 2006-06-09Revert previous. Wrong way of doing things...rpaulo 2006-06-08Bring the following change from OpenBSD:rpaulo 2006-06-08Rename sta variable. Pointed out by Havard Eidnes and Juergen Hannken-Illjes.rpaulo 2006-06-06Oops, missing arg to firmware_free.rpaulo 2006-06-05Don't leak memory on error.rpaulo 2006-06-05Add missing firmware_close().rpaulo 2006-06-04Driver for Ralink chipsets RT2460A, RT2560, RT2561S, RT2561 and RT2661rpaulo