>From 911ac6e1a65532fd9bc52799c8e650db25597f1c Mon Sep 17 00:00:00 2001 From: Avichal Agarwal <avichal.a@xxxxxxxxxxx> Date: Tue, 12 Jul 2016 18:23:27 +0530 Subject: [PATCH 3/3] dbus-signal for EVENT_IBSS_PEER_LOST This patch will send a dbsud signal IbssPeerLost when the joined peer will be lost. this signal will send the address of peer of type array of bytes Signed-off-by: Avichal Agarwal <avichal.a@xxxxxxxxxxx> --- wpa_supplicant/dbus/dbus_new.c | 36 +++++++++++++++++++++++++++++++++++- wpa_supplicant/dbus/dbus_new.h | 2 ++ wpa_supplicant/events.c | 1 + wpa_supplicant/notify.c | 5 +++++ wpa_supplicant/notify.h | 1 + 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 1300ad5..88be2ed 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -1954,6 +1954,34 @@ void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s, #endif /* CONFIG_P2P */ +void wpas_dbus_signal_ibss_peer_lost(struct wpa_supplicant *wpa_s, + const u8 *peer) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + DBusMessageIter iter,array_iter; + 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_INTERFACE, + "IbssPeerLost"); + if (msg == NULL) + return; + dbus_message_iter_init_append(msg, &iter); + if(!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, + &array_iter) || + !dbus_message_iter_append_fixed_array(&array_iter, DBUS_TYPE_BYTE, + &peer, 6) || + !dbus_message_iter_close_container(&iter, &array_iter)) + goto nomem; + dbus_connection_send(iface->con, msg, NULL); +nomem: + dbus_message_unref(msg); +} + #ifdef CONFIG_IBSS_RSN void wpas_dbus_signal_ibss_rsn_connected(struct wpa_supplicant *wpa_s, const u8 *peer) @@ -1971,7 +1999,7 @@ void wpas_dbus_signal_ibss_rsn_connected(struct wpa_supplicant *wpa_s, if (msg == NULL) return; dbus_message_iter_init_append(msg, &iter); - if(!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + if(!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &array_iter) || !dbus_message_iter_append_fixed_array(&array_iter, DBUS_TYPE_BYTE, @@ -3585,6 +3613,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { } }, #endif + { "IbssPeerLost",WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "peer","ay",ARG_OUT }, + END_ARGS + } + }, { NULL, NULL, { END_ARGS } } }; diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index 38f521d..6a8747f 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -241,6 +241,8 @@ void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_ibss_rsn_connected(struct wpa_supplicant *wpa_s, const u8 *peer); #endif /*CONFIG_IBSS_RSN*/ +void wpas_dbus_signal_ibss_peer_lost(struct wpa_supplicant *wpa_s, + const u8 *peer); #else /* CONFIG_CTRL_IFACE_DBUS_NEW */ static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index dffba32..ef4f30b 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -3992,6 +3992,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, #ifdef CONFIG_IBSS_RSN ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer); #endif /* CONFIG_IBSS_RSN */ + wpas_notify_ibss_peer_lost(wpa_s,data->ibss_peer_lost.peer); break; case EVENT_DRIVER_GTK_REKEY: if (os_memcmp(data->driver_gtk_rekey.bssid, diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 5cce236..3a6f0a8 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -155,6 +155,11 @@ void wpas_notify_ibssrsn_connected(struct wpa_supplicant *wpa_s,const u8 *peer) } #endif /*CONFIG_IBSS_RSN*/ +void wpas_notify_ibss_peer_lost(struct wpa_supplicant *wpa_s,const u8 *peer) +{ + wpas_dbus_signal_ibss_peer_lost(wpa_s,peer); +} + void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) { if (wpa_s->p2p_mgmt) diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index d90c4f3..7bb8834 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -141,6 +141,7 @@ void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s, void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s, const u8 *sa, const u8 *go_dev_addr, const u8 *bssid, int id, int op_freq); +void wpas_notify_ibss_peer_lost(struct wpa_supplicant *wpa_s,const u8 *peer); #ifdef CONFIG_IBSS_RSN void wpas_notify_ibssrsn_connected(struct wpa_supplicant *wpa_s, const u8 *peer); #endif /*CONFIG_IBSS_RSN*/ -- 1.7.9.5 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap