[PATCH] D-Bus: Add support of "InvitationReceived" Signal

Maneesh Jain maneesh.jain at samsung.com
Thu Jun 18 00:16:34 EDT 2015


This is equivalent to "P2P_EVENT_INVITATION_RECEIVED" signald on control interface
It can be used to sent the Inviatation Received signal to application
written using D-Bus.

Signed-off-by: Maneesh Jain <maneesh.jain at samsung.com>
---
 wpa_supplicant/dbus/dbus_new.c  |   73 +++++++++++++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new.h  |    3 ++
 wpa_supplicant/notify.c         |    9 +++++
 wpa_supplicant/notify.h         |    3 ++
 wpa_supplicant/p2p_supplicant.c |    4 +++
 5 files changed, 92 insertions(+)
 mode change 100644 => 100755 wpa_supplicant/dbus/dbus_new.c
 mode change 100644 => 100755 wpa_supplicant/dbus/dbus_new.h
 mode change 100644 => 100755 wpa_supplicant/notify.c
 mode change 100644 => 100755 wpa_supplicant/notify.h
 mode change 100644 => 100755 wpa_supplicant/p2p_supplicant.c

diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
old mode 100644
new mode 100755
index 0696666..c71fe4f
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -1845,6 +1845,73 @@ void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
 
 	dbus_message_unref(msg);
 }
+/**
+ *
+ * Method to emit Invitation Received signal
+ * @wpa_s: %wpa_supplicant network interface data
+ * @sa: Source address of the Invitation Request
+ * @dev_add: GO Device Addres
+ * @bssid: P2P Group BSSID or %NULL if not received
+ * @id: persistent group id or %0 if not persistent group
+ * @op_freq : Operational frequency for the group
+ */
+
+void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+					    const u8 *sa,const u8 *dev_add,const u8 *bssid,
+					    int id, int op_freq)
+{
+	DBusMessage *msg;
+	DBusMessageIter iter, dict_iter;
+	struct wpas_dbus_priv *iface;
+
+	wpa_printf(MSG_DEBUG, "%s", __func__);
+
+	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_P2PDEVICE,
+				      "InvitationReceived");
+
+	if (msg == NULL)
+		return;
+
+	dbus_message_iter_init_append(msg, &iter);
+	if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
+		goto nomem;
+
+	if (sa) {
+		if (!wpa_dbus_dict_append_byte_array(&dict_iter, "sa",
+						     (const char *) sa, ETH_ALEN))
+			goto nomem;
+	}
+	if (dev_add) {
+		if (!wpa_dbus_dict_append_byte_array(&dict_iter, "go_dev_add",
+						     (const char *) dev_add, ETH_ALEN))
+			goto nomem;
+	}
+	if (bssid) {
+		if (!wpa_dbus_dict_append_byte_array(&dict_iter, "bssid",
+						     (const char *) bssid, ETH_ALEN))
+			goto nomem;
+	}
+	if (!wpa_dbus_dict_append_int32(&dict_iter, "persistent_id", id))
+		goto nomem;
+
+	if (!wpa_dbus_dict_append_int32(&dict_iter, "op_freq", op_freq))
+		goto nomem;
+
+	if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
+		goto nomem;
+
+	dbus_connection_send(iface->con, msg, NULL);
+
+nomem:
+	dbus_message_unref(msg);
+}
+
 
 #endif /* CONFIG_P2P */
 
@@ -3218,6 +3285,12 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
 		  END_ARGS
 	  }
 	},
+	{ "InvitationReceived", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+		  {
+			{ "properties", "a{sv}", ARG_OUT },
+			END_ARGS
+		  }
+	},
 #endif /* CONFIG_P2P */
 #ifdef CONFIG_AP
 	{ "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
old mode 100644
new mode 100755
index 7503348..5ff6584
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -231,6 +231,9 @@ void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s,
 				     const u8 *sta);
 void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
 				       const u8 *sta);
+void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+					    const u8 *sa,const u8 *dev_add,const u8 *bssid,
+					    int id, int op_freq);
 
 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
 
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
old mode 100644
new mode 100755
index 822db74..391275f
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -652,6 +652,15 @@ void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
 	wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
 }
 
+void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+				       const u8 *sa, const u8 *go_dev_add,
+				       const u8 *bssid,int id,int op_freq)
+{
+	/* Notify a P2P Invitiation Request */
+	wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_add,bssid,
+							id,op_freq);
+}
+
 #endif /* CONFIG_P2P */
 
 
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
old mode 100644
new mode 100755
index 1aeec47..e60c070
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -135,5 +135,8 @@ void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
 					   struct wpa_ssid *ssid);
 void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
 				      struct wpa_ssid *ssid);
+void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
+				       const u8 *sa, const u8 *go_dev_add,
+				       const u8 *bssid,int id,int op_freq);
 
 #endif /* NOTIFY_H */
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
old mode 100644
new mode 100755
index 730d793..5343b76
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -2828,6 +2828,8 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid,
 				       " unknown-network",
 				       MAC2STR(sa), MAC2STR(go_dev_addr));
 		}
+		wpas_notify_p2p_invitation_received(wpa_s,sa,go_dev_addr,bssid,
+							0,op_freq);
 		return;
 	}
 
@@ -2840,6 +2842,8 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid,
 			       "sa=" MACSTR " persistent=%d",
 			       MAC2STR(sa), s->id);
 	}
+		wpas_notify_p2p_invitation_received(wpa_s,sa,go_dev_addr,bssid,
+						s->id,op_freq);
 }
 
 
-- 
1.7.9.5



More information about the HostAP mailing list