Lines Matching refs:hapd

45 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid)  in hostapd_eid_supp_rates()  argument
50 if (hapd->iface->current_rates == NULL) in hostapd_eid_supp_rates()
54 num = hapd->iface->num_rates; in hostapd_eid_supp_rates()
55 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) in hostapd_eid_supp_rates()
57 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) in hostapd_eid_supp_rates()
66 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num; in hostapd_eid_supp_rates()
69 *pos = hapd->iface->current_rates[i].rate / 5; in hostapd_eid_supp_rates()
70 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC) in hostapd_eid_supp_rates()
75 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht && count < 8) { in hostapd_eid_supp_rates()
80 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht && count < 8) { in hostapd_eid_supp_rates()
89 u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid) in hostapd_eid_ext_supp_rates() argument
94 if (hapd->iface->current_rates == NULL) in hostapd_eid_ext_supp_rates()
97 num = hapd->iface->num_rates; in hostapd_eid_ext_supp_rates()
98 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) in hostapd_eid_ext_supp_rates()
100 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) in hostapd_eid_ext_supp_rates()
108 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num + 8; in hostapd_eid_ext_supp_rates()
113 *pos = hapd->iface->current_rates[i].rate / 5; in hostapd_eid_ext_supp_rates()
114 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC) in hostapd_eid_ext_supp_rates()
119 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) { in hostapd_eid_ext_supp_rates()
125 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) { in hostapd_eid_ext_supp_rates()
135 u16 hostapd_own_capab_info(struct hostapd_data *hapd) in hostapd_own_capab_info() argument
142 dfs = hostapd_is_dfs_required(hapd->iface); in hostapd_own_capab_info()
149 if (hapd->iface->num_sta_no_short_preamble == 0 && in hostapd_own_capab_info()
150 hapd->iconf->preamble == SHORT_PREAMBLE) in hostapd_own_capab_info()
153 privacy = hapd->conf->ssid.wep.keys_set; in hostapd_own_capab_info()
155 if (hapd->conf->ieee802_1x && in hostapd_own_capab_info()
156 (hapd->conf->default_wep_key_len || in hostapd_own_capab_info()
157 hapd->conf->individual_wep_key_len)) in hostapd_own_capab_info()
160 if (hapd->conf->wpa) in hostapd_own_capab_info()
164 if (hapd->conf->osen) in hostapd_own_capab_info()
171 if (hapd->iface->current_mode && in hostapd_own_capab_info()
172 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G && in hostapd_own_capab_info()
173 hapd->iface->num_sta_no_short_slot_time == 0) in hostapd_own_capab_info()
182 if (hapd->iface->current_mode && in hostapd_own_capab_info()
183 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && in hostapd_own_capab_info()
184 (hapd->iconf->spectrum_mgmt_required || dfs)) in hostapd_own_capab_info()
187 if (hapd->conf->radio_measurements) in hostapd_own_capab_info()
194 static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta, in auth_shared_key() argument
198 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in auth_shared_key()
230 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in auth_shared_key()
237 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in auth_shared_key()
249 static void send_auth_reply(struct hostapd_data *hapd, in send_auth_reply() argument
267 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN); in send_auth_reply()
281 if (hostapd_drv_send_mlme(hapd, reply, rlen, 0) < 0) in send_auth_reply()
293 struct hostapd_data *hapd = ctx; in handle_auth_ft_finish() local
296 send_auth_reply(hapd, dst, bssid, WLAN_AUTH_FT, auth_transaction, in handle_auth_ft_finish()
302 sta = ap_get_sta(hapd, dst); in handle_auth_ft_finish()
306 hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211, in handle_auth_ft_finish()
309 mlme_authenticate_indication(hapd, sta); in handle_auth_ft_finish()
320 static struct wpabuf * auth_build_sae_commit(struct hostapd_data *hapd, in auth_build_sae_commit() argument
325 if (hapd->conf->ssid.wpa_passphrase == NULL) { in auth_build_sae_commit()
331 sae_prepare_commit(hapd->own_addr, sta->addr, in auth_build_sae_commit()
332 (u8 *) hapd->conf->ssid.wpa_passphrase, in auth_build_sae_commit()
333 os_strlen(hapd->conf->ssid.wpa_passphrase), in auth_build_sae_commit()
349 static struct wpabuf * auth_build_sae_confirm(struct hostapd_data *hapd, in auth_build_sae_confirm() argument
364 static int auth_sae_send_commit(struct hostapd_data *hapd, in auth_sae_send_commit() argument
370 data = auth_build_sae_commit(hapd, sta, update); in auth_sae_send_commit()
374 send_auth_reply(hapd, sta->addr, bssid, in auth_sae_send_commit()
384 static int auth_sae_send_confirm(struct hostapd_data *hapd, in auth_sae_send_confirm() argument
390 data = auth_build_sae_confirm(hapd, sta); in auth_sae_send_confirm()
394 send_auth_reply(hapd, sta->addr, bssid, in auth_sae_send_confirm()
404 static int use_sae_anti_clogging(struct hostapd_data *hapd) in use_sae_anti_clogging() argument
409 if (hapd->conf->sae_anti_clogging_threshold == 0) in use_sae_anti_clogging()
412 for (sta = hapd->sta_list; sta; sta = sta->next) { in use_sae_anti_clogging()
419 if (open >= hapd->conf->sae_anti_clogging_threshold) in use_sae_anti_clogging()
427 static int check_sae_token(struct hostapd_data *hapd, const u8 *addr, in check_sae_token() argument
434 if (hmac_sha256(hapd->sae_token_key, sizeof(hapd->sae_token_key), in check_sae_token()
443 static struct wpabuf * auth_build_token_req(struct hostapd_data *hapd, in auth_build_token_req() argument
451 if (!os_reltime_initialized(&hapd->last_sae_token_key_update) || in auth_build_token_req()
452 os_reltime_expired(&now, &hapd->last_sae_token_key_update, 60)) { in auth_build_token_req()
453 if (random_get_bytes(hapd->sae_token_key, in auth_build_token_req()
454 sizeof(hapd->sae_token_key)) < 0) in auth_build_token_req()
457 hapd->sae_token_key, sizeof(hapd->sae_token_key)); in auth_build_token_req()
458 hapd->last_sae_token_key_update = now; in auth_build_token_req()
468 hmac_sha256(hapd->sae_token_key, sizeof(hapd->sae_token_key), in auth_build_token_req()
488 struct hostapd_data *hapd = eloop_ctx; in auth_sae_retransmit_timer() local
498 ret = auth_sae_send_commit(hapd, sta, hapd->own_addr, 0); in auth_sae_retransmit_timer()
500 auth_sae_retransmit_timer, hapd, sta); in auth_sae_retransmit_timer()
503 ret = auth_sae_send_confirm(hapd, sta, hapd->own_addr); in auth_sae_retransmit_timer()
505 auth_sae_retransmit_timer, hapd, sta); in auth_sae_retransmit_timer()
517 void sae_clear_retransmit_timer(struct hostapd_data *hapd, struct sta_info *sta) in sae_clear_retransmit_timer() argument
519 eloop_cancel_timeout(auth_sae_retransmit_timer, hapd, sta); in sae_clear_retransmit_timer()
523 static void sae_set_retransmit_timer(struct hostapd_data *hapd, in sae_set_retransmit_timer() argument
526 if (!(hapd->conf->mesh & MESH_ENABLED)) in sae_set_retransmit_timer()
529 eloop_cancel_timeout(auth_sae_retransmit_timer, hapd, sta); in sae_set_retransmit_timer()
531 auth_sae_retransmit_timer, hapd, sta); in sae_set_retransmit_timer()
535 static int sae_sm_step(struct hostapd_data *hapd, struct sta_info *sta, in sae_sm_step() argument
546 ret = auth_sae_send_commit(hapd, sta, bssid, 1); in sae_sm_step()
562 if (hapd->conf->mesh & MESH_ENABLED) { in sae_sm_step()
568 ret = auth_sae_send_confirm(hapd, sta, bssid); in sae_sm_step()
583 sae_set_retransmit_timer(hapd, sta); in sae_sm_step()
585 hostapd_logger(hapd, sta->addr, in sae_sm_step()
592 sae_clear_retransmit_timer(hapd, sta); in sae_sm_step()
597 ret = auth_sae_send_confirm(hapd, sta, bssid); in sae_sm_step()
602 sae_set_retransmit_timer(hapd, sta); in sae_sm_step()
603 } else if (hapd->conf->mesh & MESH_ENABLED) { in sae_sm_step()
612 ret = auth_sae_send_commit(hapd, sta, bssid, 0); in sae_sm_step()
616 sae_set_retransmit_timer(hapd, sta); in sae_sm_step()
623 ret = auth_sae_send_confirm(hapd, sta, bssid); in sae_sm_step()
634 return sae_sm_step(hapd, sta, bssid, auth_transaction); in sae_sm_step()
638 sae_clear_retransmit_timer(hapd, sta); in sae_sm_step()
644 ret = auth_sae_send_commit(hapd, sta, bssid, 1); in sae_sm_step()
651 ret = auth_sae_send_confirm(hapd, sta, bssid); in sae_sm_step()
655 sae_set_retransmit_timer(hapd, sta); in sae_sm_step()
659 mlme_authenticate_indication(hapd, sta); in sae_sm_step()
662 wpa_auth_pmksa_add_sae(hapd->wpa_auth, sta->addr, in sae_sm_step()
671 ap_free_sta(hapd, sta); in sae_sm_step()
677 ret = auth_sae_send_confirm(hapd, sta, bssid); in sae_sm_step()
692 static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta, in handle_auth_sae() argument
712 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_auth_sae()
717 if ((hapd->conf->mesh & MESH_ENABLED) && in handle_auth_sae()
729 hapd->conf->sae_groups, in handle_auth_sae()
754 if (auth_sae_send_commit(hapd, sta, mgmt->bssid, 0)) { in handle_auth_sae()
761 sae_set_retransmit_timer(hapd, sta); in handle_auth_sae()
771 &token_len, hapd->conf->sae_groups); in handle_auth_sae()
778 if (token && check_sae_token(hapd, sta->addr, token, token_len) in handle_auth_sae()
789 if (!token && use_sae_anti_clogging(hapd)) { in handle_auth_sae()
793 data = auth_build_token_req(hapd, sta->sae->group, in handle_auth_sae()
796 if (hapd->conf->mesh & MESH_ENABLED) in handle_auth_sae()
801 resp = sae_sm_step(hapd, sta, mgmt->bssid, auth_transaction); in handle_auth_sae()
803 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_auth_sae()
810 !(hapd->conf->mesh & MESH_ENABLED)) { in handle_auth_sae()
818 resp = sae_sm_step(hapd, sta, mgmt->bssid, auth_transaction); in handle_auth_sae()
820 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_auth_sae()
831 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, WLAN_AUTH_SAE, in handle_auth_sae()
850 int auth_sae_init_committed(struct hostapd_data *hapd, struct sta_info *sta) in auth_sae_init_committed() argument
860 ret = auth_sae_send_commit(hapd, sta, hapd->own_addr, 0); in auth_sae_init_committed()
866 sae_set_retransmit_timer(hapd, sta); in auth_sae_init_committed()
874 static void handle_auth(struct hostapd_data *hapd, in handle_auth() argument
899 if (hapd->iconf->ignore_auth_probability > 0.0 && in handle_auth()
900 drand48() < hapd->iconf->ignore_auth_probability) { in handle_auth()
928 if (hapd->tkip_countermeasures) { in handle_auth()
933 if (!(((hapd->conf->auth_algs & WPA_AUTH_ALG_OPEN) && in handle_auth()
936 (hapd->conf->wpa && wpa_key_mgmt_ft(hapd->conf->wpa_key_mgmt) && in handle_auth()
940 (hapd->conf->wpa && wpa_key_mgmt_sae(hapd->conf->wpa_key_mgmt) && in handle_auth()
943 ((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) && in handle_auth()
959 if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) { in handle_auth()
966 res = hostapd_allowed_address(hapd, mgmt->sa, (u8 *) mgmt, len, in handle_auth()
987 sta = ap_get_sta(hapd, mgmt->sa); in handle_auth()
993 hostapd_logger(hapd, sta->addr, in handle_auth()
1002 if (hapd->conf->mesh & MESH_ENABLED) { in handle_auth()
1012 wpabuf_free(hapd->mesh_pending_auth); in handle_auth()
1013 hapd->mesh_pending_auth = wpabuf_alloc_copy(mgmt, len); in handle_auth()
1014 os_get_reltime(&hapd->mesh_pending_auth_time); in handle_auth()
1019 sta = ap_sta_add(hapd, mgmt->sa); in handle_auth()
1029 if (!hostapd_vlan_id_valid(hapd->conf->vlan, vlan_id)) { in handle_auth()
1030 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS, in handle_auth()
1038 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS, in handle_auth()
1043 if (hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) { in handle_auth()
1058 if (hapd->conf->acct_interim_interval == 0 && acct_interim_interval) in handle_auth()
1061 ap_sta_session_timeout(hapd, sta, session_timeout); in handle_auth()
1063 ap_sta_no_session_timeout(hapd, sta); in handle_auth()
1067 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_auth()
1073 mlme_authenticate_indication(hapd, sta); in handle_auth()
1076 resp = auth_shared_key(hapd, sta, auth_transaction, challenge, in handle_auth()
1079 mlme_authenticate_indication(hapd, sta); in handle_auth()
1092 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, in handle_auth()
1104 handle_auth_ft_finish, hapd); in handle_auth()
1112 hapd->conf->mesh & MESH_ENABLED) { in handle_auth()
1115 wpa_auth_sta_init(hapd->wpa_auth, in handle_auth()
1125 handle_auth_sae(hapd, sta, mgmt, len, auth_transaction, in handle_auth()
1136 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, auth_alg, in handle_auth()
1141 static int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta) in hostapd_get_aid() argument
1152 if (hapd->sta_aid[i] == (u32) -1) in hostapd_get_aid()
1155 if (!(hapd->sta_aid[i] & BIT(j))) in hostapd_get_aid()
1168 hapd->sta_aid[i] |= BIT(j); in hostapd_get_aid()
1174 static u16 check_ssid(struct hostapd_data *hapd, struct sta_info *sta, in check_ssid() argument
1180 if (ssid_ie_len != hapd->conf->ssid.ssid_len || in check_ssid()
1181 os_memcmp(ssid_ie, hapd->conf->ssid.ssid, ssid_ie_len) != 0) { in check_ssid()
1182 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in check_ssid()
1193 static u16 check_wmm(struct hostapd_data *hapd, struct sta_info *sta, in check_wmm() argument
1198 if (wmm_ie && hapd->conf->wmm_enabled) { in check_wmm()
1201 if (!hostapd_eid_wmm_valid(hapd, wmm_ie, wmm_ie_len)) { in check_wmm()
1202 hostapd_logger(hapd, sta->addr, in check_wmm()
1218 static u16 copy_supp_rates(struct hostapd_data *hapd, struct sta_info *sta, in copy_supp_rates() argument
1222 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in copy_supp_rates()
1230 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in copy_supp_rates()
1247 static u16 check_ext_capab(struct hostapd_data *hapd, struct sta_info *sta, in check_ext_capab() argument
1262 static u16 check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta, in check_assoc_ies() argument
1272 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in check_assoc_ies()
1278 resp = check_ssid(hapd, sta, elems.ssid, elems.ssid_len); in check_assoc_ies()
1281 resp = check_wmm(hapd, sta, elems.wmm, elems.wmm_len); in check_assoc_ies()
1284 resp = check_ext_capab(hapd, sta, elems.ext_capab, elems.ext_capab_len); in check_assoc_ies()
1287 resp = copy_supp_rates(hapd, sta, &elems); in check_assoc_ies()
1291 resp = copy_sta_ht_capab(hapd, sta, elems.ht_capabilities); in check_assoc_ies()
1294 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht && in check_assoc_ies()
1296 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in check_assoc_ies()
1304 resp = copy_sta_vht_capab(hapd, sta, elems.vht_capabilities); in check_assoc_ies()
1308 resp = set_sta_vht_opmode(hapd, sta, elems.vht_opmode_notif); in check_assoc_ies()
1312 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht && in check_assoc_ies()
1314 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in check_assoc_ies()
1320 if (hapd->conf->vendor_vht && !elems.vht_capabilities) { in check_assoc_ies()
1321 resp = copy_sta_vendor_vht(hapd, sta, elems.vendor_vht, in check_assoc_ies()
1341 if ((hapd->conf->wpa & WPA_PROTO_RSN) && elems.rsn_ie) { in check_assoc_ies()
1344 } else if ((hapd->conf->wpa & WPA_PROTO_WPA) && in check_assoc_ies()
1355 if (hapd->conf->wps_state && elems.wps_ie) { in check_assoc_ies()
1373 } else if (hapd->conf->wps_state && wpa_ie == NULL) { in check_assoc_ies()
1379 if (hapd->conf->wpa && wpa_ie == NULL) { in check_assoc_ies()
1380 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in check_assoc_ies()
1386 if (hapd->conf->wpa && wpa_ie) { in check_assoc_ies()
1391 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, in check_assoc_ies()
1399 res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm, in check_assoc_ies()
1425 ap_check_sa_query_timeout(hapd, sta); in check_assoc_ies()
1436 ap_sta_start_sa_query(hapd, sta); in check_assoc_ies()
1491 hostapd_logger(hapd, sta->addr, in check_assoc_ies()
1500 } else if (hapd->conf->osen) { in check_assoc_ies()
1503 hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in check_assoc_ies()
1511 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, in check_assoc_ies()
1518 if (wpa_validate_osen(hapd->wpa_auth, sta->wpa_sm, in check_assoc_ies()
1526 p2p_group_notif_assoc(hapd->p2p_group, sta->addr, ies, ies_len); in check_assoc_ies()
1542 static void send_deauth(struct hostapd_data *hapd, const u8 *addr, in send_deauth() argument
1552 os_memcpy(reply.sa, hapd->own_addr, ETH_ALEN); in send_deauth()
1553 os_memcpy(reply.bssid, hapd->own_addr, ETH_ALEN); in send_deauth()
1558 if (hostapd_drv_send_mlme(hapd, &reply, send_len, 0) < 0) in send_deauth()
1564 static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta, in send_assoc_resp() argument
1580 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN); in send_assoc_resp()
1581 os_memcpy(reply->bssid, hapd->own_addr, ETH_ALEN); in send_assoc_resp()
1586 host_to_le16(hostapd_own_capab_info(hapd)); in send_assoc_resp()
1590 p = hostapd_eid_supp_rates(hapd, reply->u.assoc_resp.variable); in send_assoc_resp()
1592 p = hostapd_eid_ext_supp_rates(hapd, p); in send_assoc_resp()
1606 p = hostapd_eid_assoc_comeback_time(hapd, sta, p); in send_assoc_resp()
1610 p = hostapd_eid_ht_capabilities(hapd, p); in send_assoc_resp()
1611 p = hostapd_eid_ht_operation(hapd, p); in send_assoc_resp()
1615 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) { in send_assoc_resp()
1616 p = hostapd_eid_vht_capabilities(hapd, p); in send_assoc_resp()
1617 p = hostapd_eid_vht_operation(hapd, p); in send_assoc_resp()
1621 p = hostapd_eid_ext_capab(hapd, p); in send_assoc_resp()
1622 p = hostapd_eid_bss_max_idle_period(hapd, p); in send_assoc_resp()
1624 p = hostapd_eid_qos_map_set(hapd, p); in send_assoc_resp()
1627 if (hapd->conf->vendor_vht && (sta->flags & WLAN_STA_VENDOR_VHT)) in send_assoc_resp()
1628 p = hostapd_eid_vendor_vht(hapd, p); in send_assoc_resp()
1632 p = hostapd_eid_wmm(hapd, p); in send_assoc_resp()
1636 ((sta->flags & WLAN_STA_MAYBE_WPS) && hapd->conf->wpa)) { in send_assoc_resp()
1661 p2p_resp_ie = p2p_group_assoc_resp_ie(hapd->p2p_group, status); in send_assoc_resp()
1672 if (hapd->conf->p2p & P2P_MANAGE) in send_assoc_resp()
1673 p = hostapd_eid_p2p_manage(hapd, p); in send_assoc_resp()
1678 if (hostapd_drv_send_mlme(hapd, reply, send_len, 0) < 0) in send_assoc_resp()
1684 static void handle_assoc(struct hostapd_data *hapd, in handle_assoc() argument
1703 if (hapd->iconf->ignore_reassoc_probability > 0.0 && in handle_assoc()
1704 drand48() < hapd->iconf->ignore_reassoc_probability) { in handle_assoc()
1711 if (hapd->iconf->ignore_assoc_probability > 0.0 && in handle_assoc()
1712 drand48() < hapd->iconf->ignore_assoc_probability) { in handle_assoc()
1749 sta = ap_get_sta(hapd, mgmt->sa); in handle_assoc()
1759 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, in handle_assoc()
1765 send_deauth(hapd, mgmt->sa, in handle_assoc()
1775 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_assoc()
1785 if (hapd->tkip_countermeasures) { in handle_assoc()
1790 if (listen_interval > hapd->conf->max_listen_interval) { in handle_assoc()
1791 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, in handle_assoc()
1801 resp = check_assoc_ies(hapd, sta, pos, left, reassoc); in handle_assoc()
1805 if (hostapd_get_aid(hapd, sta) < 0) { in handle_assoc()
1806 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, in handle_assoc()
1815 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) in handle_assoc()
1825 hapd->iface->num_sta_non_erp++; in handle_assoc()
1826 if (hapd->iface->num_sta_non_erp == 1) in handle_assoc()
1827 ieee802_11_set_beacons(hapd->iface); in handle_assoc()
1833 hapd->iface->num_sta_no_short_slot_time++; in handle_assoc()
1834 if (hapd->iface->current_mode->mode == in handle_assoc()
1836 hapd->iface->num_sta_no_short_slot_time == 1) in handle_assoc()
1837 ieee802_11_set_beacons(hapd->iface); in handle_assoc()
1848 hapd->iface->num_sta_no_short_preamble++; in handle_assoc()
1849 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G in handle_assoc()
1850 && hapd->iface->num_sta_no_short_preamble == 1) in handle_assoc()
1851 ieee802_11_set_beacons(hapd->iface); in handle_assoc()
1855 update_ht_state(hapd, sta); in handle_assoc()
1858 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_assoc()
1883 send_assoc_resp(hapd, sta, resp, reassoc, pos, left); in handle_assoc()
1887 static void handle_disassoc(struct hostapd_data *hapd, in handle_disassoc() argument
1902 sta = ap_get_sta(hapd, mgmt->sa); in handle_disassoc()
1909 ap_sta_set_authorized(hapd, sta, 0); in handle_disassoc()
1913 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_disassoc()
1919 accounting_sta_stop(hapd, sta); in handle_disassoc()
1922 hostapd_drv_br_delete_ip_neigh(hapd, 4, (u8 *) &sta->ipaddr); in handle_disassoc()
1923 ap_sta_ip6addr_del(hapd, sta); in handle_disassoc()
1924 hostapd_drv_sta_remove(hapd, sta->addr); in handle_disassoc()
1929 eloop_cancel_timeout(ap_handle_timer, hapd, sta); in handle_disassoc()
1931 hapd, sta); in handle_disassoc()
1935 hapd, sta, le_to_host16(mgmt->u.disassoc.reason_code)); in handle_disassoc()
1939 static void handle_deauth(struct hostapd_data *hapd, in handle_deauth() argument
1945 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "handle_deauth - too short " in handle_deauth()
1950 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "deauthentication: STA=" MACSTR in handle_deauth()
1954 sta = ap_get_sta(hapd, mgmt->sa); in handle_deauth()
1956 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying " in handle_deauth()
1962 ap_sta_set_authorized(hapd, sta, 0); in handle_deauth()
1967 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_deauth()
1970 hapd, sta, le_to_host16(mgmt->u.deauth.reason_code)); in handle_deauth()
1973 ap_free_sta(hapd, sta); in handle_deauth()
1977 static void handle_beacon(struct hostapd_data *hapd, in handle_beacon() argument
1994 ap_list_process_beacon(hapd->iface, mgmt, &elems, fi); in handle_beacon()
2000 static int hostapd_sa_query_action(struct hostapd_data *hapd, in hostapd_sa_query_action() argument
2014 ieee802_11_sa_query_action(hapd, mgmt->sa, in hostapd_sa_query_action()
2029 static int handle_action(struct hostapd_data *hapd, in handle_action() argument
2033 sta = ap_get_sta(hapd, mgmt->sa); in handle_action()
2036 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, in handle_action()
2055 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, in handle_action()
2071 hostapd_logger(hapd, sta->addr, in handle_action()
2093 hostapd_wmm_action(hapd, mgmt, len); in handle_action()
2097 return hostapd_sa_query_action(hapd, mgmt, len); in handle_action()
2101 ieee802_11_rx_wnm_action_ap(hapd, mgmt, len); in handle_action()
2113 hostapd_2040_coex_action(hapd, mgmt, len); in handle_action()
2116 if (hapd->public_action_cb) { in handle_action()
2117 hapd->public_action_cb(hapd->public_action_cb_ctx, in handle_action()
2119 hapd->iface->freq); in handle_action()
2121 if (hapd->public_action_cb2) { in handle_action()
2122 hapd->public_action_cb2(hapd->public_action_cb2_ctx, in handle_action()
2124 hapd->iface->freq); in handle_action()
2126 if (hapd->public_action_cb || hapd->public_action_cb2) in handle_action()
2130 if (hapd->vendor_action_cb) { in handle_action()
2131 if (hapd->vendor_action_cb(hapd->vendor_action_cb_ctx, in handle_action()
2133 hapd->iface->freq) == 0) in handle_action()
2139 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, in handle_action()
2160 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN); in handle_action()
2161 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN); in handle_action()
2164 if (hostapd_drv_send_mlme(hapd, resp, len, 0) < 0) { in handle_action()
2188 int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len, in ieee802_11_mgmt() argument
2204 handle_beacon(hapd, mgmt, len, fi); in ieee802_11_mgmt()
2215 !((hapd->conf->p2p & P2P_GROUP_OWNER) && in ieee802_11_mgmt()
2219 !(hapd->conf->mesh & MESH_ENABLED) && in ieee802_11_mgmt()
2221 os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) { in ieee802_11_mgmt()
2229 handle_probe_req(hapd, mgmt, len, fi->ssi_signal); in ieee802_11_mgmt()
2233 if (os_memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) { in ieee802_11_mgmt()
2234 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, in ieee802_11_mgmt()
2244 handle_auth(hapd, mgmt, len); in ieee802_11_mgmt()
2249 handle_assoc(hapd, mgmt, len, 0); in ieee802_11_mgmt()
2254 handle_assoc(hapd, mgmt, len, 1); in ieee802_11_mgmt()
2259 handle_disassoc(hapd, mgmt, len); in ieee802_11_mgmt()
2263 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "mgmt::deauth"); in ieee802_11_mgmt()
2264 handle_deauth(hapd, mgmt, len); in ieee802_11_mgmt()
2269 ret = handle_action(hapd, mgmt, len); in ieee802_11_mgmt()
2272 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, in ieee802_11_mgmt()
2282 static void handle_auth_cb(struct hostapd_data *hapd, in handle_auth_cb() argument
2290 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211, in handle_auth_cb()
2306 sta = ap_get_sta(hapd, mgmt->da); in handle_auth_cb()
2316 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_auth_cb()
2323 static void hostapd_set_wds_encryption(struct hostapd_data *hapd, in hostapd_set_wds_encryption() argument
2328 struct hostapd_ssid *ssid = &hapd->conf->ssid; in hostapd_set_wds_encryption()
2330 if (hapd->conf->ieee802_1x || hapd->conf->wpa) in hostapd_set_wds_encryption()
2335 hostapd_drv_set_key(ifname_wds, hapd, WPA_ALG_WEP, NULL, i, in hostapd_set_wds_encryption()
2347 static void handle_assoc_cb(struct hostapd_data *hapd, in handle_assoc_cb() argument
2364 sta = ap_get_sta(hapd, mgmt->da); in handle_assoc_cb()
2372 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211, in handle_assoc_cb()
2389 accounting_sta_stop(hapd, sta); in handle_assoc_cb()
2391 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_assoc_cb()
2400 if ((!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) || in handle_assoc_cb()
2406 ap_sta_set_authorized(hapd, sta, 1); in handle_assoc_cb()
2410 mlme_reassociate_indication(hapd, sta); in handle_assoc_cb()
2412 mlme_associate_indication(hapd, sta); in handle_assoc_cb()
2423 hostapd_drv_sta_remove(hapd, sta->addr); in handle_assoc_cb()
2427 hostapd_get_ht_capab(hapd, sta->ht_capabilities, &ht_cap); in handle_assoc_cb()
2431 hostapd_get_vht_capab(hapd, sta->vht_capabilities, &vht_cap); in handle_assoc_cb()
2434 if (hostapd_sta_add(hapd, sta->addr, sta->aid, sta->capability, in handle_assoc_cb()
2440 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in handle_assoc_cb()
2444 ap_sta_disconnect(hapd, sta, sta->addr, in handle_assoc_cb()
2454 ret = hostapd_set_wds_sta(hapd, ifname_wds, sta->addr, in handle_assoc_cb()
2457 hostapd_set_wds_encryption(hapd, sta, ifname_wds); in handle_assoc_cb()
2466 if (ap_sta_bind_vlan(hapd, sta) < 0) in handle_assoc_cb()
2470 if (ap_sta_bind_vlan(hapd, sta) < 0) in handle_assoc_cb()
2474 hostapd_set_sta_flags(hapd, sta); in handle_assoc_cb()
2480 hapd->new_assoc_sta_cb(hapd, sta, !new_assoc); in handle_assoc_cb()
2486 static void handle_deauth_cb(struct hostapd_data *hapd, in handle_deauth_cb() argument
2493 sta = ap_get_sta(hapd, mgmt->da); in handle_deauth_cb()
2506 ap_sta_deauth_cb(hapd, sta); in handle_deauth_cb()
2510 static void handle_disassoc_cb(struct hostapd_data *hapd, in handle_disassoc_cb() argument
2517 sta = ap_get_sta(hapd, mgmt->da); in handle_disassoc_cb()
2530 ap_sta_disassoc_cb(hapd, sta); in handle_disassoc_cb()
2543 void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len, in ieee802_11_mgmt_cb() argument
2550 if (hapd->ext_mgmt_frame_handling) { in ieee802_11_mgmt_cb()
2551 wpa_msg(hapd->msg_ctx, MSG_INFO, "MGMT-TX-STATUS stype=%u ok=%d", in ieee802_11_mgmt_cb()
2560 handle_auth_cb(hapd, mgmt, len, ok); in ieee802_11_mgmt_cb()
2564 handle_assoc_cb(hapd, mgmt, len, 0, ok); in ieee802_11_mgmt_cb()
2568 handle_assoc_cb(hapd, mgmt, len, 1, ok); in ieee802_11_mgmt_cb()
2575 handle_deauth_cb(hapd, mgmt, len, ok); in ieee802_11_mgmt_cb()
2579 handle_disassoc_cb(hapd, mgmt, len, ok); in ieee802_11_mgmt_cb()
2591 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen) in ieee802_11_get_mib() argument
2598 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, in ieee802_11_get_mib_sta() argument
2606 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr, in hostapd_tx_status() argument
2610 struct hostapd_iface *iface = hapd->iface; in hostapd_tx_status()
2612 sta = ap_get_sta(hapd, addr); in hostapd_tx_status()
2616 hapd = iface->bss[j]; in hostapd_tx_status()
2617 sta = ap_get_sta(hapd, addr); in hostapd_tx_status()
2632 ieee802_1x_tx_status(hapd, sta, buf, len, ack); in hostapd_tx_status()
2636 void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst, in hostapd_eapol_tx_status() argument
2640 struct hostapd_iface *iface = hapd->iface; in hostapd_eapol_tx_status()
2642 sta = ap_get_sta(hapd, dst); in hostapd_eapol_tx_status()
2646 hapd = iface->bss[j]; in hostapd_eapol_tx_status()
2647 sta = ap_get_sta(hapd, dst); in hostapd_eapol_tx_status()
2659 ieee802_1x_eapol_tx_status(hapd, sta, data, len, ack); in hostapd_eapol_tx_status()
2663 void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr) in hostapd_client_poll_ok() argument
2666 struct hostapd_iface *iface = hapd->iface; in hostapd_client_poll_ok()
2668 sta = ap_get_sta(hapd, addr); in hostapd_client_poll_ok()
2672 hapd = iface->bss[j]; in hostapd_client_poll_ok()
2673 sta = ap_get_sta(hapd, addr); in hostapd_client_poll_ok()
2689 void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src, in ieee802_11_rx_from_unknown() argument
2694 sta = ap_get_sta(hapd, src); in ieee802_11_rx_from_unknown()
2696 if (!hapd->conf->wds_sta) in ieee802_11_rx_from_unknown()
2707 ret = hostapd_set_wds_sta(hapd, ifname_wds, in ieee802_11_rx_from_unknown()
2710 hostapd_set_wds_encryption(hapd, sta, in ieee802_11_rx_from_unknown()
2733 hapd, src, in ieee802_11_rx_from_unknown()
2737 hapd, src, in ieee802_11_rx_from_unknown()