Lines Matching +full:scan +full:- +full:count
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
78 ic->ic_vattach[IEEE80211_M_STA] = sta_vattach; in ieee80211_sta_attach()
94 vap->iv_newstate = sta_newstate; in sta_vattach()
95 vap->iv_input = sta_input; in sta_vattach()
96 vap->iv_recv_mgmt = sta_recv_mgmt; in sta_vattach()
97 vap->iv_recv_ctl = sta_recv_ctl; in sta_vattach()
98 vap->iv_opdetach = sta_vdetach; in sta_vattach()
99 vap->iv_bmiss = sta_beacon_miss; in sta_vattach()
110 struct ieee80211com *ic = vap->iv_ic; in sta_beacon_miss()
114 KASSERT((ic->ic_flags & IEEE80211_F_SCAN) == 0, ("scanning")); in sta_beacon_miss()
115 KASSERT(vap->iv_state >= IEEE80211_S_RUN, in sta_beacon_miss()
116 ("wrong state %s", ieee80211_state_name[vap->iv_state])); in sta_beacon_miss()
120 ieee80211_opmode_name[vap->iv_opmode], in sta_beacon_miss()
121 ieee80211_state_name[vap->iv_state]); in sta_beacon_miss()
123 if (vap->iv_state == IEEE80211_S_CSA) { in sta_beacon_miss()
129 * normal scan. in sta_beacon_miss()
134 if (++vap->iv_bmiss_count < vap->iv_bmiss_max) { in sta_beacon_miss()
137 * scan; if we receive a response ic_bmiss_count will in sta_beacon_miss()
139 * so this avoids the expensive scan if the ap is in sta_beacon_miss()
142 ieee80211_send_probereq(vap->iv_bss, vap->iv_myaddr, in sta_beacon_miss()
143 vap->iv_bss->ni_bssid, vap->iv_bss->ni_bssid, in sta_beacon_miss()
144 vap->iv_bss->ni_essid, vap->iv_bss->ni_esslen); in sta_beacon_miss()
148 callout_stop(&vap->iv_swbmiss); in sta_beacon_miss()
149 vap->iv_bmiss_count = 0; in sta_beacon_miss()
150 vap->iv_stats.is_beacon_miss++; in sta_beacon_miss()
151 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) { in sta_beacon_miss()
159 if (IEEE80211_ATH_CAP(vap, vap->iv_bss, IEEE80211_NODE_TURBOP)) in sta_beacon_miss()
161 ic->ic_bsschan->ic_flags ^ IEEE80211_CHAN_TURBO); in sta_beacon_miss()
170 * a user-mode app) don't do anything that would in sta_beacon_miss()
171 * confuse them; just drop into scan mode so they'll in sta_beacon_miss()
181 * we downgrade the ap and scan.
197 ieee80211_scan_assoc_fail(vap, vap->iv_bss->ni_macaddr, reason); in sta_authretry()
198 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) in sta_authretry()
208 if (vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) { in sta_swbmiss_start()
214 vap->iv_swbmiss_period = IEEE80211_TU_TO_TICKS( in sta_swbmiss_start()
215 2 * vap->iv_bmissthreshold * vap->iv_bss->ni_intval); in sta_swbmiss_start()
216 vap->iv_swbmiss_count = 0; in sta_swbmiss_start()
217 callout_reset(&vap->iv_swbmiss, vap->iv_swbmiss_period, in sta_swbmiss_start()
229 struct ieee80211com *ic = vap->iv_ic; in sta_newstate()
235 ostate = vap->iv_state; in sta_newstate()
236 IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s -> %s (%d)\n", in sta_newstate()
239 vap->iv_state = nstate; /* state transition */ in sta_newstate()
240 callout_stop(&vap->iv_mgtsend); /* XXX callout_drain */ in sta_newstate()
242 ieee80211_cancel_scan(vap); /* background scan */ in sta_newstate()
243 ni = vap->iv_bss; /* NB: no reference held */ in sta_newstate()
244 if (vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) in sta_newstate()
245 callout_stop(&vap->iv_swbmiss); in sta_newstate()
270 /* NB: optimize INIT -> INIT case */ in sta_newstate()
273 if (vap->iv_auth->ia_detach != NULL) in sta_newstate()
274 vap->iv_auth->ia_detach(vap); in sta_newstate()
280 * Initiate a scan. We can come here as a result in sta_newstate()
283 * and the scan request parameters will be present in sta_newstate()
286 if (vap->iv_flags_ext & IEEE80211_FEXT_SCANREQ) { in sta_newstate()
288 vap->iv_scanreq_flags, in sta_newstate()
289 vap->iv_scanreq_duration, in sta_newstate()
290 vap->iv_scanreq_mindwell, in sta_newstate()
291 vap->iv_scanreq_maxdwell, in sta_newstate()
292 vap->iv_scanreq_nssid, vap->iv_scanreq_ssid); in sta_newstate()
293 vap->iv_flags_ext &= ~IEEE80211_FEXT_SCANREQ; in sta_newstate()
304 * the former we're called with a non-zero arg in sta_newstate()
306 * to the scan code so it can update state. in sta_newstate()
307 * Otherwise trigger a new scan unless we're in in sta_newstate()
309 * must issue an explicit scan request. in sta_newstate()
313 vap->iv_bss->ni_macaddr, arg); in sta_newstate()
314 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) in sta_newstate()
326 * manual) kick off a scan to re-connect. in sta_newstate()
330 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) in sta_newstate()
363 vap->iv_state = IEEE80211_S_RUN; /* stay RUN */ in sta_newstate()
367 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) { in sta_newstate()
389 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) { in sta_newstate()
400 if (vap->iv_flags & IEEE80211_F_WPA) { in sta_newstate()
412 (vap->iv_opmode == IEEE80211_M_STA ? in sta_newstate()
414 ether_sprintf(ni->ni_bssid)); in sta_newstate()
415 ieee80211_print_essid(vap->iv_bss->ni_essid, in sta_newstate()
416 ni->ni_esslen); in sta_newstate()
418 ieee80211_chan2ieee(ic, ic->ic_curchan), in sta_newstate()
422 ieee80211_scan_assoc_success(vap, ni->ni_macaddr); in sta_newstate()
428 vap->iv_sta_ps(vap, 0); in sta_newstate()
440 if (ni->ni_authmode != IEEE80211_AUTH_8021X) in sta_newstate()
445 * Don't do this if we're doing SLEEP->RUN. in sta_newstate()
447 if (ic->ic_newassoc != NULL && ostate != IEEE80211_S_SLEEP) in sta_newstate()
448 ic->ic_newassoc(vap->iv_bss, (ostate != IEEE80211_S_RUN)); in sta_newstate()
456 vap->iv_sta_ps(vap, 1); in sta_newstate()
461 "%s: unexpected state transition %s -> %s\n", __func__, in sta_newstate()
469 * Return non-zero if the frame is an echo of a multicast
479 KASSERT(vap->iv_opmode == IEEE80211_M_STA, ("wrong mode")); in isdstods_mcastecho()
481 if (!IEEE80211_IS_MULTICAST(wh->i_addr3)) in isdstods_mcastecho()
483 sa = IEEE80211_QOS_HAS_SEQ(wh) ? QWH4(wh)->i_addr4 : WH4(wh)->i_addr4; in isdstods_mcastecho()
484 return IEEE80211_ADDR_EQ(sa, vap->iv_myaddr); in isdstods_mcastecho()
490 * Return non-zero if the frame is an echo of a multicast
496 KASSERT(vap->iv_opmode == IEEE80211_M_STA, ("wrong mode")); in isfromds_mcastecho()
498 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) in isfromds_mcastecho()
500 return IEEE80211_ADDR_EQ(wh->i_addr3, vap->iv_myaddr); in isfromds_mcastecho()
514 return (vap->iv_ic->ic_flags & IEEE80211_F_SCAN); in doprint()
535 struct ieee80211vap *vap = ni->ni_vap; in sta_input()
536 struct ieee80211com *ic = ni->ni_ic; in sta_input()
537 struct ifnet *ifp = vap->iv_ifp; in sta_input()
550 type = -1; in sta_input()
553 * Bit of a cheat here, we use a pointer for a 3-address in sta_input()
560 if (m->m_pkthdr.len < 2 || m->m_pkthdr.len < ieee80211_anyhdrsize(wh)) { in sta_input()
562 ni->ni_macaddr, NULL, in sta_input()
563 "too short (1): len %u", m->m_pkthdr.len); in sta_input()
564 vap->iv_stats.is_rx_tooshort++; in sta_input()
569 ni->ni_macaddr, NULL, "wrong version, fc %02x:%02x", in sta_input()
570 wh->i_fc[0], wh->i_fc[1]); in sta_input()
571 vap->iv_stats.is_rx_badversion++; in sta_input()
580 if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_DECRYPTED)) in sta_input()
583 if (m->m_flags & M_AMPDU_MPDU) { in sta_input()
585 * Fastpath for A-MPDU reorder q resubmission. Frames in sta_input()
593 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK; in sta_input()
599 ni->ni_inact = ni->ni_inact_reload; in sta_input()
601 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK; in sta_input()
602 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in sta_input()
603 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; in sta_input()
611 (ic->ic_flags & IEEE80211_F_SCAN) == 0) { in sta_input()
612 bssid = wh->i_addr2; in sta_input()
613 if (!IEEE80211_ADDR_EQ(bssid, ni->ni_bssid)) { in sta_input()
617 vap->iv_stats.is_rx_wrongbss++; in sta_input()
630 * XXX it assumes a software-driven scan will put the NIC in sta_input()
635 if ((! IEEE80211_IS_MULTICAST(wh->i_addr1)) in sta_input()
636 && (! IEEE80211_ADDR_EQ(wh->i_addr1, vap->iv_myaddr))) { in sta_input()
639 vap->iv_myaddr, ":", wh->i_addr1, ":"); in sta_input()
640 vap->iv_stats.is_rx_wrongbss++; in sta_input()
644 IEEE80211_RSSI_LPF(ni->ni_avgrssi, rssi); in sta_input()
645 ni->ni_noise = nf; in sta_input()
647 !IEEE80211_IS_MULTICAST(wh->i_addr1)) { in sta_input()
651 ic->ic_wme.wme_hipri_traffic++; in sta_input()
660 if (m->m_len < hdrspace && in sta_input()
663 ni->ni_macaddr, NULL, in sta_input()
665 vap->iv_stats.is_rx_tooshort++; in sta_input()
669 * Handle A-MPDU re-ordering. If the frame is to be in sta_input()
674 if ((m->m_flags & M_AMPDU) && in sta_input()
693 vap->iv_stats.is_rx_mcastecho++; in sta_input()
696 if ((vap->iv_flags & IEEE80211_F_DWDS) && in sta_input()
697 IEEE80211_IS_MULTICAST(wh->i_addr1)) { in sta_input()
699 * DWDS sta's must drop 3-address mcast frames in sta_input()
700 * as they will be sent separately as a 4-addr in sta_input()
701 * frame. Accepting the 3-addr frame will in sta_input()
706 "3-address data", "%s", "DWDS enabled"); in sta_input()
707 vap->iv_stats.is_rx_mcastecho++; in sta_input()
711 if ((vap->iv_flags & IEEE80211_F_DWDS) == 0) { in sta_input()
713 IEEE80211_MSG_INPUT, wh, "4-address data", in sta_input()
715 vap->iv_stats.is_rx_wrongdir++; in sta_input()
727 "4-address data", "%s", "multicast echo"); in sta_input()
728 vap->iv_stats.is_rx_mcastecho++; in sta_input()
734 vap->iv_stats.is_rx_wrongdir++; in sta_input()
745 * ieee80211_crypto_decap() - none of the key in sta_input()
749 * MIC failure up to the stack - but we don't know in sta_input()
762 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { in sta_input()
768 vap->iv_stats.is_rx_noprivacy++; in sta_input()
778 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; in sta_input()
786 * Save QoS bits for use below--before we strip the header. in sta_input()
796 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in sta_input()
815 ni->ni_macaddr, "data", "%s", "demic error"); in sta_input()
816 vap->iv_stats.is_rx_demicfail++; in sta_input()
832 /* don't count Null data frames as errors */ in sta_input()
837 ni->ni_macaddr, "data", "%s", "decap error"); in sta_input()
838 vap->iv_stats.is_rx_decap++; in sta_input()
848 * Deny any non-PAE frames received prior to in sta_input()
849 * authorization. For open/shared-key in sta_input()
856 eh->ether_type != htons(ETHERTYPE_PAE)) { in sta_input()
858 ni->ni_macaddr, "data", "unauthorized or " in sta_input()
860 eh == NULL ? -1 : eh->ether_type, in sta_input()
861 m->m_pkthdr.len); in sta_input()
862 vap->iv_stats.is_rx_unauth++; in sta_input()
869 * any non-PAE frames received without encryption. in sta_input()
871 if ((vap->iv_flags & IEEE80211_F_DROPUNENC) && in sta_input()
872 ((has_decrypted == 0) && (m->m_flags & M_WEP) == 0) && in sta_input()
875 eh->ether_type != htons(ETHERTYPE_PAE))) { in sta_input()
879 vap->iv_stats.is_rx_unencrypted++; in sta_input()
900 vap->iv_stats.is_rx_mgmt++; in sta_input()
905 vap->iv_stats.is_rx_wrongdir++; in sta_input()
908 if (m->m_pkthdr.len < sizeof(struct ieee80211_frame)) { in sta_input()
910 ni->ni_macaddr, "mgt", "too short: len %u", in sta_input()
911 m->m_pkthdr.len); in sta_input()
912 vap->iv_stats.is_rx_tooshort++; in sta_input()
921 ether_sprintf(wh->i_addr2), rssi); in sta_input()
943 vap->iv_stats.is_rx_mgtdiscard++; /* XXX */ in sta_input()
946 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { in sta_input()
952 vap->iv_stats.is_rx_noprivacy++; in sta_input()
967 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; in sta_input()
969 vap->iv_recv_mgmt(ni, m, subtype, rxs, rssi, nf); in sta_input()
973 vap->iv_stats.is_rx_ctl++; in sta_input()
976 vap->iv_recv_ctl(ni, m, subtype); in sta_input()
1000 struct ieee80211vap *vap = ni->ni_vap; in sta_auth_open()
1002 if (ni->ni_authmode == IEEE80211_AUTH_SHARED) { in sta_auth_open()
1004 ni->ni_macaddr, "open auth", in sta_auth_open()
1005 "bad sta auth mode %u", ni->ni_authmode); in sta_auth_open()
1006 vap->iv_stats.is_rx_bad_auth++; /* XXX */ in sta_auth_open()
1009 if (vap->iv_state != IEEE80211_S_AUTH || in sta_auth_open()
1011 vap->iv_stats.is_rx_bad_auth++; in sta_auth_open()
1017 vap->iv_stats.is_rx_auth_fail++; in sta_auth_open()
1018 vap->iv_stats.is_rx_authfail_code = status; in sta_auth_open()
1030 struct ieee80211vap *vap = ni->ni_vap; in sta_auth_shared()
1034 * NB: this can happen as we allow pre-shared key in sta_auth_shared()
1041 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { in sta_auth_shared()
1043 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1048 * Pre-shared key authentication is evil; accept in sta_auth_shared()
1052 if (ni->ni_authmode != IEEE80211_AUTH_AUTO && in sta_auth_shared()
1053 ni->ni_authmode != IEEE80211_AUTH_SHARED) { in sta_auth_shared()
1055 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1056 "bad sta auth mode %u", ni->ni_authmode); in sta_auth_shared()
1057 vap->iv_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */ in sta_auth_shared()
1063 if ((frm[1] + 2) > (efrm - frm)) { in sta_auth_shared()
1065 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1067 frm[0], (frm[1] + 2) - (efrm - frm)); in sta_auth_shared()
1068 vap->iv_stats.is_rx_bad_auth++; in sta_auth_shared()
1080 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1082 vap->iv_stats.is_rx_bad_auth++; in sta_auth_shared()
1087 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1089 vap->iv_stats.is_rx_bad_auth++; in sta_auth_shared()
1095 if (vap->iv_state != IEEE80211_S_AUTH) in sta_auth_shared()
1099 if (ni->ni_challenge != NULL) { in sta_auth_shared()
1100 IEEE80211_FREE(ni->ni_challenge, M_80211_NODE); in sta_auth_shared()
1101 ni->ni_challenge = NULL; in sta_auth_shared()
1107 vap->iv_stats.is_rx_auth_fail++; in sta_auth_shared()
1108 vap->iv_stats.is_rx_authfail_code = status; in sta_auth_shared()
1117 memcpy(ni->ni_challenge, &challenge[2], challenge[1]); in sta_auth_shared()
1124 vap->iv_stats.is_rx_bad_auth++; in sta_auth_shared()
1130 * Kick the state machine. This short-circuits in sta_auth_shared()
1134 if (vap->iv_state == IEEE80211_S_AUTH) in sta_auth_shared()
1140 * Parse the WME IE for QoS and U-APSD information.
1142 * Returns -1 if the IE isn't found, 1 if it's found.
1150 ni->ni_uapsd = 0; in ieee80211_parse_wmeie()
1152 if (len < sizeof(struct ieee80211_wme_param)-2) { in ieee80211_parse_wmeie()
1153 IEEE80211_DISCARD_IE(ni->ni_vap, in ieee80211_parse_wmeie()
1156 return -1; in ieee80211_parse_wmeie()
1159 ni->ni_uapsd = frm[WME_CAPINFO_IE_OFFSET]; in ieee80211_parse_wmeie()
1161 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_POWER | IEEE80211_MSG_ASSOC, in ieee80211_parse_wmeie()
1162 ni, "U-APSD settings from STA: 0x%02x", ni->ni_uapsd); in ieee80211_parse_wmeie()
1171 struct ieee80211_wme_state *wme = &vap->iv_ic->ic_wme; in ieee80211_parse_wmeparams()
1177 if (len < sizeof(struct ieee80211_wme_param)-2) { in ieee80211_parse_wmeparams()
1181 return -1; in ieee80211_parse_wmeparams()
1187 if (qosinfo_count == wme->wme_wmeChanParams.cap_info) in ieee80211_parse_wmeparams()
1192 &wme->wme_wmeChanParams.cap_wmeParams[i]; in ieee80211_parse_wmeparams()
1194 wmep->wmep_acm = _IEEE80211_MASKSHIFT(frm[0], WME_PARAM_ACM); in ieee80211_parse_wmeparams()
1195 wmep->wmep_aifsn = in ieee80211_parse_wmeparams()
1197 wmep->wmep_logcwmin = in ieee80211_parse_wmeparams()
1199 wmep->wmep_logcwmax = in ieee80211_parse_wmeparams()
1201 wmep->wmep_txopLimit = le16dec(frm+2); in ieee80211_parse_wmeparams()
1206 wmep->wmep_acm, in ieee80211_parse_wmeparams()
1207 wmep->wmep_aifsn, in ieee80211_parse_wmeparams()
1208 wmep->wmep_logcwmin, in ieee80211_parse_wmeparams()
1209 wmep->wmep_logcwmax, in ieee80211_parse_wmeparams()
1210 wmep->wmep_txopLimit); in ieee80211_parse_wmeparams()
1213 wme->wme_wmeChanParams.cap_info = qosinfo_count; in ieee80211_parse_wmeparams()
1227 struct ieee80211com *ic = vap->iv_ic; in ieee80211_parse_csaparams()
1231 KASSERT(vap->iv_state >= IEEE80211_S_RUN, in ieee80211_parse_csaparams()
1232 ("state %s", ieee80211_state_name[vap->iv_state])); in ieee80211_parse_csaparams()
1234 if (csa->csa_mode > 1) { in ieee80211_parse_csaparams()
1237 wh, "CSA", "invalid mode %u", csa->csa_mode); in ieee80211_parse_csaparams()
1241 if ((ic->ic_flags & IEEE80211_F_CSAPENDING) == 0) { in ieee80211_parse_csaparams()
1253 ieee80211_find_channel_byieee(ic, csa->csa_newchan, in ieee80211_parse_csaparams()
1254 (ic->ic_bsschan->ic_flags & IEEE80211_CHAN_ALLTURBO)); in ieee80211_parse_csaparams()
1257 csa->csa_newchan, in ieee80211_parse_csaparams()
1258 (ic->ic_bsschan->ic_flags & IEEE80211_CHAN_ALL)); in ieee80211_parse_csaparams()
1263 csa->csa_newchan); in ieee80211_parse_csaparams()
1268 if (csa->csa_count < IEEE80211_CSA_COUNT_MIN) { in ieee80211_parse_csaparams()
1270 * Require at least IEEE80211_CSA_COUNT_MIN count to in ieee80211_parse_csaparams()
1277 * count may be any value and if 0 then a switch in ieee80211_parse_csaparams()
1282 wh, "CSA", "count %u too small, must be >= %u", in ieee80211_parse_csaparams()
1283 csa->csa_count, IEEE80211_CSA_COUNT_MIN); in ieee80211_parse_csaparams()
1287 ieee80211_csa_startswitch(ic, c, csa->csa_mode, csa->csa_count); in ieee80211_parse_csaparams()
1291 * mode and channel not change and the count must be in ieee80211_parse_csaparams()
1296 * beacon miss and scan to find the AP. in ieee80211_parse_csaparams()
1298 * XXX may want <= on count as we also process ProbeResp in ieee80211_parse_csaparams()
1299 * frames and those may come in w/ the same count as the in ieee80211_parse_csaparams()
1301 * count until we add a dead-man timer in ieee80211_parse_csaparams()
1303 if (!(csa->csa_count < ic->ic_csa_count && in ieee80211_parse_csaparams()
1304 csa->csa_mode == ic->ic_csa_mode && in ieee80211_parse_csaparams()
1305 csa->csa_newchan == ieee80211_chan2ieee(ic, ic->ic_csa_newchan))) { in ieee80211_parse_csaparams()
1308 "this ie <%d,%d,%d>", ic->ic_csa_mode, in ieee80211_parse_csaparams()
1309 ic->ic_csa_newchan, ic->ic_csa_count, in ieee80211_parse_csaparams()
1310 csa->csa_mode, csa->csa_newchan, csa->csa_count); in ieee80211_parse_csaparams()
1313 if (csa->csa_count <= 1) in ieee80211_parse_csaparams()
1316 ic->ic_csa_count = csa->csa_count; in ieee80211_parse_csaparams()
1324 * Return non-zero if a background scan may be continued:
1325 * o bg scan is active
1328 * o no full-offload scan support (no need for explicitly continuing scan then)
1331 * this is only done to start the scan. We assume that any
1338 struct ieee80211com *ic = vap->iv_ic; in contbgscan()
1340 return ((ic->ic_flags_ext & IEEE80211_FEXT_BGSCAN) && in contbgscan()
1341 (ic->ic_flags & IEEE80211_F_CSAPENDING) == 0 && in contbgscan()
1342 !(vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) && in contbgscan()
1343 vap->iv_state == IEEE80211_S_RUN && /* XXX? */ in contbgscan()
1344 ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle)); in contbgscan()
1348 * Return non-zero if a backgrond scan may be started:
1352 * o there has not been a scan recently
1353 * o there has not been any traffic recently (don't check if full-offload scan)
1358 struct ieee80211com *ic = vap->iv_ic; in startbgscan()
1360 return ((vap->iv_flags & IEEE80211_F_BGSCAN) && in startbgscan()
1361 (ic->ic_flags & IEEE80211_F_CSAPENDING) == 0 && in startbgscan()
1363 !IEEE80211_IS_CHAN_DTURBO(ic->ic_curchan) && in startbgscan()
1365 ieee80211_time_after(ticks, ic->ic_lastscan + vap->iv_bgscanintvl) && in startbgscan()
1366 ((vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) || in startbgscan()
1367 ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle))); in startbgscan()
1374 * The tbttcount isn't checked - that's not part of the configuration.
1381 if (q1->period != q2->period) in compare_quiet_ie()
1383 if (le16dec(&q1->duration) != le16dec(&q2->duration)) in compare_quiet_ie()
1385 if (le16dec(&q1->offset) != le16dec(&q2->offset)) in compare_quiet_ie()
1397 struct ieee80211vap *vap = ni->ni_vap; in sta_recv_mgmt()
1398 struct ieee80211com *ic = ni->ni_ic; in sta_recv_mgmt()
1399 struct ieee80211_channel *rxchan = ic->ic_curchan; in sta_recv_mgmt()
1410 efrm = mtod(m0, uint8_t *) + m0->m_len; in sta_recv_mgmt()
1414 struct ieee80211_scanparams scan; in sta_recv_mgmt() local
1423 if (!((ic->ic_flags & IEEE80211_F_SCAN) || ni->ni_associd)) { in sta_recv_mgmt()
1424 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1436 if (ieee80211_parse_beacon(ni, m0, rxchan, &scan) != 0) { in sta_recv_mgmt()
1437 if (! (ic->ic_flags & IEEE80211_F_SCAN)) in sta_recv_mgmt()
1438 vap->iv_stats.is_beacon_bad++; in sta_recv_mgmt()
1443 * Count frame now that we know it's to be processed. in sta_recv_mgmt()
1446 vap->iv_stats.is_rx_beacon++; /* XXX remove */ in sta_recv_mgmt()
1453 * background scan. We consider only 11g/WMM stuff right now. in sta_recv_mgmt()
1455 if (ni->ni_associd != 0 && in sta_recv_mgmt()
1456 ((ic->ic_flags & IEEE80211_F_SCAN) == 0 || in sta_recv_mgmt()
1457 IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_bssid))) { in sta_recv_mgmt()
1459 memcpy(ni->ni_tstamp.data, scan.tstamp, in sta_recv_mgmt()
1460 sizeof(ni->ni_tstamp)); in sta_recv_mgmt()
1461 /* count beacon frame for s/w bmiss handling */ in sta_recv_mgmt()
1462 vap->iv_swbmiss_count++; in sta_recv_mgmt()
1463 vap->iv_bmiss_count = 0; in sta_recv_mgmt()
1464 if (ni->ni_erp != scan.erp) { in sta_recv_mgmt()
1466 wh->i_addr2, in sta_recv_mgmt()
1468 ni->ni_erp, scan.erp); in sta_recv_mgmt()
1469 if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan) && in sta_recv_mgmt()
1470 (ni->ni_erp & IEEE80211_ERP_USE_PROTECTION)) in sta_recv_mgmt()
1471 vap->iv_flags |= IEEE80211_F_USEPROT; in sta_recv_mgmt()
1473 vap->iv_flags &= ~IEEE80211_F_USEPROT; in sta_recv_mgmt()
1474 ni->ni_erp = scan.erp; in sta_recv_mgmt()
1479 if ((ni->ni_capinfo ^ scan.capinfo) & IEEE80211_CAPINFO_SHORT_SLOTTIME) { in sta_recv_mgmt()
1481 wh->i_addr2, in sta_recv_mgmt()
1483 ni->ni_capinfo, scan.capinfo); in sta_recv_mgmt()
1489 IEEE80211_IS_CHAN_A(ic->ic_bsschan) || in sta_recv_mgmt()
1490 (scan.capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME)); in sta_recv_mgmt()
1491 ni->ni_capinfo = (ni->ni_capinfo &~ IEEE80211_CAPINFO_SHORT_SLOTTIME) in sta_recv_mgmt()
1492 | (scan.capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME); in sta_recv_mgmt()
1495 if (scan.wme != NULL && in sta_recv_mgmt()
1496 (ni->ni_flags & IEEE80211_NODE_QOS)) { in sta_recv_mgmt()
1499 scan.wme, wh, &qosinfo)) >= 0) { in sta_recv_mgmt()
1501 ni->ni_flags |= in sta_recv_mgmt()
1507 ni->ni_flags &= ~IEEE80211_NODE_UAPSD; in sta_recv_mgmt()
1509 if (scan.ath != NULL) in sta_recv_mgmt()
1510 ieee80211_parse_athparams(ni, scan.ath, wh); in sta_recv_mgmt()
1512 if (scan.htcap != NULL && scan.htinfo != NULL && in sta_recv_mgmt()
1513 (vap->iv_flags_ht & IEEE80211_FHT_HT)) { in sta_recv_mgmt()
1516 scan.htcap, scan.htinfo); in sta_recv_mgmt()
1519 if (scan.vhtcap != NULL && scan.vhtopmode != NULL && in sta_recv_mgmt()
1520 (vap->iv_vht_flags & IEEE80211_FVHT_VHT)) { in sta_recv_mgmt()
1523 scan.vhtcap, scan.vhtopmode); in sta_recv_mgmt()
1528 scan.htcap, scan.htinfo)) in sta_recv_mgmt()
1537 * IE has disappeared - only do that once rather than in sta_recv_mgmt()
1540 if (scan.quiet) { in sta_recv_mgmt()
1541 ic->ic_set_quiet(ni, scan.quiet); in sta_recv_mgmt()
1542 ni->ni_quiet_ie_set = 1; in sta_recv_mgmt()
1543 memcpy(&ni->ni_quiet_ie, scan.quiet, in sta_recv_mgmt()
1546 if (ni->ni_quiet_ie_set == 1) in sta_recv_mgmt()
1547 ic->ic_set_quiet(ni, NULL); in sta_recv_mgmt()
1548 ni->ni_quiet_ie_set = 0; in sta_recv_mgmt()
1549 bzero(&ni->ni_quiet_ie, in sta_recv_mgmt()
1553 if (scan.tim != NULL) { in sta_recv_mgmt()
1555 (struct ieee80211_tim_ie *) scan.tim; in sta_recv_mgmt()
1561 int aid = IEEE80211_AID(ni->ni_associd); in sta_recv_mgmt()
1563 int min = tim->tim_bitctl &~ 1; in sta_recv_mgmt()
1564 int max = tim->tim_len + min - 4; in sta_recv_mgmt()
1573 * the scan notification stuff should occur in sta_recv_mgmt()
1577 isset(tim->tim_bitmap - min, aid)) { in sta_recv_mgmt()
1586 if (tim->tim_bitctl & 1) { in sta_recv_mgmt()
1613 ic->ic_lastdata = ticks; in sta_recv_mgmt()
1616 ni->ni_dtim_count = tim->tim_count; in sta_recv_mgmt()
1617 ni->ni_dtim_period = tim->tim_period; in sta_recv_mgmt()
1619 if (scan.csa != NULL && in sta_recv_mgmt()
1620 (vap->iv_flags & IEEE80211_F_DOTH)) in sta_recv_mgmt()
1621 ieee80211_parse_csaparams(vap, scan.csa, wh); in sta_recv_mgmt()
1622 else if (ic->ic_flags & IEEE80211_F_CSAPENDING) { in sta_recv_mgmt()
1627 * moving we'll get a beacon miss and scan. in sta_recv_mgmt()
1634 * If scanning, pass the info to the scan module. in sta_recv_mgmt()
1636 * a background scan. Background scanning must in sta_recv_mgmt()
1640 * scan and if no data frames have come through in sta_recv_mgmt()
1641 * recently, kick off a scan. Note that this in sta_recv_mgmt()
1642 * is the mechanism by which a background scan in sta_recv_mgmt()
1644 * return on-channel to receive a beacon from in sta_recv_mgmt()
1647 if (ic->ic_flags & IEEE80211_F_SCAN) { in sta_recv_mgmt()
1649 &scan, wh, subtype, rssi, nf); in sta_recv_mgmt()
1653 vap->iv_stats.is_scan_bg++; in sta_recv_mgmt()
1670 * If we've had a channel width change (eg HT20<->HT40) in sta_recv_mgmt()
1678 * If scanning, just pass information to the scan module. in sta_recv_mgmt()
1680 if (ic->ic_flags & IEEE80211_F_SCAN) { in sta_recv_mgmt()
1681 if (ic->ic_flags_ext & IEEE80211_FEXT_PROBECHAN) { in sta_recv_mgmt()
1691 ic->ic_flags_ext &= ~IEEE80211_FEXT_PROBECHAN; in sta_recv_mgmt()
1693 ieee80211_add_scan(vap, rxchan, &scan, wh, in sta_recv_mgmt()
1709 IEEE80211_VERIFY_LENGTH(efrm - frm, 6, return); in sta_recv_mgmt()
1713 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_AUTH, wh->i_addr2, in sta_recv_mgmt()
1716 if (vap->iv_flags & IEEE80211_F_COUNTERM) { in sta_recv_mgmt()
1720 vap->iv_stats.is_rx_auth_countermeasures++; in sta_recv_mgmt()
1721 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { in sta_recv_mgmt()
1722 ieee80211_send_error(ni, wh->i_addr2, in sta_recv_mgmt()
1736 vap->iv_stats.is_rx_auth_unsupported++; in sta_recv_mgmt()
1747 if (vap->iv_state != IEEE80211_S_ASSOC) { in sta_recv_mgmt()
1748 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1763 IEEE80211_VERIFY_LENGTH(efrm - frm, 6, return); in sta_recv_mgmt()
1764 ni = vap->iv_bss; in sta_recv_mgmt()
1771 wh->i_addr2, "%sassoc failed (reason %d)", in sta_recv_mgmt()
1773 vap->iv_stats.is_rx_auth_fail++; /* XXX */ in sta_recv_mgmt()
1781 while (efrm - frm > 1) { in sta_recv_mgmt()
1782 IEEE80211_VERIFY_LENGTH(efrm - frm, frm[1] + 2, return); in sta_recv_mgmt()
1799 else if (vap->iv_flags_ht & IEEE80211_FHT_HTCOMPAT) { in sta_recv_mgmt()
1801 * Accept pre-draft HT ie's if the in sta_recv_mgmt()
1827 IEEE80211_RATE_MAXSIZE - rates[1], return); in sta_recv_mgmt()
1834 wh->i_addr2, in sta_recv_mgmt()
1837 vap->iv_stats.is_rx_assoc_norate++; in sta_recv_mgmt()
1843 ni->ni_capinfo = capinfo; in sta_recv_mgmt()
1844 ni->ni_associd = associd; in sta_recv_mgmt()
1845 if (ni->ni_jointime == 0) in sta_recv_mgmt()
1846 ni->ni_jointime = time_uptime; in sta_recv_mgmt()
1849 ni->ni_flags |= IEEE80211_NODE_QOS; in sta_recv_mgmt()
1852 ni->ni_flags &= ~IEEE80211_NODE_QOS; in sta_recv_mgmt()
1861 (vap->iv_flags_ht & IEEE80211_FHT_HT)) { in sta_recv_mgmt()
1866 (vap->iv_vht_flags & IEEE80211_FVHT_VHT)) { in sta_recv_mgmt()
1871 if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) { in sta_recv_mgmt()
1874 __func__, ni->ni_macaddr, ":"); in sta_recv_mgmt()
1893 * for doing A-MSDU encapsulation as well. in sta_recv_mgmt()
1904 if (IEEE80211_IS_CHAN_A(ic->ic_curchan) || in sta_recv_mgmt()
1905 (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)) { in sta_recv_mgmt()
1906 vap->iv_flags |= IEEE80211_F_SHPREAMBLE; in sta_recv_mgmt()
1907 vap->iv_flags &= ~IEEE80211_F_USEBARKER; in sta_recv_mgmt()
1909 vap->iv_flags &= ~IEEE80211_F_SHPREAMBLE; in sta_recv_mgmt()
1910 vap->iv_flags |= IEEE80211_F_USEBARKER; in sta_recv_mgmt()
1913 IEEE80211_IS_CHAN_A(ic->ic_curchan) || in sta_recv_mgmt()
1914 (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME)); in sta_recv_mgmt()
1919 * NB: ni_erp should zero for non-11g operation. in sta_recv_mgmt()
1921 if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan) && in sta_recv_mgmt()
1922 (ni->ni_erp & IEEE80211_ERP_USE_PROTECTION)) in sta_recv_mgmt()
1923 vap->iv_flags |= IEEE80211_F_USEPROT; in sta_recv_mgmt()
1925 vap->iv_flags &= ~IEEE80211_F_USEPROT; in sta_recv_mgmt()
1928 IEEE80211_MSG_ASSOC | IEEE80211_MSG_DEBUG, wh->i_addr2, in sta_recv_mgmt()
1932 vap->iv_flags&IEEE80211_F_SHPREAMBLE ? "short" : "long", in sta_recv_mgmt()
1933 vap->iv_flags&IEEE80211_F_SHSLOT ? "short" : "long", in sta_recv_mgmt()
1934 vap->iv_flags&IEEE80211_F_USEPROT ? ", protection" : "", in sta_recv_mgmt()
1935 ni->ni_flags & IEEE80211_NODE_QOS ? ", QoS" : "", in sta_recv_mgmt()
1936 ni->ni_flags & IEEE80211_NODE_HT ? in sta_recv_mgmt()
1937 (ni->ni_chw == IEEE80211_STA_RX_BW_40 ? ", HT40" : ", HT20") : "", in sta_recv_mgmt()
1938 ni->ni_flags & IEEE80211_NODE_AMPDU ? " (+AMPDU)" : "", in sta_recv_mgmt()
1939 ni->ni_flags & IEEE80211_NODE_AMSDU ? " (+AMSDU)" : "", in sta_recv_mgmt()
1940 ni->ni_flags & IEEE80211_NODE_MIMO_RTS ? " (+SMPS-DYN)" : in sta_recv_mgmt()
1941 ni->ni_flags & IEEE80211_NODE_MIMO_PS ? " (+SMPS)" : "", in sta_recv_mgmt()
1942 ni->ni_flags & IEEE80211_NODE_RIFS ? " (+RIFS)" : "", in sta_recv_mgmt()
1944 ", fast-frames" : "", in sta_recv_mgmt()
1955 if (vap->iv_state == IEEE80211_S_SCAN) { in sta_recv_mgmt()
1956 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1959 if (!IEEE80211_ADDR_EQ(wh->i_addr1, vap->iv_myaddr)) { in sta_recv_mgmt()
1961 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1969 IEEE80211_VERIFY_LENGTH(efrm - frm, 2, return); in sta_recv_mgmt()
1972 vap->iv_stats.is_rx_deauth++; in sta_recv_mgmt()
1973 vap->iv_stats.is_rx_deauth_code = reason; in sta_recv_mgmt()
1987 if (vap->iv_state != IEEE80211_S_RUN && in sta_recv_mgmt()
1988 vap->iv_state != IEEE80211_S_ASSOC && in sta_recv_mgmt()
1989 vap->iv_state != IEEE80211_S_AUTH) { in sta_recv_mgmt()
1990 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1993 if (!IEEE80211_ADDR_EQ(wh->i_addr1, vap->iv_myaddr)) { in sta_recv_mgmt()
1995 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
2003 IEEE80211_VERIFY_LENGTH(efrm - frm, 2, return); in sta_recv_mgmt()
2006 vap->iv_stats.is_rx_disassoc++; in sta_recv_mgmt()
2007 vap->iv_stats.is_rx_disassoc_code = reason; in sta_recv_mgmt()
2019 if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr1) && in sta_recv_mgmt()
2020 !IEEE80211_IS_MULTICAST(wh->i_addr1)) { in sta_recv_mgmt()
2023 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
2024 } else if (vap->iv_state != IEEE80211_S_RUN) { in sta_recv_mgmt()
2027 ieee80211_state_name[vap->iv_state]); in sta_recv_mgmt()
2028 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
2031 (void)ic->ic_recv_action(ni, wh, frm, efrm); in sta_recv_mgmt()
2042 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
2048 vap->iv_stats.is_rx_badsubtype++; in sta_recv_mgmt()