diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index ed908acd6..bfdb5a7e3 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -2279,6 +2279,15 @@ Interface for performing mesh operations.
A dictionary containing information of the removed mesh group.
+
  • +

    MeshPeerConnected ( a{sv} : args )

    +

    +

    Arguments

    +
    +
    a{sv} : args
    +
    A dictionary containing information of the connected mesh peer.
    +
    +
  • */ diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 41d12e31d..6c494c132 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -862,6 +862,38 @@ void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s, dbus_message_unref(msg); } + +void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s, + const u8 *peer_addr) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + DBusMessageIter iter, dict_iter; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (!iface || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_MESH, + "MeshPeerConnected"); + if (!msg) + return; + + dbus_message_iter_init_append(msg, &iter); + if (!wpa_dbus_dict_open_write(&iter, &dict_iter) || + !wpa_dbus_dict_append_byte_array(&dict_iter, "PeerAddress", + (const char *) peer_addr, + ETH_ALEN) || + !wpa_dbus_dict_close_write(&iter, &dict_iter)) + wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); + else + dbus_connection_send(iface->con, msg, NULL); + dbus_message_unref(msg); +} + #endif /* CONFIG_MESH */ @@ -3707,6 +3739,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { END_ARGS } }, + { "MeshPeerConnected", WPAS_DBUS_NEW_IFACE_MESH, + { + { "args", "a{sv}", ARG_OUT }, + END_ARGS + } + }, #endif /* CONFIG_MESH */ { NULL, NULL, { END_ARGS } } }; diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index dcc2767cd..979630617 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -246,6 +246,8 @@ void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s, const u8 *meshid, u8 meshid_len, int reason); +void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s, + const u8 *peer_addr); #else /* CONFIG_CTRL_IFACE_DBUS_NEW */ @@ -574,6 +576,12 @@ void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s, { } +static inline +void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s, + const u8 *peer_addr) +{ +} + #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ #endif /* CTRL_IFACE_DBUS_H_NEW */ diff --git a/wpa_supplicant/mesh_mpm.c b/wpa_supplicant/mesh_mpm.c index f15204496..2047fb8ec 100644 --- a/wpa_supplicant/mesh_mpm.c +++ b/wpa_supplicant/mesh_mpm.c @@ -20,6 +20,7 @@ #include "driver_i.h" #include "mesh_mpm.h" #include "mesh_rsn.h" +#include "notify.h" struct mesh_peer_mgmt_ie { const u8 *proto_id; /* Mesh Peering Protocol Identifier (2 octets) */ @@ -857,6 +858,9 @@ static void mesh_mpm_plink_estab(struct wpa_supplicant *wpa_s, /* Send ctrl event */ wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR, MAC2STR(sta->addr)); + + /* Send D-Bus event */ + wpas_notify_mesh_peer_connected(wpa_s, sta->addr); } diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index e1f575939..5ed414e53 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -875,4 +875,14 @@ void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s, reason_code); } + +void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s, + const u8 *peer_addr) +{ + if (wpa_s->p2p_mgmt) + return; + + wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr); +} + #endif /* CONFIG_MESH */ diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index d79c7a569..6c953b617 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -146,5 +146,7 @@ void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s, void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s, const u8 *meshid, u8 meshid_len, int reason_code); +void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s, + const u8 *peer_addr); #endif /* NOTIFY_H */