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