Merge "steering: make log message mention "steering""
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index d80cc24..beb8770 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -1949,9 +1949,9 @@
 		return;
 	}
 
-	wpa_printf(MSG_INFO, "disassocation: STA=" MACSTR " reason_code=%d",
+	wpa_printf(MSG_INFO, "disassocation: STA=" MACSTR " reason_code=%s",
 		   MAC2STR(mgmt->sa),
-		   le_to_host16(mgmt->u.disassoc.reason_code));
+		   reason2str(le_to_host16(mgmt->u.disassoc.reason_code)));
 
 	sta = ap_get_sta(hapd, mgmt->sa);
 	if (sta == NULL) {
@@ -2002,8 +2002,9 @@
 	}
 
 	wpa_msg(hapd->msg_ctx, MSG_INFO, "deauthentication: STA=" MACSTR
-		" reason_code=%d",
-		MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
+		" reason_code=%s",
+		MAC2STR(mgmt->sa),
+		reason2str(le_to_host16(mgmt->u.deauth.reason_code)));
 
 	sta = ap_get_sta(hapd, mgmt->sa);
 	if (sta == NULL) {
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index 17ecad5..bab2e91 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -747,8 +747,8 @@
 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
 			 u16 reason)
 {
-	wpa_printf(MSG_INFO, "%s: disassociate STA " MACSTR " (reason=0x%04x)",
-		   hapd->conf->iface, MAC2STR(sta->addr), reason);
+	wpa_printf(MSG_INFO, "%s: disassociate STA " MACSTR " (reason=%s)",
+		   hapd->conf->iface, MAC2STR(sta->addr), reason2str(reason));
 	sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
 	sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
 	ap_sta_set_authorized(hapd, sta, 0);
@@ -786,8 +786,8 @@
 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
 			   u16 reason)
 {
-	wpa_printf(MSG_INFO, "%s: deauthenticate STA " MACSTR " (reason=0x%04x)",
-		   hapd->conf->iface, MAC2STR(sta->addr), reason);
+	wpa_printf(MSG_INFO, "%s: deauthenticate STA " MACSTR " (reason=%s)",
+		   hapd->conf->iface, MAC2STR(sta->addr), reason2str(reason));
 	sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
 	sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
 	ap_sta_set_authorized(hapd, sta, 0);
diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
index 7843e6f..a51227b 100644
--- a/src/common/ieee802_11_common.c
+++ b/src/common/ieee802_11_common.c
@@ -939,3 +939,57 @@
 	return "WLAN_FC_TYPE_UNKNOWN";
 #undef C2S
 }
+
+
+const char * reason2str(u16 reason)
+{
+#define A2S(x) #x
+#define C2S(x) case x: return #x " (" A2S(x) ")";
+#define U2S(x) "WLAN_REASON_UNKNOWN (" A2S(x) ")"
+
+	switch (reason) {
+	C2S(WLAN_REASON_UNSPECIFIED)
+	C2S(WLAN_REASON_PREV_AUTH_NOT_VALID)
+	C2S(WLAN_REASON_DEAUTH_LEAVING)
+	C2S(WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY)
+	C2S(WLAN_REASON_DISASSOC_AP_BUSY)
+	C2S(WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA)
+	C2S(WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA)
+	C2S(WLAN_REASON_DISASSOC_STA_HAS_LEFT)
+	C2S(WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH)
+	/* IEEE 802.11h */
+	C2S(WLAN_REASON_PWR_CAPABILITY_NOT_VALID)
+	C2S(WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID)
+	/* IEEE 802.11i */
+	C2S(WLAN_REASON_INVALID_IE)
+	C2S(WLAN_REASON_MICHAEL_MIC_FAILURE)
+	C2S(WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT)
+	C2S(WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT)
+	C2S(WLAN_REASON_IE_IN_4WAY_DIFFERS)
+	C2S(WLAN_REASON_GROUP_CIPHER_NOT_VALID)
+	C2S(WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID)
+	C2S(WLAN_REASON_AKMP_NOT_VALID)
+	C2S(WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION)
+	C2S(WLAN_REASON_INVALID_RSN_IE_CAPAB)
+	C2S(WLAN_REASON_IEEE_802_1X_AUTH_FAILED)
+	C2S(WLAN_REASON_CIPHER_SUITE_REJECTED)
+	C2S(WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE)
+	C2S(WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED)
+	/* IEEE 802.11e */
+	C2S(WLAN_REASON_DISASSOC_LOW_ACK)
+	/* IEEE 802.11s */
+	C2S(WLAN_REASON_MESH_PEERING_CANCELLED)
+	C2S(WLAN_REASON_MESH_MAX_PEERS)
+	C2S(WLAN_REASON_MESH_CONFIG_POLICY_VIOLATION)
+	C2S(WLAN_REASON_MESH_CLOSE_RCVD)
+	C2S(WLAN_REASON_MESH_MAX_RETRIES)
+	C2S(WLAN_REASON_MESH_CONFIRM_TIMEOUT)
+	C2S(WLAN_REASON_MESH_INVALID_GTK)
+	C2S(WLAN_REASON_MESH_INCONSISTENT_PARAMS)
+	C2S(WLAN_REASON_MESH_INVALID_SECURITY_CAP)
+	}
+	return U2S(reason);
+#undef A2S
+#undef C2S
+#undef U2S
+}
diff --git a/src/drivers/driver_atheros.c b/src/drivers/driver_atheros.c
index b8e7864..cde932f 100644
--- a/src/drivers/driver_atheros.c
+++ b/src/drivers/driver_atheros.c
@@ -734,8 +734,8 @@
 	struct ieee80211req_mlme mlme;
 	int ret;
 
-	wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d",
-		   __func__, ether_sprintf(addr), reason_code);
+	wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%s",
+		   __func__, ether_sprintf(addr), reason2str(reason_code));
 
 	mlme.im_op = IEEE80211_MLME_DEAUTH;
 	mlme.im_reason = reason_code;
@@ -758,8 +758,8 @@
 	struct ieee80211req_mlme mlme;
 	int ret;
 
-	wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d",
-		   __func__, ether_sprintf(addr), reason_code);
+	wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%s",
+		   __func__, ether_sprintf(addr), reason2str(reason_code));
 
 	mlme.im_op = IEEE80211_MLME_DISASSOC;
 	mlme.im_reason = reason_code;
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 640e099..9559148 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -2749,7 +2749,8 @@
 {
 	int ret;
 
-	wpa_printf(MSG_DEBUG, "%s(reason_code=%d)", __func__, reason_code);
+	wpa_printf(MSG_DEBUG, "%s(reason_code=%s)", __func__,
+	           reason2str(reason_code));
 	nl80211_mark_disconnected(drv);
 	/* Disconnect command doesn't need BSSID - it uses cached value */
 	ret = wpa_driver_nl80211_mlme(drv, NULL, NL80211_CMD_DISCONNECT,
@@ -2776,8 +2777,8 @@
 	}
 	if (!(drv->capa.flags & WPA_DRIVER_FLAGS_SME))
 		return wpa_driver_nl80211_disconnect(drv, reason_code);
-	wpa_printf(MSG_DEBUG, "%s(addr=" MACSTR " reason_code=%d)",
-		   __func__, MAC2STR(addr), reason_code);
+	wpa_printf(MSG_DEBUG, "%s(addr=" MACSTR " reason_code=%s)",
+		   __func__, MAC2STR(addr), reason2str(reason_code));
 	nl80211_mark_disconnected(drv);
 	ret = wpa_driver_nl80211_mlme(drv, addr, NL80211_CMD_DEAUTHENTICATE,
 				      reason_code, 0);
diff --git a/src/drivers/driver_privsep.c b/src/drivers/driver_privsep.c
index 26d2bab..b2008bf 100644
--- a/src/drivers/driver_privsep.c
+++ b/src/drivers/driver_privsep.c
@@ -302,8 +302,8 @@
 					  int reason_code)
 {
 	//struct wpa_driver_privsep_data *drv = priv;
-	wpa_printf(MSG_DEBUG, "%s addr=" MACSTR " reason_code=%d",
-		   __func__, MAC2STR(addr), reason_code);
+	wpa_printf(MSG_DEBUG, "%s addr=" MACSTR " reason_code=%s",
+		   __func__, MAC2STR(addr), reason2str(reason_code));
 	wpa_printf(MSG_DEBUG, "%s - TODO", __func__);
 	return 0;
 }
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index bfb69fc..4307c57 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -13,6 +13,7 @@
 #include "utils/eloop.h"
 #include "utils/uuid.h"
 #include "common/ieee802_11_defs.h"
+#include "common/ieee802_11_common.h"
 #include "common/wpa_ctrl.h"
 #include "eapol_supp/eapol_supp_sm.h"
 #include "crypto/dh_group5.h"
@@ -708,8 +709,9 @@
 	wpa_s->ap_iface = NULL;
 	wpa_drv_deinit_ap(wpa_s);
 	wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
-		" reason=%d locally_generated=1",
-		MAC2STR(wpa_s->own_addr), WLAN_REASON_DEAUTH_LEAVING);
+		" reason=%s locally_generated=1",
+		MAC2STR(wpa_s->own_addr),
+		reason2str(WLAN_REASON_DEAUTH_LEAVING));
 }
 
 
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index d086624..d69aeff 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2269,8 +2269,7 @@
 	if (!is_zero_ether_addr(bssid) ||
 	    wpa_s->wpa_state >= WPA_AUTHENTICATING) {
 		wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
-			" reason=%d%s",
-			MAC2STR(bssid), reason_code,
+			" reason=%s%s", MAC2STR(bssid), reason2str(reason_code),
 			locally_generated ? " locally_generated=1" : "");
 	}
 }
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index b96fd8e..c78d798 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2441,9 +2441,9 @@
 	int zero_addr = 0;
 
 	wpa_dbg(wpa_s, MSG_DEBUG, "Request to deauthenticate - bssid=" MACSTR
-		" pending_bssid=" MACSTR " reason=%d state=%s",
+		" pending_bssid=" MACSTR " reason=%s state=%s",
 		MAC2STR(wpa_s->bssid), MAC2STR(wpa_s->pending_bssid),
-		reason_code, wpa_supplicant_state_txt(wpa_s->wpa_state));
+		reason2str(reason_code), wpa_supplicant_state_txt(wpa_s->wpa_state));
 
 	if (!is_zero_ether_addr(wpa_s->bssid))
 		addr = wpa_s->bssid;