-@@ -464,15 +464,30 @@ madwifi_set_key(const char *ifname, void
- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
+@@ -439,7 +439,11 @@ madwifi_set_key(const char *ifname, void
+ __func__, alg, ether_sprintf(addr), key_idx);
+
+ if (alg == WPA_ALG_WEP)
++ {
+ cipher = IEEE80211_CIPHER_WEP;
++ if ((!addr || !memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) && drv->wext)
++ return wpa_driver_wext_set_key(ifname, drv->wext, alg, addr, key_idx, set_tx, seq, seq_len, key, key_len);
++ }
+ else if (alg == WPA_ALG_TKIP)
+ cipher = IEEE80211_CIPHER_TKIP;
+ else if (alg == WPA_ALG_CCMP)
+@@ -458,20 +462,45 @@ madwifi_set_key(const char *ifname, void
+
+ memset(&wk, 0, sizeof(wk));
+ wk.ik_type = cipher;
+- wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
+- if (addr == NULL || is_broadcast_ether_addr(addr)) {
+- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
++ wk.ik_flags = IEEE80211_KEY_RECV;
++ if (set_tx)
++ wk.ik_flags |= IEEE80211_KEY_XMIT;
++ if (addr == NULL) {
++ os_memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);