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

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
29 * IEEE 802.11 Station mode support.
81 ic->ic_vattach[IEEE80211_M_STA] = sta_vattach; in ieee80211_sta_attach()
97 vap->iv_newstate = sta_newstate; in sta_vattach()
98 vap->iv_input = sta_input; in sta_vattach()
99 vap->iv_recv_mgmt = sta_recv_mgmt; in sta_vattach()
100 vap->iv_recv_ctl = sta_recv_ctl; in sta_vattach()
101 vap->iv_opdetach = sta_vdetach; in sta_vattach()
102 vap->iv_bmiss = sta_beacon_miss; in sta_vattach()
113 struct ieee80211com *ic = vap->iv_ic; in sta_beacon_miss()
117 KASSERT((ic->ic_flags & IEEE80211_F_SCAN) == 0, ("scanning")); in sta_beacon_miss()
118 KASSERT(vap->iv_state >= IEEE80211_S_RUN, in sta_beacon_miss()
119 ("wrong state %s", ieee80211_state_name[vap->iv_state])); in sta_beacon_miss()
122 "beacon miss, mode %s state %s\n", in sta_beacon_miss()
123 ieee80211_opmode_name[vap->iv_opmode], in sta_beacon_miss()
124 ieee80211_state_name[vap->iv_state]); in sta_beacon_miss()
126 if (vap->iv_state == IEEE80211_S_CSA) { in sta_beacon_miss()
137 if (++vap->iv_bmiss_count < vap->iv_bmiss_max) { in sta_beacon_miss()
145 ieee80211_send_probereq(vap->iv_bss, vap->iv_myaddr, in sta_beacon_miss()
146 vap->iv_bss->ni_bssid, vap->iv_bss->ni_bssid, in sta_beacon_miss()
147 vap->iv_bss->ni_essid, vap->iv_bss->ni_esslen); in sta_beacon_miss()
151 callout_stop(&vap->iv_swbmiss); in sta_beacon_miss()
152 vap->iv_bmiss_count = 0; in sta_beacon_miss()
153 vap->iv_stats.is_beacon_miss++; in sta_beacon_miss()
154 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) { in sta_beacon_miss()
162 if (IEEE80211_ATH_CAP(vap, vap->iv_bss, IEEE80211_NODE_TURBOP)) in sta_beacon_miss()
164 ic->ic_bsschan->ic_flags ^ IEEE80211_CHAN_TURBO); in sta_beacon_miss()
173 * a user-mode app) don't do anything that would in sta_beacon_miss()
174 * confuse them; just drop into scan mode so they'll in sta_beacon_miss()
200 ieee80211_scan_assoc_fail(vap, vap->iv_bss->ni_macaddr, reason); in sta_authretry()
201 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) in sta_authretry()
211 if (vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) { in sta_swbmiss_start()
217 vap->iv_swbmiss_period = IEEE80211_TU_TO_TICKS( in sta_swbmiss_start()
218 2 * vap->iv_bmissthreshold * vap->iv_bss->ni_intval); in sta_swbmiss_start()
219 vap->iv_swbmiss_count = 0; in sta_swbmiss_start()
220 callout_reset(&vap->iv_swbmiss, vap->iv_swbmiss_period, in sta_swbmiss_start()
232 struct ieee80211com *ic = vap->iv_ic; in sta_newstate()
238 ostate = vap->iv_state; in sta_newstate()
239 IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s -> %s (%d)\n", in sta_newstate()
242 vap->iv_state = nstate; /* state transition */ in sta_newstate()
243 callout_stop(&vap->iv_mgtsend); /* XXX callout_drain */ in sta_newstate()
246 ni = vap->iv_bss; /* NB: no reference held */ in sta_newstate()
247 if (vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) in sta_newstate()
248 callout_stop(&vap->iv_swbmiss); in sta_newstate()
253 /* XXX wakeup */ in sta_newstate()
254 /* XXX driver hook to wakeup the hardware? */ in sta_newstate()
273 /* NB: optimize INIT -> INIT case */ in sta_newstate()
276 if (vap->iv_auth->ia_detach != NULL) in sta_newstate()
277 vap->iv_auth->ia_detach(vap); in sta_newstate()
289 if (vap->iv_flags_ext & IEEE80211_FEXT_SCANREQ) { in sta_newstate()
291 vap->iv_scanreq_flags, in sta_newstate()
292 vap->iv_scanreq_duration, in sta_newstate()
293 vap->iv_scanreq_mindwell, in sta_newstate()
294 vap->iv_scanreq_maxdwell, in sta_newstate()
295 vap->iv_scanreq_nssid, vap->iv_scanreq_ssid); in sta_newstate()
296 vap->iv_flags_ext &= ~IEEE80211_FEXT_SCANREQ; in sta_newstate()
307 * the former we're called with a non-zero arg in sta_newstate()
311 * manual roaming mode in which case an application in sta_newstate()
316 vap->iv_bss->ni_macaddr, arg); in sta_newstate()
317 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) in sta_newstate()
322 * XXX if in sleep we need to wakeup the hardware. in sta_newstate()
329 * manual) kick off a scan to re-connect. in sta_newstate()
333 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) in sta_newstate()
366 vap->iv_state = IEEE80211_S_RUN; /* stay RUN */ in sta_newstate()
370 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) { in sta_newstate()
392 if (vap->iv_roaming == IEEE80211_ROAMING_AUTO) { in sta_newstate()
403 if (vap->iv_flags & IEEE80211_F_WPA) { in sta_newstate()
404 /* XXX validate prerequisites */ in sta_newstate()
415 (vap->iv_opmode == IEEE80211_M_STA ? in sta_newstate()
417 ether_sprintf(ni->ni_bssid)); in sta_newstate()
418 ieee80211_print_essid(vap->iv_bss->ni_essid, in sta_newstate()
419 ni->ni_esslen); in sta_newstate()
420 /* XXX MCS/HT */ in sta_newstate()
422 ieee80211_chan2ieee(ic, ic->ic_curchan), in sta_newstate()
423 IEEE80211_RATE2MBS(ni->ni_txrate)); in sta_newstate()
426 ieee80211_scan_assoc_success(vap, ni->ni_macaddr); in sta_newstate()
432 vap->iv_sta_ps(vap, 0); in sta_newstate()
444 if (ni->ni_authmode != IEEE80211_AUTH_8021X) in sta_newstate()
449 * Don't do this if we're doing SLEEP->RUN. in sta_newstate()
451 if (ic->ic_newassoc != NULL && ostate != IEEE80211_S_SLEEP) in sta_newstate()
452 ic->ic_newassoc(vap->iv_bss, (ostate != IEEE80211_S_RUN)); in sta_newstate()
460 vap->iv_sta_ps(vap, 1); in sta_newstate()
465 "%s: unexpected state transition %s -> %s\n", __func__, in sta_newstate()
473 * Return non-zero if the frame is an echo of a multicast
483 KASSERT(vap->iv_opmode == IEEE80211_M_STA, ("wrong mode")); in isdstods_mcastecho()
485 if (!IEEE80211_IS_MULTICAST(wh->i_addr3)) in isdstods_mcastecho()
487 sa = IEEE80211_QOS_HAS_SEQ(wh) ? QWH4(wh)->i_addr4 : WH4(wh)->i_addr4; in isdstods_mcastecho()
488 return IEEE80211_ADDR_EQ(sa, vap->iv_myaddr); in isdstods_mcastecho()
494 * Return non-zero if the frame is an echo of a multicast
500 KASSERT(vap->iv_opmode == IEEE80211_M_STA, ("wrong mode")); in isfromds_mcastecho()
502 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) in isfromds_mcastecho()
504 return IEEE80211_ADDR_EQ(wh->i_addr3, vap->iv_myaddr); in isfromds_mcastecho()
518 return (vap->iv_ic->ic_flags & IEEE80211_F_SCAN); in doprint()
539 struct ieee80211vap *vap = ni->ni_vap; in sta_input()
540 struct ieee80211com *ic = ni->ni_ic; in sta_input()
541 struct ifnet *ifp = vap->iv_ifp; in sta_input()
554 type = -1; in sta_input()
557 * Bit of a cheat here, we use a pointer for a 3-address in sta_input()
564 if (m->m_pkthdr.len < 2 || m->m_pkthdr.len < ieee80211_anyhdrsize(wh)) { in sta_input()
566 ni->ni_macaddr, NULL, in sta_input()
567 "too short (1): len %u", m->m_pkthdr.len); in sta_input()
568 vap->iv_stats.is_rx_tooshort++; in sta_input()
573 ni->ni_macaddr, NULL, "wrong version, fc %02x:%02x", in sta_input()
574 wh->i_fc[0], wh->i_fc[1]); in sta_input()
575 vap->iv_stats.is_rx_badversion++; in sta_input()
584 if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_DECRYPTED)) in sta_input()
587 if (m->m_flags & M_AMPDU_MPDU) { in sta_input()
589 * Fastpath for A-MPDU reorder q resubmission. Frames in sta_input()
597 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK; in sta_input()
599 hdrspace = ieee80211_hdrspace(ic, wh); /* XXX optimize? */ in sta_input()
603 ni->ni_inact = ni->ni_inact_reload; in sta_input()
605 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK; in sta_input()
606 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in sta_input()
607 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; in sta_input()
615 (ic->ic_flags & IEEE80211_F_SCAN) == 0) { in sta_input()
616 bssid = wh->i_addr2; in sta_input()
617 if (!IEEE80211_ADDR_EQ(bssid, ni->ni_bssid)) { in sta_input()
621 vap->iv_stats.is_rx_wrongbss++; in sta_input()
626 * Some devices may be in a promiscuous mode in sta_input()
633 * XXX TODO: This is only enforced when not scanning; in sta_input()
634 * XXX it assumes a software-driven scan will put the NIC in sta_input()
635 * XXX into a "no data frames" mode before setting this in sta_input()
636 * XXX flag. Otherwise it may be possible that we'll still in sta_input()
637 * XXX process data frames whilst scanning. in sta_input()
639 if ((! IEEE80211_IS_MULTICAST(wh->i_addr1)) in sta_input()
640 && (! IEEE80211_ADDR_EQ(wh->i_addr1, IF_LLADDR(ifp)))) { in sta_input()
643 IF_LLADDR(ifp), ":", wh->i_addr1, ":"); in sta_input()
644 vap->iv_stats.is_rx_wrongbss++; in sta_input()
648 IEEE80211_RSSI_LPF(ni->ni_avgrssi, rssi); in sta_input()
649 ni->ni_noise = nf; in sta_input()
651 !IEEE80211_IS_MULTICAST(wh->i_addr1)) { in sta_input()
655 ic->ic_wme.wme_hipri_traffic++; in sta_input()
664 if (m->m_len < hdrspace && in sta_input()
667 ni->ni_macaddr, NULL, in sta_input()
669 vap->iv_stats.is_rx_tooshort++; in sta_input()
670 goto out; /* XXX */ in sta_input()
673 * Handle A-MPDU re-ordering. If the frame is to be in sta_input()
678 if ((m->m_flags & M_AMPDU) && in sta_input()
687 if ((ifp->if_flags & IFF_SIMPLEX) && in sta_input()
697 vap->iv_stats.is_rx_mcastecho++; in sta_input()
700 if ((vap->iv_flags & IEEE80211_F_DWDS) && in sta_input()
701 IEEE80211_IS_MULTICAST(wh->i_addr1)) { in sta_input()
703 * DWDS sta's must drop 3-address mcast frames in sta_input()
704 * as they will be sent separately as a 4-addr in sta_input()
705 * frame. Accepting the 3-addr frame will in sta_input()
710 "3-address data", "%s", "DWDS enabled"); in sta_input()
711 vap->iv_stats.is_rx_mcastecho++; in sta_input()
715 if ((vap->iv_flags & IEEE80211_F_DWDS) == 0) { in sta_input()
717 IEEE80211_MSG_INPUT, wh, "4-address data", in sta_input()
719 vap->iv_stats.is_rx_wrongdir++; in sta_input()
722 if ((ifp->if_flags & IFF_SIMPLEX) && in sta_input()
731 "4-address data", "%s", "multicast echo"); in sta_input()
732 vap->iv_stats.is_rx_mcastecho++; in sta_input()
738 vap->iv_stats.is_rx_wrongdir++; in sta_input()
749 * ieee80211_crypto_decap() - none of the key in sta_input()
753 * MIC failure up to the stack - but we don't know in sta_input()
766 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { in sta_input()
772 vap->iv_stats.is_rx_noprivacy++; in sta_input()
782 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; in sta_input()
785 /* XXX M_WEP and IEEE80211_F_PRIVACY */ in sta_input()
790 * Save QoS bits for use below--before we strip the header. in sta_input()
800 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in sta_input()
819 ni->ni_macaddr, "data", "%s", "demic error"); in sta_input()
820 vap->iv_stats.is_rx_demicfail++; in sta_input()
835 /* XXX mask bit to check for both */ in sta_input()
841 ni->ni_macaddr, "data", "%s", "decap error"); in sta_input()
842 vap->iv_stats.is_rx_decap++; in sta_input()
852 * Deny any non-PAE frames received prior to in sta_input()
853 * authorization. For open/shared-key in sta_input()
860 eh->ether_type != htons(ETHERTYPE_PAE)) { in sta_input()
862 ni->ni_macaddr, "data", "unauthorized or " in sta_input()
864 eh == NULL ? -1 : eh->ether_type, in sta_input()
865 m->m_pkthdr.len); in sta_input()
866 vap->iv_stats.is_rx_unauth++; in sta_input()
873 * any non-PAE frames received without encryption. in sta_input()
875 if ((vap->iv_flags & IEEE80211_F_DROPUNENC) && in sta_input()
876 ((has_decrypted == 0) && (m->m_flags & M_WEP) == 0) && in sta_input()
879 eh->ether_type != htons(ETHERTYPE_PAE))) { in sta_input()
883 vap->iv_stats.is_rx_unencrypted++; in sta_input()
888 /* XXX require HT? */ in sta_input()
904 vap->iv_stats.is_rx_mgmt++; in sta_input()
909 vap->iv_stats.is_rx_wrongdir++; in sta_input()
912 if (m->m_pkthdr.len < sizeof(struct ieee80211_frame)) { in sta_input()
914 ni->ni_macaddr, "mgt", "too short: len %u", in sta_input()
915 m->m_pkthdr.len); in sta_input()
916 vap->iv_stats.is_rx_tooshort++; in sta_input()
924 ether_sprintf(wh->i_addr2), rssi); in sta_input()
946 vap->iv_stats.is_rx_mgtdiscard++; /* XXX */ in sta_input()
949 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { in sta_input()
955 vap->iv_stats.is_rx_noprivacy++; in sta_input()
970 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; in sta_input()
972 vap->iv_recv_mgmt(ni, m, subtype, rxs, rssi, nf); in sta_input()
976 vap->iv_stats.is_rx_ctl++; in sta_input()
978 vap->iv_recv_ctl(ni, m, subtype); in sta_input()
1002 struct ieee80211vap *vap = ni->ni_vap; in sta_auth_open()
1004 if (ni->ni_authmode == IEEE80211_AUTH_SHARED) { in sta_auth_open()
1006 ni->ni_macaddr, "open auth", in sta_auth_open()
1007 "bad sta auth mode %u", ni->ni_authmode); in sta_auth_open()
1008 vap->iv_stats.is_rx_bad_auth++; /* XXX */ in sta_auth_open()
1011 if (vap->iv_state != IEEE80211_S_AUTH || in sta_auth_open()
1013 vap->iv_stats.is_rx_bad_auth++; in sta_auth_open()
1019 vap->iv_stats.is_rx_auth_fail++; in sta_auth_open()
1020 vap->iv_stats.is_rx_authfail_code = status; in sta_auth_open()
1032 struct ieee80211vap *vap = ni->ni_vap; in sta_auth_shared()
1036 * NB: this can happen as we allow pre-shared key in sta_auth_shared()
1043 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { in sta_auth_shared()
1045 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1050 * Pre-shared key authentication is evil; accept in sta_auth_shared()
1054 if (ni->ni_authmode != IEEE80211_AUTH_AUTO && in sta_auth_shared()
1055 ni->ni_authmode != IEEE80211_AUTH_SHARED) { in sta_auth_shared()
1057 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1058 "bad sta auth mode %u", ni->ni_authmode); in sta_auth_shared()
1059 vap->iv_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */ in sta_auth_shared()
1065 if ((frm[1] + 2) > (efrm - frm)) { in sta_auth_shared()
1067 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1069 frm[0], (frm[1] + 2) - (efrm - frm)); in sta_auth_shared()
1070 vap->iv_stats.is_rx_bad_auth++; in sta_auth_shared()
1082 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1084 vap->iv_stats.is_rx_bad_auth++; in sta_auth_shared()
1089 ni->ni_macaddr, "shared key auth", in sta_auth_shared()
1091 vap->iv_stats.is_rx_bad_auth++; in sta_auth_shared()
1097 if (vap->iv_state != IEEE80211_S_AUTH) in sta_auth_shared()
1101 if (ni->ni_challenge != NULL) { in sta_auth_shared()
1102 IEEE80211_FREE(ni->ni_challenge, M_80211_NODE); in sta_auth_shared()
1103 ni->ni_challenge = NULL; in sta_auth_shared()
1109 vap->iv_stats.is_rx_auth_fail++; in sta_auth_shared()
1110 vap->iv_stats.is_rx_authfail_code = status; in sta_auth_shared()
1118 /* XXX could optimize by passing recvd challenge */ in sta_auth_shared()
1119 memcpy(ni->ni_challenge, &challenge[2], challenge[1]); in sta_auth_shared()
1126 vap->iv_stats.is_rx_bad_auth++; in sta_auth_shared()
1132 * Kick the state machine. This short-circuits in sta_auth_shared()
1136 if (vap->iv_state == IEEE80211_S_AUTH) in sta_auth_shared()
1142 * Parse the WME IE for QoS and U-APSD information.
1144 * Returns -1 if the IE isn't found, 1 if it's found.
1152 ni->ni_uapsd = 0; in ieee80211_parse_wmeie()
1154 if (len < sizeof(struct ieee80211_wme_param)-2) { in ieee80211_parse_wmeie()
1155 IEEE80211_DISCARD_IE(ni->ni_vap, in ieee80211_parse_wmeie()
1158 return -1; in ieee80211_parse_wmeie()
1161 ni->ni_uapsd = frm[WME_CAPINFO_IE_OFFSET]; in ieee80211_parse_wmeie()
1163 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_POWER | IEEE80211_MSG_ASSOC, in ieee80211_parse_wmeie()
1164 ni, "U-APSD settings from STA: 0x%02x", ni->ni_uapsd); in ieee80211_parse_wmeie()
1173 struct ieee80211_wme_state *wme = &vap->iv_ic->ic_wme; in ieee80211_parse_wmeparams()
1179 if (len < sizeof(struct ieee80211_wme_param)-2) { in ieee80211_parse_wmeparams()
1183 return -1; in ieee80211_parse_wmeparams()
1188 /* XXX do proper check for wraparound */ in ieee80211_parse_wmeparams()
1189 if (qosinfo_count == wme->wme_wmeChanParams.cap_info) in ieee80211_parse_wmeparams()
1194 &wme->wme_wmeChanParams.cap_wmeParams[i]; in ieee80211_parse_wmeparams()
1196 wmep->wmep_acm = _IEEE80211_MASKSHIFT(frm[0], WME_PARAM_ACM); in ieee80211_parse_wmeparams()
1197 wmep->wmep_aifsn = in ieee80211_parse_wmeparams()
1199 wmep->wmep_logcwmin = in ieee80211_parse_wmeparams()
1201 wmep->wmep_logcwmax = in ieee80211_parse_wmeparams()
1203 wmep->wmep_txopLimit = le16dec(frm+2); in ieee80211_parse_wmeparams()
1208 wmep->wmep_acm, in ieee80211_parse_wmeparams()
1209 wmep->wmep_aifsn, in ieee80211_parse_wmeparams()
1210 wmep->wmep_logcwmin, in ieee80211_parse_wmeparams()
1211 wmep->wmep_logcwmax, in ieee80211_parse_wmeparams()
1212 wmep->wmep_txopLimit); in ieee80211_parse_wmeparams()
1215 wme->wme_wmeChanParams.cap_info = qosinfo_count; in ieee80211_parse_wmeparams()
1223 * XXX should be public for IBSS use
1229 struct ieee80211com *ic = vap->iv_ic; in ieee80211_parse_csaparams()
1233 KASSERT(vap->iv_state >= IEEE80211_S_RUN, in ieee80211_parse_csaparams()
1234 ("state %s", ieee80211_state_name[vap->iv_state])); in ieee80211_parse_csaparams()
1236 if (csa->csa_mode > 1) { in ieee80211_parse_csaparams()
1239 wh, "CSA", "invalid mode %u", csa->csa_mode); in ieee80211_parse_csaparams()
1243 if ((ic->ic_flags & IEEE80211_F_CSAPENDING) == 0) { in ieee80211_parse_csaparams()
1255 ieee80211_find_channel_byieee(ic, csa->csa_newchan, in ieee80211_parse_csaparams()
1256 (ic->ic_bsschan->ic_flags & IEEE80211_CHAN_ALLTURBO)); in ieee80211_parse_csaparams()
1259 csa->csa_newchan, in ieee80211_parse_csaparams()
1260 (ic->ic_bsschan->ic_flags & IEEE80211_CHAN_ALL)); in ieee80211_parse_csaparams()
1265 csa->csa_newchan); in ieee80211_parse_csaparams()
1270 if (csa->csa_count < IEEE80211_CSA_COUNT_MIN) { in ieee80211_parse_csaparams()
1285 csa->csa_count, IEEE80211_CSA_COUNT_MIN); in ieee80211_parse_csaparams()
1289 ieee80211_csa_startswitch(ic, c, csa->csa_mode, csa->csa_count); in ieee80211_parse_csaparams()
1293 * mode and channel not change and the count must be in ieee80211_parse_csaparams()
1300 * XXX may want <= on count as we also process ProbeResp in ieee80211_parse_csaparams()
1303 * count until we add a dead-man timer in ieee80211_parse_csaparams()
1305 if (!(csa->csa_count < ic->ic_csa_count && in ieee80211_parse_csaparams()
1306 csa->csa_mode == ic->ic_csa_mode && in ieee80211_parse_csaparams()
1307 csa->csa_newchan == ieee80211_chan2ieee(ic, ic->ic_csa_newchan))) { in ieee80211_parse_csaparams()
1310 "this ie <%d,%d,%d>", ic->ic_csa_mode, in ieee80211_parse_csaparams()
1311 ic->ic_csa_newchan, ic->ic_csa_count, in ieee80211_parse_csaparams()
1312 csa->csa_mode, csa->csa_newchan, csa->csa_count); in ieee80211_parse_csaparams()
1315 if (csa->csa_count <= 1) in ieee80211_parse_csaparams()
1318 ic->ic_csa_count = csa->csa_count; in ieee80211_parse_csaparams()
1326 * Return non-zero if a background scan may be continued:
1330 * o no full-offload scan support (no need for explicitly continuing scan then)
1340 struct ieee80211com *ic = vap->iv_ic; in contbgscan()
1342 return ((ic->ic_flags_ext & IEEE80211_FEXT_BGSCAN) && in contbgscan()
1343 (ic->ic_flags & IEEE80211_F_CSAPENDING) == 0 && in contbgscan()
1344 !(vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) && in contbgscan()
1345 vap->iv_state == IEEE80211_S_RUN && /* XXX? */ in contbgscan()
1346 ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle)); in contbgscan()
1350 * Return non-zero if a backgrond scan may be started:
1355 * o there has not been any traffic recently (don't check if full-offload scan)
1360 struct ieee80211com *ic = vap->iv_ic; in startbgscan()
1362 return ((vap->iv_flags & IEEE80211_F_BGSCAN) && in startbgscan()
1363 (ic->ic_flags & IEEE80211_F_CSAPENDING) == 0 && in startbgscan()
1365 !IEEE80211_IS_CHAN_DTURBO(ic->ic_curchan) && in startbgscan()
1367 ieee80211_time_after(ticks, ic->ic_lastscan + vap->iv_bgscanintvl) && in startbgscan()
1368 ((vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) || in startbgscan()
1369 ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle))); in startbgscan()
1376 * The tbttcount isnt checked - that's not part of the configuration.
1383 if (q1->period != q2->period) in compare_quiet_ie()
1385 if (le16dec(&q1->duration) != le16dec(&q2->duration)) in compare_quiet_ie()
1387 if (le16dec(&q1->offset) != le16dec(&q2->offset)) in compare_quiet_ie()
1399 struct ieee80211vap *vap = ni->ni_vap; in sta_recv_mgmt()
1400 struct ieee80211com *ic = ni->ni_ic; in sta_recv_mgmt()
1401 struct ieee80211_channel *rxchan = ic->ic_curchan; in sta_recv_mgmt()
1412 efrm = mtod(m0, uint8_t *) + m0->m_len; in sta_recv_mgmt()
1421 * o station mode when associated (to collect state in sta_recv_mgmt()
1425 if (!((ic->ic_flags & IEEE80211_F_SCAN) || ni->ni_associd)) { in sta_recv_mgmt()
1426 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1437 /* XXX probe response in sta mode when !scanning? */ in sta_recv_mgmt()
1439 if (! (ic->ic_flags & IEEE80211_F_SCAN)) in sta_recv_mgmt()
1440 vap->iv_stats.is_beacon_bad++; in sta_recv_mgmt()
1448 vap->iv_stats.is_rx_beacon++; /* XXX remove */ in sta_recv_mgmt()
1453 * When operating in station mode, check for state updates. in sta_recv_mgmt()
1457 if (ni->ni_associd != 0 && in sta_recv_mgmt()
1458 ((ic->ic_flags & IEEE80211_F_SCAN) == 0 || in sta_recv_mgmt()
1459 IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_bssid))) { in sta_recv_mgmt()
1461 memcpy(ni->ni_tstamp.data, scan.tstamp, in sta_recv_mgmt()
1462 sizeof(ni->ni_tstamp)); in sta_recv_mgmt()
1464 vap->iv_swbmiss_count++; in sta_recv_mgmt()
1465 vap->iv_bmiss_count = 0; in sta_recv_mgmt()
1466 if (ni->ni_erp != scan.erp) { in sta_recv_mgmt()
1468 wh->i_addr2, in sta_recv_mgmt()
1470 ni->ni_erp, scan.erp); in sta_recv_mgmt()
1471 if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan) && in sta_recv_mgmt()
1472 (ni->ni_erp & IEEE80211_ERP_USE_PROTECTION)) in sta_recv_mgmt()
1473 vap->iv_flags |= IEEE80211_F_USEPROT; in sta_recv_mgmt()
1475 vap->iv_flags &= ~IEEE80211_F_USEPROT; in sta_recv_mgmt()
1476 ni->ni_erp = scan.erp; in sta_recv_mgmt()
1477 /* XXX statistic */ in sta_recv_mgmt()
1481 if ((ni->ni_capinfo ^ scan.capinfo) & IEEE80211_CAPINFO_SHORT_SLOTTIME) { in sta_recv_mgmt()
1483 wh->i_addr2, in sta_recv_mgmt()
1485 ni->ni_capinfo, scan.capinfo); in sta_recv_mgmt()
1491 IEEE80211_IS_CHAN_A(ic->ic_bsschan) || in sta_recv_mgmt()
1493 ni->ni_capinfo = (ni->ni_capinfo &~ IEEE80211_CAPINFO_SHORT_SLOTTIME) in sta_recv_mgmt()
1495 /* XXX statistic */ in sta_recv_mgmt()
1498 (ni->ni_flags & IEEE80211_NODE_QOS)) { in sta_recv_mgmt()
1503 ni->ni_flags |= in sta_recv_mgmt()
1509 ni->ni_flags &= ~IEEE80211_NODE_UAPSD; in sta_recv_mgmt()
1515 (vap->iv_flags_ht & IEEE80211_FHT_HT)) { in sta_recv_mgmt()
1516 /* XXX state changes? */ in sta_recv_mgmt()
1522 (vap->iv_vht_flags & IEEE80211_FVHT_VHT)) { in sta_recv_mgmt()
1523 /* XXX state changes? */ in sta_recv_mgmt()
1539 * IE has disappeared - only do that once rather than in sta_recv_mgmt()
1543 ic->ic_set_quiet(ni, scan.quiet); in sta_recv_mgmt()
1544 ni->ni_quiet_ie_set = 1; in sta_recv_mgmt()
1545 memcpy(&ni->ni_quiet_ie, scan.quiet, in sta_recv_mgmt()
1548 if (ni->ni_quiet_ie_set == 1) in sta_recv_mgmt()
1549 ic->ic_set_quiet(ni, NULL); in sta_recv_mgmt()
1550 ni->ni_quiet_ie_set = 0; in sta_recv_mgmt()
1551 bzero(&ni->ni_quiet_ie, in sta_recv_mgmt()
1559 * XXX Check/debug this code; see if it's about in sta_recv_mgmt()
1563 int aid = IEEE80211_AID(ni->ni_associd); in sta_recv_mgmt()
1565 int min = tim->tim_bitctl &~ 1; in sta_recv_mgmt()
1566 int max = tim->tim_len + min - 4; in sta_recv_mgmt()
1579 isset(tim->tim_bitmap - min, aid)) { in sta_recv_mgmt()
1588 if (tim->tim_bitctl & 1) { in sta_recv_mgmt()
1595 * us then get us out of STA mode powersave. in sta_recv_mgmt()
1615 ic->ic_lastdata = ticks; in sta_recv_mgmt()
1618 ni->ni_dtim_count = tim->tim_count; in sta_recv_mgmt()
1619 ni->ni_dtim_period = tim->tim_period; in sta_recv_mgmt()
1622 (vap->iv_flags & IEEE80211_F_DOTH)) in sta_recv_mgmt()
1624 else if (ic->ic_flags & IEEE80211_F_CSAPENDING) { in sta_recv_mgmt()
1640 * turbo phase of dynamic turbo mode. Then, in sta_recv_mgmt()
1646 * return on-channel to receive a beacon from in sta_recv_mgmt()
1649 if (ic->ic_flags & IEEE80211_F_SCAN) { in sta_recv_mgmt()
1655 vap->iv_stats.is_scan_bg++; in sta_recv_mgmt()
1672 * If we've had a channel width change (eg HT20<->HT40) in sta_recv_mgmt()
1682 if (ic->ic_flags & IEEE80211_F_SCAN) { in sta_recv_mgmt()
1683 if (ic->ic_flags_ext & IEEE80211_FEXT_PROBECHAN) { in sta_recv_mgmt()
1689 * XXX check if the beacon we recv'd gives in sta_recv_mgmt()
1693 ic->ic_flags_ext &= ~IEEE80211_FEXT_PROBECHAN; in sta_recv_mgmt()
1711 IEEE80211_VERIFY_LENGTH(efrm - frm, 6, return); in sta_recv_mgmt()
1715 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_AUTH, wh->i_addr2, in sta_recv_mgmt()
1718 if (vap->iv_flags & IEEE80211_F_COUNTERM) { in sta_recv_mgmt()
1722 vap->iv_stats.is_rx_auth_countermeasures++; in sta_recv_mgmt()
1723 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { in sta_recv_mgmt()
1724 ieee80211_send_error(ni, wh->i_addr2, in sta_recv_mgmt()
1738 vap->iv_stats.is_rx_auth_unsupported++; in sta_recv_mgmt()
1749 if (vap->iv_state != IEEE80211_S_ASSOC) { in sta_recv_mgmt()
1750 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1765 IEEE80211_VERIFY_LENGTH(efrm - frm, 6, return); in sta_recv_mgmt()
1766 ni = vap->iv_bss; in sta_recv_mgmt()
1773 wh->i_addr2, "%sassoc failed (reason %d)", in sta_recv_mgmt()
1775 vap->iv_stats.is_rx_auth_fail++; /* XXX */ in sta_recv_mgmt()
1783 while (efrm - frm > 1) { in sta_recv_mgmt()
1784 IEEE80211_VERIFY_LENGTH(efrm - frm, frm[1] + 2, return); in sta_recv_mgmt()
1801 else if (vap->iv_flags_ht & IEEE80211_FHT_HTCOMPAT) { in sta_recv_mgmt()
1803 * Accept pre-draft HT ie's if the in sta_recv_mgmt()
1814 /* XXX Atheros OUI support */ in sta_recv_mgmt()
1829 IEEE80211_RATE_MAXSIZE - rates[1], return); in sta_recv_mgmt()
1836 wh->i_addr2, in sta_recv_mgmt()
1839 vap->iv_stats.is_rx_assoc_norate++; in sta_recv_mgmt()
1845 ni->ni_capinfo = capinfo; in sta_recv_mgmt()
1846 ni->ni_associd = associd; in sta_recv_mgmt()
1847 if (ni->ni_jointime == 0) in sta_recv_mgmt()
1848 ni->ni_jointime = time_uptime; in sta_recv_mgmt()
1851 ni->ni_flags |= IEEE80211_NODE_QOS; in sta_recv_mgmt()
1854 ni->ni_flags &= ~IEEE80211_NODE_QOS; in sta_recv_mgmt()
1863 (vap->iv_flags_ht & IEEE80211_FHT_HT)) { in sta_recv_mgmt()
1868 (vap->iv_vht_flags & IEEE80211_FVHT_VHT)) { in sta_recv_mgmt()
1873 if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) { in sta_recv_mgmt()
1876 ni->ni_macaddr, in sta_recv_mgmt()
1896 * for doing A-MSDU encapsulation as well. in sta_recv_mgmt()
1905 * XXX may need different/additional driver callbacks? in sta_recv_mgmt()
1907 if (IEEE80211_IS_CHAN_A(ic->ic_curchan) || in sta_recv_mgmt()
1908 (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)) { 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()
1912 vap->iv_flags &= ~IEEE80211_F_SHPREAMBLE; in sta_recv_mgmt()
1913 vap->iv_flags |= IEEE80211_F_USEBARKER; in sta_recv_mgmt()
1916 IEEE80211_IS_CHAN_A(ic->ic_curchan) || in sta_recv_mgmt()
1917 (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME)); in sta_recv_mgmt()
1922 * NB: ni_erp should zero for non-11g operation. in sta_recv_mgmt()
1924 if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan) && in sta_recv_mgmt()
1925 (ni->ni_erp & IEEE80211_ERP_USE_PROTECTION)) in sta_recv_mgmt()
1926 vap->iv_flags |= IEEE80211_F_USEPROT; in sta_recv_mgmt()
1928 vap->iv_flags &= ~IEEE80211_F_USEPROT; in sta_recv_mgmt()
1931 IEEE80211_MSG_ASSOC | IEEE80211_MSG_DEBUG, wh->i_addr2, in sta_recv_mgmt()
1935 vap->iv_flags&IEEE80211_F_SHPREAMBLE ? "short" : "long", in sta_recv_mgmt()
1936 vap->iv_flags&IEEE80211_F_SHSLOT ? "short" : "long", in sta_recv_mgmt()
1937 vap->iv_flags&IEEE80211_F_USEPROT ? ", protection" : "", in sta_recv_mgmt()
1938 ni->ni_flags & IEEE80211_NODE_QOS ? ", QoS" : "", in sta_recv_mgmt()
1939 ni->ni_flags & IEEE80211_NODE_HT ? in sta_recv_mgmt()
1940 (ni->ni_chw == IEEE80211_STA_RX_BW_40 ? ", HT40" : ", HT20") : "", in sta_recv_mgmt()
1941 ni->ni_flags & IEEE80211_NODE_AMPDU ? " (+AMPDU)" : "", in sta_recv_mgmt()
1942 ni->ni_flags & IEEE80211_NODE_AMSDU ? " (+AMSDU)" : "", in sta_recv_mgmt()
1943 ni->ni_flags & IEEE80211_NODE_MIMO_RTS ? " (+SMPS-DYN)" : in sta_recv_mgmt()
1944 ni->ni_flags & IEEE80211_NODE_MIMO_PS ? " (+SMPS)" : "", in sta_recv_mgmt()
1945 ni->ni_flags & IEEE80211_NODE_RIFS ? " (+RIFS)" : "", in sta_recv_mgmt()
1947 ", fast-frames" : "", in sta_recv_mgmt()
1958 if (vap->iv_state == IEEE80211_S_SCAN) { in sta_recv_mgmt()
1959 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1962 if (!IEEE80211_ADDR_EQ(wh->i_addr1, vap->iv_myaddr)) { in sta_recv_mgmt()
1963 /* NB: can happen when in promiscuous mode */ in sta_recv_mgmt()
1964 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1972 IEEE80211_VERIFY_LENGTH(efrm - frm, 2, return); in sta_recv_mgmt()
1975 vap->iv_stats.is_rx_deauth++; in sta_recv_mgmt()
1976 vap->iv_stats.is_rx_deauth_code = reason; in sta_recv_mgmt()
1990 if (vap->iv_state != IEEE80211_S_RUN && in sta_recv_mgmt()
1991 vap->iv_state != IEEE80211_S_ASSOC && in sta_recv_mgmt()
1992 vap->iv_state != IEEE80211_S_AUTH) { in sta_recv_mgmt()
1993 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
1996 if (!IEEE80211_ADDR_EQ(wh->i_addr1, vap->iv_myaddr)) { in sta_recv_mgmt()
1997 /* NB: can happen when in promiscuous mode */ in sta_recv_mgmt()
1998 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
2006 IEEE80211_VERIFY_LENGTH(efrm - frm, 2, return); in sta_recv_mgmt()
2009 vap->iv_stats.is_rx_disassoc++; in sta_recv_mgmt()
2010 vap->iv_stats.is_rx_disassoc_code = reason; in sta_recv_mgmt()
2022 if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr1) && in sta_recv_mgmt()
2023 !IEEE80211_IS_MULTICAST(wh->i_addr1)) { in sta_recv_mgmt()
2026 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
2027 } else if (vap->iv_state != IEEE80211_S_RUN) { in sta_recv_mgmt()
2030 ieee80211_state_name[vap->iv_state]); in sta_recv_mgmt()
2031 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
2034 (void)ic->ic_recv_action(ni, wh, frm, efrm); in sta_recv_mgmt()
2045 vap->iv_stats.is_rx_mgtdiscard++; in sta_recv_mgmt()
2051 vap->iv_stats.is_rx_badsubtype++; in sta_recv_mgmt()