]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add ctrl_iface events for AP mode STA connect/disconnect
authorJouni Malinen <jouni.malinen@atheros.com>
Fri, 16 Oct 2009 14:51:49 +0000 (17:51 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 16 Oct 2009 14:51:49 +0000 (17:51 +0300)
These are used to notify ctrl_iface monitors when a STA completes
connection (the port becomes authorized) and when a STA disconnects.

hostapd/ieee802_11.c
hostapd/ieee802_1x.c
src/common/wpa_ctrl.h

index f2e793c903beccb7c869d8a33c7dddca852a578d..6bad2d2509d0b3671a05525ddfcc004ad8120f89 100644 (file)
@@ -36,6 +36,7 @@
 #include "accounting.h"
 #include "driver_i.h"
 #include "mlme.h"
+#include "wpa_ctrl.h"
 
 
 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid)
@@ -1198,6 +1199,8 @@ static void handle_disassoc(struct hostapd_data *hapd,
        }
 
        sta->flags &= ~WLAN_STA_ASSOC;
+       wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED MACSTR,
+               MAC2STR(sta->addr));
        wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
        hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
                       HOSTAPD_LEVEL_INFO, "disassociated");
@@ -1246,6 +1249,8 @@ static void handle_deauth(struct hostapd_data *hapd,
        }
 
        sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
+       wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED MACSTR,
+               MAC2STR(sta->addr));
        wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
        hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
                       HOSTAPD_LEVEL_DEBUG, "deauthenticated");
@@ -1661,6 +1666,8 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
        if (!hapd->conf->ieee802_1x && !hapd->conf->wpa) {
                /* Open or static WEP; no separate authorization */
                sta->flags |= WLAN_STA_AUTHORIZED;
+               wpa_msg(hapd->msg_ctx, MSG_INFO,
+                       AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
        }
 
        if (reassoc)
index 0037f62a515e8da4aeb6284cb2322ce952344142..056b6fbb55e0efd81de33b558e6e040d5fb435e1 100644 (file)
@@ -31,6 +31,7 @@
 #include "hw_features.h"
 #include "eap_server/eap.h"
 #include "ieee802_11_defs.h"
+#include "wpa_ctrl.h"
 
 
 static void ieee802_1x_finished(struct hostapd_data *hapd,
@@ -83,12 +84,20 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
                return;
 
        if (authorized) {
+               if (!(sta->flags & WLAN_STA_AUTHORIZED))
+                       wpa_msg(hapd->msg_ctx, MSG_INFO,
+                               AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
                sta->flags |= WLAN_STA_AUTHORIZED;
                res = hostapd_sta_set_flags(hapd, sta->addr, sta->flags,
                                            WLAN_STA_AUTHORIZED, ~0);
                hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
                               HOSTAPD_LEVEL_DEBUG, "authorizing port");
        } else {
+               if ((sta->flags & (WLAN_STA_AUTHORIZED | WLAN_STA_ASSOC)) ==
+                   (WLAN_STA_AUTHORIZED | WLAN_STA_ASSOC))
+                       wpa_msg(hapd->msg_ctx, MSG_INFO,
+                               AP_STA_DISCONNECTED MACSTR,
+                               MAC2STR(sta->addr));
                sta->flags &= ~WLAN_STA_AUTHORIZED;
                res = hostapd_sta_set_flags(hapd, sta->addr, sta->flags,
                                            0, ~WLAN_STA_AUTHORIZED);
index 1bfc0d6453468c897f107ec8c47f415556ddcc5d..3f511d069db0b3a36c26175f773cafca37091eba 100644 (file)
@@ -74,6 +74,8 @@ extern "C" {
 #define WPS_EVENT_NEW_AP_SETTINGS "WPS-NEW-AP-SETTINGS "
 #define WPS_EVENT_REG_SUCCESS "WPS-REG-SUCCESS "
 #define WPS_EVENT_AP_SETUP_LOCKED "WPS-AP-SETUP-LOCKED "
+#define AP_STA_CONNECTED "AP-STA-CONNECTED "
+#define AP_STA_DISCONNECTED "AP-STA-DISCONNECTED "
 
 
 /* wpa_supplicant/hostapd control interface access */