diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/acx.c | 9 | ||||
-rw-r--r-- | sys/dev/ic/atw.c | 10 | ||||
-rw-r--r-- | sys/dev/ic/bwi.c | 10 | ||||
-rw-r--r-- | sys/dev/ic/malo.c | 19 | ||||
-rw-r--r-- | sys/dev/ic/pgt.c | 6 | ||||
-rw-r--r-- | sys/dev/ic/rt2560.c | 26 | ||||
-rw-r--r-- | sys/dev/ic/rt2661.c | 28 | ||||
-rw-r--r-- | sys/dev/ic/rt2860.c | 34 | ||||
-rw-r--r-- | sys/dev/ic/rt2860reg.h | 5 | ||||
-rw-r--r-- | sys/dev/ic/rtw.c | 20 | ||||
-rw-r--r-- | sys/dev/pci/if_ipw.c | 111 | ||||
-rw-r--r-- | sys/dev/pci/if_ipwvar.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/if_iwn.c | 35 | ||||
-rw-r--r-- | sys/dev/pci/if_wpi.c | 33 | ||||
-rw-r--r-- | sys/dev/usb/if_ral.c | 14 | ||||
-rw-r--r-- | sys/dev/usb/if_rum.c | 14 | ||||
-rw-r--r-- | sys/dev/usb/if_upgt.c | 17 | ||||
-rw-r--r-- | sys/dev/usb/if_zyd.c | 13 |
18 files changed, 187 insertions, 221 deletions
diff --git a/sys/dev/ic/acx.c b/sys/dev/ic/acx.c index 472ccf0f90c..f385eb55c7c 100644 --- a/sys/dev/ic/acx.c +++ b/sys/dev/ic/acx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acx.c,v 1.81 2008/03/13 23:07:28 brad Exp $ */ +/* $OpenBSD: acx.c,v 1.82 2008/04/16 18:32:15 damien Exp $ */ /* * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> @@ -998,10 +998,11 @@ acx_start(struct ifnet *ifp) wh = mtod(m, struct ieee80211_frame *); if ((wh->i_fc[1] & IEEE80211_FC1_WEP) && !sc->chip_hw_crypt) { - m = ieee80211_wep_crypt(ifp, m, 1); - if (m == NULL) { + struct ieee80211_key *k; + + k = ieee80211_get_txkey(ic, wh, ni); + if ((m = ieee80211_encrypt(ic, m, k)) == NULL) { ieee80211_release_node(ic, ni); - m_freem(m); ifp->if_oerrors++; continue; } diff --git a/sys/dev/ic/atw.c b/sys/dev/ic/atw.c index 3525221e361..56b9ae24c6a 100644 --- a/sys/dev/ic/atw.c +++ b/sys/dev/ic/atw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atw.c,v 1.56 2008/03/13 23:07:29 brad Exp $ */ +/* $OpenBSD: atw.c,v 1.57 2008/04/16 18:32:15 damien Exp $ */ /* $NetBSD: atw.c,v 1.69 2004/07/23 07:07:55 dyoung Exp $ */ /*- @@ -3614,6 +3614,7 @@ atw_start(struct ifnet *ifp) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni; struct ieee80211_frame *wh; + struct ieee80211_key *k; struct atw_frame *hh; struct mbuf *m0, *m; struct atw_txsoft *txs, *last_txs; @@ -3670,8 +3671,11 @@ atw_start(struct ifnet *ifp) break; } - if (sc->sc_ic.ic_flags & IEEE80211_F_WEPON) { - if ((m0 = ieee80211_wep_crypt(ifp, m0, 1)) == NULL) { + if (ic->ic_flags & IEEE80211_F_WEPON) { + wh = mtod(m0, struct ieee80211_frame *); + k = ieee80211_get_txkey(ic, wh, ni); + m0 = ieee80211_encrypt(ic, m0, k); + if (m0 == NULL) { ifp->if_oerrors++; break; } diff --git a/sys/dev/ic/bwi.c b/sys/dev/ic/bwi.c index 18f2da657e4..1be7833615a 100644 --- a/sys/dev/ic/bwi.c +++ b/sys/dev/ic/bwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwi.c,v 1.74 2008/02/25 21:13:30 mglocker Exp $ */ +/* $OpenBSD: bwi.c,v 1.75 2008/04/16 18:32:15 damien Exp $ */ /* * Copyright (c) 2007 The DragonFly Project. All rights reserved. @@ -864,6 +864,7 @@ bwi_attach(struct bwi_softc *sc) ic->ic_caps = IEEE80211_C_SHSLOT | IEEE80211_C_SHPREAMBLE | IEEE80211_C_WEP | + IEEE80211_C_RSN | IEEE80211_C_MONITOR; ic->ic_state = IEEE80211_S_INIT; ic->ic_opmode = IEEE80211_M_STA; @@ -7196,6 +7197,7 @@ bwi_start(struct ifnet *ifp) while (tbd->tbd_buf[idx].tb_mbuf == NULL) { struct ieee80211_frame *wh; struct ieee80211_node *ni; + struct ieee80211_key *k; struct mbuf *m; int mgt_pkt = 0; @@ -7249,9 +7251,9 @@ bwi_start(struct ifnet *ifp) bpf_mtap(ic->ic_rawbpf, m, BPF_DIRECTION_OUT); #endif wh = mtod(m, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m = ieee80211_wep_crypt(ifp, m, 1); - if (m == NULL) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_get_txkey(ic, wh, ni); + if ((m = ieee80211_encrypt(ic, m, k)) == NULL) return; } wh = NULL; /* Catch any invalid use */ diff --git a/sys/dev/ic/malo.c b/sys/dev/ic/malo.c index a0a30abd071..e17cd6585cb 100644 --- a/sys/dev/ic/malo.c +++ b/sys/dev/ic/malo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malo.c,v 1.81 2007/11/10 14:20:15 mglocker Exp $ */ +/* $OpenBSD: malo.c,v 1.82 2008/04/16 18:32:15 damien Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -378,7 +378,8 @@ malo_attach(struct malo_softc *sc) IEEE80211_C_MONITOR | IEEE80211_C_SHPREAMBLE | IEEE80211_C_SHSLOT | - IEEE80211_C_WEP; + IEEE80211_C_WEP | + IEEE80211_C_RSN; ic->ic_opmode = IEEE80211_M_STA; ic->ic_state = IEEE80211_S_INIT; ic->ic_max_rssi = 75; @@ -1411,15 +1412,6 @@ malo_tx_mgt(struct malo_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) } wh = mtod(m0, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) - return (ENOBUFS); - - /* packet header may have moved, reset our local pointer */ - wh = mtod(m0, struct ieee80211_frame *); - } - #if NBPFILTER > 0 if (sc->sc_drvbpf != NULL) { struct mbuf mb; @@ -1506,6 +1498,7 @@ malo_tx_data(struct malo_softc *sc, struct mbuf *m0, struct malo_tx_desc *desc; struct malo_tx_data *data; struct ieee80211_frame *wh; + struct ieee80211_key *k; struct mbuf *mnew; int error; @@ -1524,8 +1517,8 @@ malo_tx_data(struct malo_softc *sc, struct mbuf *m0, wh = mtod(m0, struct ieee80211_frame *); if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) + k = ieee80211_get_txkey(ic, wh, ni); + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) return (ENOBUFS); /* packet header may have moved, reset our local pointer */ diff --git a/sys/dev/ic/pgt.c b/sys/dev/ic/pgt.c index 4b7c9ea9866..b3da4357569 100644 --- a/sys/dev/ic/pgt.c +++ b/sys/dev/ic/pgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pgt.c,v 1.47 2008/03/13 23:07:29 brad Exp $ */ +/* $OpenBSD: pgt.c,v 1.48 2008/04/16 18:32:15 damien Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -2978,10 +2978,6 @@ pgt_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) ic->ic_if.if_timer = 0; ic->ic_mgt_timer = 0; ic->ic_flags &= ~IEEE80211_F_SIBSS; - if (ic->ic_wep_ctx != NULL) { - free(ic->ic_wep_ctx, M_DEVBUF); - ic->ic_wep_ctx = NULL; - } ieee80211_free_allnodes(ic); break; case IEEE80211_S_SCAN: diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c index de3de628cb3..81bbb9f93f0 100644 --- a/sys/dev/ic/rt2560.c +++ b/sys/dev/ic/rt2560.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2560.c,v 1.35 2007/11/17 14:29:11 damien Exp $ */ +/* $OpenBSD: rt2560.c,v 1.36 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -242,7 +242,8 @@ rt2560_attach(void *xsc, int id) IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ - IEEE80211_C_WEP; /* s/w WEP */ + IEEE80211_C_WEP | /* s/w WEP */ + IEEE80211_C_RSN; /* WPA/RSN */ /* set supported .11b and .11g rates */ ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b; @@ -1595,7 +1596,6 @@ rt2560_tx_mgt(struct rt2560_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct rt2560_tx_desc *desc; struct rt2560_tx_data *data; struct ieee80211_frame *wh; @@ -1606,17 +1606,6 @@ rt2560_tx_mgt(struct rt2560_softc *sc, struct mbuf *m0, desc = &sc->prioq.desc[sc->prioq.cur]; data = &sc->prioq.data[sc->prioq.cur]; - wh = mtod(m0, struct ieee80211_frame *); - - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) - return ENOBUFS; - - /* packet header may have moved, reset our local pointer */ - wh = mtod(m0, struct ieee80211_frame *); - } - error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0) { @@ -1691,11 +1680,11 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct rt2560_tx_ring *txq = &sc->txq; struct rt2560_tx_desc *desc; struct rt2560_tx_data *data; struct ieee80211_frame *wh; + struct ieee80211_key *k; struct mbuf *mnew; uint16_t dur; uint32_t flags = 0; @@ -1703,9 +1692,10 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0, wh = mtod(m0, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) return ENOBUFS; /* packet header may have moved, reset our local pointer */ diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c index 0cc21cd0910..04a98615465 100644 --- a/sys/dev/ic/rt2661.c +++ b/sys/dev/ic/rt2661.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2661.c,v 1.40 2007/11/17 14:29:11 damien Exp $ */ +/* $OpenBSD: rt2661.c,v 1.41 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2006 @@ -252,7 +252,8 @@ rt2661_attach(void *xsc, int id) IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ - IEEE80211_C_WEP; /* s/w WEP */ + IEEE80211_C_WEP | /* s/w WEP */ + IEEE80211_C_RSN; /* WPA/RSN */ if (sc->rf_rev == RT2661_RF_5225 || sc->rf_rev == RT2661_RF_5325) { /* set supported .11a rates */ @@ -1442,7 +1443,6 @@ rt2661_tx_mgt(struct rt2661_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct rt2661_tx_desc *desc; struct rt2661_tx_data *data; struct ieee80211_frame *wh; @@ -1456,17 +1456,6 @@ rt2661_tx_mgt(struct rt2661_softc *sc, struct mbuf *m0, /* send mgt frames at the lowest available rate */ rate = IEEE80211_IS_CHAN_5GHZ(ni->ni_chan) ? 12 : 2; - wh = mtod(m0, struct ieee80211_frame *); - - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) - return ENOBUFS; - - /* packet header may have moved, reset our local pointer */ - wh = mtod(m0, struct ieee80211_frame *); - } - error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0) { @@ -1499,6 +1488,8 @@ rt2661_tx_mgt(struct rt2661_softc *sc, struct mbuf *m0, data->m = m0; data->ni = ni; + wh = mtod(m0, struct ieee80211_frame *); + if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { flags |= RT2661_TX_NEED_ACK; @@ -1539,11 +1530,11 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, int ac) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct rt2661_tx_ring *txq = &sc->txq[ac]; struct rt2661_tx_desc *desc; struct rt2661_tx_data *data; struct ieee80211_frame *wh; + struct ieee80211_key *k; struct mbuf *mnew; uint16_t dur; uint32_t flags = 0; @@ -1551,9 +1542,10 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0, wh = mtod(m0, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) return ENOBUFS; /* packet header may have moved, reset our local pointer */ diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c index 292dacacb70..82c085e6a4e 100644 --- a/sys/dev/ic/rt2860.c +++ b/sys/dev/ic/rt2860.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2860.c,v 1.11 2007/12/14 21:28:49 damien Exp $ */ +/* $OpenBSD: rt2860.c,v 1.12 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2007 @@ -127,9 +127,9 @@ void rt2860_updateslot(struct ieee80211com *); void rt2860_updateprot(struct ieee80211com *); void rt2860_updateedca(struct ieee80211com *); int rt2860_set_key(struct ieee80211com *, struct ieee80211_node *, - const struct ieee80211_key *); + struct ieee80211_key *); void rt2860_delete_key(struct ieee80211com *, - struct ieee80211_node *, int); + struct ieee80211_node *, struct ieee80211_key *); int8_t rt2860_rssi2dbm(struct rt2860_softc *, uint8_t, uint8_t); uint8_t rt2860_maxrssi_chain(struct rt2860_softc *, const struct rt2860_rxwi *); @@ -236,7 +236,8 @@ rt2860_attach(void *xsc, int id) IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ - IEEE80211_C_WEP; /* s/w WEP */ + IEEE80211_C_WEP | /* s/w WEP */ + IEEE80211_C_RSN; /* WPA/RSN */ if (sc->rf_rev == RT2860_RF_2750 || sc->rf_rev == RT2860_RF_2850) { /* set supported .11a rates */ @@ -282,9 +283,10 @@ rt2860_attach(void *xsc, int id) ic->ic_newassoc = rt2860_newassoc; ic->ic_updateslot = rt2860_updateslot; ic->ic_updateedca = rt2860_updateedca; +#ifdef notyet ic->ic_set_key = rt2860_set_key; ic->ic_delete_key = rt2860_delete_key; - +#endif /* override state transition machine */ sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = rt2860_newstate; @@ -1322,12 +1324,12 @@ rt2860_tx_data(struct rt2860_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, int qid) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct rt2860_tx_ring *ring = &sc->txq[qid]; struct rt2860_tx_data *data; struct rt2860_txd *txd; struct rt2860_txwi *txwi; struct ieee80211_frame *wh; + struct ieee80211_key *k; bus_dma_segment_t *seg; u_int hdrlen; uint16_t dur; @@ -1356,8 +1358,9 @@ rt2860_tx_data(struct rt2860_softc *sc, struct mbuf *m0, mcs = rt2860_rate2mcs(rate); if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) return ENOBUFS; /* packet header may have moved, reset our local pointer */ @@ -2098,7 +2101,7 @@ rt2860_updateedca(struct ieee80211com *ic) int rt2860_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, - const struct ieee80211_key *k) + struct ieee80211_key *k) { struct rt2860_softc *sc = ic->ic_softc; bus_size_t base; @@ -2127,8 +2130,7 @@ rt2860_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, /* install group key */ base = RT2860_SKEY(0, k->k_id); RAL_WRITE_REGION_1(sc, base, k->k_key, k->k_len); - RAL_WRITE_REGION_1(sc, base + 16, k->k_txmic, 8); - RAL_WRITE_REGION_1(sc, base + 24, k->k_rxmic, 8); + /* XXX TKIP + HostAP: swap Tx/Rx MIC */ attr = RAL_READ(sc, RT2860_SKEY_MODE_0_7); attr &= ~(0xf << (k->k_id * 4)); @@ -2139,8 +2141,7 @@ rt2860_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, wcid = RT2860_AID2WCID(ni->ni_associd); base = RT2860_PKEY(wcid); RAL_WRITE_REGION_1(sc, base, k->k_key, k->k_len); - RAL_WRITE_REGION_1(sc, base + 16, k->k_txmic, 8); - RAL_WRITE_REGION_1(sc, base + 24, k->k_rxmic, 8); + /* XXX TKIP + HostAP: swap Tx/Rx MIC */ attr = RAL_READ(sc, RT2860_WCID_ATTR(wcid)); attr = (attr & ~0xf) | (mode << 1) | RT2860_RX_PKEY_EN; @@ -2150,16 +2151,17 @@ rt2860_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, } void -rt2860_delete_key(struct ieee80211com *ic, struct ieee80211_node *ni, int kid) +rt2860_delete_key(struct ieee80211com *ic, struct ieee80211_node *ni, + struct ieee80211_key *k) { struct rt2860_softc *sc = ic->ic_softc; uint32_t attr; uint8_t wcid; - if (ni == NULL) { + if (k->k_flags & IEEE80211_KEY_GROUP) { /* remove group key */ attr = RAL_READ(sc, RT2860_SKEY_MODE_0_7); - attr &= ~(0xf << (kid * 4)); + attr &= ~(0xf << (k->k_id * 4)); RAL_WRITE(sc, RT2860_SKEY_MODE_0_7, attr); } else { diff --git a/sys/dev/ic/rt2860reg.h b/sys/dev/ic/rt2860reg.h index 951abe93a1f..b82baccef67 100644 --- a/sys/dev/ic/rt2860reg.h +++ b/sys/dev/ic/rt2860reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2860reg.h,v 1.7 2007/12/14 21:28:49 damien Exp $ */ +/* $OpenBSD: rt2860reg.h,v 1.8 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2007 @@ -842,7 +842,8 @@ struct rt2860_rxwi { { RT2860_GF40_PROT_CFG, 0x03f44084 }, \ { RT2860_MM20_PROT_CFG, 0x01744004 }, \ { RT2860_MM40_PROT_CFG, 0x03f54084 }, \ - { RT2860_TXOP_CTRL_CFG, 0x0000243f }, \ + { RT2860_TXOP_CTRL_CFG, 0x0000583f }, \ + { RT2860_TXOP_HLDR_ET, 0x00000002 }, \ { RT2860_TX_RTS_CFG, 0x00092b20 }, \ { RT2860_EXP_ACK_TIME, 0x002400ca } diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c index 9ccbdf20f2f..f0071a2be4e 100644 --- a/sys/dev/ic/rtw.c +++ b/sys/dev/ic/rtw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtw.c,v 1.65 2007/11/21 15:58:22 blambert Exp $ */ +/* $OpenBSD: rtw.c,v 1.66 2008/04/16 18:32:15 damien Exp $ */ /* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */ /*- @@ -2718,18 +2718,22 @@ rtw_dequeue(struct ifnet *ifp, struct rtw_txsoft_blk **tsbp, struct rtw_txdesc_blk **tdbp, struct mbuf **mp, struct ieee80211_node **nip) { + struct ieee80211com *ic; + struct ieee80211_frame *wh; + struct ieee80211_key *k; struct mbuf *m0; struct rtw_softc *sc; short *if_flagsp; sc = (struct rtw_softc *)ifp->if_softc; + ic = &sc->sc_ic; DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: enter %s\n", sc->sc_dev.dv_xname, __func__)); if_flagsp = &ifp->if_flags; - if (sc->sc_ic.ic_state == IEEE80211_S_RUN && + if (ic->ic_state == IEEE80211_S_RUN && (*mp = rtw_80211_dequeue(sc, &sc->sc_beaconq, RTW_TXPRIBCN, tsbp, tdbp, nip, if_flagsp)) != NULL) { DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue beacon frame\n", @@ -2737,7 +2741,7 @@ rtw_dequeue(struct ifnet *ifp, struct rtw_txsoft_blk **tsbp, return 0; } - if ((*mp = rtw_80211_dequeue(sc, &sc->sc_ic.ic_mgtq, RTW_TXPRIMD, tsbp, + if ((*mp = rtw_80211_dequeue(sc, &ic->ic_mgtq, RTW_TXPRIMD, tsbp, tdbp, nip, if_flagsp)) != NULL) { DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue mgt frame\n", __func__)); @@ -2749,14 +2753,14 @@ rtw_dequeue(struct ifnet *ifp, struct rtw_txsoft_blk **tsbp, return 0; } - if ((*mp = rtw_80211_dequeue(sc, &sc->sc_ic.ic_pwrsaveq, RTW_TXPRIHI, + if ((*mp = rtw_80211_dequeue(sc, &ic->ic_pwrsaveq, RTW_TXPRIHI, tsbp, tdbp, nip, if_flagsp)) != NULL) { DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue pwrsave frame\n", __func__)); return 0; } - if (sc->sc_ic.ic_state != IEEE80211_S_RUN) { + if (ic->ic_state != IEEE80211_S_RUN) { DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: not running\n", __func__)); return 0; } @@ -2797,8 +2801,10 @@ rtw_dequeue(struct ifnet *ifp, struct rtw_txsoft_blk **tsbp, } /* XXX should do WEP in hardware */ - if (sc->sc_ic.ic_flags & IEEE80211_F_WEPON) { - if ((m0 = ieee80211_wep_crypt(ifp, m0, 1)) == NULL) + if (ic->ic_flags & IEEE80211_F_WEPON) { + wh = mtod(m0, struct ieee80211_frame *); + k = ieee80211_get_txkey(ic, wh, *nip); + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) return -1; } diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index 9810a9f77d6..b6ff2171dcd 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,7 +1,7 @@ -/* $OpenBSD: if_ipw.c,v 1.71 2008/02/23 20:38:08 hshoexer Exp $ */ +/* $OpenBSD: if_ipw.c,v 1.72 2008/04/16 18:32:15 damien Exp $ */ /*- - * Copyright (c) 2004-2006 + * Copyright (c) 2004-2008 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -496,7 +496,6 @@ ipw_dma_alloc(struct ipw_softc *sc) error = ENOMEM; goto fail; } - MCLGET(sbuf->m, M_DONTWAIT); if (!(sbuf->m->m_flags & M_EXT)) { m_freem(sbuf->m); @@ -645,15 +644,12 @@ ipw_media_status(struct ifnet *ifp, struct ifmediareq *imr) switch (ic->ic_opmode) { case IEEE80211_M_STA: break; - case IEEE80211_M_IBSS: imr->ifm_active |= IFM_IEEE80211_IBSS; break; - case IEEE80211_M_MONITOR: imr->ifm_active |= IFM_IEEE80211_MONITOR; break; - case IEEE80211_M_AHDEMO: case IEEE80211_M_HOSTAP: /* should not get there */ @@ -835,7 +831,6 @@ ipw_data_intr(struct ipw_softc *sc, struct ipw_status *status, ifp->if_ierrors++; return; } - MCLGET(mnew, M_DONTWAIT); if (!(mnew->m_flags & M_EXT)) { m_freem(mnew); @@ -894,7 +889,6 @@ ipw_data_intr(struct ipw_softc *sc, struct ipw_status *status, #endif wh = mtod(m, struct ieee80211_frame *); - ni = ieee80211_find_rxnode(ic, wh); /* send the frame to the upper layer */ @@ -1101,7 +1095,7 @@ ipw_cmd(struct ipw_softc *sc, uint32_t type, void *data, uint32_t len) bus_dmamap_sync(sc->sc_dmat, sc->cmd_map, 0, sizeof (struct ipw_cmd), BUS_DMASYNC_PREWRITE); - + bus_dmamap_sync(sc->sc_dmat, sc->tbd_map, sc->txcur * sizeof (struct ipw_bd), sizeof (struct ipw_bd), BUS_DMASYNC_PREWRITE); @@ -1122,6 +1116,7 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) struct ipw_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_frame *wh; + struct ieee80211_key *k; struct ipw_soft_bd *sbd; struct ipw_soft_hdr *shdr; struct ipw_soft_buf *sbuf; @@ -1130,9 +1125,10 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) wh = mtod(m, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m = ieee80211_wep_crypt(ifp, m, 1); - if (m == NULL) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m = ieee80211_encrypt(ic, m, k)) == NULL) return ENOBUFS; /* packet header may have moved, reset our local pointer */ @@ -1163,7 +1159,7 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) shdr->hdr.type = htole32(IPW_HDR_TYPE_SEND); shdr->hdr.subtype = htole32(0); - shdr->hdr.encrypted = (wh->i_fc[1] & IEEE80211_FC1_WEP) ? 1 : 0; + shdr->hdr.encrypted = (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) ? 1 : 0; shdr->hdr.encrypt = 0; shdr->hdr.keyidx = 0; shdr->hdr.keysz = 0; @@ -1192,7 +1188,6 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) m_freem(m); return ENOMEM; } - M_DUP_PKTHDR(mnew, m); if (m->m_pkthdr.len > MHLEN) { MCLGET(mnew, M_DONTWAIT); @@ -1202,7 +1197,6 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) return ENOMEM; } } - m_copydata(m, 0, m->m_pkthdr.len, mtod(mnew, caddr_t)); m_freem(m); mnew->m_len = mnew->m_pkthdr.len; @@ -1297,8 +1291,8 @@ ipw_start(struct ifnet *ifp) { struct ipw_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; - struct mbuf *m; struct ieee80211_node *ni; + struct mbuf *m; if (ic->ic_state != IEEE80211_S_RUN) return; @@ -1317,16 +1311,13 @@ ipw_start(struct ifnet *ifp) if (ifp->if_bpf != NULL) bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); #endif - m = ieee80211_encap(ifp, m, &ni); if (m == NULL) continue; - #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m, BPF_DIRECTION_OUT); #endif - if (ipw_tx_start(ifp, m, ni) != 0) { if (ni != NULL) ieee80211_release_node(ic, ni); @@ -1452,14 +1443,13 @@ ipw_read_table2(struct ipw_softc *sc, uint32_t off, void *buf, uint32_t *len) info = MEM_READ_4(sc, sc->table2_base + off + 4); count = info >> 16; - size = info & 0xffff; + size = info & 0xffff; total = count * size; if (total > *len) { *len = total; return EINVAL; } - *len = total; ipw_read_mem_1(sc, addr, buf, total); @@ -1469,6 +1459,7 @@ ipw_read_table2(struct ipw_softc *sc, uint32_t off, void *buf, uint32_t *len) void ipw_stop_master(struct ipw_softc *sc) { + uint32_t tmp; int ntries; /* disable interrupts */ @@ -1484,8 +1475,8 @@ ipw_stop_master(struct ipw_softc *sc) printf("%s: timeout waiting for master\n", sc->sc_dev.dv_xname); - CSR_WRITE_4(sc, IPW_CSR_RST, CSR_READ_4(sc, IPW_CSR_RST) | - IPW_RST_PRINCETON_RESET); + tmp = CSR_READ_4(sc, IPW_CSR_RST); + CSR_WRITE_4(sc, IPW_CSR_RST, tmp | IPW_RST_PRINCETON_RESET); sc->flags &= ~IPW_FLAG_FW_INITED; } @@ -1493,13 +1484,14 @@ ipw_stop_master(struct ipw_softc *sc) int ipw_reset(struct ipw_softc *sc) { + uint32_t tmp; int ntries; ipw_stop_master(sc); /* move adapter to D0 state */ - CSR_WRITE_4(sc, IPW_CSR_CTL, CSR_READ_4(sc, IPW_CSR_CTL) | - IPW_CTL_INIT); + tmp = CSR_READ_4(sc, IPW_CSR_CTL); + CSR_WRITE_4(sc, IPW_CSR_CTL, tmp | IPW_CTL_INIT); /* wait for clock stabilization */ for (ntries = 0; ntries < 1000; ntries++) { @@ -1510,13 +1502,13 @@ ipw_reset(struct ipw_softc *sc) if (ntries == 1000) return EIO; - CSR_WRITE_4(sc, IPW_CSR_RST, CSR_READ_4(sc, IPW_CSR_RST) | - IPW_RST_SW_RESET); + tmp = CSR_READ_4(sc, IPW_CSR_RST); + CSR_WRITE_4(sc, IPW_CSR_RST, tmp | IPW_RST_SW_RESET); DELAY(10); - CSR_WRITE_4(sc, IPW_CSR_CTL, CSR_READ_4(sc, IPW_CSR_CTL) | - IPW_CTL_INIT); + tmp = CSR_READ_4(sc, IPW_CSR_CTL); + CSR_WRITE_4(sc, IPW_CSR_CTL, tmp | IPW_CTL_INIT); return 0; } @@ -1526,6 +1518,7 @@ ipw_load_ucode(struct ipw_softc *sc, u_char *uc, int size) { int ntries; + /* voodoo from the Intel Linux driver */ MEM_WRITE_4(sc, 0x3000e0, 0x80000000); CSR_WRITE_4(sc, IPW_CSR_RST, 0); @@ -1577,7 +1570,7 @@ int ipw_load_firmware(struct ipw_softc *sc, u_char *fw, int size) { u_char *p, *end; - uint32_t dst; + uint32_t tmp, dst; uint16_t len; int error; @@ -1605,8 +1598,8 @@ ipw_load_firmware(struct ipw_softc *sc, u_char *fw, int size) /* tell the adapter to initialize the firmware */ CSR_WRITE_4(sc, IPW_CSR_RST, 0); - CSR_WRITE_4(sc, IPW_CSR_CTL, CSR_READ_4(sc, IPW_CSR_CTL) | - IPW_CTL_ALLOW_STANDBY); + tmp = CSR_READ_4(sc, IPW_CSR_CTL); + CSR_WRITE_4(sc, IPW_CSR_CTL, tmp | IPW_CTL_ALLOW_STANDBY); /* wait at most one second for firmware initialization to complete */ if ((error = tsleep(sc, 0, "ipwinit", hz)) != 0) { @@ -1615,8 +1608,9 @@ ipw_load_firmware(struct ipw_softc *sc, u_char *fw, int size) return error; } - CSR_WRITE_4(sc, IPW_CSR_IO, CSR_READ_4(sc, IPW_CSR_IO) | - IPW_IO_GPIO1_MASK | IPW_IO_GPIO3_MASK); + tmp = CSR_READ_4(sc, IPW_CSR_IO); + CSR_WRITE_4(sc, IPW_CSR_IO, tmp | IPW_IO_GPIO1_MASK | + IPW_IO_GPIO3_MASK); return 0; } @@ -1624,52 +1618,42 @@ ipw_load_firmware(struct ipw_softc *sc, u_char *fw, int size) int ipw_read_firmware(struct ipw_softc *sc, struct ipw_firmware *fw) { - struct ipw_firmware_hdr *hdr; + const struct ipw_firmware_hdr *hdr; const char *name; - u_char *p; size_t size; int error; switch (sc->sc_ic.ic_opmode) { case IEEE80211_M_STA: - case IEEE80211_M_HOSTAP: name = "ipw-bss"; break; - case IEEE80211_M_IBSS: - case IEEE80211_M_AHDEMO: name = "ipw-ibss"; break; - case IEEE80211_M_MONITOR: name = "ipw-monitor"; break; + default: + /* should not get there */ + return ENODEV; } - if ((error = loadfirmware(name, &fw->data, &size)) != 0) return error; - if (size < sizeof (struct ipw_firmware_hdr)) { + if (size < sizeof (*hdr)) { error = EINVAL; goto fail; } - - p = fw->data; - hdr = (struct ipw_firmware_hdr *)p; - fw->main_size = letoh32(hdr->main_size); + hdr = (const struct ipw_firmware_hdr *)fw->data; + fw->main_size = letoh32(hdr->main_size); fw->ucode_size = letoh32(hdr->ucode_size); - p += sizeof (struct ipw_firmware_hdr); - size -= sizeof (struct ipw_firmware_hdr); - - if (size < fw->main_size + fw->ucode_size) { + if (size < sizeof (*hdr) + fw->main_size + fw->ucode_size) { error = EINVAL; goto fail; } - - fw->main = p; - fw->ucode = p + fw->main_size; - sc->fw_data = fw->data; + fw->main = fw->data + sizeof (*hdr); + fw->ucode = fw->main + fw->main_size; return 0; @@ -1692,18 +1676,17 @@ ipw_config(struct ipw_softc *sc) switch (ic->ic_opmode) { case IEEE80211_M_STA: - case IEEE80211_M_HOSTAP: data = htole32(IPW_MODE_BSS); break; - case IEEE80211_M_IBSS: - case IEEE80211_M_AHDEMO: data = htole32(IPW_MODE_IBSS); break; - case IEEE80211_M_MONITOR: data = htole32(IPW_MODE_MONITOR); break; + default: + /* should not get there */ + return ENODEV; } DPRINTF(("Setting mode to %u\n", letoh32(data))); error = ipw_cmd(sc, IPW_CMD_SET_MODE, &data, sizeof data); @@ -1892,7 +1875,6 @@ ipw_init(struct ifnet *ifp) sc->sc_dev.dv_xname, error); goto fail1; } - if ((error = ipw_load_ucode(sc, fw.ucode, fw.ucode_size)) != 0) { printf("%s: could not load microcode\n", sc->sc_dev.dv_xname); goto fail2; @@ -1924,8 +1906,8 @@ ipw_init(struct ifnet *ifp) printf("%s: could not load firmware\n", sc->sc_dev.dv_xname); goto fail2; } - sc->flags |= IPW_FLAG_FW_INITED; + free(fw.data, M_DEVBUF); /* retrieve information tables base addresses */ sc->table1_base = CSR_READ_4(sc, IPW_CSR_TABLE1_BASE); @@ -1938,7 +1920,6 @@ ipw_init(struct ifnet *ifp) sc->sc_dev.dv_xname); goto fail2; } - ifp->if_flags &= ~IFF_OACTIVE; ifp->if_flags |= IFF_RUNNING; @@ -1969,14 +1950,6 @@ ipw_stop(struct ifnet *ifp, int disable) for (i = 0; i < IPW_NTBD; i++) ipw_release_sbd(sc, &sc->stbd_list[i]); - /* - * Free memory claimed by firmware. - */ - if (sc->fw_data) { - free(sc->fw_data, M_DEVBUF); - sc->fw_data = NULL; - } - ieee80211_new_state(ic, IEEE80211_S_INIT, -1); } diff --git a/sys/dev/pci/if_ipwvar.h b/sys/dev/pci/if_ipwvar.h index 56348ad2f92..ca0d5b73a4d 100644 --- a/sys/dev/pci/if_ipwvar.h +++ b/sys/dev/pci/if_ipwvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ipwvar.h,v 1.15 2008/02/23 21:35:41 hshoexer Exp $ */ +/* $OpenBSD: if_ipwvar.h,v 1.16 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2004-2006 @@ -158,6 +158,4 @@ struct ipw_softc { #define sc_txtap sc_txtapu.th int sc_txtap_len; #endif - - void *fw_data; }; diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index 71f793a9bac..11eb562932e 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.17 2008/03/08 16:24:44 espie Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.18 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2007 @@ -135,7 +135,7 @@ int iwn_ioctl(struct ifnet *, u_long, caddr_t); int iwn_cmd(struct iwn_softc *, int, const void *, int, int); int iwn_setup_node_mrr(struct iwn_softc *, uint8_t, int); int iwn_set_key(struct ieee80211com *, struct ieee80211_node *, - const struct ieee80211_key *); + struct ieee80211_key *); void iwn_updateedca(struct ieee80211com *); void iwn_set_led(struct iwn_softc *, uint8_t, uint8_t, uint8_t); int iwn_set_critical_temp(struct iwn_softc *); @@ -293,6 +293,7 @@ iwn_attach(struct device *parent, struct device *self, void *aux) /* set device capabilities */ ic->ic_caps = IEEE80211_C_WEP | /* s/w WEP */ + IEEE80211_C_RSN | /* WPA/RSN */ IEEE80211_C_MONITOR | /* monitor mode supported */ IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -322,7 +323,9 @@ iwn_attach(struct device *parent, struct device *self, void *aux) ieee80211_ifattach(ifp); ic->ic_node_alloc = iwn_node_alloc; ic->ic_newassoc = iwn_newassoc; +#ifdef notyet ic->ic_set_key = iwn_set_key; +#endif ic->ic_updateedca = iwn_updateedca; /* override state transition machine */ @@ -1457,7 +1460,7 @@ iwn_notif_intr(struct iwn_softc *sc) DPRINTFN(4,("rx notification qid=%x idx=%d flags=%x type=%d " "len=%d\n", desc->qid, desc->idx, desc->flags, desc->type, - letoh32(desc->len))); + letoh16(desc->len))); if (!(desc->qid & 0x80)) /* reply to a command */ iwn_cmd_intr(sc, desc); @@ -1674,12 +1677,13 @@ iwn_tx_data(struct iwn_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, struct iwn_tx_cmd *cmd; struct iwn_cmd_data *tx; struct ieee80211_frame *wh; + struct ieee80211_key *k; struct mbuf *mnew; bus_addr_t paddr; uint32_t flags; uint8_t type; u_int hdrlen; - int i, rate, error, pad, ovhd = 0; + int i, rate, error, pad; desc = &ring->desc[ring->cur]; data = &ring->data[ring->cur]; @@ -1733,18 +1737,13 @@ iwn_tx_data(struct iwn_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, /* no need to bzero tx, all fields are reinitialized here */ if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { - const struct ieee80211_key *key = - &ic->ic_nw_keys[ic->ic_wep_txkey]; - if (key->k_cipher == IEEE80211_CIPHER_WEP40) - tx->security = IWN_CIPHER_WEP40; - else - tx->security = IWN_CIPHER_WEP104; - tx->security |= ic->ic_wep_txkey << 6; - memcpy(&tx->key[3], key->k_key, key->k_len); - /* compute crypto overhead */ - ovhd = IEEE80211_WEP_TOTLEN; - } else - tx->security = 0; + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) + return ENOBUFS; + + wh = mtod(m0, struct ieee80211_frame *); + } flags = IWN_TX_AUTO_SEQ; if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) @@ -1759,7 +1758,7 @@ iwn_tx_data(struct iwn_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, /* check if RTS/CTS or CTS-to-self protection must be used */ if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { /* multicast frames are not sent at OFDM rates in 802.11b/g */ - if (m0->m_pkthdr.len + ovhd + IEEE80211_CRC_LEN > + if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold) { flags |= IWN_TX_NEED_RTS | IWN_TX_FULL_TXOP; } else if ((ic->ic_flags & IEEE80211_F_USEPROT) && @@ -2256,7 +2255,7 @@ iwn_setup_node_mrr(struct iwn_softc *sc, uint8_t id, int async) */ int iwn_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, - const struct ieee80211_key *k) + struct ieee80211_key *k) { struct iwn_softc *sc = ic->ic_softc; struct iwn_node_info node; diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index f0cd31a8a1e..0549b16de86 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpi.c,v 1.59 2008/03/08 16:24:45 espie Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.60 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2006, 2007 @@ -130,7 +130,7 @@ int wpi_ioctl(struct ifnet *, u_long, caddr_t); int wpi_cmd(struct wpi_softc *, int, const void *, int, int); int wpi_mrr_setup(struct wpi_softc *); int wpi_set_key(struct ieee80211com *, struct ieee80211_node *, - const struct ieee80211_key *); + struct ieee80211_key *); void wpi_updateedca(struct ieee80211com *); void wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t); void wpi_enable_tsf(struct wpi_softc *, struct ieee80211_node *); @@ -270,6 +270,7 @@ wpi_attach(struct device *parent, struct device *self, void *aux) /* set device capabilities */ ic->ic_caps = IEEE80211_C_WEP | /* s/w WEP */ + IEEE80211_C_RSN | /* WPA/RSN */ IEEE80211_C_MONITOR | /* monitor mode supported */ IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -299,7 +300,9 @@ wpi_attach(struct device *parent, struct device *self, void *aux) ieee80211_ifattach(ifp); ic->ic_node_alloc = wpi_node_alloc; ic->ic_newassoc = wpi_newassoc; +#ifdef notyet ic->ic_set_key = wpi_set_key; +#endif ic->ic_updateedca = wpi_updateedca; /* override state transition machine */ @@ -1569,9 +1572,10 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, struct wpi_tx_cmd *cmd; struct wpi_cmd_data *tx; struct ieee80211_frame *wh; + struct ieee80211_key *k; struct mbuf *mnew; u_int hdrlen; - int i, rate, error, ovhd = 0; + int i, rate, error; desc = &ring->desc[ring->cur]; data = &ring->data[ring->cur]; @@ -1626,18 +1630,13 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, tx->flags = 0; if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { - const struct ieee80211_key *key = - &ic->ic_nw_keys[ic->ic_wep_txkey]; - if (key->k_cipher == IEEE80211_CIPHER_WEP40) - tx->security = WPI_CIPHER_WEP40; - else - tx->security = WPI_CIPHER_WEP104; - tx->security |= ic->ic_wep_txkey << 6; - memcpy(&tx->key[3], key->k_key, key->k_len); - /* compute crypto overhead */ - ovhd = IEEE80211_WEP_TOTLEN; - } else - tx->security = 0; + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) + return ENOBUFS; + + wh = mtod(m0, struct ieee80211_frame *); + } if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { tx->id = WPI_ID_BSS; @@ -1648,7 +1647,7 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, /* check if RTS/CTS or CTS-to-self protection must be used */ if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { /* multicast frames are not sent at OFDM rates in 802.11b/g */ - if (m0->m_pkthdr.len + ovhd + IEEE80211_CRC_LEN > + if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold) { tx->flags |= htole32(WPI_TX_NEED_RTS | WPI_TX_FULL_TXOP); @@ -2118,7 +2117,7 @@ wpi_mrr_setup(struct wpi_softc *sc) */ int wpi_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, - const struct ieee80211_key *k) + struct ieee80211_key *k) { struct wpi_softc *sc = ic->ic_softc; struct wpi_node_info node; diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index d1ebf3024e6..f125f66eb12 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.102 2007/10/11 18:33:14 deraadt Exp $ */ +/* $OpenBSD: if_ral.c,v 1.103 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -301,7 +301,8 @@ ural_attach(struct device *parent, struct device *self, void *aux) IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ - IEEE80211_C_WEP; /* s/w WEP */ + IEEE80211_C_WEP | /* s/w WEP */ + IEEE80211_C_RSN; /* WPA/RSN */ /* set supported .11b and .11g rates */ ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b; @@ -1034,10 +1035,10 @@ int ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct ural_tx_desc *desc; struct ural_tx_data *data; struct ieee80211_frame *wh; + struct ieee80211_key *k; uint32_t flags = RAL_TX_NEWSEQ; uint16_t dur; usbd_status error; @@ -1045,9 +1046,10 @@ ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) wh = mtod(m0, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) return ENOBUFS; /* packet header may have moved, reset our local pointer */ diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index 8864c54f7c7..ae18d4ee606 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rum.c,v 1.70 2008/04/01 13:43:53 jsg Exp $ */ +/* $OpenBSD: if_rum.c,v 1.71 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr> @@ -362,7 +362,8 @@ rum_attach(struct device *parent, struct device *self, void *aux) IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ - IEEE80211_C_WEP; /* s/w WEP */ + IEEE80211_C_WEP | /* s/w WEP */ + IEEE80211_C_RSN; /* WPA/RSN */ if (sc->rf_rev == RT2573_RF_5225 || sc->rf_rev == RT2573_RF_5226) { /* set supported .11a rates */ @@ -1048,10 +1049,10 @@ int rum_tx_data(struct rum_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct rum_tx_desc *desc; struct rum_tx_data *data; struct ieee80211_frame *wh; + struct ieee80211_key *k; uint32_t flags = 0; uint16_t dur; usbd_status error; @@ -1059,9 +1060,10 @@ rum_tx_data(struct rum_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) wh = mtod(m0, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) return ENOBUFS; /* packet header may have moved, reset our local pointer */ diff --git a/sys/dev/usb/if_upgt.c b/sys/dev/usb/if_upgt.c index 3ae7fe44d3e..e2f368a9ba2 100644 --- a/sys/dev/usb/if_upgt.c +++ b/sys/dev/usb/if_upgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_upgt.c,v 1.34 2008/02/16 21:56:43 mglocker Exp $ */ +/* $OpenBSD: if_upgt.c,v 1.35 2008/04/16 18:32:15 damien Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -401,7 +401,8 @@ upgt_attach_hook(void *arg) IEEE80211_C_MONITOR | IEEE80211_C_SHPREAMBLE | IEEE80211_C_SHSLOT | - IEEE80211_C_WEP; + IEEE80211_C_WEP | + IEEE80211_C_RSN; ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b; ic->ic_sup_rates[IEEE80211_MODE_11G] = ieee80211_std_rateset_11g; @@ -1507,8 +1508,8 @@ upgt_tx_task(void *arg) { struct upgt_softc *sc = arg; struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct ieee80211_frame *wh; + struct ieee80211_key *k; struct upgt_lmac_mem *mem; struct upgt_lmac_tx_desc *txdesc; struct mbuf *m; @@ -1533,14 +1534,16 @@ upgt_tx_task(void *arg) addr = data_tx->addr + UPGT_MEMSIZE_FRAME_HEAD; /* - * Software WEP. + * Software crypto. */ wh = mtod(m, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m = ieee80211_wep_crypt(ifp, m, 1); - if (m == NULL) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_get_txkey(ic, wh, ic->ic_bss); + + if ((m = ieee80211_encrypt(ic, m, k)) == NULL) return; + /* in case packet header moved, reset pointer */ wh = mtod(m, struct ieee80211_frame *); } diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index a01057d99f3..9b9fb3a758f 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zyd.c,v 1.66 2007/12/07 05:05:02 deraadt Exp $ */ +/* $OpenBSD: if_zyd.c,v 1.67 2008/04/16 18:32:15 damien Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> @@ -369,7 +369,8 @@ zyd_complete_attach(struct zyd_softc *sc) IEEE80211_C_MONITOR | /* monitor mode supported */ IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ - IEEE80211_C_WEP; /* s/w WEP */ + IEEE80211_C_WEP | /* s/w WEP */ + IEEE80211_C_RSN; /* WPA/RSN */ /* set supported .11b and .11g rates */ ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b; @@ -2093,15 +2094,17 @@ zyd_tx_data(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) struct zyd_tx_desc *desc; struct zyd_tx_data *data; struct ieee80211_frame *wh; + struct ieee80211_key *k; int xferlen, totlen, rate; uint16_t pktlen; usbd_status error; wh = mtod(m0, struct ieee80211_frame *); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { - m0 = ieee80211_wep_crypt(ifp, m0, 1); - if (m0 == NULL) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + k = ieee80211_get_txkey(ic, wh, ni); + + if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL) return ENOBUFS; /* packet header may have moved, reset our local pointer */ |