]>
Commit | Line | Data |
---|---|---|
b5b969e9 JM |
1 | /* |
2 | * hostapd / Callback functions for driver wrappers | |
3 | * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * Alternatively, this software may be distributed under the terms of BSD | |
10 | * license. | |
11 | * | |
12 | * See README and COPYING for more details. | |
13 | */ | |
14 | ||
6226e38d | 15 | #include "utils/includes.h" |
b5b969e9 | 16 | |
6226e38d | 17 | #include "utils/common.h" |
b5b969e9 | 18 | #include "radius/radius.h" |
6e6e8c31 | 19 | #include "drivers/driver.h" |
81f4f619 | 20 | #include "common/ieee802_11_defs.h" |
c41a1095 | 21 | #include "common/ieee802_11_common.h" |
bbb921da | 22 | #include "crypto/random.h" |
ef796391 | 23 | #include "p2p/p2p.h" |
54f489be | 24 | #include "wps/wps.h" |
6226e38d JM |
25 | #include "hostapd.h" |
26 | #include "ieee802_11.h" | |
27 | #include "sta_info.h" | |
28 | #include "accounting.h" | |
29 | #include "tkip_countermeasures.h" | |
6226e38d JM |
30 | #include "ieee802_1x.h" |
31 | #include "wpa_auth.h" | |
6226e38d | 32 | #include "wps_hostapd.h" |
51e2a27a | 33 | #include "ap_drv_ops.h" |
8b06c1ed | 34 | #include "ap_config.h" |
b5b969e9 JM |
35 | |
36 | ||
b5b969e9 | 37 | int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, |
2bb20281 | 38 | const u8 *req_ies, size_t req_ies_len, int reassoc) |
b5b969e9 JM |
39 | { |
40 | struct sta_info *sta; | |
41 | int new_assoc, res; | |
c41a1095 | 42 | struct ieee802_11_elems elems; |
2bb20281 JM |
43 | const u8 *ie; |
44 | size_t ielen; | |
08a74e6a | 45 | u16 reason = WLAN_REASON_UNSPECIFIED; |
b5b969e9 | 46 | |
68532a9c JM |
47 | if (addr == NULL) { |
48 | /* | |
49 | * This could potentially happen with unexpected event from the | |
50 | * driver wrapper. This was seen at least in one case where the | |
51 | * driver ended up being set to station mode while hostapd was | |
52 | * running, so better make sure we stop processing such an | |
53 | * event here. | |
54 | */ | |
55 | wpa_printf(MSG_DEBUG, "hostapd_notif_assoc: Skip event with " | |
56 | "no address"); | |
57 | return -1; | |
58 | } | |
bbb921da | 59 | random_add_randomness(addr, ETH_ALEN); |
68532a9c | 60 | |
b5b969e9 JM |
61 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
62 | HOSTAPD_LEVEL_INFO, "associated"); | |
63 | ||
2bb20281 | 64 | ieee802_11_parse_elems(req_ies, req_ies_len, &elems, 0); |
c41a1095 JM |
65 | if (elems.wps_ie) { |
66 | ie = elems.wps_ie - 2; | |
67 | ielen = elems.wps_ie_len + 2; | |
68 | wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)AssocReq"); | |
69 | } else if (elems.rsn_ie) { | |
70 | ie = elems.rsn_ie - 2; | |
71 | ielen = elems.rsn_ie_len + 2; | |
72 | wpa_printf(MSG_DEBUG, "STA included RSN IE in (Re)AssocReq"); | |
73 | } else if (elems.wpa_ie) { | |
74 | ie = elems.wpa_ie - 2; | |
75 | ielen = elems.wpa_ie_len + 2; | |
76 | wpa_printf(MSG_DEBUG, "STA included WPA IE in (Re)AssocReq"); | |
77 | } else { | |
78 | ie = NULL; | |
79 | ielen = 0; | |
80 | wpa_printf(MSG_DEBUG, "STA did not include WPS/RSN/WPA IE in " | |
81 | "(Re)AssocReq"); | |
82 | } | |
83 | ||
b5b969e9 JM |
84 | sta = ap_get_sta(hapd, addr); |
85 | if (sta) { | |
86 | accounting_sta_stop(hapd, sta); | |
87 | } else { | |
88 | sta = ap_sta_add(hapd, addr); | |
89 | if (sta == NULL) | |
90 | return -1; | |
91 | } | |
17f6b900 | 92 | sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2); |
b5b969e9 | 93 | |
b305c684 JM |
94 | #ifdef CONFIG_P2P |
95 | if (elems.p2p) { | |
96 | wpabuf_free(sta->p2p_ie); | |
2bb20281 | 97 | sta->p2p_ie = ieee802_11_vendor_ie_concat(req_ies, req_ies_len, |
b305c684 JM |
98 | P2P_IE_VENDOR_TYPE); |
99 | } | |
100 | #endif /* CONFIG_P2P */ | |
101 | ||
b5b969e9 JM |
102 | if (hapd->conf->wpa) { |
103 | if (ie == NULL || ielen == 0) { | |
633d4469 | 104 | #ifdef CONFIG_WPS |
b5b969e9 JM |
105 | if (hapd->conf->wps_state) { |
106 | wpa_printf(MSG_DEBUG, "STA did not include " | |
107 | "WPA/RSN IE in (Re)Association " | |
108 | "Request - possible WPS use"); | |
109 | sta->flags |= WLAN_STA_MAYBE_WPS; | |
110 | goto skip_wpa_check; | |
111 | } | |
633d4469 | 112 | #endif /* CONFIG_WPS */ |
b5b969e9 JM |
113 | |
114 | wpa_printf(MSG_DEBUG, "No WPA/RSN IE from STA"); | |
115 | return -1; | |
116 | } | |
633d4469 | 117 | #ifdef CONFIG_WPS |
b5b969e9 JM |
118 | if (hapd->conf->wps_state && ie[0] == 0xdd && ie[1] >= 4 && |
119 | os_memcmp(ie + 2, "\x00\x50\xf2\x04", 4) == 0) { | |
17f6b900 | 120 | struct wpabuf *wps; |
b5b969e9 | 121 | sta->flags |= WLAN_STA_WPS; |
17f6b900 JM |
122 | wps = ieee802_11_vendor_ie_concat(ie, ielen, |
123 | WPS_IE_VENDOR_TYPE); | |
124 | if (wps) { | |
125 | if (wps_is_20(wps)) { | |
126 | wpa_printf(MSG_DEBUG, "WPS: STA " | |
127 | "supports WPS 2.0"); | |
128 | sta->flags |= WLAN_STA_WPS2; | |
129 | } | |
130 | wpabuf_free(wps); | |
131 | } | |
b5b969e9 JM |
132 | goto skip_wpa_check; |
133 | } | |
633d4469 | 134 | #endif /* CONFIG_WPS */ |
b5b969e9 JM |
135 | |
136 | if (sta->wpa_sm == NULL) | |
137 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, | |
138 | sta->addr); | |
139 | if (sta->wpa_sm == NULL) { | |
140 | wpa_printf(MSG_ERROR, "Failed to initialize WPA state " | |
141 | "machine"); | |
142 | return -1; | |
143 | } | |
144 | res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm, | |
145 | ie, ielen, NULL, 0); | |
146 | if (res != WPA_IE_OK) { | |
147 | wpa_printf(MSG_DEBUG, "WPA/RSN information element " | |
148 | "rejected? (res %u)", res); | |
149 | wpa_hexdump(MSG_DEBUG, "IE", ie, ielen); | |
355d36a7 | 150 | if (res == WPA_INVALID_GROUP) |
08a74e6a | 151 | reason = WLAN_REASON_GROUP_CIPHER_NOT_VALID; |
355d36a7 | 152 | else if (res == WPA_INVALID_PAIRWISE) |
08a74e6a | 153 | reason = WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID; |
355d36a7 | 154 | else if (res == WPA_INVALID_AKMP) |
08a74e6a | 155 | reason = WLAN_REASON_AKMP_NOT_VALID; |
355d36a7 AT |
156 | #ifdef CONFIG_IEEE80211W |
157 | else if (res == WPA_MGMT_FRAME_PROTECTION_VIOLATION) | |
08a74e6a | 158 | reason = WLAN_REASON_INVALID_IE; |
355d36a7 | 159 | else if (res == WPA_INVALID_MGMT_GROUP_CIPHER) |
08a74e6a | 160 | reason = WLAN_REASON_GROUP_CIPHER_NOT_VALID; |
355d36a7 AT |
161 | #endif /* CONFIG_IEEE80211W */ |
162 | else | |
08a74e6a JM |
163 | reason = WLAN_REASON_INVALID_IE; |
164 | goto fail; | |
b5b969e9 | 165 | } |
a9aca28b | 166 | } else if (hapd->conf->wps_state) { |
633d4469 | 167 | #ifdef CONFIG_WPS |
17f6b900 | 168 | struct wpabuf *wps; |
2bb20281 JM |
169 | if (req_ies) |
170 | wps = ieee802_11_vendor_ie_concat(req_ies, req_ies_len, | |
fa15d405 JM |
171 | WPS_IE_VENDOR_TYPE); |
172 | else | |
173 | wps = NULL; | |
54f489be | 174 | #ifdef CONFIG_WPS_STRICT |
fa15d405 | 175 | if (wps && wps_validate_assoc_req(wps) < 0) { |
08a74e6a | 176 | reason = WLAN_REASON_INVALID_IE; |
fa15d405 | 177 | wpabuf_free(wps); |
08a74e6a | 178 | goto fail; |
54f489be | 179 | } |
54f489be | 180 | #endif /* CONFIG_WPS_STRICT */ |
fa15d405 | 181 | if (wps) { |
a9aca28b | 182 | sta->flags |= WLAN_STA_WPS; |
fa15d405 | 183 | if (wps_is_20(wps)) { |
17f6b900 JM |
184 | wpa_printf(MSG_DEBUG, "WPS: STA supports " |
185 | "WPS 2.0"); | |
186 | sta->flags |= WLAN_STA_WPS2; | |
187 | } | |
a9aca28b JM |
188 | } else |
189 | sta->flags |= WLAN_STA_MAYBE_WPS; | |
17f6b900 | 190 | wpabuf_free(wps); |
633d4469 | 191 | #endif /* CONFIG_WPS */ |
b5b969e9 | 192 | } |
633d4469 | 193 | #ifdef CONFIG_WPS |
b5b969e9 | 194 | skip_wpa_check: |
633d4469 | 195 | #endif /* CONFIG_WPS */ |
b5b969e9 JM |
196 | |
197 | new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0; | |
198 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC; | |
199 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC); | |
200 | ||
201 | hostapd_new_assoc_sta(hapd, sta, !new_assoc); | |
202 | ||
203 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 1); | |
204 | ||
ef796391 | 205 | #ifdef CONFIG_P2P |
3f4ce13f | 206 | p2p_group_notif_assoc(hapd->p2p_group, sta->addr, |
2bb20281 | 207 | req_ies, req_ies_len); |
ef796391 JM |
208 | #endif /* CONFIG_P2P */ |
209 | ||
b5b969e9 | 210 | return 0; |
08a74e6a JM |
211 | |
212 | fail: | |
213 | hostapd_drv_sta_disassoc(hapd, sta->addr, reason); | |
214 | ap_free_sta(hapd, sta); | |
215 | return -1; | |
b5b969e9 JM |
216 | } |
217 | ||
218 | ||
219 | void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr) | |
220 | { | |
221 | struct sta_info *sta; | |
222 | ||
83e843e8 JM |
223 | if (addr == NULL) { |
224 | /* | |
225 | * This could potentially happen with unexpected event from the | |
226 | * driver wrapper. This was seen at least in one case where the | |
227 | * driver ended up reporting a station mode event while hostapd | |
228 | * was running, so better make sure we stop processing such an | |
229 | * event here. | |
230 | */ | |
231 | wpa_printf(MSG_DEBUG, "hostapd_notif_disassoc: Skip event " | |
232 | "with no address"); | |
1f4c7b6b | 233 | return; |
83e843e8 JM |
234 | } |
235 | ||
b5b969e9 JM |
236 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
237 | HOSTAPD_LEVEL_INFO, "disassociated"); | |
238 | ||
239 | sta = ap_get_sta(hapd, addr); | |
240 | if (sta == NULL) { | |
241 | wpa_printf(MSG_DEBUG, "Disassociation notification for " | |
242 | "unknown STA " MACSTR, MAC2STR(addr)); | |
243 | return; | |
244 | } | |
245 | ||
ae055af4 | 246 | ap_sta_set_authorized(hapd, sta, 0); |
b5b969e9 JM |
247 | sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); |
248 | wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC); | |
249 | sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST; | |
250 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); | |
251 | ap_free_sta(hapd, sta); | |
252 | } | |
253 | ||
254 | ||
0d7e5a3a JB |
255 | void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr) |
256 | { | |
257 | struct sta_info *sta = ap_get_sta(hapd, addr); | |
258 | ||
259 | if (!sta || !hapd->conf->disassoc_low_ack) | |
260 | return; | |
261 | ||
262 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, | |
263 | HOSTAPD_LEVEL_INFO, "disconnected due to excessive " | |
264 | "missing ACKs"); | |
265 | hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_DISASSOC_LOW_ACK); | |
266 | if (sta) | |
267 | ap_sta_disassociate(hapd, sta, WLAN_REASON_DISASSOC_LOW_ACK); | |
268 | } | |
269 | ||
270 | ||
04a85e44 JM |
271 | int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da, |
272 | const u8 *bssid, const u8 *ie, size_t ie_len) | |
e67b55fb JM |
273 | { |
274 | size_t i; | |
275 | int ret = 0; | |
276 | ||
b211f3eb JM |
277 | if (sa == NULL || ie == NULL) |
278 | return -1; | |
279 | ||
280 | random_add_randomness(sa, ETH_ALEN); | |
e67b55fb JM |
281 | for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) { |
282 | if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx, | |
04a85e44 | 283 | sa, da, bssid, ie, ie_len) > 0) { |
e67b55fb JM |
284 | ret = 1; |
285 | break; | |
286 | } | |
287 | } | |
288 | return ret; | |
289 | } | |
290 | ||
291 | ||
f8b1f695 JM |
292 | #ifdef HOSTAPD |
293 | ||
fe6bdb77 | 294 | #ifdef NEED_AP_MLME |
f8b1f695 | 295 | |
f8b1f695 JM |
296 | #define HAPD_BROADCAST ((struct hostapd_data *) -1) |
297 | ||
298 | static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, | |
299 | const u8 *bssid) | |
300 | { | |
301 | size_t i; | |
302 | ||
303 | if (bssid == NULL) | |
304 | return NULL; | |
305 | if (bssid[0] == 0xff && bssid[1] == 0xff && bssid[2] == 0xff && | |
306 | bssid[3] == 0xff && bssid[4] == 0xff && bssid[5] == 0xff) | |
307 | return HAPD_BROADCAST; | |
308 | ||
309 | for (i = 0; i < iface->num_bss; i++) { | |
310 | if (os_memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0) | |
311 | return iface->bss[i]; | |
312 | } | |
313 | ||
314 | return NULL; | |
315 | } | |
316 | ||
317 | ||
318 | static void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, | |
9b90955e JB |
319 | const u8 *bssid, const u8 *addr, |
320 | int wds) | |
f8b1f695 | 321 | { |
9b90955e | 322 | hapd = get_hapd_bssid(hapd->iface, bssid); |
f8b1f695 JM |
323 | if (hapd == NULL || hapd == HAPD_BROADCAST) |
324 | return; | |
325 | ||
9b90955e | 326 | ieee802_11_rx_from_unknown(hapd, addr, wds); |
f8b1f695 JM |
327 | } |
328 | ||
329 | ||
2a8b7416 | 330 | static void hostapd_mgmt_rx(struct hostapd_data *hapd, struct rx_mgmt *rx_mgmt) |
b5b969e9 | 331 | { |
4b9841d3 | 332 | struct hostapd_iface *iface = hapd->iface; |
b57e086c | 333 | const struct ieee80211_hdr *hdr; |
4b9841d3 | 334 | const u8 *bssid; |
2a8b7416 | 335 | struct hostapd_frame_info fi; |
4b9841d3 | 336 | |
2a8b7416 JM |
337 | hdr = (const struct ieee80211_hdr *) rx_mgmt->frame; |
338 | bssid = get_hdr_bssid(hdr, rx_mgmt->frame_len); | |
4b9841d3 JM |
339 | if (bssid == NULL) |
340 | return; | |
341 | ||
342 | hapd = get_hapd_bssid(iface, bssid); | |
343 | if (hapd == NULL) { | |
344 | u16 fc; | |
345 | fc = le_to_host16(hdr->frame_control); | |
346 | ||
347 | /* | |
348 | * Drop frames to unknown BSSIDs except for Beacon frames which | |
349 | * could be used to update neighbor information. | |
350 | */ | |
351 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && | |
352 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON) | |
353 | hapd = iface->bss[0]; | |
354 | else | |
355 | return; | |
356 | } | |
357 | ||
2a8b7416 JM |
358 | os_memset(&fi, 0, sizeof(fi)); |
359 | fi.datarate = rx_mgmt->datarate; | |
360 | fi.ssi_signal = rx_mgmt->ssi_signal; | |
361 | ||
4b9841d3 JM |
362 | if (hapd == HAPD_BROADCAST) { |
363 | size_t i; | |
364 | for (i = 0; i < iface->num_bss; i++) | |
2a8b7416 JM |
365 | ieee802_11_mgmt(iface->bss[i], rx_mgmt->frame, |
366 | rx_mgmt->frame_len, &fi); | |
4b9841d3 | 367 | } else |
2a8b7416 | 368 | ieee802_11_mgmt(hapd, rx_mgmt->frame, rx_mgmt->frame_len, &fi); |
bbb921da JM |
369 | |
370 | random_add_randomness(&fi, sizeof(fi)); | |
b5b969e9 JM |
371 | } |
372 | ||
373 | ||
9e2704c3 JM |
374 | static void hostapd_rx_action(struct hostapd_data *hapd, |
375 | struct rx_action *rx_action) | |
376 | { | |
377 | struct rx_mgmt rx_mgmt; | |
378 | u8 *buf; | |
379 | struct ieee80211_hdr *hdr; | |
380 | ||
381 | wpa_printf(MSG_DEBUG, "EVENT_RX_ACTION DA=" MACSTR " SA=" MACSTR | |
382 | " BSSID=" MACSTR " category=%u", | |
383 | MAC2STR(rx_action->da), MAC2STR(rx_action->sa), | |
384 | MAC2STR(rx_action->bssid), rx_action->category); | |
385 | wpa_hexdump(MSG_MSGDUMP, "Received action frame contents", | |
386 | rx_action->data, rx_action->len); | |
387 | ||
388 | buf = os_zalloc(24 + 1 + rx_action->len); | |
389 | if (buf == NULL) | |
390 | return; | |
391 | hdr = (struct ieee80211_hdr *) buf; | |
392 | hdr->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, | |
393 | WLAN_FC_STYPE_ACTION); | |
394 | if (rx_action->category == WLAN_ACTION_SA_QUERY) { | |
395 | /* | |
396 | * Assume frame was protected; it would have been dropped if | |
397 | * not. | |
398 | */ | |
399 | hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP); | |
400 | } | |
401 | os_memcpy(hdr->addr1, rx_action->da, ETH_ALEN); | |
402 | os_memcpy(hdr->addr2, rx_action->sa, ETH_ALEN); | |
403 | os_memcpy(hdr->addr3, rx_action->bssid, ETH_ALEN); | |
404 | buf[24] = rx_action->category; | |
405 | os_memcpy(buf + 24 + 1, rx_action->data, rx_action->len); | |
406 | os_memset(&rx_mgmt, 0, sizeof(rx_mgmt)); | |
407 | rx_mgmt.frame = buf; | |
408 | rx_mgmt.frame_len = 24 + 1 + rx_action->len; | |
409 | hostapd_mgmt_rx(hapd, &rx_mgmt); | |
410 | os_free(buf); | |
411 | } | |
412 | ||
413 | ||
f8b1f695 JM |
414 | static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, |
415 | size_t len, u16 stype, int ok) | |
b5b969e9 | 416 | { |
4b9841d3 JM |
417 | struct ieee80211_hdr *hdr; |
418 | hdr = (struct ieee80211_hdr *) buf; | |
419 | hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len)); | |
420 | if (hapd == NULL || hapd == HAPD_BROADCAST) | |
421 | return; | |
b5b969e9 JM |
422 | ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); |
423 | } | |
f82ef4d8 | 424 | |
f8b1f695 | 425 | #endif /* NEED_AP_MLME */ |
ad1e68e6 JM |
426 | |
427 | ||
a8e0505b JM |
428 | static int hostapd_event_new_sta(struct hostapd_data *hapd, const u8 *addr) |
429 | { | |
430 | struct sta_info *sta = ap_get_sta(hapd, addr); | |
431 | if (sta) | |
432 | return 0; | |
433 | ||
434 | wpa_printf(MSG_DEBUG, "Data frame from unknown STA " MACSTR | |
435 | " - adding a new STA", MAC2STR(addr)); | |
436 | sta = ap_sta_add(hapd, addr); | |
437 | if (sta) { | |
438 | hostapd_new_assoc_sta(hapd, sta, 0); | |
439 | } else { | |
440 | wpa_printf(MSG_DEBUG, "Failed to add STA entry for " MACSTR, | |
441 | MAC2STR(addr)); | |
442 | return -1; | |
443 | } | |
444 | ||
445 | return 0; | |
446 | } | |
447 | ||
448 | ||
449 | static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, | |
450 | const u8 *data, size_t data_len) | |
451 | { | |
452 | struct hostapd_iface *iface = hapd->iface; | |
453 | size_t j; | |
454 | ||
455 | for (j = 0; j < iface->num_bss; j++) { | |
456 | if (ap_get_sta(iface->bss[j], src)) { | |
457 | hapd = iface->bss[j]; | |
458 | break; | |
459 | } | |
460 | } | |
461 | ||
462 | ieee802_1x_receive(hapd, src, data, data_len); | |
463 | } | |
464 | ||
465 | ||
9646a8ab | 466 | void wpa_supplicant_event(void *ctx, enum wpa_event_type event, |
ad1e68e6 JM |
467 | union wpa_event_data *data) |
468 | { | |
469 | struct hostapd_data *hapd = ctx; | |
470 | ||
471 | switch (event) { | |
472 | case EVENT_MICHAEL_MIC_FAILURE: | |
473 | michael_mic_failure(hapd, data->michael_mic_failure.src, 1); | |
474 | break; | |
475 | case EVENT_SCAN_RESULTS: | |
476 | if (hapd->iface->scan_cb) | |
477 | hapd->iface->scan_cb(hapd->iface); | |
478 | break; | |
08fd8c15 | 479 | #ifdef CONFIG_IEEE80211R |
f2dab64e | 480 | case EVENT_FT_RRB_RX: |
08fd8c15 JM |
481 | wpa_ft_rrb_rx(hapd->wpa_auth, data->ft_rrb_rx.src, |
482 | data->ft_rrb_rx.data, data->ft_rrb_rx.data_len); | |
483 | break; | |
484 | #endif /* CONFIG_IEEE80211R */ | |
fcf0f87d | 485 | case EVENT_WPS_BUTTON_PUSHED: |
d601247c | 486 | hostapd_wps_button_pushed(hapd, NULL); |
fcf0f87d | 487 | break; |
f8b1f695 JM |
488 | #ifdef NEED_AP_MLME |
489 | case EVENT_TX_STATUS: | |
490 | switch (data->tx_status.type) { | |
491 | case WLAN_FC_TYPE_MGMT: | |
492 | hostapd_mgmt_tx_cb(hapd, data->tx_status.data, | |
493 | data->tx_status.data_len, | |
494 | data->tx_status.stype, | |
495 | data->tx_status.ack); | |
496 | break; | |
497 | case WLAN_FC_TYPE_DATA: | |
498 | hostapd_tx_status(hapd, data->tx_status.dst, | |
499 | data->tx_status.data, | |
500 | data->tx_status.data_len, | |
501 | data->tx_status.ack); | |
502 | break; | |
503 | } | |
504 | break; | |
bcf24348 JB |
505 | case EVENT_DRIVER_CLIENT_POLL_OK: |
506 | hostapd_client_poll_ok(hapd, data->client_poll.addr); | |
507 | break; | |
f8b1f695 | 508 | case EVENT_RX_FROM_UNKNOWN: |
9b90955e JB |
509 | hostapd_rx_from_unknown_sta(hapd, data->rx_from_unknown.bssid, |
510 | data->rx_from_unknown.addr, | |
511 | data->rx_from_unknown.wds); | |
f8b1f695 JM |
512 | break; |
513 | case EVENT_RX_MGMT: | |
2a8b7416 | 514 | hostapd_mgmt_rx(hapd, &data->rx_mgmt); |
f8b1f695 JM |
515 | break; |
516 | #endif /* NEED_AP_MLME */ | |
a0e0d3bb | 517 | case EVENT_RX_PROBE_REQ: |
b211f3eb JM |
518 | if (data->rx_probe_req.sa == NULL || |
519 | data->rx_probe_req.ie == NULL) | |
520 | break; | |
a0e0d3bb | 521 | hostapd_probe_req_rx(hapd, data->rx_probe_req.sa, |
04a85e44 JM |
522 | data->rx_probe_req.da, |
523 | data->rx_probe_req.bssid, | |
a0e0d3bb JM |
524 | data->rx_probe_req.ie, |
525 | data->rx_probe_req.ie_len); | |
526 | break; | |
a70a5d6d | 527 | case EVENT_NEW_STA: |
a8e0505b JM |
528 | hostapd_event_new_sta(hapd, data->new_sta.addr); |
529 | break; | |
530 | case EVENT_EAPOL_RX: | |
531 | hostapd_event_eapol_rx(hapd, data->eapol_rx.src, | |
532 | data->eapol_rx.data, | |
533 | data->eapol_rx.data_len); | |
534 | break; | |
1d041bec JM |
535 | case EVENT_ASSOC: |
536 | hostapd_notif_assoc(hapd, data->assoc_info.addr, | |
537 | data->assoc_info.req_ies, | |
39b08b5f SP |
538 | data->assoc_info.req_ies_len, |
539 | data->assoc_info.reassoc); | |
1d041bec JM |
540 | break; |
541 | case EVENT_DISASSOC: | |
542 | if (data) | |
543 | hostapd_notif_disassoc(hapd, data->disassoc_info.addr); | |
544 | break; | |
545 | case EVENT_DEAUTH: | |
546 | if (data) | |
547 | hostapd_notif_disassoc(hapd, data->deauth_info.addr); | |
548 | break; | |
0d7e5a3a JB |
549 | case EVENT_STATION_LOW_ACK: |
550 | if (!data) | |
551 | break; | |
552 | hostapd_event_sta_low_ack(hapd, data->low_ack.addr); | |
553 | break; | |
7cc7307d | 554 | #ifdef NEED_AP_MLME |
9e2704c3 JM |
555 | case EVENT_RX_ACTION: |
556 | if (data->rx_action.da == NULL || data->rx_action.sa == NULL || | |
557 | data->rx_action.bssid == NULL) | |
558 | break; | |
559 | hostapd_rx_action(hapd, &data->rx_action); | |
560 | break; | |
7cc7307d | 561 | #endif /* NEED_AP_MLME */ |
ad1e68e6 JM |
562 | default: |
563 | wpa_printf(MSG_DEBUG, "Unknown event %d", event); | |
564 | break; | |
565 | } | |
566 | } | |
f8b1f695 JM |
567 | |
568 | #endif /* HOSTAPD */ |