Lines Matching +full:mode +full:- +full:xxx

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
31 * IEEE 802.11 ioctl support (FreeBSD-specific)
63 (IFNET_IS_UP_RUNNING((_vap)->iv_ifp) && \
64 (_vap)->iv_roaming == IEEE80211_ROAMING_AUTO)
68 int ieee, int mode);
76 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_getkey()
84 if (ireq->i_len != sizeof(ik)) in ieee80211_ioctl_getkey()
86 error = copyin(ireq->i_data, &ik, sizeof(ik)); in ieee80211_ioctl_getkey()
91 ni = ieee80211_find_vap_node(&ic->ic_sta, vap, ik.ik_macaddr); in ieee80211_ioctl_getkey()
94 wk = &ni->ni_ucastkey; in ieee80211_ioctl_getkey()
98 wk = &vap->iv_nw_keys[kid]; in ieee80211_ioctl_getkey()
99 IEEE80211_ADDR_COPY(&ik.ik_macaddr, vap->iv_bss->ni_macaddr); in ieee80211_ioctl_getkey()
102 cip = wk->wk_cipher; in ieee80211_ioctl_getkey()
103 ik.ik_type = cip->ic_cipher; in ieee80211_ioctl_getkey()
104 ik.ik_keylen = wk->wk_keylen; in ieee80211_ioctl_getkey()
105 ik.ik_flags = wk->wk_flags & (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV); in ieee80211_ioctl_getkey()
106 if (wk->wk_keyix == vap->iv_def_txkey) in ieee80211_ioctl_getkey()
110 ik.ik_keyrsc = wk->wk_keyrsc[IEEE80211_NONQOS_TID]; in ieee80211_ioctl_getkey()
111 ik.ik_keytsc = wk->wk_keytsc; in ieee80211_ioctl_getkey()
112 memcpy(ik.ik_keydata, wk->wk_key, wk->wk_keylen); in ieee80211_ioctl_getkey()
113 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP) { in ieee80211_ioctl_getkey()
114 memcpy(ik.ik_keydata+wk->wk_keylen, in ieee80211_ioctl_getkey()
115 wk->wk_key + IEEE80211_KEYBUF_SIZE, in ieee80211_ioctl_getkey()
126 return copyout(&ik, ireq->i_data, sizeof(ik)); in ieee80211_ioctl_getkey()
132 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_getchanlist()
134 if (sizeof(ic->ic_chan_active) < ireq->i_len) in ieee80211_ioctl_getchanlist()
135 ireq->i_len = sizeof(ic->ic_chan_active); in ieee80211_ioctl_getchanlist()
136 return copyout(&ic->ic_chan_active, ireq->i_data, ireq->i_len); in ieee80211_ioctl_getchanlist()
142 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_getchaninfo()
146 ic_chans[ic->ic_nchans]); in ieee80211_ioctl_getchaninfo()
147 if (space > ireq->i_len) in ieee80211_ioctl_getchaninfo()
148 space = ireq->i_len; in ieee80211_ioctl_getchaninfo()
149 /* XXX assumes compatible layout */ in ieee80211_ioctl_getchaninfo()
150 return copyout(&ic->ic_nchans, ireq->i_data, space); in ieee80211_ioctl_getchaninfo()
161 if (ireq->i_len < IEEE80211_ADDR_LEN) in ieee80211_ioctl_getwpaie()
167 error = copyin(ireq->i_data, wpaie->wpa_macaddr, IEEE80211_ADDR_LEN); in ieee80211_ioctl_getwpaie()
170 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, wpaie->wpa_macaddr); in ieee80211_ioctl_getwpaie()
175 if (ni->ni_ies.wpa_ie != NULL) { in ieee80211_ioctl_getwpaie()
176 int ielen = ni->ni_ies.wpa_ie[1] + 2; in ieee80211_ioctl_getwpaie()
177 if (ielen > sizeof(wpaie->wpa_ie)) in ieee80211_ioctl_getwpaie()
178 ielen = sizeof(wpaie->wpa_ie); in ieee80211_ioctl_getwpaie()
179 memcpy(wpaie->wpa_ie, ni->ni_ies.wpa_ie, ielen); in ieee80211_ioctl_getwpaie()
182 if (ni->ni_ies.rsn_ie != NULL) { in ieee80211_ioctl_getwpaie()
183 int ielen = ni->ni_ies.rsn_ie[1] + 2; in ieee80211_ioctl_getwpaie()
184 if (ielen > sizeof(wpaie->rsn_ie)) in ieee80211_ioctl_getwpaie()
185 ielen = sizeof(wpaie->rsn_ie); in ieee80211_ioctl_getwpaie()
186 memcpy(wpaie->rsn_ie, ni->ni_ies.rsn_ie, ielen); in ieee80211_ioctl_getwpaie()
188 if (ireq->i_len > sizeof(struct ieee80211req_wpaie2)) in ieee80211_ioctl_getwpaie()
189 ireq->i_len = sizeof(struct ieee80211req_wpaie2); in ieee80211_ioctl_getwpaie()
192 /* XXX check ic_flags? */ in ieee80211_ioctl_getwpaie()
193 if (ni->ni_ies.rsn_ie != NULL) { in ieee80211_ioctl_getwpaie()
194 int ielen = ni->ni_ies.rsn_ie[1] + 2; in ieee80211_ioctl_getwpaie()
195 if (ielen > sizeof(wpaie->wpa_ie)) in ieee80211_ioctl_getwpaie()
196 ielen = sizeof(wpaie->wpa_ie); in ieee80211_ioctl_getwpaie()
197 memcpy(wpaie->wpa_ie, ni->ni_ies.rsn_ie, ielen); in ieee80211_ioctl_getwpaie()
199 if (ireq->i_len > sizeof(struct ieee80211req_wpaie)) in ieee80211_ioctl_getwpaie()
200 ireq->i_len = sizeof(struct ieee80211req_wpaie); in ieee80211_ioctl_getwpaie()
203 error = copyout(wpaie, ireq->i_data, ireq->i_len); in ieee80211_ioctl_getwpaie()
217 if (ireq->i_len < off) in ieee80211_ioctl_getstastats()
219 error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN); in ieee80211_ioctl_getstastats()
222 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, macaddr); in ieee80211_ioctl_getstastats()
225 if (ireq->i_len > sizeof(struct ieee80211req_sta_stats)) in ieee80211_ioctl_getstastats()
226 ireq->i_len = sizeof(struct ieee80211req_sta_stats); in ieee80211_ioctl_getstastats()
228 error = copyout(&ni->ni_stats, (uint8_t *) ireq->i_data + off, in ieee80211_ioctl_getstastats()
229 ireq->i_len - off); in ieee80211_ioctl_getstastats()
244 *ielen = se->se_ies.len; in scan_space()
248 * 16-bits; if this is a concern we can drop the ie's. in scan_space()
250 len = sizeof(struct ieee80211req_scan_result) + se->se_ssid[1] + in scan_space()
251 se->se_meshid[1] + *ielen; in scan_space()
261 req->space += scan_space(se, &ielen); in get_scan_space()
273 if (len > req->space) in get_scan_result()
276 sr = req->sr; in get_scan_result()
278 ("len %u ssid %u ie %u", len, se->se_ssid[1], ielen)); in get_scan_result()
279 sr->isr_len = len; in get_scan_result()
280 sr->isr_ie_off = sizeof(struct ieee80211req_scan_result); in get_scan_result()
281 sr->isr_ie_len = ielen; in get_scan_result()
282 sr->isr_freq = se->se_chan->ic_freq; in get_scan_result()
283 sr->isr_flags = se->se_chan->ic_flags; in get_scan_result()
284 sr->isr_rssi = se->se_rssi; in get_scan_result()
285 sr->isr_noise = se->se_noise; in get_scan_result()
286 sr->isr_intval = se->se_intval; in get_scan_result()
287 sr->isr_capinfo = se->se_capinfo; in get_scan_result()
288 sr->isr_erp = se->se_erp; in get_scan_result()
289 IEEE80211_ADDR_COPY(sr->isr_bssid, se->se_bssid); in get_scan_result()
290 nr = min(se->se_rates[1], IEEE80211_RATE_MAXSIZE); in get_scan_result()
291 memcpy(sr->isr_rates, se->se_rates+2, nr); in get_scan_result()
292 nxr = min(se->se_xrates[1], IEEE80211_RATE_MAXSIZE - nr); in get_scan_result()
293 memcpy(sr->isr_rates+nr, se->se_xrates+2, nxr); in get_scan_result()
294 sr->isr_nrates = nr + nxr; in get_scan_result()
297 sr->isr_ssid_len = se->se_ssid[1]; in get_scan_result()
298 cp = ((uint8_t *)sr) + sr->isr_ie_off; in get_scan_result()
299 memcpy(cp, se->se_ssid+2, sr->isr_ssid_len); in get_scan_result()
302 cp += sr->isr_ssid_len; in get_scan_result()
303 sr->isr_meshid_len = se->se_meshid[1]; in get_scan_result()
304 memcpy(cp, se->se_meshid+2, sr->isr_meshid_len); in get_scan_result()
305 cp += sr->isr_meshid_len; in get_scan_result()
308 memcpy(cp, se->se_ies.data, ielen); in get_scan_result()
310 req->space -= len; in get_scan_result()
311 req->sr = (struct ieee80211req_scan_result *)(((uint8_t *)sr) + len); in get_scan_result()
321 if (ireq->i_len < sizeof(struct scanreq)) in ieee80211_ioctl_getscanresults()
327 if (req.space > ireq->i_len) in ieee80211_ioctl_getscanresults()
328 req.space = ireq->i_len; in ieee80211_ioctl_getscanresults()
334 /* XXX IEEE80211_M_WAITOK after driver lock released */ in ieee80211_ioctl_getscanresults()
341 ireq->i_len = space - req.space; in ieee80211_ioctl_getscanresults()
342 error = copyout(p, ireq->i_data, ireq->i_len); in ieee80211_ioctl_getscanresults()
345 ireq->i_len = 0; in ieee80211_ioctl_getscanresults()
358 *ielen = ni->ni_ies.len; in sta_space()
369 if (ni->ni_vap->iv_opmode == IEEE80211_M_HOSTAP && in get_sta_space()
370 ni->ni_associd == 0) /* only associated stations */ in get_sta_space()
372 req->space += sta_space(ni, &ielen); in get_sta_space()
379 struct ieee80211vap *vap = ni->ni_vap; in get_sta_info()
384 if (vap->iv_opmode == IEEE80211_M_HOSTAP && in get_sta_info()
385 ni->ni_associd == 0) /* only associated stations */ in get_sta_info()
387 if (ni->ni_chan == IEEE80211_CHAN_ANYC) /* XXX bogus entry */ in get_sta_info()
390 if (len > req->space) in get_sta_info()
392 si = req->si; in get_sta_info()
393 si->isi_len = len; in get_sta_info()
394 si->isi_ie_off = sizeof(struct ieee80211req_sta_info); in get_sta_info()
395 si->isi_ie_len = ielen; in get_sta_info()
396 si->isi_freq = ni->ni_chan->ic_freq; in get_sta_info()
397 si->isi_flags = ni->ni_chan->ic_flags; in get_sta_info()
398 si->isi_state = ni->ni_flags; in get_sta_info()
399 si->isi_authmode = ni->ni_authmode; in get_sta_info()
400 vap->iv_ic->ic_node_getsignal(ni, &si->isi_rssi, &si->isi_noise); in get_sta_info()
401 vap->iv_ic->ic_node_getmimoinfo(ni, &si->isi_mimo); in get_sta_info()
402 si->isi_capinfo = ni->ni_capinfo; in get_sta_info()
403 si->isi_erp = ni->ni_erp; in get_sta_info()
404 IEEE80211_ADDR_COPY(si->isi_macaddr, ni->ni_macaddr); in get_sta_info()
405 si->isi_nrates = ni->ni_rates.rs_nrates; in get_sta_info()
406 if (si->isi_nrates > 15) in get_sta_info()
407 si->isi_nrates = 15; in get_sta_info()
408 memcpy(si->isi_rates, ni->ni_rates.rs_rates, si->isi_nrates); in get_sta_info()
409 si->isi_txrate = ni->ni_txrate; in get_sta_info()
410 if (si->isi_txrate & IEEE80211_RATE_MCS) { in get_sta_info()
412 &ieee80211_htrates[ni->ni_txrate &~ IEEE80211_RATE_MCS]; in get_sta_info()
413 if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) { in get_sta_info()
414 if (ni->ni_flags & IEEE80211_NODE_SGI40) in get_sta_info()
415 si->isi_txmbps = mcs->ht40_rate_800ns; in get_sta_info()
417 si->isi_txmbps = mcs->ht40_rate_400ns; in get_sta_info()
419 if (ni->ni_flags & IEEE80211_NODE_SGI20) in get_sta_info()
420 si->isi_txmbps = mcs->ht20_rate_800ns; in get_sta_info()
422 si->isi_txmbps = mcs->ht20_rate_400ns; in get_sta_info()
425 si->isi_txmbps = si->isi_txrate; in get_sta_info()
426 si->isi_associd = ni->ni_associd; in get_sta_info()
427 si->isi_txpower = ni->ni_txpower; in get_sta_info()
428 si->isi_vlan = ni->ni_vlan; in get_sta_info()
429 if (ni->ni_flags & IEEE80211_NODE_QOS) { in get_sta_info()
430 memcpy(si->isi_txseqs, ni->ni_txseqs, sizeof(ni->ni_txseqs)); in get_sta_info()
431 memcpy(si->isi_rxseqs, ni->ni_rxseqs, sizeof(ni->ni_rxseqs)); in get_sta_info()
433 si->isi_txseqs[0] = ni->ni_txseqs[IEEE80211_NONQOS_TID]; in get_sta_info()
434 si->isi_rxseqs[0] = ni->ni_rxseqs[IEEE80211_NONQOS_TID]; in get_sta_info()
438 si->isi_inact = vap->iv_inact_run; in get_sta_info()
439 else if (ni->ni_associd != 0 || in get_sta_info()
440 (vap->iv_opmode == IEEE80211_M_WDS && in get_sta_info()
441 (vap->iv_flags_ext & IEEE80211_FEXT_WDSLEGACY))) in get_sta_info()
442 si->isi_inact = vap->iv_inact_auth; in get_sta_info()
444 si->isi_inact = vap->iv_inact_init; in get_sta_info()
445 si->isi_inact = (si->isi_inact - ni->ni_inact) * IEEE80211_INACT_WAIT; in get_sta_info()
446 si->isi_localid = ni->ni_mllid; in get_sta_info()
447 si->isi_peerid = ni->ni_mlpid; in get_sta_info()
448 si->isi_peerstate = ni->ni_mlstate; in get_sta_info()
451 cp = ((uint8_t *)si) + si->isi_ie_off; in get_sta_info()
452 memcpy(cp, ni->ni_ies.data, ielen); in get_sta_info()
455 req->si = (struct ieee80211req_sta_info *)(((uint8_t *)si) + len); in get_sta_info()
456 req->space -= len; in get_sta_info()
463 struct ieee80211com *ic = vap->iv_ic; in getstainfo_common()
472 ieee80211_iterate_nodes_vap(&ic->ic_sta, vap, get_sta_space, in getstainfo_common()
476 if (req.space > ireq->i_len) in getstainfo_common()
477 req.space = ireq->i_len; in getstainfo_common()
480 /* XXX IEEE80211_M_WAITOK after driver lock released */ in getstainfo_common()
489 ieee80211_iterate_nodes_vap(&ic->ic_sta, vap, in getstainfo_common()
493 ireq->i_len = space - req.space; in getstainfo_common()
494 error = copyout(p, (uint8_t *) ireq->i_data+off, ireq->i_len); in getstainfo_common()
497 ireq->i_len = 0; in getstainfo_common()
512 if (ireq->i_len < sizeof(struct ieee80211req_sta_req)) in ieee80211_ioctl_getstainfo()
514 error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN); in ieee80211_ioctl_getstainfo()
517 if (IEEE80211_ADDR_EQ(macaddr, vap->iv_ifp->if_broadcastaddr)) { in ieee80211_ioctl_getstainfo()
520 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, macaddr); in ieee80211_ioctl_getstainfo()
534 if (ireq->i_len != sizeof(txpow)) in ieee80211_ioctl_getstatxpow()
536 error = copyin(ireq->i_data, &txpow, sizeof(txpow)); in ieee80211_ioctl_getstatxpow()
539 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, txpow.it_macaddr); in ieee80211_ioctl_getstatxpow()
542 txpow.it_txpow = ni->ni_txpower; in ieee80211_ioctl_getstatxpow()
543 error = copyout(&txpow, ireq->i_data, sizeof(txpow)); in ieee80211_ioctl_getstatxpow()
551 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_getwmeparam()
552 struct ieee80211_wme_state *wme = &ic->ic_wme; in ieee80211_ioctl_getwmeparam()
556 if ((ic->ic_caps & IEEE80211_C_WME) == 0) in ieee80211_ioctl_getwmeparam()
559 ac = (ireq->i_len & IEEE80211_WMEPARAM_VAL); in ieee80211_ioctl_getwmeparam()
562 if (ireq->i_len & IEEE80211_WMEPARAM_BSS) in ieee80211_ioctl_getwmeparam()
563 wmep = &wme->wme_wmeBssChanParams.cap_wmeParams[ac]; in ieee80211_ioctl_getwmeparam()
565 wmep = &wme->wme_wmeChanParams.cap_wmeParams[ac]; in ieee80211_ioctl_getwmeparam()
566 switch (ireq->i_type) { in ieee80211_ioctl_getwmeparam()
568 ireq->i_val = wmep->wmep_logcwmin; in ieee80211_ioctl_getwmeparam()
571 ireq->i_val = wmep->wmep_logcwmax; in ieee80211_ioctl_getwmeparam()
574 ireq->i_val = wmep->wmep_aifsn; in ieee80211_ioctl_getwmeparam()
577 ireq->i_val = wmep->wmep_txopLimit; in ieee80211_ioctl_getwmeparam()
580 wmep = &wme->wme_wmeBssChanParams.cap_wmeParams[ac]; in ieee80211_ioctl_getwmeparam()
581 ireq->i_val = wmep->wmep_acm; in ieee80211_ioctl_getwmeparam()
584 wmep = &wme->wme_wmeChanParams.cap_wmeParams[ac]; in ieee80211_ioctl_getwmeparam()
585 ireq->i_val = !wmep->wmep_noackPolicy; in ieee80211_ioctl_getwmeparam()
594 const struct ieee80211_aclator *acl = vap->iv_acl; in ieee80211_ioctl_getmaccmd()
596 return (acl == NULL ? EINVAL : acl->iac_getioctl(vap, ireq)); in ieee80211_ioctl_getmaccmd()
602 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_getcurchan()
605 if (ireq->i_len != sizeof(struct ieee80211_channel)) in ieee80211_ioctl_getcurchan()
609 * in use. When in RUN state report the vap-specific channel. in ieee80211_ioctl_getcurchan()
612 if (vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP) in ieee80211_ioctl_getcurchan()
613 c = vap->iv_bss->ni_chan; in ieee80211_ioctl_getcurchan()
615 c = ic->ic_curchan; in ieee80211_ioctl_getcurchan()
616 return copyout(c, ireq->i_data, sizeof(*c)); in ieee80211_ioctl_getcurchan()
625 if (ireq->i_len > aie->ie_len) in getappie()
626 ireq->i_len = aie->ie_len; in getappie()
627 return copyout(aie->ie_data, ireq->i_data, ireq->i_len); in getappie()
635 fc0 = ireq->i_val & 0xff; in ieee80211_ioctl_getappie()
641 return getappie(vap->iv_appie_beacon, ireq); in ieee80211_ioctl_getappie()
643 return getappie(vap->iv_appie_proberesp, ireq); in ieee80211_ioctl_getappie()
645 return getappie(vap->iv_appie_assocresp, ireq); in ieee80211_ioctl_getappie()
647 return getappie(vap->iv_appie_probereq, ireq); in ieee80211_ioctl_getappie()
649 return getappie(vap->iv_appie_assocreq, ireq); in ieee80211_ioctl_getappie()
651 return getappie(vap->iv_appie_wpa, ireq); in ieee80211_ioctl_getappie()
660 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_getregdomain()
662 if (ireq->i_len != sizeof(ic->ic_regdomain)) in ieee80211_ioctl_getregdomain()
664 return copyout(&ic->ic_regdomain, ireq->i_data, in ieee80211_ioctl_getregdomain()
665 sizeof(ic->ic_regdomain)); in ieee80211_ioctl_getregdomain()
672 size_t len = ireq->i_len; in ieee80211_ioctl_getroam()
674 if (len > sizeof(vap->iv_roamparms)) in ieee80211_ioctl_getroam()
675 len = sizeof(vap->iv_roamparms); in ieee80211_ioctl_getroam()
676 return copyout(vap->iv_roamparms, ireq->i_data, len); in ieee80211_ioctl_getroam()
683 size_t len = ireq->i_len; in ieee80211_ioctl_gettxparams()
685 if (len > sizeof(vap->iv_txparms)) in ieee80211_ioctl_gettxparams()
686 len = sizeof(vap->iv_txparms); in ieee80211_ioctl_gettxparams()
687 return copyout(vap->iv_txparms, ireq->i_data, len); in ieee80211_ioctl_gettxparams()
698 maxchans = 1 + ((ireq->i_len - sizeof(struct ieee80211_devcaps_req)) / in ieee80211_ioctl_getdevcaps()
711 dc->dc_drivercaps = ic->ic_caps; in ieee80211_ioctl_getdevcaps()
716 dc->dc_cryptocaps = ic->ic_cryptocaps | ic->ic_sw_cryptocaps; in ieee80211_ioctl_getdevcaps()
717 dc->dc_htcaps = ic->ic_htcaps; in ieee80211_ioctl_getdevcaps()
718 dc->dc_vhtcaps = ic->ic_vht_cap.vht_cap_info; in ieee80211_ioctl_getdevcaps()
719 ci = &dc->dc_chaninfo; in ieee80211_ioctl_getdevcaps()
720 ic->ic_getradiocaps(ic, maxchans, &ci->ic_nchans, ci->ic_chans); in ieee80211_ioctl_getdevcaps()
721 KASSERT(ci->ic_nchans <= maxchans, in ieee80211_ioctl_getdevcaps()
722 ("nchans %d maxchans %d", ci->ic_nchans, maxchans)); in ieee80211_ioctl_getdevcaps()
723 ieee80211_sort_channels(ci->ic_chans, ci->ic_nchans); in ieee80211_ioctl_getdevcaps()
724 error = copyout(dc, ireq->i_data, IEEE80211_DEVCAPS_SPACE(dc)); in ieee80211_ioctl_getdevcaps()
736 if (ireq->i_len != sizeof(vlan)) in ieee80211_ioctl_getstavlan()
738 error = copyin(ireq->i_data, &vlan, sizeof(vlan)); in ieee80211_ioctl_getstavlan()
742 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, in ieee80211_ioctl_getstavlan()
747 ni = ieee80211_ref_node(vap->iv_bss); in ieee80211_ioctl_getstavlan()
748 vlan.sv_vlan = ni->ni_vlan; in ieee80211_ioctl_getstavlan()
749 error = copyout(&vlan, ireq->i_data, sizeof(vlan)); in ieee80211_ioctl_getstavlan()
782 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_get80211()
788 switch (ireq->i_type) { in ieee80211_ioctl_get80211()
790 len = strlen(ic->ic_name) + 1; in ieee80211_ioctl_get80211()
791 if (len > ireq->i_len) in ieee80211_ioctl_get80211()
793 ireq->i_len = len; in ieee80211_ioctl_get80211()
794 error = copyout(ic->ic_name, ireq->i_data, ireq->i_len); in ieee80211_ioctl_get80211()
797 switch (vap->iv_state) { in ieee80211_ioctl_get80211()
800 ireq->i_len = vap->iv_des_ssid[0].len; in ieee80211_ioctl_get80211()
801 memcpy(tmpssid, vap->iv_des_ssid[0].ssid, ireq->i_len); in ieee80211_ioctl_get80211()
804 ireq->i_len = vap->iv_bss->ni_esslen; in ieee80211_ioctl_get80211()
805 memcpy(tmpssid, vap->iv_bss->ni_essid, ireq->i_len); in ieee80211_ioctl_get80211()
808 error = copyout(tmpssid, ireq->i_data, ireq->i_len); in ieee80211_ioctl_get80211()
811 ireq->i_val = 1; in ieee80211_ioctl_get80211()
814 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) in ieee80211_ioctl_get80211()
815 ireq->i_val = IEEE80211_WEP_OFF; in ieee80211_ioctl_get80211()
816 else if (vap->iv_flags & IEEE80211_F_DROPUNENC) in ieee80211_ioctl_get80211()
817 ireq->i_val = IEEE80211_WEP_ON; in ieee80211_ioctl_get80211()
819 ireq->i_val = IEEE80211_WEP_MIXED; in ieee80211_ioctl_get80211()
822 kid = (u_int) ireq->i_val; in ieee80211_ioctl_get80211()
825 len = (u_int) vap->iv_nw_keys[kid].wk_keylen; in ieee80211_ioctl_get80211()
828 bcopy(vap->iv_nw_keys[kid].wk_key, tmpkey, len); in ieee80211_ioctl_get80211()
832 ireq->i_len = len; in ieee80211_ioctl_get80211()
833 error = copyout(tmpkey, ireq->i_data, len); in ieee80211_ioctl_get80211()
836 ireq->i_val = IEEE80211_WEP_NKID; in ieee80211_ioctl_get80211()
839 ireq->i_val = vap->iv_def_txkey; in ieee80211_ioctl_get80211()
842 if (vap->iv_flags & IEEE80211_F_WPA) in ieee80211_ioctl_get80211()
843 ireq->i_val = IEEE80211_AUTH_WPA; in ieee80211_ioctl_get80211()
845 ireq->i_val = vap->iv_bss->ni_authmode; in ieee80211_ioctl_get80211()
848 ireq->i_val = ieee80211_chan2ieee(ic, ic->ic_curchan); in ieee80211_ioctl_get80211()
851 if (vap->iv_flags & IEEE80211_F_PMGTON) in ieee80211_ioctl_get80211()
852 ireq->i_val = IEEE80211_POWERSAVE_ON; in ieee80211_ioctl_get80211()
854 ireq->i_val = IEEE80211_POWERSAVE_OFF; in ieee80211_ioctl_get80211()
857 ireq->i_val = ic->ic_lintval; in ieee80211_ioctl_get80211()
860 ireq->i_val = vap->iv_rtsthreshold; in ieee80211_ioctl_get80211()
863 ireq->i_val = vap->iv_protmode; in ieee80211_ioctl_get80211()
868 * power, any user-set limit, and the max the in ieee80211_ioctl_get80211()
873 ireq->i_val = 2*ic->ic_curchan->ic_maxregpower; in ieee80211_ioctl_get80211()
874 if (ireq->i_val > ic->ic_txpowlimit) in ieee80211_ioctl_get80211()
875 ireq->i_val = ic->ic_txpowlimit; in ieee80211_ioctl_get80211()
876 if (ireq->i_val > ic->ic_curchan->ic_maxpower) in ieee80211_ioctl_get80211()
877 ireq->i_val = ic->ic_curchan->ic_maxpower; in ieee80211_ioctl_get80211()
880 switch (vap->iv_flags & IEEE80211_F_WPA) { in ieee80211_ioctl_get80211()
882 ireq->i_val = 1; in ieee80211_ioctl_get80211()
885 ireq->i_val = 2; in ieee80211_ioctl_get80211()
888 ireq->i_val = 3; in ieee80211_ioctl_get80211()
891 ireq->i_val = 0; in ieee80211_ioctl_get80211()
899 ireq->i_val = vap->iv_roaming; in ieee80211_ioctl_get80211()
902 ireq->i_val = (vap->iv_flags & IEEE80211_F_PRIVACY) != 0; in ieee80211_ioctl_get80211()
905 ireq->i_val = (vap->iv_flags & IEEE80211_F_DROPUNENC) != 0; in ieee80211_ioctl_get80211()
908 ireq->i_val = (vap->iv_flags & IEEE80211_F_COUNTERM) != 0; in ieee80211_ioctl_get80211()
911 ireq->i_val = (vap->iv_flags & IEEE80211_F_WME) != 0; in ieee80211_ioctl_get80211()
914 ireq->i_val = (vap->iv_flags & IEEE80211_F_HIDESSID) != 0; in ieee80211_ioctl_get80211()
917 ireq->i_val = (vap->iv_flags & IEEE80211_F_NOBRIDGE) == 0; in ieee80211_ioctl_get80211()
926 if (ireq->i_len != IEEE80211_ADDR_LEN) in ieee80211_ioctl_get80211()
928 if (vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP) { in ieee80211_ioctl_get80211()
929 error = copyout(vap->iv_opmode == IEEE80211_M_WDS ? in ieee80211_ioctl_get80211()
930 vap->iv_bss->ni_macaddr : vap->iv_bss->ni_bssid, in ieee80211_ioctl_get80211()
931 ireq->i_data, ireq->i_len); in ieee80211_ioctl_get80211()
933 error = copyout(vap->iv_des_bssid, ireq->i_data, in ieee80211_ioctl_get80211()
934 ireq->i_len); in ieee80211_ioctl_get80211()
938 error = ieee80211_ioctl_getwpaie(vap, ireq, ireq->i_type); in ieee80211_ioctl_get80211()
947 ireq->i_val = vap->iv_bss->ni_txpower; in ieee80211_ioctl_get80211()
964 ireq->i_val = vap->iv_dtim_period; in ieee80211_ioctl_get80211()
967 /* NB: get from ic_bss for station mode */ in ieee80211_ioctl_get80211()
968 ireq->i_val = vap->iv_bss->ni_intval; in ieee80211_ioctl_get80211()
971 ireq->i_val = (vap->iv_flags & IEEE80211_F_PUREG) != 0; in ieee80211_ioctl_get80211()
974 ireq->i_val = vap->iv_quiet; in ieee80211_ioctl_get80211()
977 ireq->i_val = vap->iv_quiet_count; in ieee80211_ioctl_get80211()
980 ireq->i_val = vap->iv_quiet_period; in ieee80211_ioctl_get80211()
983 ireq->i_val = vap->iv_quiet_duration; in ieee80211_ioctl_get80211()
986 ireq->i_val = vap->iv_quiet_offset; in ieee80211_ioctl_get80211()
989 ireq->i_val = (vap->iv_flags & IEEE80211_F_BGSCAN) != 0; in ieee80211_ioctl_get80211()
992 ireq->i_val = vap->iv_bgscanidle*hz/1000; /* ms */ in ieee80211_ioctl_get80211()
995 ireq->i_val = vap->iv_bgscanintvl/hz; /* seconds */ in ieee80211_ioctl_get80211()
998 ireq->i_val = vap->iv_scanvalid/hz; /* seconds */ in ieee80211_ioctl_get80211()
1001 ireq->i_val = vap->iv_fragthreshold; in ieee80211_ioctl_get80211()
1007 ireq->i_val = (vap->iv_flags & IEEE80211_F_BURST) != 0; in ieee80211_ioctl_get80211()
1010 ireq->i_val = vap->iv_bmissthreshold; in ieee80211_ioctl_get80211()
1016 ireq->i_val = 0; in ieee80211_ioctl_get80211()
1017 if (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20) in ieee80211_ioctl_get80211()
1018 ireq->i_val |= IEEE80211_HTCAP_SHORTGI20; in ieee80211_ioctl_get80211()
1019 if (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40) in ieee80211_ioctl_get80211()
1020 ireq->i_val |= IEEE80211_HTCAP_SHORTGI40; in ieee80211_ioctl_get80211()
1023 ireq->i_val = 0; in ieee80211_ioctl_get80211()
1024 if (vap->iv_flags_ht & IEEE80211_FHT_AMPDU_TX) in ieee80211_ioctl_get80211()
1025 ireq->i_val |= 1; in ieee80211_ioctl_get80211()
1026 if (vap->iv_flags_ht & IEEE80211_FHT_AMPDU_RX) in ieee80211_ioctl_get80211()
1027 ireq->i_val |= 2; in ieee80211_ioctl_get80211()
1030 /* XXX TODO: make this a per-node thing; and leave this as global */ in ieee80211_ioctl_get80211()
1031 if (vap->iv_opmode == IEEE80211_M_HOSTAP) in ieee80211_ioctl_get80211()
1032 ireq->i_val = vap->iv_ampdu_rxmax; in ieee80211_ioctl_get80211()
1033 else if (vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP) in ieee80211_ioctl_get80211()
1035 * XXX TODO: this isn't completely correct, as we've in ieee80211_ioctl_get80211()
1038 ireq->i_val = _IEEE80211_MASKSHIFT( vap->iv_bss->ni_htparam, in ieee80211_ioctl_get80211()
1041 ireq->i_val = vap->iv_ampdu_limit; in ieee80211_ioctl_get80211()
1044 /* XXX TODO: make this a per-node thing; and leave this as global */ in ieee80211_ioctl_get80211()
1045 if (vap->iv_opmode == IEEE80211_M_STA && in ieee80211_ioctl_get80211()
1046 (vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP)) in ieee80211_ioctl_get80211()
1048 * XXX TODO: this isn't completely correct, as we've in ieee80211_ioctl_get80211()
1051 ireq->i_val = _IEEE80211_MASKSHIFT(vap->iv_bss->ni_htparam, in ieee80211_ioctl_get80211()
1054 ireq->i_val = vap->iv_ampdu_density; in ieee80211_ioctl_get80211()
1057 ireq->i_val = 0; in ieee80211_ioctl_get80211()
1058 if (vap->iv_flags_ht & IEEE80211_FHT_AMSDU_TX) in ieee80211_ioctl_get80211()
1059 ireq->i_val |= 1; in ieee80211_ioctl_get80211()
1060 if (vap->iv_flags_ht & IEEE80211_FHT_AMSDU_RX) in ieee80211_ioctl_get80211()
1061 ireq->i_val |= 2; in ieee80211_ioctl_get80211()
1064 ireq->i_val = vap->iv_amsdu_limit; /* XXX truncation? */ in ieee80211_ioctl_get80211()
1067 ireq->i_val = (vap->iv_flags_ht & IEEE80211_FHT_PUREN) != 0; in ieee80211_ioctl_get80211()
1070 ireq->i_val = (vap->iv_flags & IEEE80211_F_DOTH) != 0; in ieee80211_ioctl_get80211()
1082 ireq->i_val = (vap->iv_flags_ht & IEEE80211_FHT_HTCOMPAT) != 0; in ieee80211_ioctl_get80211()
1085 ireq->i_val = (vap->iv_flags & IEEE80211_F_DWDS) != 0; in ieee80211_ioctl_get80211()
1088 ireq->i_val = (vap->iv_flags_ext & IEEE80211_FEXT_INACT) != 0; in ieee80211_ioctl_get80211()
1094 ireq->i_val = (vap->iv_flags_ext & IEEE80211_FEXT_WPS) != 0; in ieee80211_ioctl_get80211()
1097 ireq->i_val = (vap->iv_flags_ext & IEEE80211_FEXT_TSN) != 0; in ieee80211_ioctl_get80211()
1100 ireq->i_val = (vap->iv_flags_ext & IEEE80211_FEXT_DFS) != 0; in ieee80211_ioctl_get80211()
1103 ireq->i_val = (vap->iv_flags_ext & IEEE80211_FEXT_DOTD) != 0; in ieee80211_ioctl_get80211()
1109 ireq->i_val = vap->iv_htprotmode; in ieee80211_ioctl_get80211()
1112 if (vap->iv_flags_ht & IEEE80211_FHT_HT) { in ieee80211_ioctl_get80211()
1113 ireq->i_val = 1; in ieee80211_ioctl_get80211()
1114 if (vap->iv_flags_ht & IEEE80211_FHT_USEHT40) in ieee80211_ioctl_get80211()
1115 ireq->i_val |= 2; in ieee80211_ioctl_get80211()
1117 ireq->i_val = 0; in ieee80211_ioctl_get80211()
1123 if (vap->iv_opmode == IEEE80211_M_STA && in ieee80211_ioctl_get80211()
1124 (vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP)) { in ieee80211_ioctl_get80211()
1125 if (vap->iv_bss->ni_flags & IEEE80211_NODE_MIMO_RTS) in ieee80211_ioctl_get80211()
1126 ireq->i_val = IEEE80211_HTCAP_SMPS_DYNAMIC; in ieee80211_ioctl_get80211()
1127 else if (vap->iv_bss->ni_flags & IEEE80211_NODE_MIMO_PS) in ieee80211_ioctl_get80211()
1128 ireq->i_val = IEEE80211_HTCAP_SMPS_ENA; in ieee80211_ioctl_get80211()
1130 ireq->i_val = IEEE80211_HTCAP_SMPS_OFF; in ieee80211_ioctl_get80211()
1132 ireq->i_val = vap->iv_htcaps & IEEE80211_HTCAP_SMPS; in ieee80211_ioctl_get80211()
1135 if (vap->iv_opmode == IEEE80211_M_STA && in ieee80211_ioctl_get80211()
1136 (vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP)) in ieee80211_ioctl_get80211()
1137 ireq->i_val = in ieee80211_ioctl_get80211()
1138 (vap->iv_bss->ni_flags & IEEE80211_NODE_RIFS) != 0; in ieee80211_ioctl_get80211()
1140 ireq->i_val = in ieee80211_ioctl_get80211()
1141 (vap->iv_flags_ht & IEEE80211_FHT_RIFS) != 0; in ieee80211_ioctl_get80211()
1144 ireq->i_val = 0; in ieee80211_ioctl_get80211()
1145 if (vap->iv_flags_ht & IEEE80211_FHT_STBC_TX) in ieee80211_ioctl_get80211()
1146 ireq->i_val |= 1; in ieee80211_ioctl_get80211()
1147 if (vap->iv_flags_ht & IEEE80211_FHT_STBC_RX) in ieee80211_ioctl_get80211()
1148 ireq->i_val |= 2; in ieee80211_ioctl_get80211()
1151 ireq->i_val = 0; in ieee80211_ioctl_get80211()
1152 if (vap->iv_flags_ht & IEEE80211_FHT_LDPC_TX) in ieee80211_ioctl_get80211()
1153 ireq->i_val |= 1; in ieee80211_ioctl_get80211()
1154 if (vap->iv_flags_ht & IEEE80211_FHT_LDPC_RX) in ieee80211_ioctl_get80211()
1155 ireq->i_val |= 2; in ieee80211_ioctl_get80211()
1158 ireq->i_val = 0; in ieee80211_ioctl_get80211()
1159 if (vap->iv_flags_ext & IEEE80211_FEXT_UAPSD) in ieee80211_ioctl_get80211()
1160 ireq->i_val = 1; in ieee80211_ioctl_get80211()
1163 ireq->i_val = vap->iv_vht_flags & IEEE80211_FVHT_MASK; in ieee80211_ioctl_get80211()
1181 if (ireq->i_len != sizeof(ik)) in ieee80211_ioctl_setkey()
1183 error = copyin(ireq->i_data, &ik, sizeof(ik)); in ieee80211_ioctl_setkey()
1187 /* NB: this also checks ik->ik_keylen > sizeof(wk->wk_key) */ in ieee80211_ioctl_setkey()
1192 /* XXX unicast keys currently must be tx/rx */ in ieee80211_ioctl_setkey()
1195 if (vap->iv_opmode == IEEE80211_M_STA) { in ieee80211_ioctl_setkey()
1196 ni = ieee80211_ref_node(vap->iv_bss); in ieee80211_ioctl_setkey()
1197 if (!IEEE80211_ADDR_EQ(ik.ik_macaddr, ni->ni_bssid)) { in ieee80211_ioctl_setkey()
1202 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, in ieee80211_ioctl_setkey()
1207 wk = &ni->ni_ucastkey; in ieee80211_ioctl_setkey()
1211 wk = &vap->iv_nw_keys[kid]; in ieee80211_ioctl_setkey()
1216 if (wk->wk_keyix == IEEE80211_KEYIX_NONE) in ieee80211_ioctl_setkey()
1217 wk->wk_keyix = kid; in ieee80211_ioctl_setkey()
1223 wk->wk_keylen = ik.ik_keylen; in ieee80211_ioctl_setkey()
1225 if (wk->wk_keylen > IEEE80211_KEYBUF_SIZE) in ieee80211_ioctl_setkey()
1226 wk->wk_keylen = IEEE80211_KEYBUF_SIZE; in ieee80211_ioctl_setkey()
1228 wk->wk_keyrsc[i] = ik.ik_keyrsc; in ieee80211_ioctl_setkey()
1229 wk->wk_keytsc = 0; /* new key, reset */ in ieee80211_ioctl_setkey()
1230 memset(wk->wk_key, 0, sizeof(wk->wk_key)); in ieee80211_ioctl_setkey()
1231 memcpy(wk->wk_key, ik.ik_keydata, ik.ik_keylen); in ieee80211_ioctl_setkey()
1232 IEEE80211_ADDR_COPY(wk->wk_macaddr, in ieee80211_ioctl_setkey()
1233 ni != NULL ? ni->ni_macaddr : ik.ik_macaddr); in ieee80211_ioctl_setkey()
1242 * that currently isn't the way the ioctl -> in ieee80211_ioctl_setkey()
1260 if (ireq->i_len != sizeof(dk)) in ieee80211_ioctl_delkey()
1262 error = copyin(ireq->i_data, &dk, sizeof(dk)); in ieee80211_ioctl_delkey()
1266 /* XXX uint8_t -> uint16_t */ in ieee80211_ioctl_delkey()
1270 if (vap->iv_opmode == IEEE80211_M_STA) { in ieee80211_ioctl_delkey()
1271 ni = ieee80211_ref_node(vap->iv_bss); in ieee80211_ioctl_delkey()
1272 if (!IEEE80211_ADDR_EQ(dk.idk_macaddr, ni->ni_bssid)) { in ieee80211_ioctl_delkey()
1277 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, in ieee80211_ioctl_delkey()
1282 /* XXX error return */ in ieee80211_ioctl_delkey()
1288 /* XXX error return */ in ieee80211_ioctl_delkey()
1289 ieee80211_crypto_delkey(vap, &vap->iv_nw_keys[kid]); in ieee80211_ioctl_delkey()
1347 struct ieee80211vap *vap = ni->ni_vap; in domlme()
1349 if (vap != mop->vap) in domlme()
1356 if (ni->ni_associd == 0) in domlme()
1358 mlmedebug(vap, ni->ni_macaddr, mop->op, mop->reason); in domlme()
1359 if (mop->op == IEEE80211_MLME_DEAUTH) { in domlme()
1361 mop->reason); in domlme()
1364 mop->reason); in domlme()
1373 struct ieee80211_node_table *nt = &vap->iv_ic->ic_sta; in setmlme_dropsta()
1378 if (!IEEE80211_ADDR_EQ(mac, vap->iv_ifp->if_broadcastaddr)) { in setmlme_dropsta()
1402 struct ieee80211com *ic = vap->iv_ic; in setmlme_common()
1403 struct ieee80211_node_table *nt = &ic->ic_sta; in setmlme_common()
1412 switch (vap->iv_opmode) { in setmlme_common()
1414 mlmedebug(vap, vap->iv_bss->ni_macaddr, op, reason); in setmlme_common()
1415 /* XXX not quite right */ in setmlme_common()
1425 /* XXX user app should send raw frame? */ in setmlme_common()
1431 /* XXX accept any address, simplifies user code */ in setmlme_common()
1432 if (!IEEE80211_ADDR_EQ(mac, vap->iv_bss->ni_macaddr)) { in setmlme_common()
1437 mlmedebug(vap, vap->iv_bss->ni_macaddr, op, reason); in setmlme_common()
1438 ni = ieee80211_ref_node(vap->iv_bss); in setmlme_common()
1466 if (vap->iv_opmode != IEEE80211_M_HOSTAP && in setmlme_common()
1467 vap->iv_opmode != IEEE80211_M_WDS) { in setmlme_common()
1490 if (vap->iv_opmode != IEEE80211_M_HOSTAP) { in setmlme_common()
1513 if (ni->ni_authmode != IEEE80211_AUTH_8021X && in setmlme_common()
1514 ni->ni_challenge == NULL) in setmlme_common()
1517 vap->iv_stats.is_rx_acl++; in setmlme_common()
1518 ieee80211_send_error(ni, ni->ni_macaddr, in setmlme_common()
1548 if (!IEEE80211_ADDR_EQ(look->mac, se->se_macaddr)) in mlmelookup()
1550 if (look->esslen != 0) { in mlmelookup()
1551 if (se->se_ssid[1] != look->esslen) in mlmelookup()
1553 if (memcmp(look->essid, se->se_ssid+2, look->esslen)) in mlmelookup()
1556 look->se = se; in mlmelookup()
1566 KASSERT(vap->iv_opmode == IEEE80211_M_STA, in setmlme_assoc_sta()
1568 ieee80211_opmode_name[vap->iv_opmode])); in setmlme_assoc_sta()
1579 if (!ieee80211_sta_join(vap, lookup.se->se_chan, lookup.se)) in setmlme_assoc_sta()
1580 return EIO; /* XXX unique but could be better */ in setmlme_assoc_sta()
1592 KASSERT(vap->iv_opmode == IEEE80211_M_IBSS || in setmlme_assoc_adhoc()
1593 vap->iv_opmode == IEEE80211_M_AHDEMO, in setmlme_assoc_adhoc()
1595 ieee80211_opmode_name[vap->iv_opmode])); in setmlme_assoc_adhoc()
1606 memset(vap->iv_des_ssid[0].ssid, 0, IEEE80211_NWID_LEN); in setmlme_assoc_adhoc()
1607 vap->iv_des_ssid[0].len = ssid_len; in setmlme_assoc_adhoc()
1608 memcpy(vap->iv_des_ssid[0].ssid, ssid, ssid_len); in setmlme_assoc_adhoc()
1609 vap->iv_des_nssid = 1; in setmlme_assoc_adhoc()
1611 sr->sr_flags = IEEE80211_IOC_SCAN_ACTIVE | IEEE80211_IOC_SCAN_ONCE; in setmlme_assoc_adhoc()
1612 sr->sr_duration = IEEE80211_IOC_SCAN_FOREVER; in setmlme_assoc_adhoc()
1613 memcpy(sr->sr_ssid[0].ssid, ssid, ssid_len); in setmlme_assoc_adhoc()
1614 sr->sr_ssid[0].len = ssid_len; in setmlme_assoc_adhoc()
1615 sr->sr_nssid = 1; in setmlme_assoc_adhoc()
1629 if (ireq->i_len != sizeof(mlme)) in ieee80211_ioctl_setmlme()
1631 error = copyin(ireq->i_data, &mlme, sizeof(mlme)); in ieee80211_ioctl_setmlme()
1634 if (vap->iv_opmode == IEEE80211_M_STA && in ieee80211_ioctl_setmlme()
1637 vap->iv_des_ssid[0].len, vap->iv_des_ssid[0].ssid); in ieee80211_ioctl_setmlme()
1638 else if ((vap->iv_opmode == IEEE80211_M_IBSS || in ieee80211_ioctl_setmlme()
1639 vap->iv_opmode == IEEE80211_M_AHDEMO) && in ieee80211_ioctl_setmlme()
1652 const struct ieee80211_aclator *acl = vap->iv_acl; in ieee80211_ioctl_macmac()
1655 if (ireq->i_len != sizeof(mac)) in ieee80211_ioctl_macmac()
1657 error = copyin(ireq->i_data, mac, ireq->i_len); in ieee80211_ioctl_macmac()
1662 if (acl == NULL || !acl->iac_attach(vap)) in ieee80211_ioctl_macmac()
1664 vap->iv_acl = acl; in ieee80211_ioctl_macmac()
1666 if (ireq->i_type == IEEE80211_IOC_ADDMAC) in ieee80211_ioctl_macmac()
1667 acl->iac_add(vap, mac); in ieee80211_ioctl_macmac()
1669 acl->iac_remove(vap, mac); in ieee80211_ioctl_macmac()
1676 const struct ieee80211_aclator *acl = vap->iv_acl; in ieee80211_ioctl_setmaccmd()
1678 switch (ireq->i_val) { in ieee80211_ioctl_setmaccmd()
1685 if (acl == NULL || !acl->iac_attach(vap)) in ieee80211_ioctl_setmaccmd()
1687 vap->iv_acl = acl; in ieee80211_ioctl_setmaccmd()
1689 acl->iac_setpolicy(vap, ireq->i_val); in ieee80211_ioctl_setmaccmd()
1693 acl->iac_flush(vap); in ieee80211_ioctl_setmaccmd()
1698 vap->iv_acl = NULL; in ieee80211_ioctl_setmaccmd()
1699 acl->iac_detach(vap); in ieee80211_ioctl_setmaccmd()
1706 return acl->iac_setioctl(vap, ireq); in ieee80211_ioctl_setmaccmd()
1714 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_setchanlist()
1718 if (ireq->i_len > sizeof(ic->ic_chan_active)) in ieee80211_ioctl_setchanlist()
1719 ireq->i_len = sizeof(ic->ic_chan_active); in ieee80211_ioctl_setchanlist()
1720 list = IEEE80211_MALLOC(ireq->i_len + IEEE80211_CHAN_BYTES, M_TEMP, in ieee80211_ioctl_setchanlist()
1724 error = copyin(ireq->i_data, list, ireq->i_len); in ieee80211_ioctl_setchanlist()
1730 chanlist = list + ireq->i_len; /* NB: zero'd already */ in ieee80211_ioctl_setchanlist()
1731 maxchan = ireq->i_len * NBBY; in ieee80211_ioctl_setchanlist()
1732 for (i = 0; i < ic->ic_nchans; i++) { in ieee80211_ioctl_setchanlist()
1733 const struct ieee80211_channel *c = &ic->ic_channels[i]; in ieee80211_ioctl_setchanlist()
1737 * 1-255 to get all available channels. in ieee80211_ioctl_setchanlist()
1739 if (c->ic_ieee < maxchan && isset(list, c->ic_ieee)) { in ieee80211_ioctl_setchanlist()
1740 setbit(chanlist, c->ic_ieee); in ieee80211_ioctl_setchanlist()
1748 if (ic->ic_bsschan != IEEE80211_CHAN_ANYC && /* XXX */ in ieee80211_ioctl_setchanlist()
1749 isclr(chanlist, ic->ic_bsschan->ic_ieee)) in ieee80211_ioctl_setchanlist()
1750 ic->ic_bsschan = IEEE80211_CHAN_ANYC; in ieee80211_ioctl_setchanlist()
1751 memcpy(ic->ic_chan_active, chanlist, IEEE80211_CHAN_BYTES); in ieee80211_ioctl_setchanlist()
1769 if (ireq->i_len < IEEE80211_ADDR_LEN) in ieee80211_ioctl_setstastats()
1771 error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN); in ieee80211_ioctl_setstastats()
1774 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, macaddr); in ieee80211_ioctl_setstastats()
1777 /* XXX require ni_vap == vap? */ in ieee80211_ioctl_setstastats()
1778 memset(&ni->ni_stats, 0, sizeof(ni->ni_stats)); in ieee80211_ioctl_setstastats()
1790 if (ireq->i_len != sizeof(txpow)) in ieee80211_ioctl_setstatxpow()
1792 error = copyin(ireq->i_data, &txpow, sizeof(txpow)); in ieee80211_ioctl_setstatxpow()
1795 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, txpow.it_macaddr); in ieee80211_ioctl_setstatxpow()
1798 ni->ni_txpower = txpow.it_txpow; in ieee80211_ioctl_setstatxpow()
1806 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_setwmeparam()
1807 struct ieee80211_wme_state *wme = &ic->ic_wme; in ieee80211_ioctl_setwmeparam()
1811 if ((ic->ic_caps & IEEE80211_C_WME) == 0) in ieee80211_ioctl_setwmeparam()
1814 isbss = (ireq->i_len & IEEE80211_WMEPARAM_BSS); in ieee80211_ioctl_setwmeparam()
1815 ac = (ireq->i_len & IEEE80211_WMEPARAM_VAL); in ieee80211_ioctl_setwmeparam()
1816 aggrmode = (wme->wme_flags & WME_F_AGGRMODE); in ieee80211_ioctl_setwmeparam()
1820 chanp = &wme->wme_bssChanParams.cap_wmeParams[ac]; in ieee80211_ioctl_setwmeparam()
1821 wmep = &wme->wme_wmeBssChanParams.cap_wmeParams[ac]; in ieee80211_ioctl_setwmeparam()
1823 chanp = &wme->wme_chanParams.cap_wmeParams[ac]; in ieee80211_ioctl_setwmeparam()
1824 wmep = &wme->wme_wmeChanParams.cap_wmeParams[ac]; in ieee80211_ioctl_setwmeparam()
1826 switch (ireq->i_type) { in ieee80211_ioctl_setwmeparam()
1828 wmep->wmep_logcwmin = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1830 chanp->wmep_logcwmin = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1833 wmep->wmep_logcwmax = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1835 chanp->wmep_logcwmax = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1838 wmep->wmep_aifsn = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1840 chanp->wmep_aifsn = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1843 wmep->wmep_txopLimit = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1845 chanp->wmep_txopLimit = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1848 wmep->wmep_acm = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1850 chanp->wmep_acm = ireq->i_val; in ieee80211_ioctl_setwmeparam()
1853 wmep->wmep_noackPolicy = chanp->wmep_noackPolicy = in ieee80211_ioctl_setwmeparam()
1854 (ireq->i_val) == 0; in ieee80211_ioctl_setwmeparam()
1867 for (i = start+1; i < ic->ic_nchans; i++) { in find11gchannel()
1868 c = &ic->ic_channels[i]; in find11gchannel()
1869 if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c)) in find11gchannel()
1872 /* NB: should not be needed but in case things are mis-sorted */ in find11gchannel()
1874 c = &ic->ic_channels[i]; in find11gchannel()
1875 if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c)) in find11gchannel()
1882 findchannel(struct ieee80211com *ic, int ieee, int mode) in findchannel() argument
1904 modeflags = chanflags[mode]; in findchannel()
1905 for (i = 0; i < ic->ic_nchans; i++) { in findchannel()
1906 struct ieee80211_channel *c = &ic->ic_channels[i]; in findchannel()
1908 if (c->ic_ieee != ieee) in findchannel()
1910 if (mode == IEEE80211_MODE_AUTO) { in findchannel()
1915 * XXX special-case 11b/g channels so we in findchannel()
1918 * XXX prefer HT to non-HT? in findchannel()
1921 !find11gchannel(ic, i, c->ic_freq)) in findchannel()
1925 if ((mode == IEEE80211_MODE_VHT_5GHZ || in findchannel()
1926 mode == IEEE80211_MODE_VHT_2GHZ) && in findchannel()
1931 * Must check HT specially - only match on HT, in findchannel()
1934 if ((mode == IEEE80211_MODE_11NA || in findchannel()
1935 mode == IEEE80211_MODE_11NG) && in findchannel()
1939 if ((mode == IEEE80211_MODE_11NA || in findchannel()
1940 mode == IEEE80211_MODE_11NG) && in findchannel()
1945 if ((c->ic_flags & modeflags) == modeflags) in findchannel()
1953 * Check the specified against any desired mode (aka netband).
1954 * This is only used (presently) when operating in hostap mode
1958 check_mode_consistency(const struct ieee80211_channel *c, int mode) in check_mode_consistency() argument
1962 switch (mode) { in check_mode_consistency()
1988 struct ieee80211com *ic = vap->iv_ic; in setcurchan()
1993 return EBUSY; /* XXX better code? */ in setcurchan()
1994 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { in setcurchan()
1997 if (!check_mode_consistency(c, vap->iv_des_mode)) in setcurchan()
1999 } else if (vap->iv_opmode == IEEE80211_M_IBSS) { in setcurchan()
2003 if ((vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP) && in setcurchan()
2004 vap->iv_bss->ni_chan == c) in setcurchan()
2007 vap->iv_des_chan = c; in setcurchan()
2010 if (vap->iv_opmode == IEEE80211_M_MONITOR && in setcurchan()
2011 vap->iv_des_chan != IEEE80211_CHAN_ANYC) { in setcurchan()
2013 * Monitor mode can switch directly. in setcurchan()
2015 if (IFNET_IS_UP_RUNNING(vap->iv_ifp)) { in setcurchan()
2016 /* XXX need state machine for other vap's to follow */ in setcurchan()
2017 ieee80211_setcurchan(ic, vap->iv_des_chan); in setcurchan()
2018 vap->iv_bss->ni_chan = ic->ic_curchan; in setcurchan()
2020 ic->ic_curchan = vap->iv_des_chan; in setcurchan()
2021 ic->ic_rt = ieee80211_get_ratetable(ic->ic_curchan); in setcurchan()
2031 else if (vap->iv_des_chan != IEEE80211_CHAN_ANYC) { in setcurchan()
2037 ic->ic_curchan = vap->iv_des_chan; in setcurchan()
2038 ic->ic_rt = ieee80211_get_ratetable(ic->ic_curchan); in setcurchan()
2052 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_setchannel()
2055 /* XXX 0xffff overflows 16-bit signed */ in ieee80211_ioctl_setchannel()
2056 if (ireq->i_val == 0 || in ieee80211_ioctl_setchannel()
2057 ireq->i_val == (int16_t) IEEE80211_CHAN_ANY) { in ieee80211_ioctl_setchannel()
2062 c = findchannel(ic, ireq->i_val, vap->iv_des_mode); in ieee80211_ioctl_setchannel()
2064 c = findchannel(ic, ireq->i_val, in ieee80211_ioctl_setchannel()
2071 * Fine tune channel selection based on desired mode: in ieee80211_ioctl_setchannel()
2085 switch (vap->iv_des_mode) { in ieee80211_ioctl_setchannel()
2088 c2 = findchannel(ic, ireq->i_val, in ieee80211_ioctl_setchannel()
2097 c2 = findchannel(ic, ireq->i_val, in ieee80211_ioctl_setchannel()
2105 c2 = findchannel(ic, ireq->i_val, in ieee80211_ioctl_setchannel()
2113 c2 = findchannel(ic, ireq->i_val, in ieee80211_ioctl_setchannel()
2124 c2 = findchannel(ic, ireq->i_val, in ieee80211_ioctl_setchannel()
2146 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_setcurchan()
2150 if (ireq->i_len != sizeof(chan)) in ieee80211_ioctl_setcurchan()
2152 error = copyin(ireq->i_data, &chan, sizeof(chan)); in ieee80211_ioctl_setcurchan()
2156 /* XXX 0xffff overflows 16-bit signed */ in ieee80211_ioctl_setcurchan()
2174 nchans = 1 + ((ireq->i_len - sizeof(struct ieee80211_regdomain_req)) / in ieee80211_ioctl_setregdomain()
2179 ireq->i_len, nchans); in ieee80211_ioctl_setregdomain()
2190 error = copyin(ireq->i_data, reg, IEEE80211_REGDOMAIN_SIZE(nchans)); in ieee80211_ioctl_setregdomain()
2193 if (reg->chaninfo.ic_nchans != nchans) { in ieee80211_ioctl_setregdomain()
2196 reg->chaninfo.ic_nchans, nchans); in ieee80211_ioctl_setregdomain()
2213 for (i = 0; i < rs->rs_nrates; i++) in checkrate()
2214 if ((rs->rs_rates[i] & IEEE80211_RATE_VAL) == rate) in checkrate()
2229 for (i = 0; i < rs->rs_nrates; i++) in checkmcs()
2230 if (IEEE80211_RV(rs->rs_rates[i]) == rate_val) in checkmcs()
2239 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_setroam()
2244 int changed, error, mode, is11n, nmodes; in ieee80211_ioctl_setroam() local
2246 if (ireq->i_len != sizeof(vap->iv_roamparms)) in ieee80211_ioctl_setroam()
2254 error = copyin(ireq->i_data, parms, ireq->i_len); in ieee80211_ioctl_setroam()
2262 for (mode = IEEE80211_MODE_11A; mode < nmodes; mode++) { in ieee80211_ioctl_setroam()
2263 if (isclr(ic->ic_modecaps, mode)) in ieee80211_ioctl_setroam()
2265 src = &parms->params[mode]; in ieee80211_ioctl_setroam()
2266 dst = &vap->iv_roamparms[mode]; in ieee80211_ioctl_setroam()
2267 rs = &ic->ic_sup_rates[mode]; /* NB: 11n maps to legacy */ in ieee80211_ioctl_setroam()
2268 rs_ht = &ic->ic_sup_htrates; in ieee80211_ioctl_setroam()
2269 is11n = (mode == IEEE80211_MODE_11NA || in ieee80211_ioctl_setroam()
2270 mode == IEEE80211_MODE_11NG); in ieee80211_ioctl_setroam()
2271 /* XXX TODO: 11ac */ in ieee80211_ioctl_setroam()
2272 if (src->rate != dst->rate) { in ieee80211_ioctl_setroam()
2273 if (!checkrate(rs, src->rate) && in ieee80211_ioctl_setroam()
2274 (!is11n || !checkmcs(rs_ht, src->rate))) { in ieee80211_ioctl_setroam()
2280 if (src->rssi != dst->rssi) in ieee80211_ioctl_setroam()
2288 /* XXX locking? */ in ieee80211_ioctl_setroam()
2289 for (mode = IEEE80211_MODE_11A; mode < nmodes; mode++) { in ieee80211_ioctl_setroam()
2290 if (isset(ic->ic_modecaps, mode)) in ieee80211_ioctl_setroam()
2291 vap->iv_roamparms[mode] = parms->params[mode]; in ieee80211_ioctl_setroam()
2294 if (vap->iv_roaming == IEEE80211_ROAMING_DEVICE) in ieee80211_ioctl_setroam()
2306 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_settxparams()
2307 struct ieee80211_txparams_req parms; /* XXX stack use? */ in ieee80211_ioctl_settxparams()
2311 int error, mode, changed, is11n, nmodes; in ieee80211_ioctl_settxparams() local
2314 if (ireq->i_len > sizeof(parms)) in ieee80211_ioctl_settxparams()
2316 error = copyin(ireq->i_data, &parms, ireq->i_len); in ieee80211_ioctl_settxparams()
2319 nmodes = ireq->i_len / sizeof(struct ieee80211_txparam); in ieee80211_ioctl_settxparams()
2322 for (mode = IEEE80211_MODE_11A; mode < nmodes; mode++) { in ieee80211_ioctl_settxparams()
2323 if (isclr(ic->ic_modecaps, mode)) in ieee80211_ioctl_settxparams()
2325 src = &parms.params[mode]; in ieee80211_ioctl_settxparams()
2326 dst = &vap->iv_txparms[mode]; in ieee80211_ioctl_settxparams()
2327 rs = &ic->ic_sup_rates[mode]; /* NB: 11n maps to legacy */ in ieee80211_ioctl_settxparams()
2328 rs_ht = &ic->ic_sup_htrates; in ieee80211_ioctl_settxparams()
2329 is11n = (mode == IEEE80211_MODE_11NA || in ieee80211_ioctl_settxparams()
2330 mode == IEEE80211_MODE_11NG); in ieee80211_ioctl_settxparams()
2331 if (src->ucastrate != dst->ucastrate) { in ieee80211_ioctl_settxparams()
2332 if (!checkrate(rs, src->ucastrate) && in ieee80211_ioctl_settxparams()
2333 (!is11n || !checkmcs(rs_ht, src->ucastrate))) in ieee80211_ioctl_settxparams()
2337 if (src->mcastrate != dst->mcastrate) { in ieee80211_ioctl_settxparams()
2338 if (!checkrate(rs, src->mcastrate) && in ieee80211_ioctl_settxparams()
2339 (!is11n || !checkmcs(rs_ht, src->mcastrate))) in ieee80211_ioctl_settxparams()
2343 if (src->mgmtrate != dst->mgmtrate) { in ieee80211_ioctl_settxparams()
2344 if (!checkrate(rs, src->mgmtrate) && in ieee80211_ioctl_settxparams()
2345 (!is11n || !checkmcs(rs_ht, src->mgmtrate))) in ieee80211_ioctl_settxparams()
2349 if (src->maxretry != dst->maxretry) /* NB: no bounds */ in ieee80211_ioctl_settxparams()
2357 for (mode = IEEE80211_MODE_11A; mode < nmodes; mode++) { in ieee80211_ioctl_settxparams()
2358 if (isset(ic->ic_modecaps, mode)) in ieee80211_ioctl_settxparams()
2359 vap->iv_txparms[mode] = parms.params[mode]; in ieee80211_ioctl_settxparams()
2361 /* XXX could be more intelligent, in ieee80211_ioctl_settxparams()
2378 if (ireq->i_len == 0) { /* delete any existing ie */ in setappie()
2380 *aie = NULL; /* XXX racey */ in setappie()
2385 if (!(2 <= ireq->i_len && ireq->i_len <= IEEE80211_MAX_APPIE)) in setappie()
2393 * XXX bad bad bad in setappie()
2396 sizeof(struct ieee80211_appie) + ireq->i_len, M_80211_NODE_IE, in setappie()
2400 /* XXX holding ic lock */ in setappie()
2401 error = copyin(ireq->i_data, napp->ie_data, ireq->i_len); in setappie()
2406 napp->ie_len = ireq->i_len; in setappie()
2420 vap->iv_wpa_ie = ie; in setwparsnie()
2422 vap->iv_rsn_ie = ie; in setwparsnie()
2431 IEEE80211_LOCK_ASSERT(vap->iv_ic); in ieee80211_ioctl_setappie_locked()
2435 if (vap->iv_opmode != IEEE80211_M_HOSTAP && in ieee80211_ioctl_setappie_locked()
2436 vap->iv_opmode != IEEE80211_M_IBSS) { in ieee80211_ioctl_setappie_locked()
2440 error = setappie(&vap->iv_appie_beacon, ireq); in ieee80211_ioctl_setappie_locked()
2445 error = setappie(&vap->iv_appie_proberesp, ireq); in ieee80211_ioctl_setappie_locked()
2448 if (vap->iv_opmode == IEEE80211_M_HOSTAP) in ieee80211_ioctl_setappie_locked()
2449 error = setappie(&vap->iv_appie_assocresp, ireq); in ieee80211_ioctl_setappie_locked()
2454 error = setappie(&vap->iv_appie_probereq, ireq); in ieee80211_ioctl_setappie_locked()
2457 if (vap->iv_opmode == IEEE80211_M_STA) in ieee80211_ioctl_setappie_locked()
2458 error = setappie(&vap->iv_appie_assocreq, ireq); in ieee80211_ioctl_setappie_locked()
2463 error = setappie(&vap->iv_appie_wpa, ireq); in ieee80211_ioctl_setappie_locked()
2469 * XXX use IEEE80211_IOC_WPA2 so user code does split in ieee80211_ioctl_setappie_locked()
2471 vap->iv_wpa_ie = NULL; in ieee80211_ioctl_setappie_locked()
2472 vap->iv_rsn_ie = NULL; in ieee80211_ioctl_setappie_locked()
2473 if (vap->iv_appie_wpa != NULL) { in ieee80211_ioctl_setappie_locked()
2475 vap->iv_appie_wpa; in ieee80211_ioctl_setappie_locked()
2476 uint8_t *data = appie->ie_data; in ieee80211_ioctl_setappie_locked()
2478 /* XXX ie length validate is painful, cheat */ in ieee80211_ioctl_setappie_locked()
2479 setwparsnie(vap, data, appie->ie_len); in ieee80211_ioctl_setappie_locked()
2481 appie->ie_len - (2 + data[1])); in ieee80211_ioctl_setappie_locked()
2483 if (vap->iv_opmode == IEEE80211_M_HOSTAP || in ieee80211_ioctl_setappie_locked()
2484 vap->iv_opmode == IEEE80211_M_IBSS) { in ieee80211_ioctl_setappie_locked()
2507 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_setappie()
2511 fc0 = ireq->i_val & 0xff; in ieee80211_ioctl_setappie()
2524 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_chanswitch()
2529 if (ireq->i_len != sizeof(csr)) in ieee80211_ioctl_chanswitch()
2531 error = copyin(ireq->i_data, &csr, sizeof(csr)); in ieee80211_ioctl_chanswitch()
2534 /* XXX adhoc mode not supported */ in ieee80211_ioctl_chanswitch()
2535 if (vap->iv_opmode != IEEE80211_M_HOSTAP || in ieee80211_ioctl_chanswitch()
2536 (vap->iv_flags & IEEE80211_F_DOTH) == 0) in ieee80211_ioctl_chanswitch()
2543 if ((ic->ic_flags & IEEE80211_F_CSAPENDING) == 0) in ieee80211_ioctl_chanswitch()
2562 struct ieee80211com *ic = vap->iv_ic; in ieee80211_scanreq()
2566 if (sr->sr_duration == IEEE80211_IOC_SCAN_FOREVER) in ieee80211_scanreq()
2567 sr->sr_duration = IEEE80211_SCAN_FOREVER; in ieee80211_scanreq()
2569 if (sr->sr_duration < IEEE80211_IOC_SCAN_DURATION_MIN || in ieee80211_scanreq()
2570 sr->sr_duration > IEEE80211_IOC_SCAN_DURATION_MAX) in ieee80211_scanreq()
2572 sr->sr_duration = msecs_to_ticks(sr->sr_duration); in ieee80211_scanreq()
2575 if (sr->sr_mindwell != 0) in ieee80211_scanreq()
2576 sr->sr_mindwell = msecs_to_ticks(sr->sr_mindwell); in ieee80211_scanreq()
2577 if (sr->sr_maxdwell != 0) in ieee80211_scanreq()
2578 sr->sr_maxdwell = msecs_to_ticks(sr->sr_maxdwell); in ieee80211_scanreq()
2580 if (sr->sr_nssid > IEEE80211_SCAN_MAX_SSID) in ieee80211_scanreq()
2581 sr->sr_nssid = IEEE80211_SCAN_MAX_SSID; in ieee80211_scanreq()
2582 for (i = 0; i < sr->sr_nssid; i++) in ieee80211_scanreq()
2583 if (sr->sr_ssid[i].len > IEEE80211_NWID_LEN) in ieee80211_scanreq()
2586 sr->sr_flags &= IEEE80211_IOC_SCAN_FLAGS; in ieee80211_scanreq()
2591 * roaming mode--you just need to mark the parent device UP. in ieee80211_scanreq()
2593 if ((vap->iv_ifp->if_flags & IFF_UP) == 0) in ieee80211_scanreq()
2594 sr->sr_flags |= IEEE80211_IOC_SCAN_NOPICK; in ieee80211_scanreq()
2599 __func__, vap, vap->iv_state, ieee80211_state_name[vap->iv_state], in ieee80211_scanreq()
2600 sr->sr_flags, in ieee80211_scanreq()
2601 (vap->iv_ifp->if_flags & IFF_UP) == 0 ? " (!IFF_UP)" : "", in ieee80211_scanreq()
2602 sr->sr_duration, sr->sr_mindwell, sr->sr_maxdwell, sr->sr_nssid); in ieee80211_scanreq()
2615 if (ic->ic_nrunning == 0) { in ieee80211_scanreq()
2620 if (vap->iv_state == IEEE80211_S_INIT) { in ieee80211_scanreq()
2622 vap->iv_scanreq_flags = sr->sr_flags; in ieee80211_scanreq()
2623 vap->iv_scanreq_duration = sr->sr_duration; in ieee80211_scanreq()
2624 vap->iv_scanreq_nssid = sr->sr_nssid; in ieee80211_scanreq()
2625 for (i = 0; i < sr->sr_nssid; i++) { in ieee80211_scanreq()
2626 vap->iv_scanreq_ssid[i].len = sr->sr_ssid[i].len; in ieee80211_scanreq()
2627 memcpy(vap->iv_scanreq_ssid[i].ssid, in ieee80211_scanreq()
2628 sr->sr_ssid[i].ssid, sr->sr_ssid[i].len); in ieee80211_scanreq()
2630 vap->iv_flags_ext |= IEEE80211_FEXT_SCANREQ; in ieee80211_scanreq()
2634 vap->iv_flags_ext &= ~IEEE80211_FEXT_SCANREQ; in ieee80211_scanreq()
2636 if (sr->sr_flags & IEEE80211_IOC_SCAN_CHECK) { in ieee80211_scanreq()
2637 error = ieee80211_check_scan(vap, sr->sr_flags, in ieee80211_scanreq()
2638 sr->sr_duration, sr->sr_mindwell, sr->sr_maxdwell, in ieee80211_scanreq()
2639 sr->sr_nssid, in ieee80211_scanreq()
2641 (const struct ieee80211_scan_ssid *) &sr->sr_ssid[0]); in ieee80211_scanreq()
2643 error = ieee80211_start_scan(vap, sr->sr_flags, in ieee80211_scanreq()
2644 sr->sr_duration, sr->sr_mindwell, sr->sr_maxdwell, in ieee80211_scanreq()
2645 sr->sr_nssid, in ieee80211_scanreq()
2647 (const struct ieee80211_scan_ssid *) &sr->sr_ssid[0]); in ieee80211_scanreq()
2662 if (ireq->i_len != sizeof(*sr)) in ieee80211_ioctl_scanreq()
2668 error = copyin(ireq->i_data, sr, sizeof(*sr)); in ieee80211_ioctl_scanreq()
2684 if (ireq->i_len != sizeof(vlan)) in ieee80211_ioctl_setstavlan()
2686 error = copyin(ireq->i_data, &vlan, sizeof(vlan)); in ieee80211_ioctl_setstavlan()
2690 ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, in ieee80211_ioctl_setstavlan()
2695 ni = ieee80211_ref_node(vap->iv_bss); in ieee80211_ioctl_setstavlan()
2696 ni->ni_vlan = vlan.sv_vlan; in ieee80211_ioctl_setstavlan()
2704 const struct ieee80211_node *bss = vap->iv_bss; in isvap11g()
2705 return bss->ni_chan != IEEE80211_CHAN_ANYC && in isvap11g()
2706 IEEE80211_IS_CHAN_ANYG(bss->ni_chan); in isvap11g()
2712 const struct ieee80211_node *bss = vap->iv_bss; in isvapht()
2713 return bss->ni_chan != IEEE80211_CHAN_ANYC && in isvapht()
2714 IEEE80211_IS_CHAN_HT(bss->ni_chan); in isvapht()
2744 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl_set80211()
2755 switch (ireq->i_type) { in ieee80211_ioctl_set80211()
2757 if (ireq->i_val != 0 || in ieee80211_ioctl_set80211()
2758 ireq->i_len > IEEE80211_NWID_LEN) in ieee80211_ioctl_set80211()
2760 error = copyin(ireq->i_data, tmpssid, ireq->i_len); in ieee80211_ioctl_set80211()
2763 memset(vap->iv_des_ssid[0].ssid, 0, IEEE80211_NWID_LEN); in ieee80211_ioctl_set80211()
2764 vap->iv_des_ssid[0].len = ireq->i_len; in ieee80211_ioctl_set80211()
2765 memcpy(vap->iv_des_ssid[0].ssid, tmpssid, ireq->i_len); in ieee80211_ioctl_set80211()
2766 vap->iv_des_nssid = (ireq->i_len > 0); in ieee80211_ioctl_set80211()
2770 switch (ireq->i_val) { in ieee80211_ioctl_set80211()
2772 vap->iv_flags &= ~IEEE80211_F_PRIVACY; in ieee80211_ioctl_set80211()
2773 vap->iv_flags &= ~IEEE80211_F_DROPUNENC; in ieee80211_ioctl_set80211()
2776 vap->iv_flags |= IEEE80211_F_PRIVACY; in ieee80211_ioctl_set80211()
2777 vap->iv_flags |= IEEE80211_F_DROPUNENC; in ieee80211_ioctl_set80211()
2780 vap->iv_flags |= IEEE80211_F_PRIVACY; in ieee80211_ioctl_set80211()
2781 vap->iv_flags &= ~IEEE80211_F_DROPUNENC; in ieee80211_ioctl_set80211()
2787 kid = (u_int) ireq->i_val; in ieee80211_ioctl_set80211()
2790 k = &vap->iv_nw_keys[kid]; in ieee80211_ioctl_set80211()
2791 if (ireq->i_len == 0) { in ieee80211_ioctl_set80211()
2792 /* zero-len =>'s delete any existing key */ in ieee80211_ioctl_set80211()
2796 if (ireq->i_len > sizeof(tmpkey)) in ieee80211_ioctl_set80211()
2799 error = copyin(ireq->i_data, tmpkey, ireq->i_len); in ieee80211_ioctl_set80211()
2803 k->wk_keyix = kid; /* NB: force fixed key id */ in ieee80211_ioctl_set80211()
2806 k->wk_keylen = ireq->i_len; in ieee80211_ioctl_set80211()
2807 memcpy(k->wk_key, tmpkey, sizeof(tmpkey)); in ieee80211_ioctl_set80211()
2808 IEEE80211_ADDR_COPY(k->wk_macaddr, vap->iv_myaddr); in ieee80211_ioctl_set80211()
2816 kid = (u_int) ireq->i_val; in ieee80211_ioctl_set80211()
2833 switch (ireq->i_val) { in ieee80211_ioctl_set80211()
2837 case IEEE80211_AUTH_SHARED: /* shared-key */ in ieee80211_ioctl_set80211()
2839 auth = ieee80211_authenticator_get(ireq->i_val); in ieee80211_ioctl_set80211()
2846 switch (ireq->i_val) { in ieee80211_ioctl_set80211()
2848 vap->iv_flags |= IEEE80211_F_PRIVACY; in ieee80211_ioctl_set80211()
2849 ireq->i_val = IEEE80211_AUTH_8021X; in ieee80211_ioctl_set80211()
2852 vap->iv_flags &= ~(IEEE80211_F_WPA|IEEE80211_F_PRIVACY); in ieee80211_ioctl_set80211()
2854 case IEEE80211_AUTH_SHARED: /* shared-key */ in ieee80211_ioctl_set80211()
2856 vap->iv_flags &= ~IEEE80211_F_WPA; in ieee80211_ioctl_set80211()
2858 vap->iv_flags |= IEEE80211_F_PRIVACY; in ieee80211_ioctl_set80211()
2861 vap->iv_flags &= ~IEEE80211_F_WPA; in ieee80211_ioctl_set80211()
2862 /* XXX PRIVACY handling? */ in ieee80211_ioctl_set80211()
2863 /* XXX what's the right way to do this? */ in ieee80211_ioctl_set80211()
2867 vap->iv_bss->ni_authmode = ireq->i_val; in ieee80211_ioctl_set80211()
2868 /* XXX mixed/mode/usage? */ in ieee80211_ioctl_set80211()
2869 vap->iv_auth = auth; in ieee80211_ioctl_set80211()
2876 switch (ireq->i_val) { in ieee80211_ioctl_set80211()
2878 if (vap->iv_flags & IEEE80211_F_PMGTON) { in ieee80211_ioctl_set80211()
2879 ieee80211_syncflag(vap, -IEEE80211_F_PMGTON); in ieee80211_ioctl_set80211()
2884 if ((vap->iv_caps & IEEE80211_C_PMGT) == 0) in ieee80211_ioctl_set80211()
2886 else if ((vap->iv_flags & IEEE80211_F_PMGTON) == 0) { in ieee80211_ioctl_set80211()
2897 if (ireq->i_val < 0) in ieee80211_ioctl_set80211()
2899 ic->ic_lintval = ireq->i_val; in ieee80211_ioctl_set80211()
2903 if (!(IEEE80211_RTS_MIN <= ireq->i_val && in ieee80211_ioctl_set80211()
2904 ireq->i_val <= IEEE80211_RTS_MAX)) in ieee80211_ioctl_set80211()
2906 vap->iv_rtsthreshold = ireq->i_val; in ieee80211_ioctl_set80211()
2910 if (ireq->i_val > IEEE80211_PROT_RTSCTS) in ieee80211_ioctl_set80211()
2912 vap->iv_protmode = (enum ieee80211_protmode)ireq->i_val; in ieee80211_ioctl_set80211()
2914 if (ic->ic_bsschan != IEEE80211_CHAN_ANYC && in ieee80211_ioctl_set80211()
2915 IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan)) in ieee80211_ioctl_set80211()
2917 /* driver callback for protection mode update */ in ieee80211_ioctl_set80211()
2921 if ((ic->ic_caps & IEEE80211_C_TXPMGT) == 0) in ieee80211_ioctl_set80211()
2923 if (!(IEEE80211_TXPOWER_MIN <= ireq->i_val && in ieee80211_ioctl_set80211()
2924 ireq->i_val <= IEEE80211_TXPOWER_MAX)) in ieee80211_ioctl_set80211()
2926 ic->ic_txpowlimit = ireq->i_val; in ieee80211_ioctl_set80211()
2930 if (!(IEEE80211_ROAMING_DEVICE <= ireq->i_val && in ieee80211_ioctl_set80211()
2931 ireq->i_val <= IEEE80211_ROAMING_MANUAL)) in ieee80211_ioctl_set80211()
2933 vap->iv_roaming = (enum ieee80211_roamingmode)ireq->i_val; in ieee80211_ioctl_set80211()
2937 if (ireq->i_val) { in ieee80211_ioctl_set80211()
2938 /* XXX check for key state? */ in ieee80211_ioctl_set80211()
2939 vap->iv_flags |= IEEE80211_F_PRIVACY; in ieee80211_ioctl_set80211()
2941 vap->iv_flags &= ~IEEE80211_F_PRIVACY; in ieee80211_ioctl_set80211()
2942 /* XXX ERESTART? */ in ieee80211_ioctl_set80211()
2945 if (ireq->i_val) in ieee80211_ioctl_set80211()
2946 vap->iv_flags |= IEEE80211_F_DROPUNENC; in ieee80211_ioctl_set80211()
2948 vap->iv_flags &= ~IEEE80211_F_DROPUNENC; in ieee80211_ioctl_set80211()
2949 /* XXX ERESTART? */ in ieee80211_ioctl_set80211()
2961 if (ireq->i_val) { in ieee80211_ioctl_set80211()
2962 if ((vap->iv_flags & IEEE80211_F_WPA) == 0) in ieee80211_ioctl_set80211()
2964 vap->iv_flags |= IEEE80211_F_COUNTERM; in ieee80211_ioctl_set80211()
2966 vap->iv_flags &= ~IEEE80211_F_COUNTERM; in ieee80211_ioctl_set80211()
2967 /* XXX ERESTART? */ in ieee80211_ioctl_set80211()
2970 if (ireq->i_val > 3) in ieee80211_ioctl_set80211()
2972 /* XXX verify ciphers available */ in ieee80211_ioctl_set80211()
2973 flags = vap->iv_flags & ~IEEE80211_F_WPA; in ieee80211_ioctl_set80211()
2974 switch (ireq->i_val) { in ieee80211_ioctl_set80211()
2979 if (!(vap->iv_caps & IEEE80211_C_WPA1)) in ieee80211_ioctl_set80211()
2984 if (!(vap->iv_caps & IEEE80211_C_WPA2)) in ieee80211_ioctl_set80211()
2989 if ((vap->iv_caps & IEEE80211_C_WPA) != IEEE80211_C_WPA) in ieee80211_ioctl_set80211()
2993 default: /* Can't set any -> error */ in ieee80211_ioctl_set80211()
2996 vap->iv_flags = flags; in ieee80211_ioctl_set80211()
3000 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3001 if ((vap->iv_caps & IEEE80211_C_WME) == 0) in ieee80211_ioctl_set80211()
3005 ieee80211_syncflag(vap, -IEEE80211_F_WME); in ieee80211_ioctl_set80211()
3009 if (ireq->i_val) in ieee80211_ioctl_set80211()
3010 vap->iv_flags |= IEEE80211_F_HIDESSID; in ieee80211_ioctl_set80211()
3012 vap->iv_flags &= ~IEEE80211_F_HIDESSID; in ieee80211_ioctl_set80211()
3013 error = ERESTART; /* XXX ENETRESET? */ in ieee80211_ioctl_set80211()
3016 if (ireq->i_val == 0) in ieee80211_ioctl_set80211()
3017 vap->iv_flags |= IEEE80211_F_NOBRIDGE; in ieee80211_ioctl_set80211()
3019 vap->iv_flags &= ~IEEE80211_F_NOBRIDGE; in ieee80211_ioctl_set80211()
3022 if (ireq->i_len != sizeof(tmpbssid)) in ieee80211_ioctl_set80211()
3024 error = copyin(ireq->i_data, tmpbssid, ireq->i_len); in ieee80211_ioctl_set80211()
3027 IEEE80211_ADDR_COPY(vap->iv_des_bssid, tmpbssid); in ieee80211_ioctl_set80211()
3028 if (IEEE80211_ADDR_EQ(vap->iv_des_bssid, zerobssid)) in ieee80211_ioctl_set80211()
3029 vap->iv_flags &= ~IEEE80211_F_DESBSSID; in ieee80211_ioctl_set80211()
3031 vap->iv_flags |= IEEE80211_F_DESBSSID; in ieee80211_ioctl_set80211()
3047 * a one-time scan. in ieee80211_ioctl_set80211()
3049 if (vap->iv_state == IEEE80211_S_INIT) in ieee80211_ioctl_set80211()
3057 /* XXX use ioctl params */ in ieee80211_ioctl_set80211()
3058 vap->iv_des_nssid, vap->iv_des_ssid); in ieee80211_ioctl_set80211()
3070 if (ireq->i_val & 1) in ieee80211_ioctl_set80211()
3073 ieee80211_syncflag_ht(vap, -IEEE80211_FHT_HT); in ieee80211_ioctl_set80211()
3074 if (ireq->i_val & 2) in ieee80211_ioctl_set80211()
3077 ieee80211_syncflag_ht(vap, -IEEE80211_FHT_USEHT40); in ieee80211_ioctl_set80211()
3102 if (vap->iv_opmode != IEEE80211_M_HOSTAP && in ieee80211_ioctl_set80211()
3103 vap->iv_opmode != IEEE80211_M_MBSS && in ieee80211_ioctl_set80211()
3104 vap->iv_opmode != IEEE80211_M_IBSS) in ieee80211_ioctl_set80211()
3106 if (IEEE80211_DTIM_MIN <= ireq->i_val && in ieee80211_ioctl_set80211()
3107 ireq->i_val <= IEEE80211_DTIM_MAX) { in ieee80211_ioctl_set80211()
3108 vap->iv_dtim_period = ireq->i_val; in ieee80211_ioctl_set80211()
3114 if (vap->iv_opmode != IEEE80211_M_HOSTAP && in ieee80211_ioctl_set80211()
3115 vap->iv_opmode != IEEE80211_M_MBSS && in ieee80211_ioctl_set80211()
3116 vap->iv_opmode != IEEE80211_M_IBSS) in ieee80211_ioctl_set80211()
3118 if (IEEE80211_BINTVAL_MIN <= ireq->i_val && in ieee80211_ioctl_set80211()
3119 ireq->i_val <= IEEE80211_BINTVAL_MAX) { in ieee80211_ioctl_set80211()
3120 ic->ic_bintval = ireq->i_val; in ieee80211_ioctl_set80211()
3126 if (ireq->i_val) in ieee80211_ioctl_set80211()
3127 vap->iv_flags |= IEEE80211_F_PUREG; in ieee80211_ioctl_set80211()
3129 vap->iv_flags &= ~IEEE80211_F_PUREG; in ieee80211_ioctl_set80211()
3135 vap->iv_quiet= ireq->i_val; in ieee80211_ioctl_set80211()
3138 vap->iv_quiet_count=ireq->i_val; in ieee80211_ioctl_set80211()
3141 vap->iv_quiet_period=ireq->i_val; in ieee80211_ioctl_set80211()
3144 vap->iv_quiet_offset=ireq->i_val; in ieee80211_ioctl_set80211()
3147 if(ireq->i_val < vap->iv_bss->ni_intval) in ieee80211_ioctl_set80211()
3148 vap->iv_quiet_duration = ireq->i_val; in ieee80211_ioctl_set80211()
3153 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3154 if ((vap->iv_caps & IEEE80211_C_BGSCAN) == 0) in ieee80211_ioctl_set80211()
3156 vap->iv_flags |= IEEE80211_F_BGSCAN; in ieee80211_ioctl_set80211()
3158 vap->iv_flags &= ~IEEE80211_F_BGSCAN; in ieee80211_ioctl_set80211()
3161 if (ireq->i_val >= IEEE80211_BGSCAN_IDLE_MIN) in ieee80211_ioctl_set80211()
3162 vap->iv_bgscanidle = ireq->i_val*hz/1000; in ieee80211_ioctl_set80211()
3167 if (ireq->i_val >= IEEE80211_BGSCAN_INTVAL_MIN) in ieee80211_ioctl_set80211()
3168 vap->iv_bgscanintvl = ireq->i_val*hz; in ieee80211_ioctl_set80211()
3173 if (ireq->i_val >= IEEE80211_SCAN_VALID_MIN) in ieee80211_ioctl_set80211()
3174 vap->iv_scanvalid = ireq->i_val*hz; in ieee80211_ioctl_set80211()
3179 if ((vap->iv_caps & IEEE80211_C_TXFRAG) == 0 && in ieee80211_ioctl_set80211()
3180 ireq->i_val != IEEE80211_FRAG_MAX) in ieee80211_ioctl_set80211()
3182 if (!(IEEE80211_FRAG_MIN <= ireq->i_val && in ieee80211_ioctl_set80211()
3183 ireq->i_val <= IEEE80211_FRAG_MAX)) in ieee80211_ioctl_set80211()
3185 vap->iv_fragthreshold = ireq->i_val; in ieee80211_ioctl_set80211()
3189 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3190 if ((vap->iv_caps & IEEE80211_C_BURST) == 0) in ieee80211_ioctl_set80211()
3194 ieee80211_syncflag(vap, -IEEE80211_F_BURST); in ieee80211_ioctl_set80211()
3198 if (!(IEEE80211_HWBMISS_MIN <= ireq->i_val && in ieee80211_ioctl_set80211()
3199 ireq->i_val <= IEEE80211_HWBMISS_MAX)) in ieee80211_ioctl_set80211()
3201 vap->iv_bmissthreshold = ireq->i_val; in ieee80211_ioctl_set80211()
3208 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3211 if (((ireq->i_val ^ vap->iv_htcaps) & IEEE80211_HTCAP_SHORTGI) != 0) in ieee80211_ioctl_set80211()
3213 if (ireq->i_val & IEEE80211_HTCAP_SHORTGI20) in ieee80211_ioctl_set80211()
3214 vap->iv_flags_ht |= IEEE80211_FHT_SHORTGI20; in ieee80211_ioctl_set80211()
3215 if (ireq->i_val & IEEE80211_HTCAP_SHORTGI40) in ieee80211_ioctl_set80211()
3216 vap->iv_flags_ht |= IEEE80211_FHT_SHORTGI40; in ieee80211_ioctl_set80211()
3219 vap->iv_flags_ht &= in ieee80211_ioctl_set80211()
3224 if (ireq->i_val && (vap->iv_htcaps & IEEE80211_HTC_AMPDU) == 0) in ieee80211_ioctl_set80211()
3226 if (ireq->i_val & 1) in ieee80211_ioctl_set80211()
3227 vap->iv_flags_ht |= IEEE80211_FHT_AMPDU_TX; in ieee80211_ioctl_set80211()
3229 vap->iv_flags_ht &= ~IEEE80211_FHT_AMPDU_TX; in ieee80211_ioctl_set80211()
3230 if (ireq->i_val & 2) in ieee80211_ioctl_set80211()
3231 vap->iv_flags_ht |= IEEE80211_FHT_AMPDU_RX; in ieee80211_ioctl_set80211()
3233 vap->iv_flags_ht &= ~IEEE80211_FHT_AMPDU_RX; in ieee80211_ioctl_set80211()
3239 /* XXX TODO: figure out ampdu_limit versus ampdu_rxmax */ in ieee80211_ioctl_set80211()
3240 if (!(IEEE80211_HTCAP_MAXRXAMPDU_8K <= ireq->i_val && in ieee80211_ioctl_set80211()
3241 ireq->i_val <= IEEE80211_HTCAP_MAXRXAMPDU_64K)) in ieee80211_ioctl_set80211()
3243 if (vap->iv_opmode == IEEE80211_M_HOSTAP) in ieee80211_ioctl_set80211()
3244 vap->iv_ampdu_rxmax = ireq->i_val; in ieee80211_ioctl_set80211()
3246 vap->iv_ampdu_limit = ireq->i_val; in ieee80211_ioctl_set80211()
3250 if (!(IEEE80211_HTCAP_MPDUDENSITY_NA <= ireq->i_val && in ieee80211_ioctl_set80211()
3251 ireq->i_val <= IEEE80211_HTCAP_MPDUDENSITY_16)) in ieee80211_ioctl_set80211()
3253 vap->iv_ampdu_density = ireq->i_val; in ieee80211_ioctl_set80211()
3257 if (ireq->i_val && (vap->iv_htcaps & IEEE80211_HTC_AMSDU) == 0) in ieee80211_ioctl_set80211()
3259 if (ireq->i_val & 1) in ieee80211_ioctl_set80211()
3260 vap->iv_flags_ht |= IEEE80211_FHT_AMSDU_TX; in ieee80211_ioctl_set80211()
3262 vap->iv_flags_ht &= ~IEEE80211_FHT_AMSDU_TX; in ieee80211_ioctl_set80211()
3263 if (ireq->i_val & 2) in ieee80211_ioctl_set80211()
3264 vap->iv_flags_ht |= IEEE80211_FHT_AMSDU_RX; in ieee80211_ioctl_set80211()
3266 vap->iv_flags_ht &= ~IEEE80211_FHT_AMSDU_RX; in ieee80211_ioctl_set80211()
3272 /* XXX validate */ in ieee80211_ioctl_set80211()
3273 vap->iv_amsdu_limit = ireq->i_val; /* XXX truncation? */ in ieee80211_ioctl_set80211()
3276 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3277 if ((vap->iv_flags_ht & IEEE80211_FHT_HT) == 0) in ieee80211_ioctl_set80211()
3279 vap->iv_flags_ht |= IEEE80211_FHT_PUREN; in ieee80211_ioctl_set80211()
3281 vap->iv_flags_ht &= ~IEEE80211_FHT_PUREN; in ieee80211_ioctl_set80211()
3287 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3289 /* XXX no capability */ in ieee80211_ioctl_set80211()
3290 if ((vap->iv_caps & IEEE80211_C_DOTH) == 0) in ieee80211_ioctl_set80211()
3293 vap->iv_flags |= IEEE80211_F_DOTH; in ieee80211_ioctl_set80211()
3295 vap->iv_flags &= ~IEEE80211_F_DOTH; in ieee80211_ioctl_set80211()
3308 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3309 if ((vap->iv_flags_ht & IEEE80211_FHT_HT) == 0) in ieee80211_ioctl_set80211()
3311 vap->iv_flags_ht |= IEEE80211_FHT_HTCOMPAT; in ieee80211_ioctl_set80211()
3313 vap->iv_flags_ht &= ~IEEE80211_FHT_HTCOMPAT; in ieee80211_ioctl_set80211()
3319 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3320 /* NB: DWDS only makes sense for WDS-capable devices */ in ieee80211_ioctl_set80211()
3321 if ((ic->ic_caps & IEEE80211_C_WDS) == 0) in ieee80211_ioctl_set80211()
3324 if (vap->iv_opmode != IEEE80211_M_HOSTAP && in ieee80211_ioctl_set80211()
3325 vap->iv_opmode != IEEE80211_M_STA) in ieee80211_ioctl_set80211()
3327 vap->iv_flags |= IEEE80211_F_DWDS; in ieee80211_ioctl_set80211()
3328 if (vap->iv_opmode == IEEE80211_M_STA) in ieee80211_ioctl_set80211()
3329 vap->iv_flags_ext |= IEEE80211_FEXT_4ADDR; in ieee80211_ioctl_set80211()
3331 vap->iv_flags &= ~IEEE80211_F_DWDS; in ieee80211_ioctl_set80211()
3332 if (vap->iv_opmode == IEEE80211_M_STA) in ieee80211_ioctl_set80211()
3333 vap->iv_flags_ext &= ~IEEE80211_FEXT_4ADDR; in ieee80211_ioctl_set80211()
3337 if (ireq->i_val) in ieee80211_ioctl_set80211()
3338 vap->iv_flags_ext |= IEEE80211_FEXT_INACT; in ieee80211_ioctl_set80211()
3340 vap->iv_flags_ext &= ~IEEE80211_FEXT_INACT; in ieee80211_ioctl_set80211()
3346 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3347 if ((vap->iv_caps & IEEE80211_C_WPA) == 0) in ieee80211_ioctl_set80211()
3349 vap->iv_flags_ext |= IEEE80211_FEXT_WPS; in ieee80211_ioctl_set80211()
3351 vap->iv_flags_ext &= ~IEEE80211_FEXT_WPS; in ieee80211_ioctl_set80211()
3354 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3355 if ((vap->iv_caps & IEEE80211_C_WPA) == 0) in ieee80211_ioctl_set80211()
3357 vap->iv_flags_ext |= IEEE80211_FEXT_TSN; in ieee80211_ioctl_set80211()
3359 vap->iv_flags_ext &= ~IEEE80211_FEXT_TSN; in ieee80211_ioctl_set80211()
3365 if (ireq->i_val) { in ieee80211_ioctl_set80211()
3366 if ((vap->iv_caps & IEEE80211_C_DFS) == 0) in ieee80211_ioctl_set80211()
3369 if ((vap->iv_flags & IEEE80211_F_DOTH) == 0) in ieee80211_ioctl_set80211()
3371 vap->iv_flags_ext |= IEEE80211_FEXT_DFS; in ieee80211_ioctl_set80211()
3373 vap->iv_flags_ext &= ~IEEE80211_FEXT_DFS; in ieee80211_ioctl_set80211()
3376 if (ireq->i_val) in ieee80211_ioctl_set80211()
3377 vap->iv_flags_ext |= IEEE80211_FEXT_DOTD; in ieee80211_ioctl_set80211()
3379 vap->iv_flags_ext &= ~IEEE80211_FEXT_DOTD; in ieee80211_ioctl_set80211()
3380 if (vap->iv_opmode == IEEE80211_M_STA) in ieee80211_ioctl_set80211()
3384 if (ireq->i_val > IEEE80211_PROT_RTSCTS) in ieee80211_ioctl_set80211()
3386 vap->iv_htprotmode = ireq->i_val ? in ieee80211_ioctl_set80211()
3398 if ((ireq->i_val &~ IEEE80211_HTCAP_SMPS) != 0 || in ieee80211_ioctl_set80211()
3399 ireq->i_val == 0x0008) /* value of 2 is reserved */ in ieee80211_ioctl_set80211()
3401 if (ireq->i_val != IEEE80211_HTCAP_SMPS_OFF && in ieee80211_ioctl_set80211()
3402 (vap->iv_htcaps & IEEE80211_HTC_SMPS) == 0) in ieee80211_ioctl_set80211()
3404 vap->iv_htcaps = (vap->iv_htcaps &~ IEEE80211_HTCAP_SMPS) | in ieee80211_ioctl_set80211()
3405 ireq->i_val; in ieee80211_ioctl_set80211()
3411 if (ireq->i_val != 0) { in ieee80211_ioctl_set80211()
3412 if ((vap->iv_htcaps & IEEE80211_HTC_RIFS) == 0) in ieee80211_ioctl_set80211()
3414 vap->iv_flags_ht |= IEEE80211_FHT_RIFS; in ieee80211_ioctl_set80211()
3416 vap->iv_flags_ht &= ~IEEE80211_FHT_RIFS; in ieee80211_ioctl_set80211()
3423 if ((ireq->i_val & 1) && in ieee80211_ioctl_set80211()
3424 ((vap->iv_htcaps & IEEE80211_HTCAP_TXSTBC) == 0)) in ieee80211_ioctl_set80211()
3426 if ((ireq->i_val & 2) && in ieee80211_ioctl_set80211()
3427 ((vap->iv_htcaps & IEEE80211_HTCAP_RXSTBC) == 0)) in ieee80211_ioctl_set80211()
3431 if (ireq->i_val & 1) in ieee80211_ioctl_set80211()
3432 vap->iv_flags_ht |= IEEE80211_FHT_STBC_TX; in ieee80211_ioctl_set80211()
3434 vap->iv_flags_ht &= ~IEEE80211_FHT_STBC_TX; in ieee80211_ioctl_set80211()
3437 if (ireq->i_val & 2) in ieee80211_ioctl_set80211()
3438 vap->iv_flags_ht |= IEEE80211_FHT_STBC_RX; in ieee80211_ioctl_set80211()
3440 vap->iv_flags_ht &= ~IEEE80211_FHT_STBC_RX; in ieee80211_ioctl_set80211()
3448 if ((ireq->i_val & 1) && in ieee80211_ioctl_set80211()
3449 (vap->iv_htcaps & IEEE80211_HTC_TXLDPC) == 0) in ieee80211_ioctl_set80211()
3451 if ((ireq->i_val & 2) && in ieee80211_ioctl_set80211()
3452 (vap->iv_htcaps & IEEE80211_HTCAP_LDPC) == 0) in ieee80211_ioctl_set80211()
3456 if (ireq->i_val & 1) in ieee80211_ioctl_set80211()
3457 vap->iv_flags_ht |= IEEE80211_FHT_LDPC_TX; in ieee80211_ioctl_set80211()
3459 vap->iv_flags_ht &= ~IEEE80211_FHT_LDPC_TX; in ieee80211_ioctl_set80211()
3462 if (ireq->i_val & 2) in ieee80211_ioctl_set80211()
3463 vap->iv_flags_ht |= IEEE80211_FHT_LDPC_RX; in ieee80211_ioctl_set80211()
3465 vap->iv_flags_ht &= ~IEEE80211_FHT_LDPC_RX; in ieee80211_ioctl_set80211()
3472 if ((vap->iv_caps & IEEE80211_C_UAPSD) == 0) in ieee80211_ioctl_set80211()
3474 if (ireq->i_val == 0) in ieee80211_ioctl_set80211()
3475 vap->iv_flags_ext &= ~IEEE80211_FEXT_UAPSD; in ieee80211_ioctl_set80211()
3476 else if (ireq->i_val == 1) in ieee80211_ioctl_set80211()
3477 vap->iv_flags_ext |= IEEE80211_FEXT_UAPSD; in ieee80211_ioctl_set80211()
3484 if (ireq->i_val & IEEE80211_FVHT_VHT) in ieee80211_ioctl_set80211()
3487 ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_VHT); in ieee80211_ioctl_set80211()
3489 if (ireq->i_val & IEEE80211_FVHT_USEVHT40) in ieee80211_ioctl_set80211()
3492 ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_USEVHT40); in ieee80211_ioctl_set80211()
3494 if (ireq->i_val & IEEE80211_FVHT_USEVHT80) in ieee80211_ioctl_set80211()
3497 ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_USEVHT80); in ieee80211_ioctl_set80211()
3499 if (ireq->i_val & IEEE80211_FVHT_USEVHT160) in ieee80211_ioctl_set80211()
3502 ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_USEVHT160); in ieee80211_ioctl_set80211()
3504 if (ireq->i_val & IEEE80211_FVHT_USEVHT80P80) in ieee80211_ioctl_set80211()
3507 ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_USEVHT80P80); in ieee80211_ioctl_set80211()
3510 if ((ireq->i_val & IEEE80211_FVHT_STBC_TX) && in ieee80211_ioctl_set80211()
3511 ((vap->iv_vht_cap.vht_cap_info & IEEE80211_VHTCAP_TXSTBC) == 0)) in ieee80211_ioctl_set80211()
3513 if ((ireq->i_val & IEEE80211_FVHT_STBC_RX) && in ieee80211_ioctl_set80211()
3514 ((vap->iv_vht_cap.vht_cap_info & IEEE80211_VHTCAP_RXSTBC_MASK) == 0)) in ieee80211_ioctl_set80211()
3518 if (ireq->i_val & IEEE80211_FVHT_STBC_TX) in ieee80211_ioctl_set80211()
3521 ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_STBC_TX); in ieee80211_ioctl_set80211()
3524 if (ireq->i_val & IEEE80211_FVHT_STBC_RX) in ieee80211_ioctl_set80211()
3527 ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_STBC_RX); in ieee80211_ioctl_set80211()
3538 * requires a complete re-initialization of the device (e.g. in ieee80211_ioctl_set80211()
3550 error = IFNET_IS_UP_RUNNING(vap->iv_ifp) ? in ieee80211_ioctl_set80211()
3551 vap->iv_reset(vap, ireq->i_type) : 0; in ieee80211_ioctl_set80211()
3553 /* XXX need to re-think AUTO handling */ in ieee80211_ioctl_set80211()
3564 struct ieee80211vap *vap = ifp->if_softc; in ieee80211_ioctl()
3565 struct ieee80211com *ic = vap->iv_ic; in ieee80211_ioctl()
3568 struct ifaddr *ifa; /* XXX */ in ieee80211_ioctl()
3577 if ((ifp->if_flags ^ vap->iv_ifflags) & IFF_PROMISC) { in ieee80211_ioctl()
3579 * Enable promiscuous mode when: in ieee80211_ioctl()
3582 * 3. In monitor (or adhoc-demo) mode. in ieee80211_ioctl()
3584 if (ifp->if_bridge == NULL || in ieee80211_ioctl()
3585 (ifp->if_flags & IFF_PPROMISC) != 0 || in ieee80211_ioctl()
3586 vap->iv_opmode == IEEE80211_M_MONITOR || in ieee80211_ioctl()
3587 (vap->iv_opmode == IEEE80211_M_AHDEMO && in ieee80211_ioctl()
3588 (vap->iv_caps & IEEE80211_C_TDMA) == 0)) { in ieee80211_ioctl()
3590 ifp->if_flags & IFF_PROMISC); in ieee80211_ioctl()
3591 vap->iv_ifflags ^= IFF_PROMISC; in ieee80211_ioctl()
3594 if ((ifp->if_flags ^ vap->iv_ifflags) & IFF_ALLMULTI) { in ieee80211_ioctl()
3595 ieee80211_allmulti(vap, ifp->if_flags & IFF_ALLMULTI); in ieee80211_ioctl()
3596 vap->iv_ifflags ^= IFF_ALLMULTI; in ieee80211_ioctl()
3598 if (ifp->if_flags & IFF_UP) { in ieee80211_ioctl()
3603 * side-effect of bringing ourself up. in ieee80211_ioctl()
3605 if (vap->iv_state == IEEE80211_S_INIT) { in ieee80211_ioctl()
3606 if (ic->ic_nrunning == 0) in ieee80211_ioctl()
3610 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) { in ieee80211_ioctl()
3615 if (ic->ic_nrunning == 1) in ieee80211_ioctl()
3634 if (ifp->if_ioctl == ieee80211_ioctl && in ieee80211_ioctl()
3635 (ifp->if_flags & IFF_UP) == 0 && in ieee80211_ioctl()
3636 !IEEE80211_ADDR_EQ(vap->iv_myaddr, IF_LLADDR(ifp))) in ieee80211_ioctl()
3637 IEEE80211_ADDR_COPY(vap->iv_myaddr, in ieee80211_ioctl()
3644 ieee80211_runtask(ic, &ic->ic_mcast_task); in ieee80211_ioctl()
3649 error = ifmedia_ioctl(ifp, ifr, &vap->iv_media, cmd); in ieee80211_ioctl()
3663 error = copyout(&vap->iv_stats, ifr_data_get_ptr(ifr), in ieee80211_ioctl()
3664 sizeof(vap->iv_stats)); in ieee80211_ioctl()
3668 if (!(IEEE80211_MTU_MIN <= ifr->ifr_mtu && in ieee80211_ioctl()
3669 ifr->ifr_mtu <= IEEE80211_MTU_MAX)) in ieee80211_ioctl()
3672 ifp->if_mtu = ifr->ifr_mtu; in ieee80211_ioctl()
3676 * XXX Handle this directly so we can suppress if_init calls. in ieee80211_ioctl()
3677 * XXX This should be done in ether_ioctl but for the moment in ieee80211_ioctl()
3678 * XXX there are too many other parts of the system that in ieee80211_ioctl()
3679 * XXX set IFF_UP and so suppress if_init being called when in ieee80211_ioctl()
3680 * XXX it should be. in ieee80211_ioctl()
3683 switch (ifa->ifa_addr->sa_family) { in ieee80211_ioctl()
3686 if ((ifp->if_flags & IFF_UP) == 0) { in ieee80211_ioctl()
3687 ifp->if_flags |= IFF_UP; in ieee80211_ioctl()
3688 ifp->if_init(ifp->if_softc); in ieee80211_ioctl()
3694 if ((ifp->if_flags & IFF_UP) == 0) { in ieee80211_ioctl()
3695 ifp->if_flags |= IFF_UP; in ieee80211_ioctl()
3696 ifp->if_init(ifp->if_softc); in ieee80211_ioctl()
3711 if (ic->ic_ioctl != NULL && in ieee80211_ioctl()
3712 (error = ic->ic_ioctl(ic, cmd, data)) != ENOTTY) in ieee80211_ioctl()