Home | History | Annotate | Download | only in ap

Lines Matching defs:hapd

44 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid)
49 if (hapd->iface->current_rates == NULL)
53 num = hapd->iface->num_rates;
54 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht)
56 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht)
66 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num;
69 *pos = hapd->iface->current_rates[i].rate / 5;
70 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC)
75 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht && count < 8) {
80 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht && count < 8) {
89 u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid)
94 if (hapd->iface->current_rates == NULL)
97 num = hapd->iface->num_rates;
98 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht)
100 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht)
109 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num + 8;
114 *pos = hapd->iface->current_rates[i].rate / 5;
115 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC)
120 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) {
126 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) {
136 u16 hostapd_own_capab_info(struct hostapd_data *hapd, struct sta_info *sta,
142 if (hapd->iface->num_sta_no_short_preamble == 0 &&
143 hapd->iconf->preamble == SHORT_PREAMBLE)
146 privacy = hapd->conf->ssid.wep.keys_set;
148 if (hapd->conf->ieee802_1x &&
149 (hapd->conf->default_wep_key_len ||
150 hapd->conf->individual_wep_key_len))
153 if (hapd->conf->wpa)
173 if (hapd->iface->current_mode &&
174 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
175 hapd->iface->num_sta_no_short_slot_time == 0)
197 static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta,
201 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
232 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
239 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
256 static void send_auth_reply(struct hostapd_data *hapd,
274 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
288 if (hostapd_drv_send_mlme(hapd, reply, rlen, 0) < 0)
300 struct hostapd_data *hapd = ctx;
303 send_auth_reply(hapd, dst, bssid, WLAN_AUTH_FT, auth_transaction,
309 sta = ap_get_sta(hapd, dst);
313 hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211,
316 mlme_authenticate_indication(hapd, sta);
323 static struct wpabuf * auth_process_sae_commit(struct hostapd_data *hapd,
328 if (hapd->conf->ssid.wpa_passphrase == NULL) {
333 if (sae_prepare_commit(hapd->own_addr, sta->addr,
334 (u8 *) hapd->conf->ssid.wpa_passphrase,
335 os_strlen(hapd->conf->ssid.wpa_passphrase),
355 static struct wpabuf * auth_build_sae_confirm(struct hostapd_data *hapd,
370 static int use_sae_anti_clogging(struct hostapd_data *hapd)
375 if (hapd->conf->sae_anti_clogging_threshold == 0)
378 for (sta = hapd->sta_list; sta; sta = sta->next) {
385 if (open >= hapd->conf->sae_anti_clogging_threshold)
393 static int check_sae_token(struct hostapd_data *hapd, const u8 *addr,
400 if (hmac_sha256(hapd->sae_token_key, sizeof(hapd->sae_token_key),
409 static struct wpabuf * auth_build_token_req(struct hostapd_data *hapd,
417 if (hapd->last_sae_token_key_update == 0 ||
418 t.sec > hapd->last_sae_token_key_update + 60) {
419 if (random_get_bytes(hapd->sae_token_key,
420 sizeof(hapd->sae_token_key)) < 0)
423 hapd->sae_token_key, sizeof(hapd->sae_token_key));
424 hapd->last_sae_token_key_update = t.sec;
432 hmac_sha256(hapd->sae_token_key, sizeof(hapd->sae_token_key),
439 static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta,
458 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
464 &token_len, hapd->conf->sae_groups);
465 if (token && check_sae_token(hapd, sta->addr, token, token_len)
474 if (!token && use_sae_anti_clogging(hapd)) {
478 data = auth_build_token_req(hapd, sta->addr);
481 data = auth_process_sae_commit(hapd, sta);
490 hostapd_logger(hapd, sta->addr,
496 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
508 mlme_authenticate_indication(hapd, sta);
510 data = auth_build_sae_confirm(hapd, sta);
519 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
528 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, WLAN_AUTH_SAE,
537 static void handle_auth(struct hostapd_data *hapd,
561 if (hapd->iconf->ignore_auth_probability > 0.0d &&
562 drand48() < hapd->iconf->ignore_auth_probability) {
587 if (hapd->tkip_countermeasures) {
592 if (!(((hapd->conf->auth_algs & WPA_AUTH_ALG_OPEN) &&
595 (hapd->conf->wpa && wpa_key_mgmt_ft(hapd->conf->wpa_key_mgmt) &&
599 (hapd->conf->wpa && wpa_key_mgmt_sae(hapd->conf->wpa_key_mgmt) &&
602 ((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) &&
618 if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
625 hapd, mgmt->sa, (u8 *) mgmt, len,
646 sta = ap_sta_add(hapd, mgmt->sa);
653 if (!hostapd_vlan_id_valid(hapd->conf->vlan, vlan_id)) {
654 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
662 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
667 if (hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) {
682 if (hapd->conf->acct_interim_interval == 0 && acct_interim_interval)
685 ap_sta_session_timeout(hapd, sta, session_timeout);
687 ap_sta_no_session_timeout(hapd, sta);
691 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
701 mlme_authenticate_indication(hapd, sta);
705 resp = auth_shared_key(hapd, sta, auth_transaction, challenge,
708 mlme_authenticate_indication(hapd, sta);
721 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
733 handle_auth_ft_finish, hapd);
739 handle_auth_sae(hapd, sta, mgmt, len, auth_transaction);
749 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, auth_alg,
754 static int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
765 if (hapd->sta_aid[i] == (u32) -1)
768 if (!(hapd->sta_aid[i] & BIT(j)))
781 hapd->sta_aid[i] |= BIT(j);
787 static u16 check_ssid(struct hostapd_data *hapd, struct sta_info *sta,
793 if (ssid_ie_len != hapd->conf->ssid.ssid_len ||
794 os_memcmp(ssid_ie, hapd->conf->ssid.ssid, ssid_ie_len) != 0) {
797 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
808 static u16 check_wmm(struct hostapd_data *hapd, struct sta_info *sta,
813 if (wmm_ie && hapd->conf->wmm_enabled) {
816 if (!hostapd_eid_wmm_valid(hapd, wmm_ie, wmm_ie_len)) {
817 hostapd_logger(hapd, sta->addr,
833 static u16 copy_supp_rates(struct hostapd_data *hapd, struct sta_info *sta,
837 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
845 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
862 static u16 check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
872 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
878 resp = check_ssid(hapd, sta, elems.ssid, elems.ssid_len);
881 resp = check_wmm(hapd, sta, elems.wmm, elems.wmm_len);
884 resp = copy_supp_rates(hapd, sta, &elems);
888 resp = copy_sta_ht_capab(hapd, sta, elems.ht_capabilities,
892 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht &&
894 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
902 resp = copy_sta_vht_capab(hapd, sta, elems.vht_capabilities,
906 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht &&
908 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
928 if ((hapd->conf->wpa & WPA_PROTO_RSN) && elems.rsn_ie) {
931 } else if ((hapd->conf->wpa & WPA_PROTO_WPA) &&
942 if (hapd->conf->wps_state && elems.wps_ie) {
960 } else if (hapd->conf->wps_state && wpa_ie == NULL) {
966 if (hapd->conf->wpa && wpa_ie == NULL) {
967 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
973 if (hapd->conf->wpa && wpa_ie) {
978 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
986 res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
1012 ap_check_sa_query_timeout(hapd, sta);
1023 ap_sta_start_sa_query(hapd, sta);
1064 hostapd_logger(hapd, sta->addr,
1076 p2p_group_notif_assoc(hapd->p2p_group, sta->addr, ies, ies_len);
1092 static void send_deauth(struct hostapd_data *hapd, const u8 *addr,
1102 os_memcpy(reply.sa, hapd->own_addr, ETH_ALEN);
1103 os_memcpy(reply.bssid, hapd->own_addr, ETH_ALEN);
1108 if (hostapd_drv_send_mlme(hapd, &reply, send_len, 0) < 0)
1114 static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
1130 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
1131 os_memcpy(reply->bssid, hapd->own_addr, ETH_ALEN);
1136 host_to_le16(hostapd_own_capab_info(hapd, sta, 0));
1141 p = hostapd_eid_supp_rates(hapd, reply->u.assoc_resp.variable);
1143 p = hostapd_eid_ext_supp_rates(hapd, p);
1157 p = hostapd_eid_assoc_comeback_time(hapd, sta, p);
1161 p = hostapd_eid_ht_capabilities(hapd, p);
1162 p = hostapd_eid_ht_operation(hapd, p);
1166 p = hostapd_eid_vht_capabilities(hapd, p);
1167 p = hostapd_eid_vht_operation(hapd, p);
1170 hapd, p);
1171 p = hostapd_eid_bss_max_idle_period(hapd, p);
1174 p = hostapd_eid_wmm(hapd, p);
1178 ((sta->flags & WLAN_STA_MAYBE_WPS) && hapd->conf->wpa)) {
1203 p2p_resp_ie = p2p_group_assoc_resp_ie(hapd->p2p_group, status);
1214 if (hapd->conf->p2p & P2P_MANAGE)
1215 p = hostapd_eid_p2p_manage(hapd, p);
1220 if (hostapd_drv_send_mlme(hapd, reply, send_len, 0) < 0)
1226 static void handle_assoc(struct hostapd_data *hapd,
1245 if (hapd->iconf->ignore_reassoc_probability > 0.0d &&
1246 drand48() < hapd->iconf->ignore_reassoc_probability) {
1253 if (hapd->iconf->ignore_assoc_probability > 0.0d &&
1254 drand48() < hapd->iconf->ignore_assoc_probability) {
1285 sta = ap_get_sta(hapd, mgmt->sa);
1295 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1301 send_deauth(hapd, mgmt->sa,
1306 if (hapd->tkip_countermeasures) {
1311 if (listen_interval > hapd->conf->max_listen_interval) {
1312 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1322 resp = check_assoc_ies(hapd, sta, pos, left, reassoc);
1326 if (hostapd_get_aid(hapd, sta) < 0) {
1327 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1336 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
1346 hapd->iface->num_sta_non_erp++;
1347 if (hapd->iface->num_sta_non_erp == 1)
1348 ieee802_11_set_beacons(hapd->iface);
1354 hapd->iface->num_sta_no_short_slot_time++;
1355 if (hapd->iface->current_mode->mode ==
1357 hapd->iface->num_sta_no_short_slot_time == 1)
1358 ieee802_11_set_beacons(hapd->iface);
1369 hapd->iface->num_sta_no_short_preamble++;
1370 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
1371 && hapd->iface->num_sta_no_short_preamble == 1)
1372 ieee802_11_set_beacons(hapd->iface);
1376 update_ht_state(hapd, sta);
1379 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1415 send_assoc_resp(hapd, sta, resp, reassoc, pos, left);
1419 static void handle_disassoc(struct hostapd_data *hapd,
1434 sta = ap_get_sta(hapd, mgmt->sa);
1441 ap_sta_set_authorized(hapd, sta, 0);
1444 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1450 accounting_sta_stop(hapd, sta);
1452 hostapd_drv_sta_remove(hapd, sta->addr);
1457 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
1459 hapd, sta);
1463 hapd, sta, le_to_host16(mgmt->u.disassoc.reason_code));
1467 static void handle_deauth(struct hostapd_data *hapd,
1473 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "handle_deauth - too short "
1478 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "deauthentication: STA=" MACSTR
1482 sta = ap_get_sta(hapd, mgmt->sa);
1484 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
1490 ap_sta_set_authorized(hapd, sta, 0);
1494 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1497 hapd, sta, le_to_host16(mgmt->u.deauth.reason_code));
1500 ap_free_sta(hapd, sta);
1504 static void handle_beacon(struct hostapd_data *hapd,
1521 ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
1527 static void hostapd_sa_query_action(struct hostapd_data *hapd,
1541 ieee802_11_sa_query_action(hapd, mgmt->sa,
1556 static void hostapd_wnm_action(struct hostapd_data *hapd, struct sta_info *sta,
1570 action.freq = hapd->iface->freq;
1571 ieee802_11_rx_wnm_action_ap(hapd, &action);
1576 static void handle_action(struct hostapd_data *hapd,
1580 sta = ap_get_sta(hapd, mgmt->sa);
1583 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1602 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1619 hostapd_wmm_action(hapd, mgmt, len);
1623 hostapd_sa_query_action(hapd, mgmt, len);
1628 hostapd_wnm_action(hapd, sta, mgmt, len);
1632 if (hapd->public_action_cb) {
1633 hapd->public_action_cb(hapd->public_action_cb_ctx,
1635 hapd->iface->freq);
1637 if (hapd->public_action_cb2) {
1638 hapd->public_action_cb2(hapd->public_action_cb2_ctx,
1640 hapd->iface->freq);
1642 if (hapd->public_action_cb || hapd->public_action_cb2)
1646 if (hapd->vendor_action_cb) {
1647 if (hapd->vendor_action_cb(hapd->vendor_action_cb_ctx,
1649 hapd->iface->freq) == 0)
1655 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1676 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
1677 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
1680 if (hostapd_drv_send_mlme(hapd, resp, len, 0) < 0) {
1691 * @hapd: hostapd BSS data structure (the BSS to which the management frame was
1702 void ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
1717 handle_beacon(hapd, mgmt, len, fi);
1728 !((hapd->conf->p2p & P2P_GROUP_OWNER) &&
1731 os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) {
1739 handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
1743 if (os_memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) {
1744 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1754 handle_auth(hapd, mgmt, len);
1758 handle_assoc(hapd, mgmt, len, 0);
1762 handle_assoc(hapd, mgmt, len, 1);
1766 handle_disassoc(hapd, mgmt, len);
1769 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "mgmt::deauth");
1770 handle_deauth(hapd, mgmt, len);
1774 handle_action(hapd, mgmt, len);
1777 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1785 static void handle_auth_cb(struct hostapd_data *hapd,
1793 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
1809 sta = ap_get_sta(hapd, mgmt->da);
1819 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1826 static void hostapd_set_wds_encryption(struct hostapd_data *hapd,
1833 if (hapd->conf->ieee802_1x || hapd->conf->wpa)
1838 hostapd_drv_set_key(ifname_wds, hapd, WPA_ALG_WEP, NULL, i,
1850 static void handle_assoc_cb(struct hostapd_data *hapd,
1867 sta = ap_get_sta(hapd, mgmt->da);
1875 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
1892 accounting_sta_stop(hapd, sta);
1894 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1902 if ((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
1908 ap_sta_set_authorized(hapd, sta, 1);
1912 mlme_reassociate_indication(hapd, sta);
1914 mlme_associate_indication(hapd, sta);
1925 hostapd_drv_sta_remove(hapd, sta->addr);
1929 hostapd_get_ht_capab(hapd, sta->ht_capabilities, &ht_cap);
1933 hostapd_get_vht_capab(hapd, sta->vht_capabilities, &vht_cap);
1936 if (hostapd_sta_add(hapd, sta->addr, sta->aid, sta->capability,
1942 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1946 ap_sta_disconnect(hapd, sta, sta->addr,
1956 ret = hostapd_set_wds_sta(hapd, ifname_wds, sta->addr,
1959 hostapd_set_wds_encryption(hapd, sta, ifname_wds);
1968 if (ap_sta_bind_vlan(hapd, sta, 0) < 0)
1972 if (ap_sta_bind_vlan(hapd, sta, 0) < 0)
1976 hostapd_set_sta_flags(hapd, sta);
1982 hapd->new_assoc_sta_cb(hapd, sta, !new_assoc);
1995 static void handle_deauth_cb(struct hostapd_data *hapd,
2002 sta = ap_get_sta(hapd, mgmt->da);
2015 ap_sta_deauth_cb(hapd, sta);
2019 static void handle_disassoc_cb(struct hostapd_data *hapd,
2026 sta = ap_get_sta(hapd, mgmt->da);
2039 ap_sta_disassoc_cb(hapd, sta);
2045 * @hapd: hostapd BSS data structure (the BSS from which the management frame
2052 void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,
2061 handle_auth_cb(hapd, mgmt, len, ok);
2065 handle_assoc_cb(hapd, mgmt, len, 0, ok);
2069 handle_assoc_cb(hapd, mgmt, len, 1, ok);
2076 handle_deauth_cb(hapd, mgmt, len, ok);
2080 handle_disassoc_cb(hapd, mgmt, len, ok);
2092 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
2099 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
2107 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
2111 struct hostapd_iface *iface = hapd->iface;
2113 sta = ap_get_sta(hapd, addr);
2117 hapd = iface->bss[j];
2118 sta = ap_get_sta(hapd, addr);
2133 ieee802_1x_tx_status(hapd, sta, buf, len, ack);
2137 void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst,
2141 struct hostapd_iface *iface = hapd->iface;
2143 sta = ap_get_sta(hapd, dst);
2147 hapd = iface->bss[j];
2148 sta = ap_get_sta(hapd, dst);
2160 ieee802_1x_eapol_tx_status(hapd, sta, data, len, ack);
2164 void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr)
2167 struct hostapd_iface *iface = hapd->iface;
2169 sta = ap_get_sta(hapd, addr);
2173 hapd = iface->bss[j];
2174 sta = ap_get_sta(hapd, addr);
2190 void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
2195 sta = ap_get_sta(hapd, src);
2197 if (!hapd->conf->wds_sta)
2208 ret = hostapd_set_wds_sta(hapd, ifname_wds,
2211 hostapd_set_wds_encryption(hapd, sta,
2234 hapd, src,
2238 hapd, src,