Patchwork wpa_supplicant: Add DBus "Reassociate" command

login
register
mail settings
Submitter Paul Stewart
Date Aug. 9, 2012, 4:28 a.m.
Message ID <20120809043449.7BBB620815@glenhelen.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/175994/
State Accepted
Commit 6ed31175613806297b2a6db0cb02ecaf78f9e78d
Headers show

Comments

Paul Stewart - Aug. 9, 2012, 4:28 a.m.
Create a DBus command to reassociate, similar to the
ctrl-interface "reassociate" command.

Signed-hostap: Paul Stewart <pstew@chromium.org>
---
 wpa_supplicant/dbus/dbus_new.c          |    6 ++++++
 wpa_supplicant/dbus/dbus_new_handlers.c |   26 ++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers.h |    3 +++
 3 files changed, 35 insertions(+), 0 deletions(-)
Jouni Malinen - Aug. 9, 2012, 10:56 a.m.
On Wed, Aug 08, 2012 at 09:28:21PM -0700, Paul Stewart wrote:
> Create a DBus command to reassociate, similar to the
> ctrl-interface "reassociate" command.

Thanks, applied with a call to wpa_supplicant_reinit_autoscan() added.


PS.

As with any other change to the D-Bus interface, an update to
src/doc/dbus.doxygen would be appreciated.

Patch

diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index e2b1e49..4eeb93a 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -2384,6 +2384,12 @@  static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
 		  END_ARGS
 	  }
 	},
+	{ "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE,
+	  (WPADBusMethodHandler) &wpas_dbus_handler_reassociate,
+	  {
+		  END_ARGS
+	  }
+	},
 	{ "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
 	  (WPADBusMethodHandler) &wpas_dbus_handler_remove_network,
 	  {
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index c28ba30..b93c370 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -1405,6 +1405,32 @@  err:
 
 
 /**
+ * wpas_dbus_handler_reassociate - Reassociate to current AP
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: NotConnected DBus error message if not connected
+ * or NULL otherwise.
+ *
+ * Handler function for "Reassociate" method call of network interface.
+ */
+DBusMessage * wpas_dbus_handler_reassociate(DBusMessage *message,
+					    struct wpa_supplicant *wpa_s)
+{
+	if (wpa_s->current_ssid != NULL) {
+		wpa_s->normal_scans = 0;
+		wpa_s->disconnected = 0;
+		wpa_s->reassociate = 1;
+		wpa_supplicant_req_scan(wpa_s, 0, 0);
+
+		return NULL;
+	}
+
+	return dbus_message_new_error(message, WPAS_DBUS_ERROR_NOT_CONNECTED,
+				      "This interface is not connected");
+}
+
+
+/**
  * wpas_dbus_handler_remove_network - Remove a configured network
  * @message: Pointer to incoming dbus message
  * @wpa_s: wpa_supplicant structure for a network interface
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index cff218f..178a76b 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -94,6 +94,9 @@  dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
 DBusMessage * wpas_dbus_handler_add_network(DBusMessage *message,
 					    struct wpa_supplicant *wpa_s);
 
+DBusMessage * wpas_dbus_handler_reassociate(DBusMessage *message,
+					    struct wpa_supplicant *wpa_s);
+
 DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message,
 					       struct wpa_supplicant *wpa_s);