Patchwork [1/2] supplicant: Print human readable event names.

login
register
mail settings
Submitter Ben Greear
Date Nov. 4, 2011, 11:14 p.m.
Message ID <1320448498-23810-1-git-send-email-greearb@candelatech.com>
Download mbox | patch
Permalink /patch/123712/
State Superseded
Headers show

Comments

Ben Greear - Nov. 4, 2011, 11:14 p.m.
From: Ben Greear <greearb@candelatech.com>

This makes it easier to understand the event related
logs.

Also, print re-entrancy depth in the event handler.
I'm suspicious that it could be called in a re-entrant
manner if netlink events are received & processed as
part of another event.

Signed-hostap: Ben Greear <greearb@candelatech.com>
---
:100644 100644 24a61e4... 6626c80... M	src/common/wpa_common.c
:100644 100644 06f2db3... ead35c0... M	src/drivers/driver.h
:100644 100644 9a0663b... 4b8ac96... M	wpa_supplicant/events.c
 src/common/wpa_common.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++
 src/drivers/driver.h    |    4 +++
 wpa_supplicant/events.c |   13 +++++++---
 3 files changed, 70 insertions(+), 4 deletions(-)
Dan Williams - Nov. 4, 2011, 11:26 p.m.
On Fri, 2011-11-04 at 16:14 -0700, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> This makes it easier to understand the event related
> logs.
> 
> Also, print re-entrancy depth in the event handler.
> I'm suspicious that it could be called in a re-entrant
> manner if netlink events are received & processed as
> part of another event.
> 
> Signed-hostap: Ben Greear <greearb@candelatech.com>
> ---
> :100644 100644 24a61e4... 6626c80... M	src/common/wpa_common.c
> :100644 100644 06f2db3... ead35c0... M	src/drivers/driver.h
> :100644 100644 9a0663b... 4b8ac96... M	wpa_supplicant/events.c
>  src/common/wpa_common.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++
>  src/drivers/driver.h    |    4 +++
>  wpa_supplicant/events.c |   13 +++++++---
>  3 files changed, 70 insertions(+), 4 deletions(-)
> 
> diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
> index 24a61e4..6626c80 100644
> --- a/src/common/wpa_common.c
> +++ b/src/common/wpa_common.c
> @@ -23,8 +23,65 @@
>  #include "ieee802_11_defs.h"
>  #include "defs.h"
>  #include "wpa_common.h"
> +#include "drivers/driver.h"
>  
> 
> +const char* cstr(enum wpa_event_type event)

Can we name that something other than "cstr", like maybe
wpas_event_to_string() or event_to_string() or eventstr()?

Dan

> +{
> +	switch (event) {
> +	case EVENT_ASSOC: return "ASSOC";
> +	case EVENT_DISASSOC: return "DISASSOC";
> +	case EVENT_MICHAEL_MIC_FAILURE: return "MICHAEL_MIC_FAILURE";
> +	case EVENT_SCAN_RESULTS: return "SCAN_RESULTS";
> +	case EVENT_ASSOCINFO: return "ASSOCINFO";
> +	case EVENT_INTERFACE_STATUS: return "INTERFACE_STATUS";
> +	case EVENT_PMKID_CANDIDATE: return "PMKID_CANDIDATE";
> +	case EVENT_STKSTART: return "STKSTART";
> +	case EVENT_TDLS: return "TDLS";
> +	case EVENT_FT_RESPONSE: return "FT_RESPONSE";
> +	case EVENT_IBSS_RSN_START: return "IBSS_RSN_START";
> +	case EVENT_AUTH: return "AUTH";
> +	case EVENT_DEAUTH: return "DEAUTH";
> +	case EVENT_ASSOC_REJECT: return "ASSOC_REJECT";
> +	case EVENT_AUTH_TIMED_OUT: return "AUTH_TIMED_OUT";
> +	case EVENT_ASSOC_TIMED_OUT: return "ASSOC_TIMED_OUT";
> +	case EVENT_FT_RRB_RX: return "FT_RRB_RX";
> +	case EVENT_WPS_BUTTON_PUSHED: return "WPS_BUTTON_PUSHED";
> +	case EVENT_TX_STATUS: return "TX_STATUS";
> +	case EVENT_RX_FROM_UNKNOWN: return "RX_FROM_UNKNOWN";
> +	case EVENT_RX_MGMT: return "RX_MGMT";
> +	case EVENT_RX_ACTION: return "RX_ACTION";
> +	case EVENT_REMAIN_ON_CHANNEL: return "REMAIN_ON_CHANNEL";
> +	case EVENT_CANCEL_REMAIN_ON_CHANNEL: return "CANCEL_ROC";
> +	case EVENT_MLME_RX: return "MLME_RX";
> +	case EVENT_RX_PROBE_REQ: return "RX_PROBE_REQ";
> +	case EVENT_NEW_STA: return "NEW_STA";
> +	case EVENT_EAPOL_RX: return "EAPOL_RX";
> +	case EVENT_SIGNAL_CHANGE: return "SIGNAL_CHANGE";
> +	case EVENT_INTERFACE_ENABLED: return "IFACE_ENABLED";
> +	case EVENT_INTERFACE_DISABLED: return "IFACE_DISABLED";
> +	case EVENT_CHANNEL_LIST_CHANGED: return "CHANNEL_LIST_CHANGED";
> +	case EVENT_INTERFACE_UNAVAILABLE: return "INTERFACE_UNAVAILABLE";
> +	case EVENT_BEST_CHANNEL: return "BEST_CHANNEL";
> +	case EVENT_UNPROT_DEAUTH: return "UNPROT_DEAUTH";
> +	case EVENT_UNPROT_DISASSOC: return "UNPROT_DISASSOC";
> +	case EVENT_STATION_LOW_ACK: return "STA_LOW_ACK";
> +	case EVENT_P2P_DEV_FOUND: return "P2P_DEV_FOUND";
> +	case EVENT_P2P_GO_NEG_REQ_RX: return "P2P_GO_NEG_REQ_RX";
> +	case EVENT_P2P_GO_NEG_COMPLETED: return "P2P_GO_NEG_COMPLETED";
> +	case EVENT_P2P_PROV_DISC_REQUEST: return "P2P_PROV_DISC_REQUEST";
> +	case EVENT_P2P_PROV_DISC_RESPONSE: return "P2P_PROV_DISC_RESPONSE";
> +	case EVENT_P2P_SD_REQUEST: return "P2P_SD_REQUEST";
> +	case EVENT_P2P_SD_RESPONSE: return "P2P_SD_RESPONSE";
> +	case EVENT_IBSS_PEER_LOST: return "IBSS_PEER_LOST";
> +	case EVENT_DRIVER_GTK_REKEY: return "DRIVER_GTK_REKEY";
> +	case EVENT_SCHED_SCAN_STOPPED: return "SCHED_SCAN_STOPPED";
> +	case EVENT_DRIVER_CLIENT_POLL_OK: return "CLIENT_POLL_OK";
> +
> +	default: return "UNKNOWN";
> +	}
> +}
> +
>  /**
>   * wpa_eapol_key_mic - Calculate EAPOL-Key MIC
>   * @key: EAPOL-Key Key Confirmation Key (KCK)
> diff --git a/src/drivers/driver.h b/src/drivers/driver.h
> index 06f2db3..ead35c0 100644
> --- a/src/drivers/driver.h
> +++ b/src/drivers/driver.h
> @@ -3456,6 +3456,10 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
>  			  union wpa_event_data *data);
>  
> 
> +/* Convert wpa_event_type to a string for logging. */
> +const char* cstr(enum wpa_event_type event);
> +
> +
>  /*
>   * The following inline functions are provided for convenience to simplify
>   * event indication for some of the common events.
> diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> index 9a0663b..4b8ac96 100644
> --- a/wpa_supplicant/events.c
> +++ b/wpa_supplicant/events.c
> @@ -1941,17 +1941,20 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
>  {
>  	struct wpa_supplicant *wpa_s = ctx;
>  	u16 reason_code = 0;
> +	static int depth = 0;
>  
>  	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
>  	    event != EVENT_INTERFACE_ENABLED &&
>  	    event != EVENT_INTERFACE_STATUS) {
> -		wpa_dbg(wpa_s, MSG_DEBUG, "Ignore event %d while interface is "
> -			"disabled", event);
> +		wpa_dbg(wpa_s, MSG_DEBUG,
> +			"Ignore event %s (%d) while interface is disabled",
> +			cstr(event), event);
>  		return;
>  	}
>  
> -	wpa_dbg(wpa_s, MSG_DEBUG, "Event %d received on interface %s",
> -		event, wpa_s->ifname);
> +	depth++;
> +	wpa_dbg(wpa_s, MSG_DEBUG, "Event %s (%d) received, depth: %i",
> +		cstr(event), event, depth);
>  
>  	switch (event) {
>  	case EVENT_AUTH:
> @@ -2458,4 +2461,6 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
>  		wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);
>  		break;
>  	}
> +
> +	depth--;
>  }
Ben Greear - Nov. 4, 2011, 11:28 p.m.
On 11/04/2011 04:26 PM, Dan Williams wrote:
> On Fri, 2011-11-04 at 16:14 -0700, greearb@candelatech.com wrote:
>> From: Ben Greear<greearb@candelatech.com>
>>
>> This makes it easier to understand the event related
>> logs.
>>
>> Also, print re-entrancy depth in the event handler.
>> I'm suspicious that it could be called in a re-entrant
>> manner if netlink events are received&  processed as
>> part of another event.
>>
>> Signed-hostap: Ben Greear<greearb@candelatech.com>
>> ---
>> :100644 100644 24a61e4... 6626c80... M	src/common/wpa_common.c
>> :100644 100644 06f2db3... ead35c0... M	src/drivers/driver.h
>> :100644 100644 9a0663b... 4b8ac96... M	wpa_supplicant/events.c
>>   src/common/wpa_common.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++
>>   src/drivers/driver.h    |    4 +++
>>   wpa_supplicant/events.c |   13 +++++++---
>>   3 files changed, 70 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
>> index 24a61e4..6626c80 100644
>> --- a/src/common/wpa_common.c
>> +++ b/src/common/wpa_common.c
>> @@ -23,8 +23,65 @@
>>   #include "ieee802_11_defs.h"
>>   #include "defs.h"
>>   #include "wpa_common.h"
>> +#include "drivers/driver.h"
>>
>>
>> +const char* cstr(enum wpa_event_type event)
>
> Can we name that something other than "cstr", like maybe
> wpas_event_to_string() or event_to_string() or eventstr()?

Sure...  I'll fix that up shortly.

Thanks,
Ben

Patch

diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
index 24a61e4..6626c80 100644
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
@@ -23,8 +23,65 @@ 
 #include "ieee802_11_defs.h"
 #include "defs.h"
 #include "wpa_common.h"
+#include "drivers/driver.h"
 
 
+const char* cstr(enum wpa_event_type event)
+{
+	switch (event) {
+	case EVENT_ASSOC: return "ASSOC";
+	case EVENT_DISASSOC: return "DISASSOC";
+	case EVENT_MICHAEL_MIC_FAILURE: return "MICHAEL_MIC_FAILURE";
+	case EVENT_SCAN_RESULTS: return "SCAN_RESULTS";
+	case EVENT_ASSOCINFO: return "ASSOCINFO";
+	case EVENT_INTERFACE_STATUS: return "INTERFACE_STATUS";
+	case EVENT_PMKID_CANDIDATE: return "PMKID_CANDIDATE";
+	case EVENT_STKSTART: return "STKSTART";
+	case EVENT_TDLS: return "TDLS";
+	case EVENT_FT_RESPONSE: return "FT_RESPONSE";
+	case EVENT_IBSS_RSN_START: return "IBSS_RSN_START";
+	case EVENT_AUTH: return "AUTH";
+	case EVENT_DEAUTH: return "DEAUTH";
+	case EVENT_ASSOC_REJECT: return "ASSOC_REJECT";
+	case EVENT_AUTH_TIMED_OUT: return "AUTH_TIMED_OUT";
+	case EVENT_ASSOC_TIMED_OUT: return "ASSOC_TIMED_OUT";
+	case EVENT_FT_RRB_RX: return "FT_RRB_RX";
+	case EVENT_WPS_BUTTON_PUSHED: return "WPS_BUTTON_PUSHED";
+	case EVENT_TX_STATUS: return "TX_STATUS";
+	case EVENT_RX_FROM_UNKNOWN: return "RX_FROM_UNKNOWN";
+	case EVENT_RX_MGMT: return "RX_MGMT";
+	case EVENT_RX_ACTION: return "RX_ACTION";
+	case EVENT_REMAIN_ON_CHANNEL: return "REMAIN_ON_CHANNEL";
+	case EVENT_CANCEL_REMAIN_ON_CHANNEL: return "CANCEL_ROC";
+	case EVENT_MLME_RX: return "MLME_RX";
+	case EVENT_RX_PROBE_REQ: return "RX_PROBE_REQ";
+	case EVENT_NEW_STA: return "NEW_STA";
+	case EVENT_EAPOL_RX: return "EAPOL_RX";
+	case EVENT_SIGNAL_CHANGE: return "SIGNAL_CHANGE";
+	case EVENT_INTERFACE_ENABLED: return "IFACE_ENABLED";
+	case EVENT_INTERFACE_DISABLED: return "IFACE_DISABLED";
+	case EVENT_CHANNEL_LIST_CHANGED: return "CHANNEL_LIST_CHANGED";
+	case EVENT_INTERFACE_UNAVAILABLE: return "INTERFACE_UNAVAILABLE";
+	case EVENT_BEST_CHANNEL: return "BEST_CHANNEL";
+	case EVENT_UNPROT_DEAUTH: return "UNPROT_DEAUTH";
+	case EVENT_UNPROT_DISASSOC: return "UNPROT_DISASSOC";
+	case EVENT_STATION_LOW_ACK: return "STA_LOW_ACK";
+	case EVENT_P2P_DEV_FOUND: return "P2P_DEV_FOUND";
+	case EVENT_P2P_GO_NEG_REQ_RX: return "P2P_GO_NEG_REQ_RX";
+	case EVENT_P2P_GO_NEG_COMPLETED: return "P2P_GO_NEG_COMPLETED";
+	case EVENT_P2P_PROV_DISC_REQUEST: return "P2P_PROV_DISC_REQUEST";
+	case EVENT_P2P_PROV_DISC_RESPONSE: return "P2P_PROV_DISC_RESPONSE";
+	case EVENT_P2P_SD_REQUEST: return "P2P_SD_REQUEST";
+	case EVENT_P2P_SD_RESPONSE: return "P2P_SD_RESPONSE";
+	case EVENT_IBSS_PEER_LOST: return "IBSS_PEER_LOST";
+	case EVENT_DRIVER_GTK_REKEY: return "DRIVER_GTK_REKEY";
+	case EVENT_SCHED_SCAN_STOPPED: return "SCHED_SCAN_STOPPED";
+	case EVENT_DRIVER_CLIENT_POLL_OK: return "CLIENT_POLL_OK";
+
+	default: return "UNKNOWN";
+	}
+}
+
 /**
  * wpa_eapol_key_mic - Calculate EAPOL-Key MIC
  * @key: EAPOL-Key Key Confirmation Key (KCK)
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 06f2db3..ead35c0 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -3456,6 +3456,10 @@  void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 			  union wpa_event_data *data);
 
 
+/* Convert wpa_event_type to a string for logging. */
+const char* cstr(enum wpa_event_type event);
+
+
 /*
  * The following inline functions are provided for convenience to simplify
  * event indication for some of the common events.
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 9a0663b..4b8ac96 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -1941,17 +1941,20 @@  void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 {
 	struct wpa_supplicant *wpa_s = ctx;
 	u16 reason_code = 0;
+	static int depth = 0;
 
 	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
 	    event != EVENT_INTERFACE_ENABLED &&
 	    event != EVENT_INTERFACE_STATUS) {
-		wpa_dbg(wpa_s, MSG_DEBUG, "Ignore event %d while interface is "
-			"disabled", event);
+		wpa_dbg(wpa_s, MSG_DEBUG,
+			"Ignore event %s (%d) while interface is disabled",
+			cstr(event), event);
 		return;
 	}
 
-	wpa_dbg(wpa_s, MSG_DEBUG, "Event %d received on interface %s",
-		event, wpa_s->ifname);
+	depth++;
+	wpa_dbg(wpa_s, MSG_DEBUG, "Event %s (%d) received, depth: %i",
+		cstr(event), event, depth);
 
 	switch (event) {
 	case EVENT_AUTH:
@@ -2458,4 +2461,6 @@  void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 		wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);
 		break;
 	}
+
+	depth--;
 }