Patchwork [3/7] Adding AutoScan interface method to set or unset autoscan parameters

login
register
mail settings
Submitter Tomasz Bursztyka
Date May 3, 2012, 1:16 p.m.
Message ID <1336051016-15005-4-git-send-email-tomasz.bursztyka@linux.intel.com>
Download mbox | patch
Permalink /patch/156694/
State Changes Requested
Headers show

Comments

Tomasz Bursztyka - May 3, 2012, 1:16 p.m.
Signed-hostap: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
---
 wpa_supplicant/dbus/dbus_new.c          |    9 ++++++
 wpa_supplicant/dbus/dbus_new_handlers.c |   44 +++++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers.h |    5 +++
 3 files changed, 58 insertions(+), 0 deletions(-)
Jouni Malinen - June 24, 2012, 9:55 a.m.
On Thu, May 03, 2012 at 04:16:52PM +0300, Tomasz Bursztyka wrote:
> diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
> @@ -1885,6 +1885,15 @@ static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
> +#ifdef CONFIG_AUTOSCAN
> +	{ "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
> +	  (WPADBusMethodHandler) &wpas_dbus_handler_autoscan,

An update to doc/dbus.doxygen would be appreciated whenever the D-Bus
interface is modified.

Patch

diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 1760dd2..4bef058 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -1885,6 +1885,15 @@  static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
 		  END_ARGS
 	  }
 	},
+#ifdef CONFIG_AUTOSCAN
+	{ "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
+	  (WPADBusMethodHandler) &wpas_dbus_handler_autoscan,
+	  {
+		  { "arg", "s", ARG_IN },
+		  END_ARGS
+	  }
+	},
+#endif /* CONFIG_AUTOSCAN */
 	{ NULL, NULL, NULL, { END_ARGS } }
 };
 
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 1c7592d..2d2c6dd 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -1810,6 +1810,50 @@  DBusMessage * wpas_dbus_handler_flush_bss(DBusMessage *message,
 	return NULL;
 }
 
+#ifdef CONFIG_AUTOSCAN
+/**
+ * wpas_dbus_handler_autoscan - Set autoscan parameters for the interface
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: NULL
+ *
+ * Handler function for "AutoScan" method call of network interface.
+ */
+DBusMessage * wpas_dbus_handler_autoscan(DBusMessage *message,
+					 struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply = NULL;
+	enum wpa_states state = wpa_s->wpa_state;
+	char *arg;
+
+	dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg,
+			      DBUS_TYPE_INVALID);
+
+	if (wpa_s->conf->autoscan != NULL) {
+		os_free(wpa_s->conf->autoscan);
+		wpa_s->conf->autoscan = NULL;
+	}
+
+	if (arg != NULL && os_strlen(arg) > 0) {
+		wpa_s->conf->autoscan = os_strdup(arg);
+		if (wpa_s->conf->autoscan == NULL) {
+			reply = dbus_message_new_error(message,
+						       DBUS_ERROR_NO_MEMORY,
+						       NULL);
+		}
+
+		if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
+			autoscan_init(wpa_s);
+	} else if (os_strlen(arg) == 0)
+		autoscan_deinit(wpa_s);
+	else
+		reply = dbus_message_new_error(message,
+					       DBUS_ERROR_INVALID_ARGS,
+					       NULL);
+
+	return reply;
+}
+#endif /* CONFIG_AUTOSCAN */
 
 /**
  * wpas_dbus_getter_capabilities - Return interface capabilities
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index d78aa20..c8b8a94 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -124,6 +124,11 @@  DBusMessage * wpas_dbus_handler_remove_blob(DBusMessage *message,
 DBusMessage * wpas_dbus_handler_flush_bss(DBusMessage *message,
 					  struct wpa_supplicant *wpa_s);
 
+#ifdef CONFIG_AUTOSCAN
+DBusMessage * wpas_dbus_handler_autoscan(DBusMessage *message,
+					 struct wpa_supplicant *wpa_s);
+#endif /* CONFIG_AUTOSCAN */
+
 dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
 					  DBusError *error, void *user_data);