From: stsp Date: Wed, 15 Mar 2023 22:47:35 +0000 (+0000) Subject: make WEP encryption work on bwfm(4) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c8e9388c5445ac25c54fa7633402337877d23dc1;p=openbsd make WEP encryption work on bwfm(4) based on an initial diff by jsg@ brokenness pointed out by kn@ ok jsg@ --- diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c index 56c8e2365b5..a5e6d0788da 100644 --- a/sys/dev/ic/bwfm.c +++ b/sys/dev/ic/bwfm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfm.c,v 1.106 2022/12/30 16:49:34 kettenis Exp $ */ +/* $OpenBSD: bwfm.c,v 1.107 2023/03/15 22:47:35 stsp Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -199,6 +199,7 @@ bwfm_attach(struct bwfm_softc *sc) ic->ic_state = IEEE80211_S_INIT; ic->ic_caps = + IEEE80211_C_WEP | #ifndef IEEE80211_STA_ONLY IEEE80211_C_HOSTAP | /* Access Point */ #endif @@ -2001,8 +2002,7 @@ bwfm_connect(struct bwfm_softc *sc) uint8_t *frm; /* - * OPEN: Open or WPA/WPA2 on newer Chips/Firmware. - * SHARED KEY: WEP. + * OPEN: Open or WEP or WPA/WPA2 on newer Chips/Firmware. * AUTO: Automatic, probably for older Chips/Firmware. */ if (ic->ic_flags & IEEE80211_F_RSNON) { @@ -2041,6 +2041,9 @@ bwfm_connect(struct bwfm_softc *sc) bwfm_fwvar_var_set_int(sc, "wpa_auth", wpa); bwfm_fwvar_var_set_int(sc, "wsec", wsec); + } else if (ic->ic_flags & IEEE80211_F_WEPON) { + bwfm_fwvar_var_set_int(sc, "wpa_auth", BWFM_WPA_AUTH_DISABLED); + bwfm_fwvar_var_set_int(sc, "wsec", BWFM_WSEC_WEP); } else { bwfm_fwvar_var_set_int(sc, "wpa_auth", BWFM_WPA_AUTH_DISABLED); bwfm_fwvar_var_set_int(sc, "wsec", BWFM_WSEC_NONE); @@ -2083,8 +2086,7 @@ bwfm_hostap(struct bwfm_softc *sc) struct bwfm_join_params join; /* - * OPEN: Open or WPA/WPA2 on newer Chips/Firmware. - * SHARED KEY: WEP. + * OPEN: Open or WEP or WPA/WPA2 on newer Chips/Firmware. * AUTO: Automatic, probably for older Chips/Firmware. */ if (ic->ic_flags & IEEE80211_F_RSNON) { @@ -2883,10 +2885,12 @@ bwfm_set_key_cb(struct bwfm_softc *sc, void *arg) bwfm_fwvar_var_set_data(sc, "wsec_key", &key, sizeof(key)); bwfm_fwvar_var_get_int(sc, "wsec", &wsec); + wsec &= ~(BWFM_WSEC_WEP | BWFM_WSEC_TKIP | BWFM_WSEC_AES); wsec |= wsec_enable; bwfm_fwvar_var_set_int(sc, "wsec", wsec); - if (sc->sc_key_tasks == 0) { + if (wsec_enable != BWFM_WSEC_WEP && cmd->ni != NULL && + sc->sc_key_tasks == 0) { DPRINTF(("%s: marking port %s valid\n", DEVNAME(sc), ether_sprintf(cmd->ni->ni_macaddr))); cmd->ni->ni_port_valid = 1;