All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ieee80211: Print human-readable disassoc/deauth reason codes
@ 2014-02-06  1:44 Calvin Owens
  2014-02-06  4:44 ` Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Calvin Owens @ 2014-02-06  1:44 UTC (permalink / raw)
  To: Johannes Berg, David S. Miller, John W. Linville
  Cc: linux-wireless, linux-kernel, Calvin Owens

Create a function to return a descriptive string for each reason code,
and print that instead of the numeric value in the kernel log. These
codes are easily found on popular search engines, but one is generally
not able to access the internet when dealing with wireless connectivity
issues.

On x86_64, this patch only enlarges the kernel binary by 489 bytes.

Signed-off-by: Calvin Owens <jcalvinowens@gmail.com>
---
 include/net/mac80211.h | 11 +++++++++
 net/mac80211/main.c    | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
 net/mac80211/mlme.c    | 12 ++++-----
 3 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index f4ab2fb..5983b25 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2973,6 +2973,17 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
 					const struct ieee80211_ops *ops);
 
 /**
+ * ieee80211_get_reason_code_string - Get human readable reason code
+ *
+ * This function returns a string describing the @reason_code.
+ *
+ * @reason_code: Reason code we want a human readable string for
+ *
+ * Return: Human readable reason string, or "(INVALID)"
+ */
+const char *ieee80211_get_reason_code_string(u16 reason_code);
+
+/**
  * ieee80211_register_hw - Register hardware device
  *
  * You must call this function before any other functions in
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index d767cfb..a1eb3ab 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -743,6 +743,72 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
 	return 0;
 }
 
+static const char *reason_code_strings[49] = {
+	"(RESERVED)",
+	"UNSPECIFIED",
+	"PREV_AUTH_NOT_VALID",
+	"DEAUTH_LEAVING",
+	"DISASSOC_DUE_TO_INACTIVITY",
+	"DISASSOC_AP_BUSY",
+	"CLASS2_FRAME_FROM_NONAUTH_STA",
+	"CLASS3_FRAME_FROM_NONASSOC_STA",
+	"DISASSOC_STA_HAS_LEFT",
+	"STA_REQ_ASSOC_WITHOUT_AUTH",
+	"DISASSOC_BAD_POWER",
+	"DISASSOC_BAD_SUPP_CHAN",
+	"(RESERVED)",
+	"INVALID_IE",
+	"MIC_FAILURE",
+	"4WAY_HANDSHAKE_TIMEOUT",
+	"GROUP_KEY_HANDSHAKE_TIMEOUT",
+	"IE_DIFFERENT",
+	"INVALID_GROUP_CIPHER",
+	"INVALID_PAIRWISE_CIPHER",
+	"INVALID_AKMP",
+	"UNSUPP_RSN_VERSION",
+	"INVALID_RSN_IE_CAP",
+	"IEEE8021X_FAILED",
+	"CIPHER_SUITE_REJECTED", /* 24 */
+	"DISASSOC_UNSPECIFIED_QOS", /* 32 (25) */
+	"DISASSOC_QAP_NO_BANDWIDTH",
+	"DISASSOC_LOW_ACK",
+	"DISASSOC_QAP_EXCEED_TXOP",
+	"QSTA_LEAVE_QBSS",
+	"QSTA_NOT_USE",
+	"QSTA_REQUIRE_SETUP",
+	"QSTA_TIMEOUT",
+	"QSTA_CIPHER_NOT_SUPP", /* 45 (33) */
+	"MESH_PEER_CANCELED", /* 52 (34) */
+	"MESH_MAX_PEERS",
+	"MESH_CONFIG",
+	"MESH_CLOSE",
+	"MESH_MAX_RETRIES",
+	"MESH_CONFIRM_TIMEOUT",
+	"MESH_INVALID_GTK",
+	"MESH_INCONSISTENT_PARAM",
+	"MESH_INVALID_SECURITY",
+	"MESH_PATH_ERROR",
+	"MESH_PATH_NOFORWARD",
+	"MESH_PATH_DEST_UNREACHABLE",
+	"MAC_EXISTS_IN_MBSS",
+	"MESH_CHAN_REGULATORY",
+	"MESH_CHAN" /* 66 (48) */
+};
+
+const char *ieee80211_get_reason_code_string(u16 reason_code)
+{
+	if (reason_code <= 24)
+		return reason_code_strings[reason_code];
+	else if (reason_code >= 32 && reason_code <= 39)
+		return reason_code_strings[reason_code - 7];
+	else if (reason_code == 45)
+		return reason_code_strings[33];
+	else if (reason_code >= 52 && reason_code <= 66)
+		return reason_code_strings[reason_code - 18];
+	else
+		return "(INVALID)";
+}
+
 int ieee80211_register_hw(struct ieee80211_hw *hw)
 {
 	struct ieee80211_local *local = hw_to_local(hw);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index fc1d824..74e4585 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2231,8 +2231,8 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
 
 	reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
 
-	sdata_info(sdata, "deauthenticated from %pM (Reason: %u)\n",
-		   bssid, reason_code);
+	sdata_info(sdata, "deauthenticated from %pM (reason: %s)\n",
+		   bssid, ieee80211_get_reason_code_string(reason_code));
 
 	ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
 
@@ -4301,8 +4301,8 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
 	bool report_frame = false;
 
 	sdata_info(sdata,
-		   "deauthenticating from %pM by local choice (reason=%d)\n",
-		   req->bssid, req->reason_code);
+		   "deauthenticating from %pM by local choice (reason: %s)\n",
+		   req->bssid, ieee80211_get_reason_code_string(req->reason_code));
 
 	if (ifmgd->auth_data) {
 		drv_mgd_prepare_tx(sdata->local, sdata);
@@ -4348,8 +4348,8 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
 		return -ENOLINK;
 
 	sdata_info(sdata,
-		   "disassociating from %pM by local choice (reason=%d)\n",
-		   req->bss->bssid, req->reason_code);
+		   "disassociating from %pM by local choice (reason: %s)\n",
+		   req->bss->bssid, ieee80211_get_reason_code_string(req->reason_code));
 
 	memcpy(bssid, req->bss->bssid, ETH_ALEN);
 	ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DISASSOC,
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2014-02-12 10:46 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-06  1:44 [PATCH] ieee80211: Print human-readable disassoc/deauth reason codes Calvin Owens
2014-02-06  4:44 ` Joe Perches
2014-02-10 11:09   ` Johannes Berg
2014-02-10 16:39     ` Joe Perches
2014-02-11  1:25       ` [PATCH v2] " Calvin Owens
2014-02-11  1:39         ` Joe Perches
2014-02-11 16:37           ` [PATCH v3] " Calvin Owens
2014-02-11 16:48             ` Antonio Quartulli
2014-02-11 17:59               ` Calvin Owens
2014-02-11 18:19               ` Johannes Berg
2014-02-11 17:13             ` Joe Perches
2014-02-11 17:52               ` Calvin Owens
2014-02-11 18:36                 ` [PATCH v4] " Calvin Owens
2014-02-12 10:46                   ` Johannes Berg
2014-02-06  8:37 ` [PATCH] " Johannes Berg
2014-02-07 12:53   ` Kalle Valo
2014-02-07 15:46     ` Larry Finger
2014-02-07 22:25       ` Luca Coelho
2014-02-08  6:38         ` Kalle Valo
2014-02-07 20:50   ` Calvin Owens
2014-02-10  8:50 ` Jouni Malinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.