Avoid direct call to hostapd_new_assoc_sta from ieee802_11.c
[libeap.git] / hostapd / sta_info.c
index 606e85d..7e564b2 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * hostapd / Station table
  * Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
- * Copyright (c) 2007-2008, Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -15,8 +14,8 @@
 
 #include "includes.h"
 
+#include "common.h"
 #include "hostapd.h"
-#include "sta_flags.h"
 #include "sta_info.h"
 #include "eloop.h"
 #include "accounting.h"
@@ -121,6 +120,7 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
 
        accounting_sta_stop(hapd, sta);
 
+       hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 0);
        if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC) &&
            !(sta->flags & WLAN_STA_PREAUTH))
                hostapd_sta_remove(hapd, sta->addr);
@@ -156,7 +156,6 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
                        set_beacon++;
        }
 
-#ifdef CONFIG_IEEE80211N
        if (sta->no_ht_gf_set) {
                sta->no_ht_gf_set = 0;
                hapd->iface->num_sta_ht_no_gf--;
@@ -172,11 +171,10 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
                hapd->iface->num_sta_ht_20mhz--;
        }
 
-#ifdef NEED_AP_MLME
+#if defined(NEED_AP_MLME) && defined(CONFIG_IEEE80211N)
        if (hostapd_ht_operation_update(hapd->iface) > 0)
                set_beacon++;
-#endif /* NEED_AP_MLME */
-#endif /* CONFIG_IEEE80211N */
+#endif /* NEED_AP_MLME && CONFIG_IEEE80211N */
 
        if (set_beacon)
                ieee802_11_set_beacons(hapd->iface);
@@ -187,7 +185,9 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
        ieee802_1x_free_station(sta);
        wpa_auth_sta_deinit(sta->wpa_sm);
        rsn_preauth_free_station(hapd, sta);
+#ifndef CONFIG_NO_RADIUS
        radius_client_flush_auth(hapd->radius, sta->addr);
+#endif /* CONFIG_NO_RADIUS */
 
        os_free(sta->last_assoc_req);
        os_free(sta->challenge);
@@ -199,6 +199,8 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
 
        wpabuf_free(sta->wps_ie);
 
+       os_free(sta->ht_capabilities);
+
        os_free(sta);
 }
 
@@ -315,7 +317,7 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
                          ETH_ALEN);
                os_memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN);
 
-               if (hostapd_send_mgmt_frame(hapd, &hdr, sizeof(hdr)) < 0)
+               if (hapd->drv.send_mgmt_frame(hapd, &hdr, sizeof(hdr)) < 0)
                        perror("ap_handle_timer: send");
 #endif /* CONFIG_NATIVE_WINDOWS */
        } else if (sta->timeout_next != STA_REMOVE) {
@@ -719,3 +721,22 @@ void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
 }
 
 #endif /* CONFIG_IEEE80211W */
+
+
+void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
+                      const u8 *addr, u16 reason)
+{
+
+       if (sta == NULL && addr)
+               sta = ap_get_sta(hapd, addr);
+
+       if (addr)
+               hostapd_sta_deauth(hapd, addr, reason);
+
+       if (sta == NULL)
+               return;
+       sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_AUTHORIZED);
+       eloop_cancel_timeout(ap_handle_timer, hapd, sta);
+       eloop_register_timeout(0, 0, ap_handle_timer, hapd, sta);
+       sta->timeout_next = STA_REMOVE;
+}