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