static int __init init_crypto_wep_test(void) { struct ieee80211com ic; struct ieee80211vap vap; int i, pass, total; memset(&ic, 0, sizeof(ic)); memset(&vap, 0, sizeof(vap)); vap.iv_ic = ⁣ if (debug) vap.iv_debug = IEEE80211_MSG_CRYPTO; ieee80211_crypto_attach(&ic); ieee80211_crypto_vattach(&vap); pass = 0; total = 0; for (i = 0; i < ARRAY_SIZE(weptests); i++) if (tests & (1 << i)) { total++; pass += runtest(&vap, &weptests[i]); } printk("%u of %u 802.11i WEP test vectors passed\n", pass, total); ieee80211_crypto_vdetach(&vap); ieee80211_crypto_detach(&ic); return (pass == total ? 0 : -ENXIO); }
/* * Tear down vap state and reclaim the ifnet. * The driver is assumed to have prepared for * this; e.g. by turning off interrupts for the * underlying device. */ void ieee80211_vap_detach(struct ieee80211vap *vap) { struct ieee80211com *ic = vap->iv_ic; struct ifnet *ifp = vap->iv_ifp; IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s parent %s\n", __func__, ieee80211_opmode_name[vap->iv_opmode], ic->ic_ifp->if_xname); /* NB: bpfdetach is called by ether_ifdetach and claims all taps */ ether_ifdetach(ifp); ieee80211_stop(vap); /* * Flush any deferred vap tasks. */ ieee80211_draintask(ic, &vap->iv_nstate_task); ieee80211_draintask(ic, &vap->iv_swbmiss_task); /* XXX band-aid until ifnet handles this for us */ taskqueue_drain(taskqueue_swi, &ifp->if_linktask); IEEE80211_LOCK(ic); KASSERT(vap->iv_state == IEEE80211_S_INIT , ("vap still running")); TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next); ieee80211_syncflag_locked(ic, IEEE80211_F_WME); #ifdef IEEE80211_SUPPORT_SUPERG ieee80211_syncflag_locked(ic, IEEE80211_F_TURBOP); #endif ieee80211_syncflag_locked(ic, IEEE80211_F_PCF); ieee80211_syncflag_locked(ic, IEEE80211_F_BURST); ieee80211_syncflag_ht_locked(ic, IEEE80211_FHT_HT); ieee80211_syncflag_ht_locked(ic, IEEE80211_FHT_USEHT40); /* NB: this handles the bpfdetach done below */ ieee80211_syncflag_ext_locked(ic, IEEE80211_FEXT_BPF); ieee80211_syncifflag_locked(ic, IFF_PROMISC); ieee80211_syncifflag_locked(ic, IFF_ALLMULTI); IEEE80211_UNLOCK(ic); ifmedia_removeall(&vap->iv_media); ieee80211_radiotap_vdetach(vap); ieee80211_regdomain_vdetach(vap); ieee80211_scan_vdetach(vap); #ifdef IEEE80211_SUPPORT_SUPERG ieee80211_superg_vdetach(vap); #endif ieee80211_ht_vdetach(vap); /* NB: must be before ieee80211_node_vdetach */ ieee80211_proto_vdetach(vap); ieee80211_crypto_vdetach(vap); ieee80211_power_vdetach(vap); ieee80211_node_vdetach(vap); ieee80211_sysctl_vdetach(vap); if_free(ifp); }
static int __init init_crypto_wep_test(void) { struct { struct ieee80211vap vap; struct ieee80211com ic; struct net_device netdev; } *buf; struct ieee80211vap *vap; int i, pass, total; buf = kzalloc(sizeof(*buf), GFP_KERNEL); if (!buf) return -ENOMEM; vap = &buf->vap; vap->iv_ic = &buf->ic; vap->iv_dev = &buf->netdev; vap->iv_ic->ic_dev = vap->iv_dev; strncpy(vap->iv_dev->name, "WEP test", sizeof(vap->iv_dev->name) - 1); if (debug) vap->iv_debug = IEEE80211_MSG_CRYPTO; ieee80211_crypto_attach(vap->iv_ic); ieee80211_crypto_vattach(vap); pass = 0; total = 0; for (i = 0; i < ARRAY_SIZE(weptests); i++) if (tests & (1 << i)) { total++; pass += runtest(vap, &weptests[i]); } printk("%u of %u 802.11i WEP test vectors passed\n", pass, total); ieee80211_crypto_vdetach(vap); ieee80211_crypto_detach(vap->iv_ic); kfree(buf); return (pass == total ? 0 : -ENXIO); }
static int __init init_crypto_ccmp_test(void) { struct ieee80211com *ic; struct ieee80211vap *vap; int i, pass, total; ic = kzalloc(sizeof(*ic), GFP_KERNEL); if (!ic) return -ENOMEM; ieee80211_crypto_attach(ic); vap = kzalloc(sizeof(*vap), GFP_KERNEL); if (!vap) { kfree(ic); return -ENOMEM; } vap->iv_ic = ic; if (debug) vap->iv_debug = IEEE80211_MSG_CRYPTO; ieee80211_crypto_vattach(vap); pass = 0; total = 0; for (i = 0; i < ARRAY_SIZE(ccmptests); i++) if (tests & (1 << i)) { total++; pass += runtest(vap, &ccmptests[i]); } printk("%u of %u 802.11i AES-CCMP test vectors passed\n", pass, total); ieee80211_crypto_vdetach(vap); ieee80211_crypto_detach(ic); kfree(vap); kfree(ic); return (pass == total ? 0 : -ENXIO); }