2 * hostapd / Initialization and configuration
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
18 #include "utils/eloop.h"
19 #include "common/ieee802_11_defs.h"
20 #include "radius/radius_client.h"
21 #include "drivers/driver.h"
25 #include "accounting.h"
29 #include "ieee802_1x.h"
30 #include "ieee802_11_auth.h"
31 #include "vlan_init.h"
33 #include "wps_hostapd.h"
34 #include "hw_features.h"
35 #include "wpa_auth_glue.h"
36 #include "ap_drv_ops.h"
37 #include "ap_config.h"
40 static int hostapd_flush_old_stations(struct hostapd_data *hapd);
41 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd);
43 extern int wpa_debug_level;
46 int hostapd_reload_config(struct hostapd_iface *iface)
48 struct hostapd_data *hapd = iface->bss[0];
49 struct hostapd_config *newconf, *oldconf;
52 if (iface->config_read_cb == NULL)
54 newconf = iface->config_read_cb(iface->config_fname);
59 * Deauthenticate all stations since the new configuration may not
60 * allow them to use the BSS anymore.
62 for (j = 0; j < iface->num_bss; j++)
63 hostapd_flush_old_stations(iface->bss[j]);
65 #ifndef CONFIG_NO_RADIUS
66 /* TODO: update dynamic data based on changed configuration
67 * items (e.g., open/close sockets, etc.) */
68 radius_client_flush(hapd->radius, 0);
69 #endif /* CONFIG_NO_RADIUS */
71 oldconf = hapd->iconf;
72 hapd->iconf = newconf;
73 hapd->conf = &newconf->bss[0];
74 iface->conf = newconf;
76 if (hostapd_setup_wpa_psk(hapd->conf)) {
77 wpa_printf(MSG_ERROR, "Failed to re-configure WPA PSK "
78 "after reloading configuration");
81 if (hapd->conf->ieee802_1x || hapd->conf->wpa)
82 hapd->drv.set_drv_ieee8021x(hapd, hapd->conf->iface, 1);
84 hapd->drv.set_drv_ieee8021x(hapd, hapd->conf->iface, 0);
86 if (hapd->conf->wpa && hapd->wpa_auth == NULL)
87 hostapd_setup_wpa(hapd);
88 else if (hapd->conf->wpa) {
91 hostapd_reconfig_wpa(hapd);
92 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len);
93 if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len))
94 wpa_printf(MSG_ERROR, "Failed to configure WPA IE for "
95 "the kernel driver.");
96 } else if (hapd->wpa_auth) {
97 wpa_deinit(hapd->wpa_auth);
98 hapd->wpa_auth = NULL;
99 hostapd_set_privacy(hapd, 0);
100 hostapd_setup_encryption(hapd->conf->iface, hapd);
101 hostapd_set_generic_elem(hapd, (u8 *) "", 0);
104 ieee802_11_set_beacon(hapd);
105 hostapd_update_wps(hapd);
107 if (hapd->conf->ssid.ssid_set &&
108 hostapd_set_ssid(hapd, (u8 *) hapd->conf->ssid.ssid,
109 hapd->conf->ssid.ssid_len)) {
110 wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver");
111 /* try to continue */
114 hostapd_config_free(oldconf);
116 wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface);
122 static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd,
127 for (i = 0; i < NUM_WEP_KEYS; i++) {
128 if (hapd->drv.set_key(ifname, hapd, WPA_ALG_NONE, NULL, i,
129 i == 0 ? 1 : 0, NULL, 0, NULL, 0)) {
130 wpa_printf(MSG_DEBUG, "Failed to clear default "
131 "encryption keys (ifname=%s keyidx=%d)",
135 #ifdef CONFIG_IEEE80211W
136 if (hapd->conf->ieee80211w) {
137 for (i = NUM_WEP_KEYS; i < NUM_WEP_KEYS + 2; i++) {
138 if (hapd->drv.set_key(ifname, hapd, WPA_ALG_NONE, NULL,
139 i, i == 0 ? 1 : 0, NULL, 0,
141 wpa_printf(MSG_DEBUG, "Failed to clear "
142 "default mgmt encryption keys "
143 "(ifname=%s keyidx=%d)", ifname, i);
147 #endif /* CONFIG_IEEE80211W */
151 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd)
153 hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface);
158 static int hostapd_broadcast_wep_set(struct hostapd_data *hapd)
161 struct hostapd_ssid *ssid = &hapd->conf->ssid;
164 if (ssid->wep.default_len &&
165 hapd->drv.set_key(hapd->conf->iface,
166 hapd, WPA_ALG_WEP, NULL, idx,
167 idx == ssid->wep.idx,
168 NULL, 0, ssid->wep.key[idx],
169 ssid->wep.len[idx])) {
170 wpa_printf(MSG_WARNING, "Could not set WEP encryption.");
174 if (ssid->dyn_vlan_keys) {
176 for (i = 0; i <= ssid->max_dyn_vlan_keys; i++) {
178 struct hostapd_wep_keys *key = ssid->dyn_vlan_keys[i];
181 ifname = hostapd_get_vlan_id_ifname(hapd->conf->vlan,
187 if (hapd->drv.set_key(ifname, hapd, WPA_ALG_WEP, NULL,
188 idx, idx == key->idx, NULL, 0,
189 key->key[idx], key->len[idx])) {
190 wpa_printf(MSG_WARNING, "Could not set "
191 "dynamic VLAN WEP encryption.");
201 * hostapd_cleanup - Per-BSS cleanup (deinitialization)
202 * @hapd: Pointer to BSS data
204 * This function is used to free all per-BSS data structures and resources.
205 * This gets called in a loop for each BSS between calls to
206 * hostapd_cleanup_iface_pre() and hostapd_cleanup_iface() when an interface
207 * is deinitialized. Most of the modules that are initialized in
208 * hostapd_setup_bss() are deinitialized here.
210 static void hostapd_cleanup(struct hostapd_data *hapd)
212 if (hapd->iface->ctrl_iface_deinit)
213 hapd->iface->ctrl_iface_deinit(hapd);
215 iapp_deinit(hapd->iapp);
217 accounting_deinit(hapd);
218 hostapd_deinit_wpa(hapd);
220 hostapd_acl_deinit(hapd);
221 #ifndef CONFIG_NO_RADIUS
222 radius_client_deinit(hapd->radius);
224 #endif /* CONFIG_NO_RADIUS */
226 hostapd_deinit_wps(hapd);
228 authsrv_deinit(hapd);
230 if (hapd->interface_added &&
231 hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) {
232 wpa_printf(MSG_WARNING, "Failed to remove BSS interface %s",
236 os_free(hapd->probereq_cb);
237 hapd->probereq_cb = NULL;
240 wpabuf_free(hapd->p2p_beacon_ie);
241 hapd->p2p_beacon_ie = NULL;
242 wpabuf_free(hapd->p2p_probe_resp_ie);
243 hapd->p2p_probe_resp_ie = NULL;
244 #endif /* CONFIG_P2P */
249 * hostapd_cleanup_iface_pre - Preliminary per-interface cleanup
250 * @iface: Pointer to interface data
252 * This function is called before per-BSS data structures are deinitialized
253 * with hostapd_cleanup().
255 static void hostapd_cleanup_iface_pre(struct hostapd_iface *iface)
261 * hostapd_cleanup_iface - Complete per-interface cleanup
262 * @iface: Pointer to interface data
264 * This function is called after per-BSS data structures are deinitialized
265 * with hostapd_cleanup().
267 static void hostapd_cleanup_iface(struct hostapd_iface *iface)
269 hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
270 iface->hw_features = NULL;
271 os_free(iface->current_rates);
272 iface->current_rates = NULL;
273 ap_list_deinit(iface);
274 hostapd_config_free(iface->conf);
277 os_free(iface->config_fname);
283 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd)
287 hostapd_broadcast_wep_set(hapd);
289 if (hapd->conf->ssid.wep.default_len) {
290 hostapd_set_privacy(hapd, 1);
294 for (i = 0; i < 4; i++) {
295 if (hapd->conf->ssid.wep.key[i] &&
296 hapd->drv.set_key(iface, hapd, WPA_ALG_WEP, NULL, i,
297 i == hapd->conf->ssid.wep.idx, NULL, 0,
298 hapd->conf->ssid.wep.key[i],
299 hapd->conf->ssid.wep.len[i])) {
300 wpa_printf(MSG_WARNING, "Could not set WEP "
304 if (hapd->conf->ssid.wep.key[i] &&
305 i == hapd->conf->ssid.wep.idx)
306 hostapd_set_privacy(hapd, 1);
313 static int hostapd_flush_old_stations(struct hostapd_data *hapd)
317 if (hostapd_drv_none(hapd) || hapd->drv_priv == NULL)
320 wpa_printf(MSG_DEBUG, "Flushing old station entries");
321 if (hostapd_flush(hapd)) {
322 wpa_printf(MSG_WARNING, "Could not connect to kernel driver.");
325 wpa_printf(MSG_DEBUG, "Deauthenticate all stations");
327 /* New Prism2.5/3 STA firmware versions seem to have issues with this
328 * broadcast deauth frame. This gets the firmware in odd state where
329 * nothing works correctly, so let's skip sending this for the hostap
331 if (hapd->driver && os_strcmp(hapd->driver->name, "hostap") != 0) {
333 os_memset(addr, 0xff, ETH_ALEN);
334 hapd->drv.sta_deauth(hapd, addr,
335 WLAN_REASON_PREV_AUTH_NOT_VALID);
343 * hostapd_validate_bssid_configuration - Validate BSSID configuration
344 * @iface: Pointer to interface data
345 * Returns: 0 on success, -1 on failure
347 * This function is used to validate that the configured BSSIDs are valid.
349 static int hostapd_validate_bssid_configuration(struct hostapd_iface *iface)
351 u8 mask[ETH_ALEN] = { 0 };
352 struct hostapd_data *hapd = iface->bss[0];
353 unsigned int i = iface->conf->num_bss, bits = 0, j;
357 if (hostapd_drv_none(hapd))
360 /* Generate BSSID mask that is large enough to cover the BSSIDs. */
362 /* Determine the bits necessary to cover the number of BSSIDs. */
363 for (i--; i; i >>= 1)
366 /* Determine the bits necessary to any configured BSSIDs,
367 if they are higher than the number of BSSIDs. */
368 for (j = 0; j < iface->conf->num_bss; j++) {
369 if (hostapd_mac_comp_empty(iface->conf->bss[j].bssid) == 0) {
375 for (i = 0; i < ETH_ALEN; i++) {
377 iface->conf->bss[j].bssid[i] ^
385 for (i = 0; i < ETH_ALEN && mask[i] == 0; i++)
391 while (mask[i] != 0) {
401 wpa_printf(MSG_ERROR, "Too many bits in the BSSID mask (%u)",
406 os_memset(mask, 0xff, ETH_ALEN);
408 for (i = 5; i > 5 - j; i--)
415 wpa_printf(MSG_DEBUG, "BSS count %lu, BSSID mask " MACSTR " (%d bits)",
416 (unsigned long) iface->conf->num_bss, MAC2STR(mask), bits);
418 res = hostapd_valid_bss_mask(hapd, hapd->own_addr, mask);
423 wpa_printf(MSG_ERROR, "Driver did not accept BSSID mask "
424 MACSTR " for start address " MACSTR ".",
425 MAC2STR(mask), MAC2STR(hapd->own_addr));
432 for (i = 0; i < ETH_ALEN; i++) {
433 if ((hapd->own_addr[i] & mask[i]) != hapd->own_addr[i]) {
434 wpa_printf(MSG_ERROR, "Invalid BSSID mask " MACSTR
435 " for start address " MACSTR ".",
436 MAC2STR(mask), MAC2STR(hapd->own_addr));
437 wpa_printf(MSG_ERROR, "Start address must be the "
438 "first address in the block (i.e., addr "
439 "AND mask == addr).");
448 static int mac_in_conf(struct hostapd_config *conf, const void *a)
452 for (i = 0; i < conf->num_bss; i++) {
453 if (hostapd_mac_comp(conf->bss[i].bssid, a) == 0) {
465 * hostapd_setup_bss - Per-BSS setup (initialization)
466 * @hapd: Pointer to BSS data
467 * @first: Whether this BSS is the first BSS of an interface
469 * This function is used to initialize all per-BSS data structures and
470 * resources. This gets called in a loop for each BSS when an interface is
471 * initialized. Most of the modules that are initialized here will be
472 * deinitialized in hostapd_cleanup().
474 static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
476 struct hostapd_bss_config *conf = hapd->conf;
477 u8 ssid[HOSTAPD_MAX_SSID_LEN + 1];
478 int ssid_len, set_ssid;
479 char force_ifname[IFNAMSIZ];
480 u8 if_addr[ETH_ALEN];
483 if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0) {
484 /* Allocate the next available BSSID. */
486 inc_byte_array(hapd->own_addr, ETH_ALEN);
487 } while (mac_in_conf(hapd->iconf, hapd->own_addr));
489 /* Allocate the configured BSSID. */
490 os_memcpy(hapd->own_addr, hapd->conf->bssid, ETH_ALEN);
492 if (hostapd_mac_comp(hapd->own_addr,
493 hapd->iface->bss[0]->own_addr) ==
495 wpa_printf(MSG_ERROR, "BSS '%s' may not have "
496 "BSSID set to the MAC address of "
497 "the radio", hapd->conf->iface);
502 hapd->interface_added = 1;
503 if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS,
504 hapd->conf->iface, hapd->own_addr, hapd,
505 &hapd->drv_priv, force_ifname, if_addr)) {
506 wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID="
507 MACSTR ")", MAC2STR(hapd->own_addr));
512 hostapd_flush_old_stations(hapd);
513 hostapd_set_privacy(hapd, 0);
515 hostapd_broadcast_wep_clear(hapd);
516 if (hostapd_setup_encryption(hapd->conf->iface, hapd))
520 * Fetch the SSID from the system and use it or,
521 * if one was specified in the config file, verify they
524 ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid));
526 wpa_printf(MSG_ERROR, "Could not read SSID from system");
529 if (conf->ssid.ssid_set) {
531 * If SSID is specified in the config file and it differs
532 * from what is being used then force installation of the
535 set_ssid = (conf->ssid.ssid_len != (size_t) ssid_len ||
536 os_memcmp(conf->ssid.ssid, ssid, ssid_len) != 0);
539 * No SSID in the config file; just use the one we got
543 conf->ssid.ssid_len = ssid_len;
544 os_memcpy(conf->ssid.ssid, ssid, conf->ssid.ssid_len);
545 conf->ssid.ssid[conf->ssid.ssid_len] = '\0';
548 if (!hostapd_drv_none(hapd)) {
549 wpa_printf(MSG_ERROR, "Using interface %s with hwaddr " MACSTR
551 hapd->conf->iface, MAC2STR(hapd->own_addr),
552 hapd->conf->ssid.ssid);
555 if (hostapd_setup_wpa_psk(conf)) {
556 wpa_printf(MSG_ERROR, "WPA-PSK setup failed.");
560 /* Set SSID for the kernel driver (to be used in beacon and probe
561 * response frames) */
562 if (set_ssid && hostapd_set_ssid(hapd, (u8 *) conf->ssid.ssid,
563 conf->ssid.ssid_len)) {
564 wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver");
568 if (wpa_debug_level == MSG_MSGDUMP)
569 conf->radius->msg_dumps = 1;
570 #ifndef CONFIG_NO_RADIUS
571 hapd->radius = radius_client_init(hapd, conf->radius);
572 if (hapd->radius == NULL) {
573 wpa_printf(MSG_ERROR, "RADIUS client initialization failed.");
576 #endif /* CONFIG_NO_RADIUS */
578 if (hostapd_acl_init(hapd)) {
579 wpa_printf(MSG_ERROR, "ACL initialization failed.");
582 if (hostapd_init_wps(hapd, conf))
585 if (authsrv_init(hapd) < 0)
588 if (ieee802_1x_init(hapd)) {
589 wpa_printf(MSG_ERROR, "IEEE 802.1X initialization failed.");
593 if (hapd->conf->wpa && hostapd_setup_wpa(hapd))
596 if (accounting_init(hapd)) {
597 wpa_printf(MSG_ERROR, "Accounting initialization failed.");
601 if (hapd->conf->ieee802_11f &&
602 (hapd->iapp = iapp_init(hapd, hapd->conf->iapp_iface)) == NULL) {
603 wpa_printf(MSG_ERROR, "IEEE 802.11F (IAPP) initialization "
608 if (hapd->iface->ctrl_iface_init &&
609 hapd->iface->ctrl_iface_init(hapd)) {
610 wpa_printf(MSG_ERROR, "Failed to setup control interface");
614 if (!hostapd_drv_none(hapd) && vlan_init(hapd)) {
615 wpa_printf(MSG_ERROR, "VLAN initialization failed.");
619 ieee802_11_set_beacon(hapd);
625 static void hostapd_tx_queue_params(struct hostapd_iface *iface)
627 struct hostapd_data *hapd = iface->bss[0];
629 struct hostapd_tx_queue_params *p;
631 for (i = 0; i < NUM_TX_QUEUES; i++) {
632 p = &iface->conf->tx_queue[i];
637 if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin,
638 p->cwmax, p->burst)) {
639 wpa_printf(MSG_DEBUG, "Failed to set TX queue "
640 "parameters for queue %d.", i);
641 /* Continue anyway */
647 static int setup_interface(struct hostapd_iface *iface)
649 struct hostapd_data *hapd = iface->bss[0];
654 * Make sure that all BSSes get configured with a pointer to the same
657 for (i = 1; i < iface->num_bss; i++) {
658 iface->bss[i]->driver = hapd->driver;
659 iface->bss[i]->drv_priv = hapd->drv_priv;
662 if (hostapd_validate_bssid_configuration(iface))
665 if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
666 os_memcpy(country, hapd->iconf->country, 3);
668 if (hostapd_set_country(hapd, country) < 0) {
669 wpa_printf(MSG_ERROR, "Failed to set country code");
674 if (hostapd_get_hw_features(iface)) {
675 /* Not all drivers support this yet, so continue without hw
678 int ret = hostapd_select_hw_mode(iface);
680 wpa_printf(MSG_ERROR, "Could not select hw_mode and "
681 "channel. (%d)", ret);
684 ret = hostapd_check_ht_capab(iface);
688 wpa_printf(MSG_DEBUG, "Interface initialization will "
689 "be completed in a callback");
693 return hostapd_setup_interface_complete(iface, 0);
697 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
699 struct hostapd_data *hapd = iface->bss[0];
704 wpa_printf(MSG_ERROR, "Interface initialization failed");
709 wpa_printf(MSG_DEBUG, "Completing interface initialization");
710 if (hapd->iconf->channel) {
711 iface->freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
712 wpa_printf(MSG_DEBUG, "Mode: %s Channel: %d "
714 hostapd_hw_mode_txt(hapd->iconf->hw_mode),
715 hapd->iconf->channel, iface->freq);
717 if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
718 hapd->iconf->channel,
719 hapd->iconf->ieee80211n,
720 hapd->iconf->secondary_channel)) {
721 wpa_printf(MSG_ERROR, "Could not set channel for "
727 if (hapd->iconf->rts_threshold > -1 &&
728 hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
729 wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
734 if (hapd->iconf->fragm_threshold > -1 &&
735 hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) {
736 wpa_printf(MSG_ERROR, "Could not set fragmentation threshold "
737 "for kernel driver");
741 prev_addr = hapd->own_addr;
743 for (j = 0; j < iface->num_bss; j++) {
744 hapd = iface->bss[j];
746 os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
747 if (hostapd_setup_bss(hapd, j == 0))
749 if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
750 prev_addr = hapd->own_addr;
753 hostapd_tx_queue_params(iface);
757 if (hostapd_driver_commit(hapd) < 0) {
758 wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
759 "configuration", __func__);
763 wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
764 iface->bss[0]->conf->iface);
771 * hostapd_setup_interface - Setup of an interface
772 * @iface: Pointer to interface data.
773 * Returns: 0 on success, -1 on failure
775 * Initializes the driver interface, validates the configuration,
776 * and sets driver parameters based on the configuration.
777 * Flushes old stations, sets the channel, encryption,
778 * beacons, and WDS links based on the configuration.
780 int hostapd_setup_interface(struct hostapd_iface *iface)
784 ret = setup_interface(iface);
786 wpa_printf(MSG_ERROR, "%s: Unable to setup interface.",
787 iface->bss[0]->conf->iface);
796 * hostapd_alloc_bss_data - Allocate and initialize per-BSS data
797 * @hapd_iface: Pointer to interface data
798 * @conf: Pointer to per-interface configuration
799 * @bss: Pointer to per-BSS configuration for this BSS
800 * Returns: Pointer to allocated BSS data
802 * This function is used to allocate per-BSS data structure. This data will be
803 * freed after hostapd_cleanup() is called for it during interface
806 struct hostapd_data *
807 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
808 struct hostapd_config *conf,
809 struct hostapd_bss_config *bss)
811 struct hostapd_data *hapd;
813 hapd = os_zalloc(sizeof(*hapd));
817 hostapd_set_driver_ops(&hapd->drv);
818 hapd->new_assoc_sta_cb = hostapd_new_assoc_sta;
821 hapd->iface = hapd_iface;
822 hapd->driver = hapd->iconf->driver;
828 void hostapd_interface_deinit(struct hostapd_iface *iface)
835 hostapd_cleanup_iface_pre(iface);
836 for (j = 0; j < iface->num_bss; j++) {
837 struct hostapd_data *hapd = iface->bss[j];
838 hostapd_free_stas(hapd);
839 hostapd_flush_old_stations(hapd);
840 hostapd_cleanup(hapd);
845 void hostapd_interface_free(struct hostapd_iface *iface)
848 for (j = 0; j < iface->num_bss; j++)
849 os_free(iface->bss[j]);
850 hostapd_cleanup_iface(iface);
855 * hostapd_new_assoc_sta - Notify that a new station associated with the AP
856 * @hapd: Pointer to BSS data
857 * @sta: Pointer to the associated STA data
858 * @reassoc: 1 to indicate this was a re-association; 0 = first association
860 * This function will be called whenever a station associates with the AP. It
861 * can be called from ieee802_11.c for drivers that export MLME to hostapd and
862 * from drv_callbacks.c based on driver events for drivers that take care of
863 * management frames (IEEE 802.11 authentication and association) internally.
865 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
868 if (hapd->tkip_countermeasures) {
869 hapd->drv.sta_deauth(hapd, sta->addr,
870 WLAN_REASON_MICHAEL_MIC_FAILURE);
874 hostapd_prune_associations(hapd, sta->addr);
876 /* IEEE 802.11F (IAPP) */
877 if (hapd->conf->ieee802_11f)
878 iapp_new_station(hapd->iapp, sta);
880 /* Start accounting here, if IEEE 802.1X and WPA are not used.
881 * IEEE 802.1X/WPA code will start accounting after the station has
882 * been authorized. */
883 if (!hapd->conf->ieee802_1x && !hapd->conf->wpa)
884 accounting_sta_start(hapd, sta);
886 /* Start IEEE 802.1X authentication process for new stations */
887 ieee802_1x_new_station(hapd, sta);
889 if (sta->auth_alg != WLAN_AUTH_FT &&
890 !(sta->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS)))
891 wpa_auth_sm_event(sta->wpa_sm, WPA_REAUTH);
893 wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm);