[PATCH 2/2] hostapd: Update logging related to inactivity and disassociation.

Ben Greear greearb at candelatech.com
Fri Jan 14 12:54:40 EST 2011


Add MAC addresses for stations, use wpa_msg instead of printf
methods.  Makes it easier to grep logs and find messages for
the station in question.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 94898cc... c599c34... M	src/ap/ieee802_11.c
:100644 100644 07de034... 3a9121b... M	src/ap/sta_info.c
 src/ap/ieee802_11.c |   20 +++++++++++---------
 src/ap/sta_info.c   |   21 ++++++++++++++-------
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 94898cc..c599c34 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -1146,20 +1146,22 @@ 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_ERROR,
+			"handle_deauth - too short payload (len=%lu)\n",
+			(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_ERROR,
+			"Station " MACSTR " trying to deauthenticate, but it "
+			"is not authenticated.\n", MAC2STR(mgmt->sa));
 		return;
 	}
 
@@ -1512,7 +1514,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 07de034..3a9121b 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -270,27 +270,34 @@ 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 "
+				"from 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: %i sec, max allowed: %i",
+				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 has ACKed data poll");
 		/* data nullfunc frame poll did not produce TX errors; assume
 		 * station ACKed it */
 		sta->timeout_next = STA_NULLFUNC;
-- 
1.7.2.3



More information about the HostAP mailing list