Moved disassociation processing away from driver_*.c
authorJouni Malinen <jouni.malinen@atheros.com>
Fri, 9 Jan 2009 14:27:30 +0000 (16:27 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 9 Jan 2009 14:27:30 +0000 (16:27 +0200)
hostapd/driver.h
hostapd/driver_bsd.c
hostapd/driver_madwifi.c
hostapd/driver_test.c
hostapd/hostapd.c

index d13c919..5d21463 100644 (file)
@@ -218,5 +218,6 @@ void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
 void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, const u8 *addr);
 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
                        const u8 *ie, size_t ielen);
+void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
 
 #endif /* DRIVER_H */
index f200d15..05210b7 100644 (file)
 #include "driver.h"
 #include "ieee802_1x.h"
 #include "eloop.h"
-#include "sta_info.h"
 #include "l2_packet/l2_packet.h"
 
 #include "eapol_sm.h"
-#include "wpa.h"
-#include "radius/radius.h"
 #include "ieee802_11.h"
 #include "common.h"
 
@@ -505,28 +502,6 @@ bsd_sta_disassoc(void *priv, const u8 *addr, int reason_code)
 }
 
 static int
-bsd_del_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
-{
-       struct hostapd_data *hapd = drv->hapd;
-       struct hostapd_bss_config *conf = hapd->conf;
-       struct sta_info *sta;
-
-       hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
-               HOSTAPD_LEVEL_INFO, "deassociated");
-
-       sta = ap_get_sta(hapd, addr);
-       if (sta != NULL) {
-               sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
-               if (conf->wpa)
-                       wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
-               sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
-               ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
-               ap_free_sta(hapd, sta);
-       }
-       return 0;
-}
-
-static int
 bsd_new_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
 {
        struct hostapd_data *hapd = drv->hapd;
@@ -593,7 +568,7 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
                        break;
                case RTM_IEEE80211_LEAVE:
                        leave = (struct ieee80211_leave_event *) &ifan[1];
-                       bsd_del_sta(drv, leave->iev_addr);
+                       hostapd_notif_disassoc(drv, leave->iev_addr);
                        break;
                case RTM_IEEE80211_JOIN:
 #ifdef RTM_IEEE80211_REJOIN
index a009bd6..8ea7037 100644 (file)
 #include "ieee802_1x.h"
 #include "eloop.h"
 #include "priv_netlink.h"
-#include "sta_info.h"
 #include "l2_packet/l2_packet.h"
 
-#include "wpa.h"
-#include "radius/radius.h"
 #include "ieee802_11.h"
-#include "accounting.h"
 #include "common.h"
 #include "wps_hostapd.h"
 
@@ -795,26 +791,6 @@ static int madwifi_receive_probe_req(struct madwifi_driver_data *drv)
        return ret;
 }
 
-static int
-madwifi_del_sta(struct madwifi_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
-{
-       struct hostapd_data *hapd = drv->hapd;
-       struct sta_info *sta;
-
-       hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
-               HOSTAPD_LEVEL_INFO, "disassociated");
-
-       sta = ap_get_sta(hapd, addr);
-       if (sta != NULL) {
-               sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
-               wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
-               sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
-               ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
-               ap_free_sta(hapd, sta);
-       }
-       return 0;
-}
-
 #ifdef CONFIG_WPS
 static int
 madwifi_set_wps_ie(void *priv, const u8 *ie, size_t len, u32 frametype)
@@ -994,7 +970,8 @@ madwifi_wireless_event_wireless(struct madwifi_driver_data *drv,
 
                switch (iwe->cmd) {
                case IWEVEXPIRED:
-                       madwifi_del_sta(drv, (u8 *) iwe->u.addr.sa_data);
+                       hostapd_notif_disassoc(drv->hapd,
+                                              (u8 *) iwe->u.addr.sa_data);
                        break;
                case IWEVREGISTERED:
                        madwifi_new_sta(drv, (u8 *) iwe->u.addr.sa_data);
index 667ed98..d5879d5 100644 (file)
 #include "sha1.h"
 #include "eloop.h"
 #include "ieee802_1x.h"
-#include "sta_info.h"
 #include "wpa.h"
-#include "accounting.h"
-#include "radius/radius.h"
 #include "l2_packet/l2_packet.h"
 #include "ieee802_11.h"
 #include "hw_features.h"
@@ -522,24 +519,12 @@ static void test_driver_disassoc(struct test_driver_data *drv,
                                 struct sockaddr_un *from, socklen_t fromlen)
 {
        struct test_client_socket *cli;
-       struct sta_info *sta;
 
        cli = test_driver_get_cli(drv, from, fromlen);
        if (!cli)
                return;
 
-       hostapd_logger(drv->hapd, cli->addr, HOSTAPD_MODULE_IEEE80211,
-                      HOSTAPD_LEVEL_INFO, "disassociated");
-
-       sta = ap_get_sta(drv->hapd, cli->addr);
-       if (sta != NULL) {
-               sta->flags &= ~WLAN_STA_ASSOC;
-               wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
-               sta->acct_terminate_cause =
-                       RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
-               ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
-               ap_free_sta(drv->hapd, sta);
-       }
+       hostapd_notif_disassoc(drv->hapd, cli->addr);
 }
 
 
index 8a692ee..d5c2648 100644 (file)
@@ -33,6 +33,7 @@
 #include "driver_i.h"
 #include "radius/radius_client.h"
 #include "radius/radius_server.h"
+#include "radius/radius.h"
 #include "wpa.h"
 #include "preauth.h"
 #include "wme.h"
@@ -367,6 +368,28 @@ skip_wpa_check:
 }
 
 
+void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr)
+{
+       struct sta_info *sta;
+
+       hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
+                      HOSTAPD_LEVEL_INFO, "disassociated");
+
+       sta = ap_get_sta(hapd, addr);
+       if (sta == NULL) {
+               wpa_printf(MSG_DEBUG, "Disassociation notification for "
+                          "unknown STA " MACSTR, MAC2STR(addr));
+               return;
+       }
+
+       sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
+       wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
+       sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
+       ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
+       ap_free_sta(hapd, sta);
+}
+
+
 #ifdef EAP_SERVER
 static int hostapd_sim_db_cb_sta(struct hostapd_data *hapd,
                                 struct sta_info *sta, void *ctx)