]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/ap/drv_callbacks.c
AP: Reset STA timeout_next on driver-based-SME association
[thirdparty/hostap.git] / src / ap / drv_callbacks.c
CommitLineData
b5b969e9
JM
1/*
2 * hostapd / Callback functions for driver wrappers
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
4 *
0f3d578e
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
b5b969e9
JM
7 */
8
6226e38d 9#include "utils/includes.h"
b5b969e9 10
6226e38d 11#include "utils/common.h"
b5b969e9 12#include "radius/radius.h"
6e6e8c31 13#include "drivers/driver.h"
81f4f619 14#include "common/ieee802_11_defs.h"
c41a1095 15#include "common/ieee802_11_common.h"
bbb921da 16#include "crypto/random.h"
ef796391 17#include "p2p/p2p.h"
54f489be 18#include "wps/wps.h"
6226e38d
JM
19#include "hostapd.h"
20#include "ieee802_11.h"
21#include "sta_info.h"
22#include "accounting.h"
23#include "tkip_countermeasures.h"
6226e38d
JM
24#include "ieee802_1x.h"
25#include "wpa_auth.h"
6226e38d 26#include "wps_hostapd.h"
51e2a27a 27#include "ap_drv_ops.h"
8b06c1ed 28#include "ap_config.h"
b5b969e9
JM
29
30
b5b969e9 31int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
2bb20281 32 const u8 *req_ies, size_t req_ies_len, int reassoc)
b5b969e9
JM
33{
34 struct sta_info *sta;
35 int new_assoc, res;
c41a1095 36 struct ieee802_11_elems elems;
2bb20281
JM
37 const u8 *ie;
38 size_t ielen;
08a74e6a 39 u16 reason = WLAN_REASON_UNSPECIFIED;
b5b969e9 40
68532a9c
JM
41 if (addr == NULL) {
42 /*
43 * This could potentially happen with unexpected event from the
44 * driver wrapper. This was seen at least in one case where the
45 * driver ended up being set to station mode while hostapd was
46 * running, so better make sure we stop processing such an
47 * event here.
48 */
49 wpa_printf(MSG_DEBUG, "hostapd_notif_assoc: Skip event with "
50 "no address");
51 return -1;
52 }
bbb921da 53 random_add_randomness(addr, ETH_ALEN);
68532a9c 54
b5b969e9
JM
55 hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
56 HOSTAPD_LEVEL_INFO, "associated");
57
2bb20281 58 ieee802_11_parse_elems(req_ies, req_ies_len, &elems, 0);
c41a1095
JM
59 if (elems.wps_ie) {
60 ie = elems.wps_ie - 2;
61 ielen = elems.wps_ie_len + 2;
62 wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)AssocReq");
63 } else if (elems.rsn_ie) {
64 ie = elems.rsn_ie - 2;
65 ielen = elems.rsn_ie_len + 2;
66 wpa_printf(MSG_DEBUG, "STA included RSN IE in (Re)AssocReq");
67 } else if (elems.wpa_ie) {
68 ie = elems.wpa_ie - 2;
69 ielen = elems.wpa_ie_len + 2;
70 wpa_printf(MSG_DEBUG, "STA included WPA IE in (Re)AssocReq");
71 } else {
72 ie = NULL;
73 ielen = 0;
74 wpa_printf(MSG_DEBUG, "STA did not include WPS/RSN/WPA IE in "
75 "(Re)AssocReq");
76 }
77
b5b969e9
JM
78 sta = ap_get_sta(hapd, addr);
79 if (sta) {
80 accounting_sta_stop(hapd, sta);
c72bd6d4
JM
81
82 /*
83 * Make sure that the previously registered inactivity timer
84 * will not remove the STA immediately.
85 */
86 sta->timeout_next = STA_NULLFUNC;
b5b969e9
JM
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 194skip_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
99c01af9
JM
206 if (req_ies) {
207 p2p_group_notif_assoc(hapd->p2p_group, sta->addr,
208 req_ies, req_ies_len);
209 }
ef796391
JM
210#endif /* CONFIG_P2P */
211
b5b969e9 212 return 0;
08a74e6a
JM
213
214fail:
215 hostapd_drv_sta_disassoc(hapd, sta->addr, reason);
216 ap_free_sta(hapd, sta);
217 return -1;
b5b969e9
JM
218}
219
220
221void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr)
222{
223 struct sta_info *sta;
224
83e843e8
JM
225 if (addr == NULL) {
226 /*
227 * This could potentially happen with unexpected event from the
228 * driver wrapper. This was seen at least in one case where the
229 * driver ended up reporting a station mode event while hostapd
230 * was running, so better make sure we stop processing such an
231 * event here.
232 */
233 wpa_printf(MSG_DEBUG, "hostapd_notif_disassoc: Skip event "
234 "with no address");
1f4c7b6b 235 return;
83e843e8
JM
236 }
237
b5b969e9
JM
238 hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
239 HOSTAPD_LEVEL_INFO, "disassociated");
240
241 sta = ap_get_sta(hapd, addr);
242 if (sta == NULL) {
243 wpa_printf(MSG_DEBUG, "Disassociation notification for "
244 "unknown STA " MACSTR, MAC2STR(addr));
245 return;
246 }
247
ae055af4 248 ap_sta_set_authorized(hapd, sta, 0);
b5b969e9
JM
249 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
250 wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
251 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
252 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
253 ap_free_sta(hapd, sta);
254}
255
256
0d7e5a3a
JB
257void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr)
258{
259 struct sta_info *sta = ap_get_sta(hapd, addr);
260
261 if (!sta || !hapd->conf->disassoc_low_ack)
262 return;
263
264 hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
265 HOSTAPD_LEVEL_INFO, "disconnected due to excessive "
266 "missing ACKs");
267 hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_DISASSOC_LOW_ACK);
268 if (sta)
269 ap_sta_disassociate(hapd, sta, WLAN_REASON_DISASSOC_LOW_ACK);
270}
271
272
04a85e44 273int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
baf513d6
JB
274 const u8 *bssid, const u8 *ie, size_t ie_len,
275 int ssi_signal)
e67b55fb
JM
276{
277 size_t i;
278 int ret = 0;
279
b211f3eb
JM
280 if (sa == NULL || ie == NULL)
281 return -1;
282
283 random_add_randomness(sa, ETH_ALEN);
e67b55fb
JM
284 for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) {
285 if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
baf513d6
JB
286 sa, da, bssid, ie, ie_len,
287 ssi_signal) > 0) {
e67b55fb
JM
288 ret = 1;
289 break;
290 }
291 }
292 return ret;
293}
294
295
f8b1f695
JM
296#ifdef HOSTAPD
297
fe6bdb77 298#ifdef NEED_AP_MLME
f8b1f695 299
f8b1f695
JM
300#define HAPD_BROADCAST ((struct hostapd_data *) -1)
301
302static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface,
303 const u8 *bssid)
304{
305 size_t i;
306
307 if (bssid == NULL)
308 return NULL;
309 if (bssid[0] == 0xff && bssid[1] == 0xff && bssid[2] == 0xff &&
310 bssid[3] == 0xff && bssid[4] == 0xff && bssid[5] == 0xff)
311 return HAPD_BROADCAST;
312
313 for (i = 0; i < iface->num_bss; i++) {
314 if (os_memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0)
315 return iface->bss[i];
316 }
317
318 return NULL;
319}
320
321
322static void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd,
9b90955e
JB
323 const u8 *bssid, const u8 *addr,
324 int wds)
f8b1f695 325{
9b90955e 326 hapd = get_hapd_bssid(hapd->iface, bssid);
f8b1f695
JM
327 if (hapd == NULL || hapd == HAPD_BROADCAST)
328 return;
329
9b90955e 330 ieee802_11_rx_from_unknown(hapd, addr, wds);
f8b1f695
JM
331}
332
333
2a8b7416 334static void hostapd_mgmt_rx(struct hostapd_data *hapd, struct rx_mgmt *rx_mgmt)
b5b969e9 335{
4b9841d3 336 struct hostapd_iface *iface = hapd->iface;
b57e086c 337 const struct ieee80211_hdr *hdr;
4b9841d3 338 const u8 *bssid;
2a8b7416 339 struct hostapd_frame_info fi;
4b9841d3 340
2a8b7416
JM
341 hdr = (const struct ieee80211_hdr *) rx_mgmt->frame;
342 bssid = get_hdr_bssid(hdr, rx_mgmt->frame_len);
4b9841d3
JM
343 if (bssid == NULL)
344 return;
345
346 hapd = get_hapd_bssid(iface, bssid);
347 if (hapd == NULL) {
348 u16 fc;
349 fc = le_to_host16(hdr->frame_control);
350
351 /*
352 * Drop frames to unknown BSSIDs except for Beacon frames which
353 * could be used to update neighbor information.
354 */
355 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
356 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
357 hapd = iface->bss[0];
358 else
359 return;
360 }
361
2a8b7416
JM
362 os_memset(&fi, 0, sizeof(fi));
363 fi.datarate = rx_mgmt->datarate;
364 fi.ssi_signal = rx_mgmt->ssi_signal;
365
4b9841d3
JM
366 if (hapd == HAPD_BROADCAST) {
367 size_t i;
368 for (i = 0; i < iface->num_bss; i++)
2a8b7416
JM
369 ieee802_11_mgmt(iface->bss[i], rx_mgmt->frame,
370 rx_mgmt->frame_len, &fi);
4b9841d3 371 } else
2a8b7416 372 ieee802_11_mgmt(hapd, rx_mgmt->frame, rx_mgmt->frame_len, &fi);
bbb921da
JM
373
374 random_add_randomness(&fi, sizeof(fi));
b5b969e9
JM
375}
376
377
9e2704c3
JM
378static void hostapd_rx_action(struct hostapd_data *hapd,
379 struct rx_action *rx_action)
380{
381 struct rx_mgmt rx_mgmt;
382 u8 *buf;
383 struct ieee80211_hdr *hdr;
384
385 wpa_printf(MSG_DEBUG, "EVENT_RX_ACTION DA=" MACSTR " SA=" MACSTR
386 " BSSID=" MACSTR " category=%u",
387 MAC2STR(rx_action->da), MAC2STR(rx_action->sa),
388 MAC2STR(rx_action->bssid), rx_action->category);
389 wpa_hexdump(MSG_MSGDUMP, "Received action frame contents",
390 rx_action->data, rx_action->len);
391
392 buf = os_zalloc(24 + 1 + rx_action->len);
393 if (buf == NULL)
394 return;
395 hdr = (struct ieee80211_hdr *) buf;
396 hdr->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
397 WLAN_FC_STYPE_ACTION);
398 if (rx_action->category == WLAN_ACTION_SA_QUERY) {
399 /*
400 * Assume frame was protected; it would have been dropped if
401 * not.
402 */
403 hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
404 }
405 os_memcpy(hdr->addr1, rx_action->da, ETH_ALEN);
406 os_memcpy(hdr->addr2, rx_action->sa, ETH_ALEN);
407 os_memcpy(hdr->addr3, rx_action->bssid, ETH_ALEN);
408 buf[24] = rx_action->category;
409 os_memcpy(buf + 24 + 1, rx_action->data, rx_action->len);
410 os_memset(&rx_mgmt, 0, sizeof(rx_mgmt));
411 rx_mgmt.frame = buf;
412 rx_mgmt.frame_len = 24 + 1 + rx_action->len;
413 hostapd_mgmt_rx(hapd, &rx_mgmt);
414 os_free(buf);
415}
416
417
f8b1f695
JM
418static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf,
419 size_t len, u16 stype, int ok)
b5b969e9 420{
4b9841d3
JM
421 struct ieee80211_hdr *hdr;
422 hdr = (struct ieee80211_hdr *) buf;
423 hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len));
424 if (hapd == NULL || hapd == HAPD_BROADCAST)
425 return;
b5b969e9
JM
426 ieee802_11_mgmt_cb(hapd, buf, len, stype, ok);
427}
f82ef4d8 428
f8b1f695 429#endif /* NEED_AP_MLME */
ad1e68e6
JM
430
431
a8e0505b
JM
432static int hostapd_event_new_sta(struct hostapd_data *hapd, const u8 *addr)
433{
434 struct sta_info *sta = ap_get_sta(hapd, addr);
435 if (sta)
436 return 0;
437
438 wpa_printf(MSG_DEBUG, "Data frame from unknown STA " MACSTR
439 " - adding a new STA", MAC2STR(addr));
440 sta = ap_sta_add(hapd, addr);
441 if (sta) {
442 hostapd_new_assoc_sta(hapd, sta, 0);
443 } else {
444 wpa_printf(MSG_DEBUG, "Failed to add STA entry for " MACSTR,
445 MAC2STR(addr));
446 return -1;
447 }
448
449 return 0;
450}
451
452
453static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src,
454 const u8 *data, size_t data_len)
455{
456 struct hostapd_iface *iface = hapd->iface;
457 size_t j;
458
459 for (j = 0; j < iface->num_bss; j++) {
460 if (ap_get_sta(iface->bss[j], src)) {
461 hapd = iface->bss[j];
462 break;
463 }
464 }
465
466 ieee802_1x_receive(hapd, src, data, data_len);
467}
468
469
9646a8ab 470void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
ad1e68e6
JM
471 union wpa_event_data *data)
472{
473 struct hostapd_data *hapd = ctx;
74781dfc
JM
474#ifndef CONFIG_NO_STDOUT_DEBUG
475 int level = MSG_DEBUG;
ad1e68e6 476
74781dfc
JM
477 if (event == EVENT_RX_MGMT && data && data->rx_mgmt.frame &&
478 data->rx_mgmt.frame_len >= 24) {
479 const struct ieee80211_hdr *hdr;
480 u16 fc;
481 hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame;
482 fc = le_to_host16(hdr->frame_control);
483 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
484 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
485 level = MSG_EXCESSIVE;
486 }
487
488 wpa_dbg(hapd->msg_ctx, level, "Event %s (%d) received",
e26cd1a1 489 event_to_string(event), event);
74781dfc 490#endif /* CONFIG_NO_STDOUT_DEBUG */
e26cd1a1 491
ad1e68e6
JM
492 switch (event) {
493 case EVENT_MICHAEL_MIC_FAILURE:
494 michael_mic_failure(hapd, data->michael_mic_failure.src, 1);
495 break;
496 case EVENT_SCAN_RESULTS:
497 if (hapd->iface->scan_cb)
498 hapd->iface->scan_cb(hapd->iface);
499 break;
08fd8c15 500#ifdef CONFIG_IEEE80211R
f2dab64e 501 case EVENT_FT_RRB_RX:
08fd8c15
JM
502 wpa_ft_rrb_rx(hapd->wpa_auth, data->ft_rrb_rx.src,
503 data->ft_rrb_rx.data, data->ft_rrb_rx.data_len);
504 break;
505#endif /* CONFIG_IEEE80211R */
fcf0f87d 506 case EVENT_WPS_BUTTON_PUSHED:
d601247c 507 hostapd_wps_button_pushed(hapd, NULL);
fcf0f87d 508 break;
f8b1f695
JM
509#ifdef NEED_AP_MLME
510 case EVENT_TX_STATUS:
511 switch (data->tx_status.type) {
512 case WLAN_FC_TYPE_MGMT:
513 hostapd_mgmt_tx_cb(hapd, data->tx_status.data,
514 data->tx_status.data_len,
515 data->tx_status.stype,
516 data->tx_status.ack);
517 break;
518 case WLAN_FC_TYPE_DATA:
519 hostapd_tx_status(hapd, data->tx_status.dst,
520 data->tx_status.data,
521 data->tx_status.data_len,
522 data->tx_status.ack);
523 break;
524 }
525 break;
dd840f79
JB
526 case EVENT_EAPOL_TX_STATUS:
527 hostapd_eapol_tx_status(hapd, data->eapol_tx_status.dst,
528 data->eapol_tx_status.data,
529 data->eapol_tx_status.data_len,
530 data->eapol_tx_status.ack);
531 break;
bcf24348
JB
532 case EVENT_DRIVER_CLIENT_POLL_OK:
533 hostapd_client_poll_ok(hapd, data->client_poll.addr);
534 break;
f8b1f695 535 case EVENT_RX_FROM_UNKNOWN:
9b90955e
JB
536 hostapd_rx_from_unknown_sta(hapd, data->rx_from_unknown.bssid,
537 data->rx_from_unknown.addr,
538 data->rx_from_unknown.wds);
f8b1f695
JM
539 break;
540 case EVENT_RX_MGMT:
2a8b7416 541 hostapd_mgmt_rx(hapd, &data->rx_mgmt);
f8b1f695
JM
542 break;
543#endif /* NEED_AP_MLME */
a0e0d3bb 544 case EVENT_RX_PROBE_REQ:
b211f3eb
JM
545 if (data->rx_probe_req.sa == NULL ||
546 data->rx_probe_req.ie == NULL)
547 break;
a0e0d3bb 548 hostapd_probe_req_rx(hapd, data->rx_probe_req.sa,
04a85e44
JM
549 data->rx_probe_req.da,
550 data->rx_probe_req.bssid,
a0e0d3bb 551 data->rx_probe_req.ie,
baf513d6
JB
552 data->rx_probe_req.ie_len,
553 data->rx_probe_req.ssi_signal);
a0e0d3bb 554 break;
a70a5d6d 555 case EVENT_NEW_STA:
a8e0505b
JM
556 hostapd_event_new_sta(hapd, data->new_sta.addr);
557 break;
558 case EVENT_EAPOL_RX:
559 hostapd_event_eapol_rx(hapd, data->eapol_rx.src,
560 data->eapol_rx.data,
561 data->eapol_rx.data_len);
562 break;
1d041bec
JM
563 case EVENT_ASSOC:
564 hostapd_notif_assoc(hapd, data->assoc_info.addr,
565 data->assoc_info.req_ies,
39b08b5f
SP
566 data->assoc_info.req_ies_len,
567 data->assoc_info.reassoc);
1d041bec
JM
568 break;
569 case EVENT_DISASSOC:
570 if (data)
571 hostapd_notif_disassoc(hapd, data->disassoc_info.addr);
572 break;
573 case EVENT_DEAUTH:
574 if (data)
575 hostapd_notif_disassoc(hapd, data->deauth_info.addr);
576 break;
0d7e5a3a
JB
577 case EVENT_STATION_LOW_ACK:
578 if (!data)
579 break;
580 hostapd_event_sta_low_ack(hapd, data->low_ack.addr);
581 break;
7cc7307d 582#ifdef NEED_AP_MLME
9e2704c3
JM
583 case EVENT_RX_ACTION:
584 if (data->rx_action.da == NULL || data->rx_action.sa == NULL ||
585 data->rx_action.bssid == NULL)
586 break;
587 hostapd_rx_action(hapd, &data->rx_action);
588 break;
7cc7307d 589#endif /* NEED_AP_MLME */
ad1e68e6
JM
590 default:
591 wpa_printf(MSG_DEBUG, "Unknown event %d", event);
592 break;
593 }
594}
f8b1f695
JM
595
596#endif /* HOSTAPD */