dbus: Add MeshPeerDisconnected signal

This is similar to the control interface event MESH-PEER-DISCONNECTED.

Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
This commit is contained in:
Saurav Babu 2017-07-18 12:37:55 +05:30 committed by Jouni Malinen
parent 9b0701fbf5
commit a9de99b1c5
6 changed files with 73 additions and 0 deletions

View file

@ -2288,6 +2288,15 @@ Interface for performing mesh operations.
<dd>A dictionary containing information of the connected mesh peer.</dd> <dd>A dictionary containing information of the connected mesh peer.</dd>
</dl> </dl>
</li> </li>
<li>
<h3>MeshPeerDisconnected ( a{sv} : args )</h3>
<p></p>
<h4>Arguments</h4>
<dl>
<dt>a{sv} : args</dt>
<dd>A dictionary containing information of the disconnected mesh peer.</dd>
</dl>
</li>
</ul> </ul>
*/ */

View file

@ -894,6 +894,40 @@ void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
dbus_message_unref(msg); dbus_message_unref(msg);
} }
void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *peer_addr, int reason)
{
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,
"MeshPeerDisconnected");
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_append_int32(&dict_iter, "DisconnectReason",
reason) ||
!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 */ #endif /* CONFIG_MESH */
@ -3745,6 +3779,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
END_ARGS END_ARGS
} }
}, },
{ "MeshPeerDisconnected", WPAS_DBUS_NEW_IFACE_MESH,
{
{ "args", "a{sv}", ARG_OUT },
END_ARGS
}
},
#endif /* CONFIG_MESH */ #endif /* CONFIG_MESH */
{ NULL, NULL, { END_ARGS } } { NULL, NULL, { END_ARGS } }
}; };

View file

@ -248,6 +248,8 @@ void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
int reason); int reason);
void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
const u8 *peer_addr); const u8 *peer_addr);
void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *peer_addr, int reason);
#else /* CONFIG_CTRL_IFACE_DBUS_NEW */ #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
@ -582,6 +584,12 @@ void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
{ {
} }
static inline
void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *peer_addr, int reason)
{
}
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
#endif /* CTRL_IFACE_DBUS_H_NEW */ #endif /* CTRL_IFACE_DBUS_H_NEW */

View file

@ -1013,6 +1013,10 @@ static void mesh_mpm_fsm(struct wpa_supplicant *wpa_s, struct sta_info *sta,
wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR, wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
MAC2STR(sta->addr)); MAC2STR(sta->addr));
/* Send D-Bus event */
wpas_notify_mesh_peer_disconnected(wpa_s, sta->addr,
reason);
hapd->num_plinks--; hapd->num_plinks--;
mesh_mpm_send_plink_action(wpa_s, sta, mesh_mpm_send_plink_action(wpa_s, sta,

View file

@ -885,4 +885,14 @@ void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr); wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
} }
void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *peer_addr, int reason_code)
{
if (wpa_s->p2p_mgmt)
return;
wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
}
#endif /* CONFIG_MESH */ #endif /* CONFIG_MESH */

View file

@ -148,5 +148,7 @@ void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
int reason_code); int reason_code);
void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s, void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
const u8 *peer_addr); const u8 *peer_addr);
void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *peer_addr, int reason_code);
#endif /* NOTIFY_H */ #endif /* NOTIFY_H */