-/* $OpenBSD: if_zyd.c,v 1.70 2008/08/27 09:05:03 damien Exp $ */
+/* $OpenBSD: if_zyd.c,v 1.71 2008/08/27 09:49:32 damien Exp $ */
/*-
* Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr>
const struct zyd_plcphdr *plcp;
const struct zyd_rx_stat *stat;
struct mbuf *m;
- int rlen, s;
+ int s;
if (len < ZYD_MIN_FRAGSZ) {
- printf("%s: frame too short (length=%d)\n",
- sc->sc_dev.dv_xname, len);
+ DPRINTFN(2, ("frame too short (length=%d)\n", len));
ifp->if_ierrors++;
return;
}
plcp = (const struct zyd_plcphdr *)buf;
- stat = (const struct zyd_rx_stat *)
- (buf + len - sizeof (struct zyd_rx_stat));
+ stat = (const struct zyd_rx_stat *)(buf + len - sizeof (*stat));
if (stat->flags & ZYD_RX_ERROR) {
DPRINTF(("%s: RX status indicated error (%x)\n",
}
/* compute actual frame length */
- rlen = len - sizeof (struct zyd_plcphdr) -
- sizeof (struct zyd_rx_stat) - IEEE80211_CRC_LEN;
+ len -= sizeof (*plcp) - sizeof (*stat) - IEEE80211_CRC_LEN;
+
+ if (len > MCLBYTES) {
+ DPRINTFN(2, ("frame too large (length=%d)\n", len));
+ ifp->if_ierrors++;
+ return;
+ }
/* allocate a mbuf to store the frame */
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
- printf("%s: could not allocate rx mbuf\n",
- sc->sc_dev.dv_xname);
ifp->if_ierrors++;
return;
}
- if (rlen > MHLEN) {
+ if (len > MHLEN) {
MCLGET(m, M_DONTWAIT);
if (!(m->m_flags & M_EXT)) {
- printf("%s: could not allocate rx mbuf cluster\n",
- sc->sc_dev.dv_xname);
- m_freem(m);
ifp->if_ierrors++;
+ m_freem(m);
return;
}
}
+ bcopy(plcp + 1, mtod(m, caddr_t), len);
m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = m->m_len = rlen;
- bcopy((const uint8_t *)(plcp + 1), mtod(m, uint8_t *), rlen);
+ m->m_pkthdr.len = m->m_len = len;
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
if (len < ZYD_MIN_RXBUFSZ) {
- printf("%s: xfer too short (length=%d)\n",
- sc->sc_dev.dv_xname, len);
+ DPRINTFN(2, ("xfer too short (length=%d)\n", len));
ifp->if_ierrors++;
goto skip;
}
-/* $OpenBSD: if_zydreg.h,v 1.22 2007/11/27 20:30:14 damien Exp $ */
+/* $OpenBSD: if_zydreg.h,v 1.23 2008/08/27 09:49:32 damien Exp $ */
/*-
* Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr>
#define ZYD_FILTER_CFE_A (1 << 31)
/* helpers for register ZYD_MAC_RXFILTER */
-#define ZYD_FILTER_MONITOR 0xffffffff
+#define ZYD_FILTER_MONITOR 0x000fffff
+#if 1
+/* magic from the vendor's driver */
+#define ZYD_FILTER_BSS 0x2400ffff
+#else
#define ZYD_FILTER_BSS \
(ZYD_FILTER_ASS_RSP | ZYD_FILTER_REASS_RSP | \
ZYD_FILTER_PRB_RSP | ZYD_FILTER_BCN | ZYD_FILTER_DEASS | \
ZYD_FILTER_AUTH | ZYD_FILTER_DEAUTH)
+#endif
#define ZYD_FILTER_HOSTAP \
(ZYD_FILTER_ASS_REQ | ZYD_FILTER_REASS_REQ | \
ZYD_FILTER_PRB_REQ | ZYD_FILTER_DEASS | ZYD_FILTER_AUTH | \
(sizeof (struct zyd_tx_desc) + IEEE80211_MAX_LEN)
#define ZYD_MIN_FRAGSZ \
- (sizeof (struct zyd_plcphdr) + IEEE80211_MIN_LEN + \
+ (sizeof (struct zyd_plcphdr) + IEEE80211_ACK_LEN + \
sizeof (struct zyd_rx_stat))
#define ZYD_MIN_RXBUFSZ ZYD_MIN_FRAGSZ
#define ZYX_MAX_RXBUFSZ \