AP: Update logging related to inactivity and disassociation
authorBen Greear <greearb@candelatech.com>
Thu, 24 Feb 2011 15:44:45 +0000 (17:44 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 24 Feb 2011 15:44:45 +0000 (17:44 +0200)
Add MAC addresses for stations and use wpa_msg instead of printf
methods to make it easier to grep logs and find messages for the
station in question.

Signed-off-by: Ben Greear <greearb@candelatech.com>
src/ap/ieee802_11.c
src/ap/sta_info.c

index 45180cc..c08cfe7 100644 (file)
@@ -1192,20 +1192,20 @@ static void handle_deauth(struct hostapd_data *hapd,
        struct sta_info *sta;
 
        if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.deauth)) {
-               printf("handle_deauth - too short payload (len=%lu)\n",
-                      (unsigned long) len);
+               wpa_msg(hapd, MSG_DEBUG, "handle_deauth - too short payload "
+                       "(len=%lu)", (unsigned long) len);
                return;
        }
 
-       wpa_printf(MSG_DEBUG, "deauthentication: STA=" MACSTR
-                  " reason_code=%d",
-                  MAC2STR(mgmt->sa),
-                  le_to_host16(mgmt->u.deauth.reason_code));
+       wpa_msg(hapd, MSG_DEBUG, "deauthentication: STA=" MACSTR
+               " reason_code=%d",
+               MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
 
        sta = ap_get_sta(hapd, mgmt->sa);
        if (sta == NULL) {
-               printf("Station " MACSTR " trying to deauthenticate, but it "
-                      "is not authenticated.\n", MAC2STR(mgmt->sa));
+               wpa_msg(hapd, MSG_DEBUG, "Station " MACSTR " trying to "
+                       "deauthenticate, but it is not authenticated",
+                       MAC2STR(mgmt->sa));
                return;
        }
 
@@ -1561,7 +1561,7 @@ void ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
                handle_disassoc(hapd, mgmt, len);
                break;
        case WLAN_FC_STYPE_DEAUTH:
-               wpa_printf(MSG_DEBUG, "mgmt::deauth");
+               wpa_msg(hapd, MSG_DEBUG, "mgmt::deauth");
                handle_deauth(hapd, mgmt, len);
                break;
        case WLAN_FC_STYPE_ACTION:
index 3818d06..e829447 100644 (file)
@@ -273,27 +273,33 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
            (sta->timeout_next == STA_NULLFUNC ||
             sta->timeout_next == STA_DISASSOC)) {
                int inactive_sec;
-               wpa_printf(MSG_DEBUG, "Checking STA " MACSTR " inactivity:",
-                          MAC2STR(sta->addr));
                inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
                if (inactive_sec == -1) {
-                       wpa_printf(MSG_DEBUG, "Could not get station info "
-                                  "from kernel driver for " MACSTR ".",
-                                  MAC2STR(sta->addr));
+                       wpa_msg(hapd, MSG_DEBUG, "Check inactivity: Could not "
+                               "get station info rom kernel driver for "
+                               MACSTR, MAC2STR(sta->addr));
                } else if (inactive_sec < hapd->conf->ap_max_inactivity &&
                           sta->flags & WLAN_STA_ASSOC) {
                        /* station activity detected; reset timeout state */
-                       wpa_printf(MSG_DEBUG, "  Station has been active");
+                       wpa_msg(hapd, MSG_DEBUG, "Station " MACSTR " has been "
+                               "active %is ago",
+                               MAC2STR(sta->addr), inactive_sec);
                        sta->timeout_next = STA_NULLFUNC;
                        next_time = hapd->conf->ap_max_inactivity -
                                inactive_sec;
+               } else {
+                       wpa_msg(hapd, MSG_DEBUG, "Station " MACSTR " has been "
+                               "inactive too long: %d sec, max allowed: %d",
+                               MAC2STR(sta->addr), inactive_sec,
+                               hapd->conf->ap_max_inactivity);
                }
        }
 
        if ((sta->flags & WLAN_STA_ASSOC) &&
            sta->timeout_next == STA_DISASSOC &&
            !(sta->flags & WLAN_STA_PENDING_POLL)) {
-               wpa_printf(MSG_DEBUG, "  Station has ACKed data poll");
+               wpa_msg(hapd, MSG_DEBUG, "Station " MACSTR " has ACKed data "
+                       "poll", MAC2STR(sta->addr));
                /* data nullfunc frame poll did not produce TX errors; assume
                 * station ACKed it */
                sta->timeout_next = STA_NULLFUNC;