From b649c0afd4c5adf04fe5986b8bb2d70746ce7fac Mon Sep 17 00:00:00 2001 From: MAYANK HAARIT Date: Fri, 12 Jun 2015 11:27:19 +0000 Subject: [PATCH] dbus: Add Reconnect command to D-Bus Interface This has same behavior as the ctrl_iface RECONNECT command. Signed-off-by: Mayank Haarit Signed-off-by: Purushottam Kushwaha --- doc/dbus.doxygen | 10 ++++++++++ wpa_supplicant/dbus/dbus_new.c | 6 ++++++ wpa_supplicant/dbus/dbus_new_handlers.c | 24 ++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_handlers.h | 3 +++ 4 files changed, 43 insertions(+) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index be7f51a5b..7355dbb2a 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -306,6 +306,16 @@ fi.w1.wpa_supplicant1.CreateInterface. +
  • +

    Reconnect ( ) --> nothing

    +

    Attempt reconnection and connect if in disconnected state.

    +

    Possible errors

    +
    +
    fi.w1.wpa_supplicant1.InterfaceDisabled
    +
    The interface is disabled.
    +
    +
  • +
  • AddBlob ( s : name, ay : data ) --> nothing

    Adds a blob to the interface.

    diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index fb674d479..06966665e 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -2552,6 +2552,12 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = { END_ARGS } }, + { "Reconnect", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_reconnect, + { + 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 97db9a873..2a7e2cf9b 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -1600,6 +1600,30 @@ DBusMessage * wpas_dbus_handler_reattach(DBusMessage *message, } +/** + * wpas_dbus_handler_reconnect - Reconnect if disconnected + * @message: Pointer to incoming dbus message + * @wpa_s: wpa_supplicant structure for a network interface + * Returns: InterfaceDisabled DBus error message if disabled + * or NULL otherwise. + * + * Handler function for "Reconnect" method call of network interface. + */ +DBusMessage * wpas_dbus_handler_reconnect(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) { + return dbus_message_new_error(message, + WPAS_DBUS_ERROR_IFACE_DISABLED, + "This interface is disabled"); + } + + if (wpa_s->disconnected) + wpas_request_connection(wpa_s); + return NULL; +} + + /** * wpas_dbus_handler_remove_network - Remove a configured network * @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 9afdc0597..50f72ec50 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -107,6 +107,9 @@ DBusMessage * wpas_dbus_handler_reassociate(DBusMessage *message, DBusMessage * wpas_dbus_handler_reattach(DBusMessage *message, struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_handler_reconnect(DBusMessage *message, + struct wpa_supplicant *wpa_s); + DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message, struct wpa_supplicant *wpa_s);