From: Nishant Chaprana Date: Mon, 20 Jun 2016 04:48:21 +0000 (+0530) Subject: D-Bus: Add DeviceFoundProperties signal for discovered peers X-Git-Tag: hostap_2_6~322 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=mech_eap.git;a=commitdiff_plain;h=82b9ec3125d628fdf1773b1d1184fbc1579dc3c8 D-Bus: Add DeviceFoundProperties signal for discovered peers This signal sends the peer properties to applications for discovered peers. The signature of this event is "oa{sv}". This event is needed because the current DeviceFound signal provides only the peer object path. If there are many peers in range there will be many DeviceFound signals and for each DeviceFound signal, applications would need to use GetAll to fetch peer properties. Doing this many times would create extra load over application as well as over wpa_supplicant, so it is better to send peer properties in the event so that applications can extract found peer information without extra steps. The existing DeviceFound signal is left as-is to avoid changing its signature. The issue is not applicable to the control interface because the P2P-DEVICE-FOUND event includes peer info in it, but over D-Bus interface DeviceFound provides only the peer object. Signed-off-by: Nishant Chaprana --- diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 28ee371..e6c70f9 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -1632,6 +1632,20 @@ Interface for performing P2P (Wi-Fi Peer-to-Peer) P2P Device operations.
  • +

    DeviceFoundProperties ( o : path, a{sv} : properties )

    +

    A new peer device has been found.

    +

    Arguments

    +
    +
    o : path
    +
    A D-Bus path to an object representing the found peer device.
    +
    +
    +
    a{sv} : properties
    +
    A dictionary containing properties of the found peer device.
    +
    +
  • + +
  • DeviceLost ( o : path )

  • diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 0263b2c..6d73bbc 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -3352,6 +3352,13 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { END_ARGS } }, + { "DeviceFoundProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE, + { + { "path", "o", ARG_OUT }, + { "properties", "a{sv}", ARG_OUT }, + END_ARGS + } + }, { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE, { { "path", "o", ARG_OUT }, @@ -3800,12 +3807,13 @@ static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = { * In case of peer objects, it would be emitted by either * the "interface object" or by "peer objects" * @sig_name: signal name - DeviceFound + * @properties: Whether to add a second argument with object properties * - * Notify listeners about event related with newly found p2p peer device + * Notify listeners about event related with p2p peer device */ static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr, const char *interface, - const char *sig_name) + const char *sig_name, int properties) { struct wpas_dbus_priv *iface; DBusMessage *msg; @@ -3833,7 +3841,10 @@ static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s, dbus_message_iter_init_append(msg, &iter); path = peer_obj_path; if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, - &path)) + &path) || + (properties && !wpa_dbus_get_object_properties( + iface, peer_obj_path, WPAS_DBUS_NEW_IFACE_P2P_PEER, + &iter))) wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); else dbus_connection_send(iface->con, msg, NULL); @@ -3854,7 +3865,11 @@ void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s, { wpas_dbus_signal_peer(wpa_s, dev_addr, WPAS_DBUS_NEW_IFACE_P2PDEVICE, - "DeviceFound"); + "DeviceFound", FALSE); + + wpas_dbus_signal_peer(wpa_s, dev_addr, + WPAS_DBUS_NEW_IFACE_P2PDEVICE, + "DeviceFoundProperties", TRUE); } /** @@ -3869,7 +3884,7 @@ void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s, { wpas_dbus_signal_peer(wpa_s, dev_addr, WPAS_DBUS_NEW_IFACE_P2PDEVICE, - "DeviceLost"); + "DeviceLost", FALSE); } /**