Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * hostapd / Callback functions for driver wrappers |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 3 | * Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi> |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
| 12 | #include "radius/radius.h" |
| 13 | #include "drivers/driver.h" |
| 14 | #include "common/ieee802_11_defs.h" |
| 15 | #include "common/ieee802_11_common.h" |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 16 | #include "common/wpa_ctrl.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 17 | #include "crypto/random.h" |
| 18 | #include "p2p/p2p.h" |
| 19 | #include "wps/wps.h" |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 20 | #include "wnm_ap.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 21 | #include "hostapd.h" |
| 22 | #include "ieee802_11.h" |
| 23 | #include "sta_info.h" |
| 24 | #include "accounting.h" |
| 25 | #include "tkip_countermeasures.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 26 | #include "ieee802_1x.h" |
| 27 | #include "wpa_auth.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 28 | #include "wps_hostapd.h" |
| 29 | #include "ap_drv_ops.h" |
| 30 | #include "ap_config.h" |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 31 | #include "hw_features.h" |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 32 | #include "dfs.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 33 | |
| 34 | |
| 35 | int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 36 | const u8 *req_ies, size_t req_ies_len, int reassoc) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 37 | { |
| 38 | struct sta_info *sta; |
| 39 | int new_assoc, res; |
| 40 | struct ieee802_11_elems elems; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 41 | const u8 *ie; |
| 42 | size_t ielen; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 43 | #ifdef CONFIG_IEEE80211R |
| 44 | u8 buf[sizeof(struct ieee80211_mgmt) + 1024]; |
| 45 | u8 *p = buf; |
| 46 | #endif /* CONFIG_IEEE80211R */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 47 | u16 reason = WLAN_REASON_UNSPECIFIED; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 48 | u16 status = WLAN_STATUS_SUCCESS; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 49 | const u8 *p2p_dev_addr = NULL; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 50 | |
| 51 | if (addr == NULL) { |
| 52 | /* |
| 53 | * This could potentially happen with unexpected event from the |
| 54 | * driver wrapper. This was seen at least in one case where the |
| 55 | * driver ended up being set to station mode while hostapd was |
| 56 | * running, so better make sure we stop processing such an |
| 57 | * event here. |
| 58 | */ |
| 59 | wpa_printf(MSG_DEBUG, "hostapd_notif_assoc: Skip event with " |
| 60 | "no address"); |
| 61 | return -1; |
| 62 | } |
| 63 | random_add_randomness(addr, ETH_ALEN); |
| 64 | |
| 65 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
| 66 | HOSTAPD_LEVEL_INFO, "associated"); |
| 67 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 68 | ieee802_11_parse_elems(req_ies, req_ies_len, &elems, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 69 | if (elems.wps_ie) { |
| 70 | ie = elems.wps_ie - 2; |
| 71 | ielen = elems.wps_ie_len + 2; |
| 72 | wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)AssocReq"); |
| 73 | } else if (elems.rsn_ie) { |
| 74 | ie = elems.rsn_ie - 2; |
| 75 | ielen = elems.rsn_ie_len + 2; |
| 76 | wpa_printf(MSG_DEBUG, "STA included RSN IE in (Re)AssocReq"); |
| 77 | } else if (elems.wpa_ie) { |
| 78 | ie = elems.wpa_ie - 2; |
| 79 | ielen = elems.wpa_ie_len + 2; |
| 80 | wpa_printf(MSG_DEBUG, "STA included WPA IE in (Re)AssocReq"); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 81 | #ifdef CONFIG_HS20 |
| 82 | } else if (elems.osen) { |
| 83 | ie = elems.osen - 2; |
| 84 | ielen = elems.osen_len + 2; |
| 85 | wpa_printf(MSG_DEBUG, "STA included OSEN IE in (Re)AssocReq"); |
| 86 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 87 | } else { |
| 88 | ie = NULL; |
| 89 | ielen = 0; |
| 90 | wpa_printf(MSG_DEBUG, "STA did not include WPS/RSN/WPA IE in " |
| 91 | "(Re)AssocReq"); |
| 92 | } |
| 93 | |
| 94 | sta = ap_get_sta(hapd, addr); |
| 95 | if (sta) { |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 96 | ap_sta_no_session_timeout(hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 97 | accounting_sta_stop(hapd, sta); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 98 | |
| 99 | /* |
| 100 | * Make sure that the previously registered inactivity timer |
| 101 | * will not remove the STA immediately. |
| 102 | */ |
| 103 | sta->timeout_next = STA_NULLFUNC; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 104 | } else { |
| 105 | sta = ap_sta_add(hapd, addr); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 106 | if (sta == NULL) { |
| 107 | hostapd_drv_sta_disassoc(hapd, addr, |
| 108 | WLAN_REASON_DISASSOC_AP_BUSY); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 109 | return -1; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 110 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 111 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 112 | sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 113 | |
| 114 | #ifdef CONFIG_P2P |
| 115 | if (elems.p2p) { |
| 116 | wpabuf_free(sta->p2p_ie); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 117 | sta->p2p_ie = ieee802_11_vendor_ie_concat(req_ies, req_ies_len, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 118 | P2P_IE_VENDOR_TYPE); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 119 | if (sta->p2p_ie) |
| 120 | p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 121 | } |
| 122 | #endif /* CONFIG_P2P */ |
| 123 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 124 | #ifdef CONFIG_INTERWORKING |
| 125 | if (elems.ext_capab && elems.ext_capab_len > 4) { |
| 126 | if (elems.ext_capab[4] & 0x01) |
| 127 | sta->qos_map_enabled = 1; |
| 128 | } |
| 129 | #endif /* CONFIG_INTERWORKING */ |
| 130 | |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 131 | #ifdef CONFIG_HS20 |
| 132 | wpabuf_free(sta->hs20_ie); |
| 133 | if (elems.hs20 && elems.hs20_len > 4) { |
| 134 | sta->hs20_ie = wpabuf_alloc_copy(elems.hs20 + 4, |
| 135 | elems.hs20_len - 4); |
| 136 | } else |
| 137 | sta->hs20_ie = NULL; |
| 138 | #endif /* CONFIG_HS20 */ |
| 139 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 140 | if (hapd->conf->wpa) { |
| 141 | if (ie == NULL || ielen == 0) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 142 | #ifdef CONFIG_WPS |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 143 | if (hapd->conf->wps_state) { |
| 144 | wpa_printf(MSG_DEBUG, "STA did not include " |
| 145 | "WPA/RSN IE in (Re)Association " |
| 146 | "Request - possible WPS use"); |
| 147 | sta->flags |= WLAN_STA_MAYBE_WPS; |
| 148 | goto skip_wpa_check; |
| 149 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 150 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 151 | |
| 152 | wpa_printf(MSG_DEBUG, "No WPA/RSN IE from STA"); |
| 153 | return -1; |
| 154 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 155 | #ifdef CONFIG_WPS |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 156 | if (hapd->conf->wps_state && ie[0] == 0xdd && ie[1] >= 4 && |
| 157 | os_memcmp(ie + 2, "\x00\x50\xf2\x04", 4) == 0) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 158 | struct wpabuf *wps; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 159 | sta->flags |= WLAN_STA_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 160 | wps = ieee802_11_vendor_ie_concat(ie, ielen, |
| 161 | WPS_IE_VENDOR_TYPE); |
| 162 | if (wps) { |
| 163 | if (wps_is_20(wps)) { |
| 164 | wpa_printf(MSG_DEBUG, "WPS: STA " |
| 165 | "supports WPS 2.0"); |
| 166 | sta->flags |= WLAN_STA_WPS2; |
| 167 | } |
| 168 | wpabuf_free(wps); |
| 169 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 170 | goto skip_wpa_check; |
| 171 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 172 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 173 | |
| 174 | if (sta->wpa_sm == NULL) |
| 175 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 176 | sta->addr, |
| 177 | p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 178 | if (sta->wpa_sm == NULL) { |
| 179 | wpa_printf(MSG_ERROR, "Failed to initialize WPA state " |
| 180 | "machine"); |
| 181 | return -1; |
| 182 | } |
| 183 | res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm, |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 184 | ie, ielen, |
| 185 | elems.mdie, elems.mdie_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 186 | if (res != WPA_IE_OK) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 187 | wpa_printf(MSG_DEBUG, "WPA/RSN information element " |
| 188 | "rejected? (res %u)", res); |
| 189 | wpa_hexdump(MSG_DEBUG, "IE", ie, ielen); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 190 | if (res == WPA_INVALID_GROUP) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 191 | reason = WLAN_REASON_GROUP_CIPHER_NOT_VALID; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 192 | status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; |
| 193 | } else if (res == WPA_INVALID_PAIRWISE) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 194 | reason = WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 195 | status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; |
| 196 | } else if (res == WPA_INVALID_AKMP) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 197 | reason = WLAN_REASON_AKMP_NOT_VALID; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 198 | status = WLAN_STATUS_AKMP_NOT_VALID; |
| 199 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 200 | #ifdef CONFIG_IEEE80211W |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 201 | else if (res == WPA_MGMT_FRAME_PROTECTION_VIOLATION) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 202 | reason = WLAN_REASON_INVALID_IE; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 203 | status = WLAN_STATUS_INVALID_IE; |
| 204 | } else if (res == WPA_INVALID_MGMT_GROUP_CIPHER) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 205 | reason = WLAN_REASON_GROUP_CIPHER_NOT_VALID; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 206 | status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; |
| 207 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 208 | #endif /* CONFIG_IEEE80211W */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 209 | else { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 210 | reason = WLAN_REASON_INVALID_IE; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 211 | status = WLAN_STATUS_INVALID_IE; |
| 212 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 213 | goto fail; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 214 | } |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 215 | #ifdef CONFIG_IEEE80211W |
| 216 | if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out && |
| 217 | sta->sa_query_count > 0) |
| 218 | ap_check_sa_query_timeout(hapd, sta); |
| 219 | if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out && |
| 220 | (sta->auth_alg != WLAN_AUTH_FT)) { |
| 221 | /* |
| 222 | * STA has already been associated with MFP and SA |
| 223 | * Query timeout has not been reached. Reject the |
| 224 | * association attempt temporarily and start SA Query, |
| 225 | * if one is not pending. |
| 226 | */ |
| 227 | |
| 228 | if (sta->sa_query_count == 0) |
| 229 | ap_sta_start_sa_query(hapd, sta); |
| 230 | |
| 231 | #ifdef CONFIG_IEEE80211R |
| 232 | status = WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY; |
| 233 | |
| 234 | p = hostapd_eid_assoc_comeback_time(hapd, sta, p); |
| 235 | |
| 236 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, |
| 237 | p - buf); |
| 238 | #endif /* CONFIG_IEEE80211R */ |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | if (wpa_auth_uses_mfp(sta->wpa_sm)) |
| 243 | sta->flags |= WLAN_STA_MFP; |
| 244 | else |
| 245 | sta->flags &= ~WLAN_STA_MFP; |
| 246 | #endif /* CONFIG_IEEE80211W */ |
| 247 | |
| 248 | #ifdef CONFIG_IEEE80211R |
| 249 | if (sta->auth_alg == WLAN_AUTH_FT) { |
| 250 | status = wpa_ft_validate_reassoc(sta->wpa_sm, req_ies, |
| 251 | req_ies_len); |
| 252 | if (status != WLAN_STATUS_SUCCESS) { |
| 253 | if (status == WLAN_STATUS_INVALID_PMKID) |
| 254 | reason = WLAN_REASON_INVALID_IE; |
| 255 | if (status == WLAN_STATUS_INVALID_MDIE) |
| 256 | reason = WLAN_REASON_INVALID_IE; |
| 257 | if (status == WLAN_STATUS_INVALID_FTIE) |
| 258 | reason = WLAN_REASON_INVALID_IE; |
| 259 | goto fail; |
| 260 | } |
| 261 | } |
| 262 | #endif /* CONFIG_IEEE80211R */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 263 | } else if (hapd->conf->wps_state) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 264 | #ifdef CONFIG_WPS |
| 265 | struct wpabuf *wps; |
| 266 | if (req_ies) |
| 267 | wps = ieee802_11_vendor_ie_concat(req_ies, req_ies_len, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 268 | WPS_IE_VENDOR_TYPE); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 269 | else |
| 270 | wps = NULL; |
| 271 | #ifdef CONFIG_WPS_STRICT |
| 272 | if (wps && wps_validate_assoc_req(wps) < 0) { |
| 273 | reason = WLAN_REASON_INVALID_IE; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 274 | status = WLAN_STATUS_INVALID_IE; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 275 | wpabuf_free(wps); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 276 | goto fail; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 277 | } |
| 278 | #endif /* CONFIG_WPS_STRICT */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 279 | if (wps) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 280 | sta->flags |= WLAN_STA_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 281 | if (wps_is_20(wps)) { |
| 282 | wpa_printf(MSG_DEBUG, "WPS: STA supports " |
| 283 | "WPS 2.0"); |
| 284 | sta->flags |= WLAN_STA_WPS2; |
| 285 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 286 | } else |
| 287 | sta->flags |= WLAN_STA_MAYBE_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 288 | wpabuf_free(wps); |
| 289 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 290 | #ifdef CONFIG_HS20 |
| 291 | } else if (hapd->conf->osen) { |
| 292 | if (elems.osen == NULL) { |
| 293 | hostapd_logger( |
| 294 | hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 295 | HOSTAPD_LEVEL_INFO, |
| 296 | "No HS 2.0 OSEN element in association request"); |
| 297 | return WLAN_STATUS_INVALID_IE; |
| 298 | } |
| 299 | |
| 300 | wpa_printf(MSG_DEBUG, "HS 2.0: OSEN association"); |
| 301 | if (sta->wpa_sm == NULL) |
| 302 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
| 303 | sta->addr, NULL); |
| 304 | if (sta->wpa_sm == NULL) { |
| 305 | wpa_printf(MSG_WARNING, "Failed to initialize WPA " |
| 306 | "state machine"); |
| 307 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 308 | } |
| 309 | if (wpa_validate_osen(hapd->wpa_auth, sta->wpa_sm, |
| 310 | elems.osen - 2, elems.osen_len + 2) < 0) |
| 311 | return WLAN_STATUS_INVALID_IE; |
| 312 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 313 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 314 | #ifdef CONFIG_WPS |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 315 | skip_wpa_check: |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 316 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 317 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 318 | #ifdef CONFIG_IEEE80211R |
| 319 | p = wpa_sm_write_assoc_resp_ies(sta->wpa_sm, buf, sizeof(buf), |
| 320 | sta->auth_alg, req_ies, req_ies_len); |
| 321 | |
| 322 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, p - buf); |
| 323 | #else /* CONFIG_IEEE80211R */ |
| 324 | /* Keep compiler silent about unused variables */ |
| 325 | if (status) { |
| 326 | } |
| 327 | #endif /* CONFIG_IEEE80211R */ |
| 328 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 329 | new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0; |
| 330 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 331 | sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 332 | |
| 333 | if (reassoc && (sta->auth_alg == WLAN_AUTH_FT)) |
| 334 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT); |
| 335 | else |
| 336 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 337 | |
| 338 | hostapd_new_assoc_sta(hapd, sta, !new_assoc); |
| 339 | |
| 340 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 1); |
| 341 | |
| 342 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 343 | if (req_ies) { |
| 344 | p2p_group_notif_assoc(hapd->p2p_group, sta->addr, |
| 345 | req_ies, req_ies_len); |
| 346 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 347 | #endif /* CONFIG_P2P */ |
| 348 | |
| 349 | return 0; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 350 | |
| 351 | fail: |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 352 | #ifdef CONFIG_IEEE80211R |
| 353 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, p - buf); |
| 354 | #endif /* CONFIG_IEEE80211R */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 355 | hostapd_drv_sta_disassoc(hapd, sta->addr, reason); |
| 356 | ap_free_sta(hapd, sta); |
| 357 | return -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | |
| 361 | void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr) |
| 362 | { |
| 363 | struct sta_info *sta; |
| 364 | |
| 365 | if (addr == NULL) { |
| 366 | /* |
| 367 | * This could potentially happen with unexpected event from the |
| 368 | * driver wrapper. This was seen at least in one case where the |
| 369 | * driver ended up reporting a station mode event while hostapd |
| 370 | * was running, so better make sure we stop processing such an |
| 371 | * event here. |
| 372 | */ |
| 373 | wpa_printf(MSG_DEBUG, "hostapd_notif_disassoc: Skip event " |
| 374 | "with no address"); |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
| 379 | HOSTAPD_LEVEL_INFO, "disassociated"); |
| 380 | |
| 381 | sta = ap_get_sta(hapd, addr); |
| 382 | if (sta == NULL) { |
| 383 | wpa_printf(MSG_DEBUG, "Disassociation notification for " |
| 384 | "unknown STA " MACSTR, MAC2STR(addr)); |
| 385 | return; |
| 386 | } |
| 387 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 388 | ap_sta_set_authorized(hapd, sta, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 389 | sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 390 | wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC); |
| 391 | sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST; |
| 392 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); |
| 393 | ap_free_sta(hapd, sta); |
| 394 | } |
| 395 | |
| 396 | |
| 397 | void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr) |
| 398 | { |
| 399 | struct sta_info *sta = ap_get_sta(hapd, addr); |
| 400 | |
| 401 | if (!sta || !hapd->conf->disassoc_low_ack) |
| 402 | return; |
| 403 | |
| 404 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
| 405 | HOSTAPD_LEVEL_INFO, "disconnected due to excessive " |
| 406 | "missing ACKs"); |
| 407 | hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_DISASSOC_LOW_ACK); |
| 408 | if (sta) |
| 409 | ap_sta_disassociate(hapd, sta, WLAN_REASON_DISASSOC_LOW_ACK); |
| 410 | } |
| 411 | |
| 412 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 413 | void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 414 | int offset, int width, int cf1, int cf2) |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 415 | { |
| 416 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 417 | int channel, chwidth, seg0_idx = 0, seg1_idx = 0; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 418 | |
| 419 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 420 | HOSTAPD_LEVEL_INFO, "driver had channel switch: " |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 421 | "freq=%d, ht=%d, offset=%d, width=%d, cf1=%d, cf2=%d", |
| 422 | freq, ht, offset, width, cf1, cf2); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 423 | |
| 424 | hapd->iface->freq = freq; |
| 425 | |
| 426 | channel = hostapd_hw_get_channel(hapd, freq); |
| 427 | if (!channel) { |
| 428 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 429 | HOSTAPD_LEVEL_WARNING, "driver switched to " |
| 430 | "bad channel!"); |
| 431 | return; |
| 432 | } |
| 433 | |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 434 | switch (width) { |
| 435 | case CHAN_WIDTH_80: |
| 436 | chwidth = VHT_CHANWIDTH_80MHZ; |
| 437 | break; |
| 438 | case CHAN_WIDTH_80P80: |
| 439 | chwidth = VHT_CHANWIDTH_80P80MHZ; |
| 440 | break; |
| 441 | case CHAN_WIDTH_160: |
| 442 | chwidth = VHT_CHANWIDTH_160MHZ; |
| 443 | break; |
| 444 | case CHAN_WIDTH_20_NOHT: |
| 445 | case CHAN_WIDTH_20: |
| 446 | case CHAN_WIDTH_40: |
| 447 | default: |
| 448 | chwidth = VHT_CHANWIDTH_USE_HT; |
| 449 | break; |
| 450 | } |
| 451 | |
| 452 | switch (hapd->iface->current_mode->mode) { |
| 453 | case HOSTAPD_MODE_IEEE80211A: |
| 454 | if (cf1 > 5000) |
| 455 | seg0_idx = (cf1 - 5000) / 5; |
| 456 | if (cf2 > 5000) |
| 457 | seg1_idx = (cf2 - 5000) / 5; |
| 458 | break; |
| 459 | default: |
| 460 | seg0_idx = hostapd_hw_get_channel(hapd, cf1); |
| 461 | seg1_idx = hostapd_hw_get_channel(hapd, cf2); |
| 462 | break; |
| 463 | } |
| 464 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 465 | hapd->iconf->channel = channel; |
| 466 | hapd->iconf->ieee80211n = ht; |
| 467 | hapd->iconf->secondary_channel = offset; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 468 | hapd->iconf->vht_oper_chwidth = chwidth; |
| 469 | hapd->iconf->vht_oper_centr_freq_seg0_idx = seg0_idx; |
| 470 | hapd->iconf->vht_oper_centr_freq_seg1_idx = seg1_idx; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 471 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 472 | if (hapd->iface->csa_in_progress && |
| 473 | freq == hapd->iface->cs_freq_params.freq) { |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 474 | hostapd_cleanup_cs_params(hapd); |
| 475 | |
| 476 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_CSA_FINISHED "freq=%d", |
| 477 | freq); |
| 478 | } |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 479 | #endif /* NEED_AP_MLME */ |
| 480 | } |
| 481 | |
| 482 | |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 483 | void hostapd_event_connect_failed_reason(struct hostapd_data *hapd, |
| 484 | const u8 *addr, int reason_code) |
| 485 | { |
| 486 | switch (reason_code) { |
| 487 | case MAX_CLIENT_REACHED: |
| 488 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_REJECTED_MAX_STA MACSTR, |
| 489 | MAC2STR(addr)); |
| 490 | break; |
| 491 | case BLOCKED_CLIENT: |
| 492 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_REJECTED_BLOCKED_STA MACSTR, |
| 493 | MAC2STR(addr)); |
| 494 | break; |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 499 | int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 500 | const u8 *bssid, const u8 *ie, size_t ie_len, |
| 501 | int ssi_signal) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 502 | { |
| 503 | size_t i; |
| 504 | int ret = 0; |
| 505 | |
| 506 | if (sa == NULL || ie == NULL) |
| 507 | return -1; |
| 508 | |
| 509 | random_add_randomness(sa, ETH_ALEN); |
| 510 | for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) { |
| 511 | if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 512 | sa, da, bssid, ie, ie_len, |
| 513 | ssi_signal) > 0) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 514 | ret = 1; |
| 515 | break; |
| 516 | } |
| 517 | } |
| 518 | return ret; |
| 519 | } |
| 520 | |
| 521 | |
| 522 | #ifdef HOSTAPD |
| 523 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 524 | #ifdef CONFIG_IEEE80211R |
| 525 | static void hostapd_notify_auth_ft_finish(void *ctx, const u8 *dst, |
| 526 | const u8 *bssid, |
| 527 | u16 auth_transaction, u16 status, |
| 528 | const u8 *ies, size_t ies_len) |
| 529 | { |
| 530 | struct hostapd_data *hapd = ctx; |
| 531 | struct sta_info *sta; |
| 532 | |
| 533 | sta = ap_get_sta(hapd, dst); |
| 534 | if (sta == NULL) |
| 535 | return; |
| 536 | |
| 537 | hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211, |
| 538 | HOSTAPD_LEVEL_DEBUG, "authentication OK (FT)"); |
| 539 | sta->flags |= WLAN_STA_AUTH; |
| 540 | |
| 541 | hostapd_sta_auth(hapd, dst, auth_transaction, status, ies, ies_len); |
| 542 | } |
| 543 | #endif /* CONFIG_IEEE80211R */ |
| 544 | |
| 545 | |
| 546 | static void hostapd_notif_auth(struct hostapd_data *hapd, |
| 547 | struct auth_info *rx_auth) |
| 548 | { |
| 549 | struct sta_info *sta; |
| 550 | u16 status = WLAN_STATUS_SUCCESS; |
| 551 | u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN]; |
| 552 | size_t resp_ies_len = 0; |
| 553 | |
| 554 | sta = ap_get_sta(hapd, rx_auth->peer); |
| 555 | if (!sta) { |
| 556 | sta = ap_sta_add(hapd, rx_auth->peer); |
| 557 | if (sta == NULL) { |
Dmitry Shmidt | 4b06059 | 2013-04-29 16:42:49 -0700 | [diff] [blame] | 558 | status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 559 | goto fail; |
| 560 | } |
| 561 | } |
| 562 | sta->flags &= ~WLAN_STA_PREAUTH; |
| 563 | ieee802_1x_notify_pre_auth(sta->eapol_sm, 0); |
| 564 | #ifdef CONFIG_IEEE80211R |
| 565 | if (rx_auth->auth_type == WLAN_AUTH_FT && hapd->wpa_auth) { |
| 566 | sta->auth_alg = WLAN_AUTH_FT; |
| 567 | if (sta->wpa_sm == NULL) |
| 568 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 569 | sta->addr, NULL); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 570 | if (sta->wpa_sm == NULL) { |
| 571 | wpa_printf(MSG_DEBUG, "FT: Failed to initialize WPA " |
| 572 | "state machine"); |
| 573 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 574 | goto fail; |
| 575 | } |
| 576 | wpa_ft_process_auth(sta->wpa_sm, rx_auth->bssid, |
| 577 | rx_auth->auth_transaction, rx_auth->ies, |
| 578 | rx_auth->ies_len, |
| 579 | hostapd_notify_auth_ft_finish, hapd); |
| 580 | return; |
| 581 | } |
| 582 | #endif /* CONFIG_IEEE80211R */ |
| 583 | fail: |
| 584 | hostapd_sta_auth(hapd, rx_auth->peer, rx_auth->auth_transaction + 1, |
| 585 | status, resp_ies, resp_ies_len); |
| 586 | } |
| 587 | |
| 588 | |
| 589 | static void hostapd_action_rx(struct hostapd_data *hapd, |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 590 | struct rx_mgmt *drv_mgmt) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 591 | { |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 592 | struct ieee80211_mgmt *mgmt; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 593 | struct sta_info *sta; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 594 | size_t plen __maybe_unused; |
| 595 | u16 fc; |
| 596 | |
| 597 | if (drv_mgmt->frame_len < 24 + 1) |
| 598 | return; |
| 599 | |
| 600 | plen = drv_mgmt->frame_len - 24 - 1; |
| 601 | |
| 602 | mgmt = (struct ieee80211_mgmt *) drv_mgmt->frame; |
| 603 | fc = le_to_host16(mgmt->frame_control); |
| 604 | if (WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_ACTION) |
| 605 | return; /* handled by the driver */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 606 | |
| 607 | wpa_printf(MSG_DEBUG, "RX_ACTION cat %d action plen %d", |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 608 | mgmt->u.action.category, (int) plen); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 609 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 610 | sta = ap_get_sta(hapd, mgmt->sa); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 611 | if (sta == NULL) { |
| 612 | wpa_printf(MSG_DEBUG, "%s: station not found", __func__); |
| 613 | return; |
| 614 | } |
| 615 | #ifdef CONFIG_IEEE80211R |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 616 | if (mgmt->u.action.category == WLAN_ACTION_FT) { |
| 617 | const u8 *payload = drv_mgmt->frame + 24 + 1; |
| 618 | wpa_ft_action_rx(sta->wpa_sm, payload, plen); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 619 | } |
| 620 | #endif /* CONFIG_IEEE80211R */ |
| 621 | #ifdef CONFIG_IEEE80211W |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 622 | if (mgmt->u.action.category == WLAN_ACTION_SA_QUERY && plen >= 4) { |
| 623 | ieee802_11_sa_query_action( |
| 624 | hapd, mgmt->sa, |
| 625 | mgmt->u.action.u.sa_query_resp.action, |
| 626 | mgmt->u.action.u.sa_query_resp.trans_id); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 627 | } |
| 628 | #endif /* CONFIG_IEEE80211W */ |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 629 | #ifdef CONFIG_WNM |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 630 | if (mgmt->u.action.category == WLAN_ACTION_WNM) { |
| 631 | ieee802_11_rx_wnm_action_ap(hapd, mgmt, drv_mgmt->frame_len); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 632 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 633 | #endif /* CONFIG_WNM */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 637 | #ifdef NEED_AP_MLME |
| 638 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 639 | #define HAPD_BROADCAST ((struct hostapd_data *) -1) |
| 640 | |
| 641 | static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 642 | const u8 *bssid) |
| 643 | { |
| 644 | size_t i; |
| 645 | |
| 646 | if (bssid == NULL) |
| 647 | return NULL; |
| 648 | if (bssid[0] == 0xff && bssid[1] == 0xff && bssid[2] == 0xff && |
| 649 | bssid[3] == 0xff && bssid[4] == 0xff && bssid[5] == 0xff) |
| 650 | return HAPD_BROADCAST; |
| 651 | |
| 652 | for (i = 0; i < iface->num_bss; i++) { |
| 653 | if (os_memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0) |
| 654 | return iface->bss[i]; |
| 655 | } |
| 656 | |
| 657 | return NULL; |
| 658 | } |
| 659 | |
| 660 | |
| 661 | static void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 662 | const u8 *bssid, const u8 *addr, |
| 663 | int wds) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 664 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 665 | hapd = get_hapd_bssid(hapd->iface, bssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 666 | if (hapd == NULL || hapd == HAPD_BROADCAST) |
| 667 | return; |
| 668 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 669 | ieee802_11_rx_from_unknown(hapd, addr, wds); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 673 | static int hostapd_mgmt_rx(struct hostapd_data *hapd, struct rx_mgmt *rx_mgmt) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 674 | { |
| 675 | struct hostapd_iface *iface = hapd->iface; |
| 676 | const struct ieee80211_hdr *hdr; |
| 677 | const u8 *bssid; |
| 678 | struct hostapd_frame_info fi; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 679 | int ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 680 | |
Dmitry Shmidt | 7d5c8f2 | 2014-03-03 13:53:28 -0800 | [diff] [blame] | 681 | #ifdef CONFIG_TESTING_OPTIONS |
| 682 | if (hapd->ext_mgmt_frame_handling) { |
| 683 | size_t hex_len = 2 * rx_mgmt->frame_len + 1; |
| 684 | char *hex = os_malloc(hex_len); |
| 685 | if (hex) { |
| 686 | wpa_snprintf_hex(hex, hex_len, rx_mgmt->frame, |
| 687 | rx_mgmt->frame_len); |
| 688 | wpa_msg(hapd->msg_ctx, MSG_INFO, "MGMT-RX %s", hex); |
| 689 | os_free(hex); |
| 690 | } |
| 691 | return 1; |
| 692 | } |
| 693 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 694 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 695 | hdr = (const struct ieee80211_hdr *) rx_mgmt->frame; |
| 696 | bssid = get_hdr_bssid(hdr, rx_mgmt->frame_len); |
| 697 | if (bssid == NULL) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 698 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 699 | |
| 700 | hapd = get_hapd_bssid(iface, bssid); |
| 701 | if (hapd == NULL) { |
| 702 | u16 fc; |
| 703 | fc = le_to_host16(hdr->frame_control); |
| 704 | |
| 705 | /* |
| 706 | * Drop frames to unknown BSSIDs except for Beacon frames which |
| 707 | * could be used to update neighbor information. |
| 708 | */ |
| 709 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 710 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON) |
| 711 | hapd = iface->bss[0]; |
| 712 | else |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 713 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | os_memset(&fi, 0, sizeof(fi)); |
| 717 | fi.datarate = rx_mgmt->datarate; |
| 718 | fi.ssi_signal = rx_mgmt->ssi_signal; |
| 719 | |
| 720 | if (hapd == HAPD_BROADCAST) { |
| 721 | size_t i; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 722 | ret = 0; |
| 723 | for (i = 0; i < iface->num_bss; i++) { |
Dmitry Shmidt | 9866086 | 2014-03-11 17:26:21 -0700 | [diff] [blame^] | 724 | /* if bss is set, driver will call this function for |
| 725 | * each bss individually. */ |
| 726 | if (rx_mgmt->drv_priv && |
| 727 | (iface->bss[i]->drv_priv != rx_mgmt->drv_priv)) |
| 728 | continue; |
| 729 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 730 | if (ieee802_11_mgmt(iface->bss[i], rx_mgmt->frame, |
| 731 | rx_mgmt->frame_len, &fi) > 0) |
| 732 | ret = 1; |
| 733 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 734 | } else |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 735 | ret = ieee802_11_mgmt(hapd, rx_mgmt->frame, rx_mgmt->frame_len, |
| 736 | &fi); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 737 | |
| 738 | random_add_randomness(&fi, sizeof(fi)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 739 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 740 | return ret; |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 744 | static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, |
| 745 | size_t len, u16 stype, int ok) |
| 746 | { |
| 747 | struct ieee80211_hdr *hdr; |
| 748 | hdr = (struct ieee80211_hdr *) buf; |
| 749 | hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len)); |
| 750 | if (hapd == NULL || hapd == HAPD_BROADCAST) |
| 751 | return; |
| 752 | ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); |
| 753 | } |
| 754 | |
| 755 | #endif /* NEED_AP_MLME */ |
| 756 | |
| 757 | |
| 758 | static int hostapd_event_new_sta(struct hostapd_data *hapd, const u8 *addr) |
| 759 | { |
| 760 | struct sta_info *sta = ap_get_sta(hapd, addr); |
| 761 | if (sta) |
| 762 | return 0; |
| 763 | |
| 764 | wpa_printf(MSG_DEBUG, "Data frame from unknown STA " MACSTR |
| 765 | " - adding a new STA", MAC2STR(addr)); |
| 766 | sta = ap_sta_add(hapd, addr); |
| 767 | if (sta) { |
| 768 | hostapd_new_assoc_sta(hapd, sta, 0); |
| 769 | } else { |
| 770 | wpa_printf(MSG_DEBUG, "Failed to add STA entry for " MACSTR, |
| 771 | MAC2STR(addr)); |
| 772 | return -1; |
| 773 | } |
| 774 | |
| 775 | return 0; |
| 776 | } |
| 777 | |
| 778 | |
| 779 | static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, |
| 780 | const u8 *data, size_t data_len) |
| 781 | { |
| 782 | struct hostapd_iface *iface = hapd->iface; |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 783 | struct sta_info *sta; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 784 | size_t j; |
| 785 | |
| 786 | for (j = 0; j < iface->num_bss; j++) { |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 787 | if ((sta = ap_get_sta(iface->bss[j], src))) { |
| 788 | if (sta->flags & WLAN_STA_ASSOC) { |
| 789 | hapd = iface->bss[j]; |
| 790 | break; |
| 791 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 792 | } |
| 793 | } |
| 794 | |
| 795 | ieee802_1x_receive(hapd, src, data, data_len); |
| 796 | } |
| 797 | |
| 798 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 799 | static struct hostapd_channel_data * hostapd_get_mode_channel( |
| 800 | struct hostapd_iface *iface, unsigned int freq) |
| 801 | { |
| 802 | int i; |
| 803 | struct hostapd_channel_data *chan; |
| 804 | |
| 805 | for (i = 0; i < iface->current_mode->num_channels; i++) { |
| 806 | chan = &iface->current_mode->channels[i]; |
| 807 | if (!chan) |
| 808 | return NULL; |
| 809 | if ((unsigned int) chan->freq == freq) |
| 810 | return chan; |
| 811 | } |
| 812 | |
| 813 | return NULL; |
| 814 | } |
| 815 | |
| 816 | |
| 817 | static void hostapd_update_nf(struct hostapd_iface *iface, |
| 818 | struct hostapd_channel_data *chan, |
| 819 | struct freq_survey *survey) |
| 820 | { |
| 821 | if (!iface->chans_surveyed) { |
| 822 | chan->min_nf = survey->nf; |
| 823 | iface->lowest_nf = survey->nf; |
| 824 | } else { |
| 825 | if (dl_list_empty(&chan->survey_list)) |
| 826 | chan->min_nf = survey->nf; |
| 827 | else if (survey->nf < chan->min_nf) |
| 828 | chan->min_nf = survey->nf; |
| 829 | if (survey->nf < iface->lowest_nf) |
| 830 | iface->lowest_nf = survey->nf; |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | |
| 835 | static void hostapd_event_get_survey(struct hostapd_data *hapd, |
| 836 | struct survey_results *survey_results) |
| 837 | { |
| 838 | struct hostapd_iface *iface = hapd->iface; |
| 839 | struct freq_survey *survey, *tmp; |
| 840 | struct hostapd_channel_data *chan; |
| 841 | |
| 842 | if (dl_list_empty(&survey_results->survey_list)) { |
| 843 | wpa_printf(MSG_DEBUG, "No survey data received"); |
| 844 | return; |
| 845 | } |
| 846 | |
| 847 | dl_list_for_each_safe(survey, tmp, &survey_results->survey_list, |
| 848 | struct freq_survey, list) { |
| 849 | chan = hostapd_get_mode_channel(iface, survey->freq); |
| 850 | if (!chan) |
| 851 | continue; |
| 852 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 853 | continue; |
| 854 | |
| 855 | dl_list_del(&survey->list); |
| 856 | dl_list_add_tail(&chan->survey_list, &survey->list); |
| 857 | |
| 858 | hostapd_update_nf(iface, chan, survey); |
| 859 | |
| 860 | iface->chans_surveyed++; |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 865 | #ifdef NEED_AP_MLME |
| 866 | |
| 867 | static void hostapd_event_dfs_radar_detected(struct hostapd_data *hapd, |
| 868 | struct dfs_event *radar) |
| 869 | { |
| 870 | wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 871 | hostapd_dfs_radar_detected(hapd->iface, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 872 | radar->chan_offset, radar->chan_width, |
| 873 | radar->cf1, radar->cf2); |
| 874 | } |
| 875 | |
| 876 | |
| 877 | static void hostapd_event_dfs_cac_finished(struct hostapd_data *hapd, |
| 878 | struct dfs_event *radar) |
| 879 | { |
| 880 | wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 881 | hostapd_dfs_complete_cac(hapd->iface, 1, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 882 | radar->chan_offset, radar->chan_width, |
| 883 | radar->cf1, radar->cf2); |
| 884 | } |
| 885 | |
| 886 | |
| 887 | static void hostapd_event_dfs_cac_aborted(struct hostapd_data *hapd, |
| 888 | struct dfs_event *radar) |
| 889 | { |
| 890 | wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 891 | hostapd_dfs_complete_cac(hapd->iface, 0, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 892 | radar->chan_offset, radar->chan_width, |
| 893 | radar->cf1, radar->cf2); |
| 894 | } |
| 895 | |
| 896 | |
| 897 | static void hostapd_event_dfs_nop_finished(struct hostapd_data *hapd, |
| 898 | struct dfs_event *radar) |
| 899 | { |
| 900 | wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 901 | hostapd_dfs_nop_finished(hapd->iface, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 902 | radar->chan_offset, radar->chan_width, |
| 903 | radar->cf1, radar->cf2); |
| 904 | } |
| 905 | |
| 906 | #endif /* NEED_AP_MLME */ |
| 907 | |
| 908 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 909 | void wpa_supplicant_event(void *ctx, enum wpa_event_type event, |
| 910 | union wpa_event_data *data) |
| 911 | { |
| 912 | struct hostapd_data *hapd = ctx; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 913 | #ifndef CONFIG_NO_STDOUT_DEBUG |
| 914 | int level = MSG_DEBUG; |
| 915 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 916 | if (event == EVENT_RX_MGMT && data->rx_mgmt.frame && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 917 | data->rx_mgmt.frame_len >= 24) { |
| 918 | const struct ieee80211_hdr *hdr; |
| 919 | u16 fc; |
| 920 | hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame; |
| 921 | fc = le_to_host16(hdr->frame_control); |
| 922 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 923 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON) |
| 924 | level = MSG_EXCESSIVE; |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 925 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 926 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_PROBE_REQ) |
| 927 | level = MSG_EXCESSIVE; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | wpa_dbg(hapd->msg_ctx, level, "Event %s (%d) received", |
| 931 | event_to_string(event), event); |
| 932 | #endif /* CONFIG_NO_STDOUT_DEBUG */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 933 | |
| 934 | switch (event) { |
| 935 | case EVENT_MICHAEL_MIC_FAILURE: |
| 936 | michael_mic_failure(hapd, data->michael_mic_failure.src, 1); |
| 937 | break; |
| 938 | case EVENT_SCAN_RESULTS: |
| 939 | if (hapd->iface->scan_cb) |
| 940 | hapd->iface->scan_cb(hapd->iface); |
| 941 | break; |
| 942 | #ifdef CONFIG_IEEE80211R |
| 943 | case EVENT_FT_RRB_RX: |
| 944 | wpa_ft_rrb_rx(hapd->wpa_auth, data->ft_rrb_rx.src, |
| 945 | data->ft_rrb_rx.data, data->ft_rrb_rx.data_len); |
| 946 | break; |
| 947 | #endif /* CONFIG_IEEE80211R */ |
| 948 | case EVENT_WPS_BUTTON_PUSHED: |
| 949 | hostapd_wps_button_pushed(hapd, NULL); |
| 950 | break; |
| 951 | #ifdef NEED_AP_MLME |
| 952 | case EVENT_TX_STATUS: |
| 953 | switch (data->tx_status.type) { |
| 954 | case WLAN_FC_TYPE_MGMT: |
| 955 | hostapd_mgmt_tx_cb(hapd, data->tx_status.data, |
| 956 | data->tx_status.data_len, |
| 957 | data->tx_status.stype, |
| 958 | data->tx_status.ack); |
| 959 | break; |
| 960 | case WLAN_FC_TYPE_DATA: |
| 961 | hostapd_tx_status(hapd, data->tx_status.dst, |
| 962 | data->tx_status.data, |
| 963 | data->tx_status.data_len, |
| 964 | data->tx_status.ack); |
| 965 | break; |
| 966 | } |
| 967 | break; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 968 | case EVENT_EAPOL_TX_STATUS: |
| 969 | hostapd_eapol_tx_status(hapd, data->eapol_tx_status.dst, |
| 970 | data->eapol_tx_status.data, |
| 971 | data->eapol_tx_status.data_len, |
| 972 | data->eapol_tx_status.ack); |
| 973 | break; |
| 974 | case EVENT_DRIVER_CLIENT_POLL_OK: |
| 975 | hostapd_client_poll_ok(hapd, data->client_poll.addr); |
| 976 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 977 | case EVENT_RX_FROM_UNKNOWN: |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 978 | hostapd_rx_from_unknown_sta(hapd, data->rx_from_unknown.bssid, |
| 979 | data->rx_from_unknown.addr, |
| 980 | data->rx_from_unknown.wds); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 981 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 982 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 983 | case EVENT_RX_MGMT: |
| 984 | #ifdef NEED_AP_MLME |
| 985 | if (hostapd_mgmt_rx(hapd, &data->rx_mgmt) > 0) |
| 986 | break; |
| 987 | #endif /* NEED_AP_MLME */ |
| 988 | hostapd_action_rx(hapd, &data->rx_mgmt); |
| 989 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 990 | case EVENT_RX_PROBE_REQ: |
| 991 | if (data->rx_probe_req.sa == NULL || |
| 992 | data->rx_probe_req.ie == NULL) |
| 993 | break; |
| 994 | hostapd_probe_req_rx(hapd, data->rx_probe_req.sa, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 995 | data->rx_probe_req.da, |
| 996 | data->rx_probe_req.bssid, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 997 | data->rx_probe_req.ie, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 998 | data->rx_probe_req.ie_len, |
| 999 | data->rx_probe_req.ssi_signal); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1000 | break; |
| 1001 | case EVENT_NEW_STA: |
| 1002 | hostapd_event_new_sta(hapd, data->new_sta.addr); |
| 1003 | break; |
| 1004 | case EVENT_EAPOL_RX: |
| 1005 | hostapd_event_eapol_rx(hapd, data->eapol_rx.src, |
| 1006 | data->eapol_rx.data, |
| 1007 | data->eapol_rx.data_len); |
| 1008 | break; |
| 1009 | case EVENT_ASSOC: |
| 1010 | hostapd_notif_assoc(hapd, data->assoc_info.addr, |
| 1011 | data->assoc_info.req_ies, |
| 1012 | data->assoc_info.req_ies_len, |
| 1013 | data->assoc_info.reassoc); |
| 1014 | break; |
| 1015 | case EVENT_DISASSOC: |
| 1016 | if (data) |
| 1017 | hostapd_notif_disassoc(hapd, data->disassoc_info.addr); |
| 1018 | break; |
| 1019 | case EVENT_DEAUTH: |
| 1020 | if (data) |
| 1021 | hostapd_notif_disassoc(hapd, data->deauth_info.addr); |
| 1022 | break; |
| 1023 | case EVENT_STATION_LOW_ACK: |
| 1024 | if (!data) |
| 1025 | break; |
| 1026 | hostapd_event_sta_low_ack(hapd, data->low_ack.addr); |
| 1027 | break; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1028 | case EVENT_AUTH: |
| 1029 | hostapd_notif_auth(hapd, &data->auth); |
| 1030 | break; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1031 | case EVENT_CH_SWITCH: |
| 1032 | if (!data) |
| 1033 | break; |
| 1034 | hostapd_event_ch_switch(hapd, data->ch_switch.freq, |
| 1035 | data->ch_switch.ht_enabled, |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1036 | data->ch_switch.ch_offset, |
| 1037 | data->ch_switch.ch_width, |
| 1038 | data->ch_switch.cf1, |
| 1039 | data->ch_switch.cf2); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1040 | break; |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 1041 | case EVENT_CONNECT_FAILED_REASON: |
| 1042 | if (!data) |
| 1043 | break; |
| 1044 | hostapd_event_connect_failed_reason( |
| 1045 | hapd, data->connect_failed_reason.addr, |
| 1046 | data->connect_failed_reason.code); |
| 1047 | break; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 1048 | case EVENT_SURVEY: |
| 1049 | hostapd_event_get_survey(hapd, &data->survey_results); |
| 1050 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1051 | #ifdef NEED_AP_MLME |
| 1052 | case EVENT_DFS_RADAR_DETECTED: |
| 1053 | if (!data) |
| 1054 | break; |
| 1055 | hostapd_event_dfs_radar_detected(hapd, &data->dfs_event); |
| 1056 | break; |
| 1057 | case EVENT_DFS_CAC_FINISHED: |
| 1058 | if (!data) |
| 1059 | break; |
| 1060 | hostapd_event_dfs_cac_finished(hapd, &data->dfs_event); |
| 1061 | break; |
| 1062 | case EVENT_DFS_CAC_ABORTED: |
| 1063 | if (!data) |
| 1064 | break; |
| 1065 | hostapd_event_dfs_cac_aborted(hapd, &data->dfs_event); |
| 1066 | break; |
| 1067 | case EVENT_DFS_NOP_FINISHED: |
| 1068 | if (!data) |
| 1069 | break; |
| 1070 | hostapd_event_dfs_nop_finished(hapd, &data->dfs_event); |
| 1071 | break; |
| 1072 | case EVENT_CHANNEL_LIST_CHANGED: |
| 1073 | /* channel list changed (regulatory?), update channel list */ |
| 1074 | /* TODO: check this. hostapd_get_hw_features() initializes |
| 1075 | * too much stuff. */ |
| 1076 | /* hostapd_get_hw_features(hapd->iface); */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1077 | hostapd_channel_list_updated( |
| 1078 | hapd->iface, data->channel_list_changed.initiator); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1079 | break; |
| 1080 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1081 | default: |
| 1082 | wpa_printf(MSG_DEBUG, "Unknown event %d", event); |
| 1083 | break; |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | #endif /* HOSTAPD */ |