From 24d75245bdade189ac20ee276403ac4572e62cd9 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 24 Feb 2011 17:44:45 +0200 Subject: [PATCH] AP: Update logging related to inactivity and disassociation 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 --- src/ap/ieee802_11.c | 18 +++++++++--------- src/ap/sta_info.c | 20 +++++++++++++------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 45180ccb2..c08cfe784 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -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: diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index 3818d065e..e829447da 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -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;