diff options
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/bwfm.c | 32 | ||||
-rw-r--r-- | sys/dev/ic/bwfmvar.h | 4 |
2 files changed, 9 insertions, 27 deletions
diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c index 1756315bced..c610fd5f8f1 100644 --- a/sys/dev/ic/bwfm.c +++ b/sys/dev/ic/bwfm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfm.c,v 1.23 2017/12/26 00:51:29 patrick Exp $ */ +/* $OpenBSD: bwfm.c,v 1.24 2018/01/03 21:01:16 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se> @@ -118,7 +118,7 @@ void bwfm_set_key_cb(struct bwfm_softc *, void *); void bwfm_delete_key_cb(struct bwfm_softc *, void *); void bwfm_newstate_cb(struct bwfm_softc *, void *); -void bwfm_rx(struct bwfm_softc *, char *, size_t); +void bwfm_rx(struct bwfm_softc *, struct mbuf *); void bwfm_rx_event(struct bwfm_softc *, char *, size_t); void bwfm_scan_node(struct bwfm_softc *, struct bwfm_bss_info *, size_t); @@ -1399,39 +1399,21 @@ bwfm_scan(struct bwfm_softc *sc) } void -bwfm_rx(struct bwfm_softc *sc, char *buf, size_t len) +bwfm_rx(struct bwfm_softc *sc, struct mbuf *m) { struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &ic->ic_if; - struct bwfm_event *e = (void *)buf; + struct bwfm_event *e = mtod(m, struct bwfm_event *); struct mbuf_list ml = MBUF_LIST_INITIALIZER(); - struct mbuf *m; - char *mb; - if (len >= sizeof(e->ehdr) && + if (m->m_len >= sizeof(e->ehdr) && ntohs(e->ehdr.ether_type) == BWFM_ETHERTYPE_LINK_CTL && memcmp(BWFM_BRCM_OUI, e->hdr.oui, sizeof(e->hdr.oui)) == 0 && ntohs(e->hdr.usr_subtype) == BWFM_BRCM_SUBTYPE_EVENT) - bwfm_rx_event(sc, buf, len); - - if (__predict_false(len > MCLBYTES)) - return; - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (__predict_false(m == NULL)) - return; - if (len > MHLEN) { - MCLGET(m, M_DONTWAIT); - if (!(m->m_flags & M_EXT)) { - m_free(m); - return; - } - } - mb = mtod(m, char *); - memcpy(mb, buf, len); - m->m_pkthdr.len = m->m_len = len; + bwfm_rx_event(sc, mtod(m, char *), m->m_len); if ((ic->ic_flags & IEEE80211_F_RSNON) && - len >= sizeof(e->ehdr) && + m->m_len >= sizeof(e->ehdr) && ntohs(e->ehdr.ether_type) == ETHERTYPE_PAE) { ifp->if_ipackets++; #if NBPFILTER > 0 diff --git a/sys/dev/ic/bwfmvar.h b/sys/dev/ic/bwfmvar.h index b2fd4126406..d924cab70ba 100644 --- a/sys/dev/ic/bwfmvar.h +++ b/sys/dev/ic/bwfmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfmvar.h,v 1.5 2017/12/16 23:39:58 patrick Exp $ */ +/* $OpenBSD: bwfmvar.h,v 1.6 2018/01/03 21:01:16 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se> @@ -160,4 +160,4 @@ int bwfm_chip_set_active(struct bwfm_softc *, uint32_t); void bwfm_chip_set_passive(struct bwfm_softc *); struct bwfm_core *bwfm_chip_get_core(struct bwfm_softc *, int); struct bwfm_core *bwfm_chip_get_pmu(struct bwfm_softc *); -void bwfm_rx(struct bwfm_softc *, char *, size_t); +void bwfm_rx(struct bwfm_softc *, struct mbuf *); |