[PATCH] Adding some important wlan cotnrol events as dbus signals

Dan Williams dcbw
Mon Jun 1 06:28:02 PDT 2015


On Mon, 2015-06-01 at 06:21 +0000, Avichal Agarwal wrote:
>  From 51363ead405042ca466a418b4676086ec060de4c Mon Sep 17 00:00:00 2001
> 
> Following events are added as dbus signals , this patch will help application
> to make quick decisions based on events , as happens in wpa ctrl_socket
> based application. This make dbus interface fast.
> Now no more waithing for state change notifications.
> 
> 1. WPA-CONNECTED
> 2. WPA-DISCONNECTED
> 3. WPA-ASSOCREJECT
> 4. WPA-TERMINATING
> 5. WPA-SCAN-STARTED
> 6. WPA-SCAN-RESULTS
> 7. WPA-SCAN-FAILED
> 8. WPS-EVENT-OVERLAP

I guess  I replied to the "FWD" version of this message that came later;
so please see my replies to that one.

Dan

> Signed-off-by: Avichal Agarwal <avichal.a at samsung.com>
> ---
>  0001-added-variable-to-get-runtime-values.patch |   27 ++++
>  wpa_supplicant/ap.c                             |    1 +
>  wpa_supplicant/dbus/dbus_new.c                  |  194 +++++++++++++++++++++++
>  wpa_supplicant/dbus/dbus_new.h                  |   32 ++++
>  wpa_supplicant/events.c                         |    4 +
>  wpa_supplicant/notify.c                         |   50 ++++++
>  wpa_supplicant/notify.h                         |    7 +
>  wpa_supplicant/scan.c                           |    3 +
>  wpa_supplicant/wpa_supplicant.c                 |    5 +-
>  9 files changed, 322 insertions(+), 1 deletion(-)
>  create mode 100644 0001-added-variable-to-get-runtime-values.patch
> 
> diff --git a/0001-added-variable-to-get-runtime-values.patch b/0001-added-variable-to-get-runtime-values.patch
> new file mode 100644
> index 0000000..90c4741
> --- /dev/null
> +++ b/0001-added-variable-to-get-runtime-values.patch
> @@ -0,0 +1,27 @@
> +From 5599cabefc5a66a5b467e4d577df6c1b02dd7999 Mon Sep 17 00:00:00 2001
> +From: samsung <samsung at samsung.(none)>
> +Date: Mon, 1 Jun 2015 09:10:04 +0530
> +Subject: [PATCH] added variable to get runtime values
> +
> +descriptoin goes here
> +
> +Signed-off-by: Avichal Agarwal <avichal.a at samsung.com>
> +---
> + wpa_supplicant/main.c |    1 +
> + 1 file changed, 1 insertion(+)
> +
> +diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c
> +index 2282747..d938b02 100644
> +--- a/wpa_supplicant/main.c
> ++++ b/wpa_supplicant/main.c
> +@@ -20,6 +20,7 @@
> + static void usage(void)
> + {
> + 	int i;
> ++	int p;
> + 	printf("%s\n\n%s\n"
> + 	       "usage:\n"
> + 	       "  wpa_supplicant [-BddhKLqq"
> +-- 
> +1.7.9.5
> +
> diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
> index bfb69fc..faa7f92 100644
> --- a/wpa_supplicant/ap.c
> +++ b/wpa_supplicant/ap.c
> @@ -707,6 +707,7 @@ void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
>  	hostapd_interface_free(wpa_s->ap_iface);
>  	wpa_s->ap_iface = NULL;
>  	wpa_drv_deinit_ap(wpa_s);
> +	wpas_notify_disconnected(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);
> diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
> index 6382d77..4e1b66f 100644
> --- a/wpa_supplicant/dbus/dbus_new.c
> +++ b/wpa_supplicant/dbus/dbus_new.c
> @@ -2965,6 +2965,48 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
>  		  END_ARGS
>  	  }
>  	},
> +
> +	{ "WPA-CONNECTED", WPAS_DBUS_NEW_IFACE_INTERFACE,
> +	  {
> +
> +		  END_ARGS
> +	  }
> +	},
> +
> +	{ "WPA-DISCONNECTED", WPAS_DBUS_NEW_IFACE_INTERFACE,
> +	  {
> +
> +		  END_ARGS
> +	  }
> +	},
> +
> +
> +	{ "WPA-ASSOCREJECT", WPAS_DBUS_NEW_IFACE_INTERFACE,
> +		  {
> +
> +			  END_ARGS
> +		  }
> +	},
> +
> +	{ "WPA-TERMINATING", WPAS_DBUS_NEW_IFACE_INTERFACE,
> +		  {
> +
> +			  END_ARGS
> +		  }
> +	},
> +
> +	{ "WPA-SCAN-STARTED", WPAS_DBUS_NEW_IFACE_INTERFACE,
> +		  {
> +
> +			  END_ARGS
> +		  }
> +	},
> +	{ "WPA-SCAN-FAILED", WPAS_DBUS_NEW_IFACE_INTERFACE,
> +		  {
> +
> +			  END_ARGS
> +		  }
> +	},
>  	{ "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
>  	  {
>  		  { "path", "o", ARG_OUT },
> @@ -3037,6 +3079,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
>  		  END_ARGS
>  	  }
>  	},
> +	{ "WPS-EVENT-OVERLAP", WPAS_DBUS_NEW_IFACE_WPS,
> +		  {
> +
> +			  END_ARGS
> +		  }
> +	},
>  #endif /* CONFIG_WPS */
>  #ifdef CONFIG_P2P
>  	{ "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
> @@ -3216,6 +3264,152 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
>  };
>  
> 
> +
> +
> +void wpas_dbus_signal_wpa_connected(struct wpa_supplicant *wpa_s)
> +{
> +	struct wpas_dbus_priv *iface;
> +	DBusMessage *msg;
> +
> +	iface = wpa_s->global->dbus;
> +
> +	/* Do nothing if the control interface is not turned on */
> +	if (iface == NULL || !wpa_s->dbus_new_path)
> +		return;
> +
> +	msg = dbus_message_new_signal(wpa_s->dbus_new_path,	WPAS_DBUS_NEW_IFACE_INTERFACE,"WPA-CONNECTED");
> +	if (msg == NULL)
> +		return;
> +
> +	dbus_connection_send(iface->con, msg, NULL);
> +
> +	dbus_message_unref(msg);
> +}
> +
> +void wpas_dbus_signal_wpa_disconnected(struct wpa_supplicant *wpa_s)
> +{
> +	struct wpas_dbus_priv *iface;
> +	DBusMessage *msg;
> +
> +	iface = wpa_s->global->dbus;
> +
> +	/* Do nothing if the control interface is not turned on */
> +	if (iface == NULL || !wpa_s->dbus_new_path)
> +		return;
> +
> +	msg = dbus_message_new_signal(wpa_s->dbus_new_path,	WPAS_DBUS_NEW_IFACE_INTERFACE,"WPA-DISCONNECTED");
> +	if (msg == NULL)
> +		return;
> +
> +	dbus_connection_send(iface->con, msg, NULL);
> +
> +	dbus_message_unref(msg);
> +}
> +
> +void wpas_dbus_signal_assoc_reject(struct wpa_supplicant *wpa_s)
> +{
> +	struct wpas_dbus_priv *iface;
> +	DBusMessage *msg;
> +
> +	iface = wpa_s->global->dbus;
> +
> +	/* Do nothing if the control interface is not turned on */
> +	if (iface == NULL || !wpa_s->dbus_new_path)
> +		return;
> +
> +	msg = dbus_message_new_signal(wpa_s->dbus_new_path,	WPAS_DBUS_NEW_IFACE_INTERFACE,"WPA-ASSOCREJECT");
> +	if (msg == NULL)
> +		return;
> +
> +	dbus_connection_send(iface->con, msg, NULL);
> +
> +	dbus_message_unref(msg);
> +}
> +
> +void wpas_dbus_signal_terminating(struct wpa_supplicant *wpa_s)
> +{
> +	struct wpas_dbus_priv *iface;
> +	DBusMessage *msg;
> +
> +	iface = wpa_s->global->dbus;
> +
> +	/* Do nothing if the control interface is not turned on */
> +	if (iface == NULL || !wpa_s->dbus_new_path)
> +		return;
> +
> +	msg = dbus_message_new_signal(wpa_s->dbus_new_path,	WPAS_DBUS_NEW_IFACE_INTERFACE,"WPA-TERMINATING");
> +	if (msg == NULL)
> +		return;
> +
> +	dbus_connection_send(iface->con, msg, NULL);
> +
> +	dbus_message_unref(msg);
> +}
> +
> +
> +void wpas_dbus_signal_scan_started(struct wpa_supplicant *wpa_s)
> +{
> +	struct wpas_dbus_priv *iface;
> +	DBusMessage *msg;
> +
> +	iface = wpa_s->global->dbus;
> +
> +	/* Do nothing if the control interface is not turned on */
> +	if (iface == NULL || !wpa_s->dbus_new_path)
> +		return;
> +
> +	msg = dbus_message_new_signal(wpa_s->dbus_new_path,	WPAS_DBUS_NEW_IFACE_INTERFACE,"WPA-SCAN-STARTED");
> +	if (msg == NULL)
> +		return;
> +
> +	dbus_connection_send(iface->con, msg, NULL);
> +
> +	dbus_message_unref(msg);
> +}
> +
> +void wpas_dbus_signal_scan_failed(struct wpa_supplicant *wpa_s)
> +{
> +	struct wpas_dbus_priv *iface;
> +	DBusMessage *msg;
> +
> +	iface = wpa_s->global->dbus;
> +
> +	/* Do nothing if the control interface is not turned on */
> +	if (iface == NULL || !wpa_s->dbus_new_path)
> +		return;
> +
> +	msg = dbus_message_new_signal(wpa_s->dbus_new_path,	WPAS_DBUS_NEW_IFACE_INTERFACE,"WPA-SCAN-FAILED");
> +	if (msg == NULL)
> +		return;
> +
> +	dbus_connection_send(iface->con, msg, NULL);
> +
> +	dbus_message_unref(msg);
> +}
> +
> +
> +
> +void wpas_dbus_signal_wps_overlap(struct wpa_supplicant *wpa_s)
> +{
> +	struct wpas_dbus_priv *iface;
> +	DBusMessage *msg;
> +
> +	iface = wpa_s->global->dbus;
> +
> +	/* Do nothing if the control interface is not turned on */
> +	if (iface == NULL || !wpa_s->dbus_new_path)
> +		return;
> +
> +	msg = dbus_message_new_signal(wpa_s->dbus_new_path,	WPAS_DBUS_NEW_IFACE_WPS,"WPS-EVENT-OVERLAP");
> +	if (msg == NULL)
> +		return;
> +
> +	dbus_connection_send(iface->con, msg, NULL);
> +
> +	dbus_message_unref(msg);
> +}
> +
> +
>  int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
>  {
>  
> diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
> index 31db8d4..2319db1 100644
> --- a/wpa_supplicant/dbus/dbus_new.h
> +++ b/wpa_supplicant/dbus/dbus_new.h
> @@ -271,11 +271,38 @@ static inline void wpas_dbus_signal_network_request(
>  {
>  }
>  
> +static inline void wpas_dbus_signal_wpa_connected(struct wpa_supplicant *wpa_s)
> +{
> +
> +}
> +
> +static inline void wpas_dbus_signal_wpa_disconnected(struct wpa_supplicant *wpa_s)
> +{
> +
> +}
> +static inline void wpas_dbus_signal_assoc_reject(struct wpa_supplicant *wpa_s)
> +{
> +
> +}
> +static inline void wpas_dbus_signal_terminating(struct wpa_supplicant *wpa_s)
> +{
> +
> +}
> +
> +
>  static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s,
>  					      int success)
>  {
>  }
>  
> +static inline void  wpas_dbus_signal_scan_started(struct wpa_supplicant *wpa_s)
> +{
> +
> +}
> +static inline void wpas_dbus_signal_scan_failed(struct wpa_supplicant *wpa_s)
> +{
> +
> +}
>  static inline void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
>  					     const struct wps_credential *cred)
>  {
> @@ -286,6 +313,11 @@ static inline void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
>  {
>  }
>  
> +static inline void wpas_dbus_signal_wps_overlap(struct wpa_supplicant *wpa_s)
> +{
> +
> +}
> +
>  static inline void wpas_dbus_signal_wps_event_fail(
>  	struct wpa_supplicant *wpa_s, struct wps_event_fail *fail)
>  {
> diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> index d086624..26153dc 100644
> --- a/wpa_supplicant/events.c
> +++ b/wpa_supplicant/events.c
> @@ -1177,6 +1177,7 @@ int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
>  			   struct wpa_ssid *ssid)
>  {
>  	if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
> +		wpas_notify_wps_overlap(wpa_s);
>  		wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
>  			"PBC session overlap");
>  #ifdef CONFIG_P2P
> @@ -2268,6 +2269,7 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s,
>  
>  	if (!is_zero_ether_addr(bssid) ||
>  	    wpa_s->wpa_state >= WPA_AUTHENTICATING) {
> +		wpas_notify_disconnected(wpa_s);
>  		wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
>  			" reason=%d%s",
>  			MAC2STR(bssid), reason_code,
> @@ -3218,6 +3220,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
>  #ifndef CONFIG_NO_SCAN_PROCESSING
>  	case EVENT_SCAN_STARTED:
>  		os_get_reltime(&wpa_s->scan_start_time);
> +		wpas_notify_scan_started(wpa_s);
>  		if (wpa_s->own_scan_requested) {
>  			struct os_reltime diff;
>  
> @@ -3294,6 +3297,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
>  		break;
>  #endif /* CONFIG_IBSS_RSN */
>  	case EVENT_ASSOC_REJECT:
> +		wpas_notify_assoc_reject(wpa_s);
>  		if (data->assoc_reject.bssid)
>  			wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
>  				"bssid=" MACSTR	" status_code=%u",
> diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
> index 4df9d90..9d1d7f8 100644
> --- a/wpa_supplicant/notify.c
> +++ b/wpa_supplicant/notify.c
> @@ -206,6 +206,56 @@ void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
>  	wpas_dbus_signal_scan_done(wpa_s, success);
>  }
>  
> +void wpas_notify_connected(struct wpa_supplicant *wpa_s)
> +{
> +	if (wpa_s->p2p_mgmt)
> +				return;
> +	wpas_dbus_signal_wpa_connected(wpa_s);
> +}
> +
> +void wpas_notify_disconnected(struct wpa_supplicant *wpa_s)
> +{
> +	if (wpa_s->p2p_mgmt)
> +				return;
> +	wpas_dbus_signal_wpa_disconnected(wpa_s);
> +}
> +
> +void wpas_notify_assoc_reject(struct wpa_supplicant *wpa_s)
> +{
> +	if (wpa_s->p2p_mgmt)
> +				return;
> +	 wpas_dbus_signal_assoc_reject(wpa_s);
> +}
> +
> +void wpas_notify_terminating(struct wpa_supplicant *wpa_s)
> +{
> +	 wpas_dbus_signal_terminating(wpa_s);
> +}
> +
> +void wpas_notify_scan_started(struct wpa_supplicant *wpa_s)
> +{
> +	if (wpa_s->p2p_mgmt)
> +			return;
> +	wpas_dbus_signal_scan_started(wpa_s);
> +
> +}
> +
> +void wpas_notify_scan_failed(struct wpa_supplicant *wpa_s)
> +{
> +	if (wpa_s->p2p_mgmt)
> +			return;
> +	wpas_dbus_signal_scan_failed(wpa_s);
> +
> +}
> +
> +
> +void wpas_notify_wps_overlap(struct wpa_supplicant *wpa_s)
> +{
> +	if (wpa_s->p2p_mgmt)
> +			return;
> +	 wpas_dbus_signal_wps_overlap(wpa_s);
> +
> +}
>  
>  void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
>  {
> diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
> index 1025ca8..9a98660 100644
> --- a/wpa_supplicant/notify.h
> +++ b/wpa_supplicant/notify.h
> @@ -134,5 +134,12 @@ void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
>  					   struct wpa_ssid *ssid);
>  void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
>  				      struct wpa_ssid *ssid);
> +void wpas_notify_connected(struct wpa_supplicant *wpa_s);
> +void wpas_notify_disconnected(struct wpa_supplicant *wpa_s);
> +void wpas_notify_assoc_reject(struct wpa_supplicant *wpa_s);
> +void wpas_notify_terminating(struct wpa_supplicant *wpa_s);
> +void wpas_notify_scan_started(struct wpa_supplicant *wpa_s);
> +void wpas_notify_scan_failed(struct wpa_supplicant *wpa_s);
> +void wpas_notify_wps_overlap(struct wpa_supplicant *wpa_s);
>  
>  #endif /* NOTIFY_H */
> diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
> index 3c6b2c7..9ad5302 100644
> --- a/wpa_supplicant/scan.c
> +++ b/wpa_supplicant/scan.c
> @@ -189,10 +189,13 @@ static void wpas_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
>  		wpa_supplicant_notify_scanning(wpa_s, 0);
>  		wpas_notify_scan_done(wpa_s, 0);
>  		if (wpa_s->wpa_state == WPA_SCANNING)
> +		{
> +			 wpas_notify_scan_failed(wpa_s);
>  			wpa_supplicant_set_state(wpa_s,
>  						 wpa_s->scan_prev_wpa_state);
>  		wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_FAILED "ret=%d%s",
>  			ret, retry ? " retry=1" : "");
> +		}
>  		radio_work_done(work);
>  
>  		if (retry) {
> diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
> index 48bded6..abeced8 100644
> --- a/wpa_supplicant/wpa_supplicant.c
> +++ b/wpa_supplicant/wpa_supplicant.c
> @@ -723,6 +723,7 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
>  
>  	if (state == WPA_COMPLETED && wpa_s->new_connection) {
>  		struct wpa_ssid *ssid = wpa_s->current_ssid;
> +		 wpas_notify_connected(wpa_s);
>  #if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
>  		wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_CONNECTED "- Connection to "
>  			MACSTR " completed [id=%d id_str=%s]",
> @@ -4317,8 +4318,10 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
>  		wpas_notify_iface_removed(wpa_s);
>  
>  	if (terminate)
> +	{
> +		wpas_notify_terminating(wpa_s);
>  		wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
> -
> +	}
>  	if (wpa_s->ctrl_iface) {
>  		wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
>  		wpa_s->ctrl_iface = NULL;





More information about the Hostap mailing list