Add D-Bus interface for ROAM command, imitating the existing wpa_cli command. Chromium OS has been carrying a form of this patch for a very long time. I've cleaned it up a bit and documented it. Signed-off-by: Brian Norris <briannorris@xxxxxxxxxxxx> --- doc/dbus.doxygen | 16 ++++++++ wpa_supplicant/dbus/dbus_new.c | 8 ++++ wpa_supplicant/dbus/dbus_new_handlers.c | 53 +++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_handlers.h | 3 ++ 4 files changed, 80 insertions(+) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index a2e5de26227b..dbc3e2b2af7d 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -322,6 +322,22 @@ fi.w1.wpa_supplicant1.CreateInterface. </dl> </li> + <li> + <h3>Roam ( s : addr ) --> nothing</h3> + <p>Initiate a roam to another BSS within the current ESS.</p> + <h4>Possible errors</h4> + <dl> + <dt>fi.w1.wpa_supplicant1.InvalidArgs</dt> + <dd>Missing address argument.</dd> + <dt>fi.w1.wpa_supplicant1.InvalidArgs</dt> + <dd>Invalid hardware address format.</dd> + <dt>fi.w1.wpa_supplicant1.NotConnected</dt> + <dd>Interface is not connected to any network.</dd> + <dt>fi.w1.wpa_supplicant1.UnknownError</dt> + <dd>Scan processing was not included in the build.</dd> + </dl> + </li> + <li> <h3>AddBlob ( s : name, ay : data ) --> nothing</h3> <p>Adds a blob to the interface.</p> diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 793a881efb0e..f50ec41ba17d 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -3212,6 +3212,14 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = { END_ARGS } }, + { "Roam", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) &wpas_dbus_handler_roam, + { + { "addr", "s", ARG_IN }, + END_ARGS + } + }, + #ifndef CONFIG_NO_CONFIG_BLOBS { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE, (WPADBusMethodHandler) wpas_dbus_handler_add_blob, diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index d1f9607c602d..0431ba35c54f 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -1889,6 +1889,59 @@ out: } +/** + * wpas_dbus_handler_roam - Send ROAM command to wpa_supplicant + * @message: Pointer to incoming dbus message + * @wpa_s: wpa_supplicant structure for a network interface + * Returns: NULL on success or dbus error on failure + * + * Handler function for "Roam" method call of network interface. + */ +DBusMessage * wpas_dbus_handler_roam(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ +#ifdef CONFIG_NO_SCAN_PROCESSING + return wpas_dbus_error_unknown_error( + message, "scan processing not included"); +#else /* CONFIG_NO_SCAN_PROCESSING */ + u8 bssid[ETH_ALEN]; + struct wpa_bss *bss; + struct wpa_ssid *ssid = wpa_s->current_ssid; + char *addr; + + if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &addr, + DBUS_TYPE_INVALID)) { + return wpas_dbus_error_invalid_args(message, NULL); + } + + if (hwaddr_aton(addr, bssid)) { + return wpas_dbus_error_invalid_args( + message, "Invalid hardware address format"); + } + + wpa_printf(MSG_DEBUG, "dbus: ROAM " MACSTR, MAC2STR(bssid)); + + if (!ssid) { + return dbus_message_new_error( + message, WPAS_DBUS_ERROR_NOT_CONNECTED, + "This interface is not connected"); + } + + bss = wpa_bss_get(wpa_s, bssid, ssid->ssid, ssid->ssid_len); + if (!bss) { + wpa_printf(MSG_DEBUG, "dbus: ROAM: Target BSS not found"); + return wpas_dbus_error_invalid_args( + message, "Target BSS not found"); + } + + wpa_s->reassociate = 1; + wpa_supplicant_connect(wpa_s, bss, ssid); + + return NULL; +#endif /* CONFIG_NO_SCAN_PROCESSING */ +} + + /** * wpas_dbus_handler_network_reply - Reply to a NetworkRequest signal * @message: Pointer to incoming dbus message diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index afa26efed675..d5f21fc1483d 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -117,6 +117,9 @@ DBusMessage * wpas_dbus_handler_select_network(DBusMessage *message, DBusMessage * wpas_dbus_handler_network_reply(DBusMessage *message, struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_handler_roam(DBusMessage *message, + struct wpa_supplicant *wpa_s); + DBusMessage * wpas_dbus_handler_add_blob(DBusMessage *message, struct wpa_supplicant *wpa_s); -- 2.27.0.278.ge193c7cf3a9-goog _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap