From 2a95fac94421a9351d994e10768373c05c4be482 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 20 Aug 2015 16:28:33 +0530 Subject: [PATCH] P2P: Add D-Bus signal GroupFormationFailure This is similar to the control interface event P2P-GROUP-FORMATION-FAILURE. Signed-off-by: Nishant Chaprana --- doc/dbus.doxygen | 10 ++++++++ wpa_supplicant/dbus/dbus_new.c | 41 +++++++++++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new.h | 8 +++++++ wpa_supplicant/notify.c | 8 +++++++ wpa_supplicant/notify.h | 2 ++ wpa_supplicant/p2p_supplicant.c | 4 ++++ 6 files changed, 73 insertions(+) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 3a08ad788..d46e50016 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -1533,6 +1533,16 @@ Interface for performing P2P (Wi-Fi Peer-to-Peer) P2P Device operations. + +
  • +

    GroupFormationFailure ( s : reason )

    +

    +

    Arguments

    +
    +
    s : reason
    +
    Reason for failure or empty string if not known.
    +
    +
  • \section dbus_bss fi.w1.wpa_supplicant1.BSS diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 1959ea798..aaeabb5b2 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -1857,6 +1857,41 @@ void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s, dbus_message_unref(msg); } + +/** + * wpas_dbus_signal_p2p_group_formation_failure - Signals GroupFormationFailure event + * @wpa_s: %wpa_supplicant network interface data + * @reason: indicates the reason code for group formation failure + * + * Sends Event dbus signal and string reason code when available. + */ +void wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, + const char *reason) +{ + DBusMessage *msg; + struct wpas_dbus_priv *iface; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (iface == NULL) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_P2PDEVICE, + "GroupFormationFailure"); + if (msg == NULL) + return; + + if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &reason, + DBUS_TYPE_INVALID)) + dbus_connection_send(iface->con, msg, NULL); + else + wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); + + dbus_message_unref(msg); +} + #endif /* CONFIG_P2P */ @@ -3172,6 +3207,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { END_ARGS } }, + { "GroupFormationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE, + { + { "reason", "s", ARG_OUT }, + END_ARGS + } + }, { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE, { { "properties", "a{sv}", ARG_OUT }, diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index 7503348cc..fe6396682 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -191,6 +191,8 @@ void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int client, int network_id); +void wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, + const char *reason); void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, @@ -399,6 +401,12 @@ wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s, { } +static inline void +wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, + const char *reason) +{ +} + static inline void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index aa8c21486..4ece411b5 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -657,6 +657,14 @@ void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, } +void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, + const char *reason) +{ + /* Notify a group formation failed */ + wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason); +} + + void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s, struct wps_event_fail *fail) { diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index 1aeec47b0..6860671c9 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -114,6 +114,8 @@ void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s, void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, int network_id, int client); +void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, + const char *reason); void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index d1e7bae1e..b87624a7f 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -1286,6 +1286,7 @@ static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s, if (!success) { wpa_msg_global(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_FORMATION_FAILURE); + wpas_notify_p2p_group_formation_failure(wpa_s, ""); if (already_deleted) return; wpas_p2p_group_delete(wpa_s, @@ -4412,6 +4413,7 @@ static void wpas_p2p_check_join_scan_limit(struct wpa_supplicant *wpa_s) } wpa_msg_global(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_FORMATION_FAILURE); + wpas_notify_p2p_group_formation_failure(wpa_s, ""); } } @@ -4637,6 +4639,8 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s, wpa_msg_global(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_FORMATION_FAILURE "reason=FREQ_CONFLICT"); + wpas_notify_p2p_group_formation_failure( + wpa_s, "FREQ_CONFLICT"); return; }