From 7b642dc80b965de3cb5c559febc340116aac54cb Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Wed, 13 May 2015 17:33:48 +0530 Subject: [PATCH] P2P: Add D-Bus FindStopped to notify P2P-FIND-STOPPED event Add D-Bus notification mechanism of P2P-FIND-STOPPED event on fi.w1.wpa_supplicant1.Interface.P2PDevice interface. Signed-off-by: Nishant Chaprana --- doc/dbus.doxygen | 4 ++++ wpa_supplicant/dbus/dbus_new.c | 34 +++++++++++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new.h | 6 ++++++ wpa_supplicant/notify.c | 7 +++++++ wpa_supplicant/notify.h | 1 + wpa_supplicant/p2p_supplicant.c | 1 + 6 files changed, 53 insertions(+) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 329e5d03b..d623116d1 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -1286,6 +1286,10 @@ Interface for performing P2P (Wi-Fi Peer-to-Peer) P2P Device operations.

DeviceLost ( o : path )

+
  • +

    FindStopped ( )

    +
  • +
  • ProvisionDiscoveryRequestDisplayPin ( o : peer_object, s : pin )

  • diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 89a562c1b..840d1050a 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -3039,6 +3039,11 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { END_ARGS } }, + { "FindStopped", WPAS_DBUS_NEW_IFACE_P2PDEVICE, + { + END_ARGS + } + }, { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE, { { "peer_object", "o", ARG_OUT }, @@ -3530,6 +3535,35 @@ int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s, } +/** + * wpas_dbus_signal_p2p_find_stopped - Send P2P Find stopped signal + * @wpa_s: %wpa_supplicant network interface data + * + * Notify listeners about P2P Find stopped + */ +void wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (iface == NULL || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_P2PDEVICE, + "FindStopped"); + if (msg == NULL) + return; + + dbus_connection_send(iface->con, msg, NULL); + + dbus_message_unref(msg); +} + + void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s, const u8 *dev_addr) { diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index d162d2b66..31db8d41d 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -168,6 +168,7 @@ void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global); void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global); int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr); +void wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s); void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s, const u8 *dev_addr); int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s, @@ -459,6 +460,11 @@ wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s, { } +static inline void +wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s) +{ +} + static inline void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s, const u8 *dev_addr) diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 184a95c8b..4df9d9039 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -520,6 +520,13 @@ void wpas_notify_resume(struct wpa_global *global) #ifdef CONFIG_P2P +void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s) +{ + /* Notify P2P find has stopped */ + wpas_dbus_signal_p2p_find_stopped(wpa_s); +} + + void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, const u8 *dev_addr, int new_device) { diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index b268332ff..1025ca8b0 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -84,6 +84,7 @@ void wpas_notify_resume(struct wpa_global *global); void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s, const u8 *mac_addr, int authorized, const u8 *p2p_dev_addr); +void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s); void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, const u8 *dev_addr, int new_device); void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 7a8a46a3b..2ccc5ea3e 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -2248,6 +2248,7 @@ static void wpas_find_stopped(void *ctx) { struct wpa_supplicant *wpa_s = ctx; wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_FIND_STOPPED); + wpas_notify_p2p_find_stopped(wpa_s); }