]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Notify P2P2 bootstrapping request and completed events
authorShivani Baranwal <quic_shivbara@quicinc.com>
Thu, 30 May 2024 19:53:51 +0000 (01:23 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 31 Oct 2024 19:55:19 +0000 (21:55 +0200)
Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
doc/dbus.doxygen
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new.h
wpa_supplicant/notify.c
wpa_supplicant/notify.h
wpa_supplicant/p2p_supplicant.c

index 37a65365fb079664c9765c9d23bc1dd4cd34c293..b91a81cd1badeb7fe1d91efea7be74b8623fdad6 100644 (file)
@@ -2339,7 +2339,14 @@ Interface for performing P2P (Wi-Fi Peer-to-Peer) P2P Device operations.
       <dd>Reason for failure or empty string if not known.</dd>
     </dl>
   </li>
-</ul>
+
+  <li>
+    <h3>BootstrappingRequest ( o : path, q : bootstrap_method )</h3>
+  </li>
+
+  <li>
+    <h3>BootstrappingCompleted ( o : path, i : status )</h3>
+  </li>
 
 \section dbus_bss fi.w1.wpa_supplicant1.BSS
 
index 4332636b32e5102b864e3ec11d6d45bb3fb74d26..ff7e003cbe93f934ecf097c7f4666ab7bc85255b 100644 (file)
@@ -2332,6 +2332,113 @@ void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
 }
 
 
+/**
+ * wpas_dbus_signal_p2p_bootstrap_req - Signals BootstrappingRequest event
+ * @wpa_s: %wpa_supplicant network interface data
+ * @src: Source address of the message triggering this notification
+ * @bootstrap_method: Peer's bootstrap method
+ *
+ * Sends a signal to notify that a peer P2P Device is requesting bootstrapping
+ * negotiation with us.
+ */
+void wpas_dbus_signal_p2p_bootstrap_req(struct wpa_supplicant *wpa_s,
+                                       const u8 *src, u16 bootstrap_method)
+{
+       DBusMessage *msg;
+       DBusMessageIter iter;
+       struct wpas_dbus_priv *iface;
+       char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+
+       iface = wpa_s->global->dbus;
+
+       /* Do nothing if the control interface is not turned on */
+       if (!iface)
+               return;
+
+       if (wpa_s->p2p_mgmt)
+               wpa_s = wpa_s->parent;
+       if (!wpa_s->dbus_new_path)
+               return;
+
+       os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+                   "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
+                   wpa_s->dbus_new_path, MAC2STR(src));
+       path = peer_obj_path;
+
+       msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+                                     WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+                                     "BootstrappingRequest");
+       if (!msg)
+               return;
+
+       dbus_message_iter_init_append(msg, &iter);
+
+       if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+                                           &path) ||
+           !dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
+                                           &bootstrap_method))
+               wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+       else
+               dbus_connection_send(iface->con, msg, NULL);
+
+       dbus_message_unref(msg);
+}
+
+
+/**
+ * wpas_dbus_signal_p2p_bootstrap_completed - Signals BootstrappingCompleted event
+ * event
+ * @wpa_s: %wpa_supplicant network interface data
+ * @src: Source address of the peer with which bootstrapping is done
+ * @status: Status of Bootstrapping handshake
+ *
+ * Sends a signal to notify that a peer P2P Device is requesting bootstrapping
+ * negotiation with us.
+ */
+void wpas_dbus_signal_p2p_bootstrap_completed(struct wpa_supplicant *wpa_s,
+                                             const u8 *src, int status)
+{
+       DBusMessage *msg;
+       DBusMessageIter iter;
+       struct wpas_dbus_priv *iface;
+       char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+
+       iface = wpa_s->global->dbus;
+
+       /* Do nothing if the control interface is not turned on */
+       if (!iface)
+               return;
+
+       if (wpa_s->p2p_mgmt)
+               wpa_s = wpa_s->parent;
+       if (!wpa_s->dbus_new_path)
+               return;
+
+       os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+                   "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
+                   wpa_s->dbus_new_path, MAC2STR(src));
+       path = peer_obj_path;
+
+       msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+                                     WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+                                     "BootstrappingCompleted");
+       if (!msg)
+               return;
+
+       dbus_message_iter_init_append(msg, &iter);
+
+       if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+                                           &path) ||
+           !dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32,
+                                           &status))
+               wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+       else
+               dbus_connection_send(iface->con, msg, NULL);
+
+       dbus_message_unref(msg);
+}
+
+
 #endif /* CONFIG_P2P */
 
 
@@ -4319,6 +4426,20 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
                  END_ARGS
          }
        },
+       { "BootstrappingRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+         {
+                 { "path", "o", ARG_OUT },
+                 { "bootstrap_method", "q", ARG_OUT },
+                 END_ARGS
+         }
+       },
+       { "BootstrappingCompleted", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+         {
+                 { "path", "o", ARG_OUT },
+                 { "status", "i", ARG_OUT },
+                 END_ARGS
+         }
+       },
 #endif /* CONFIG_P2P */
 #ifdef CONFIG_AP
        { "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
index 4daf71be526f346b8815c01c889c59e98a57a98d..f9ff636420acd893266d9c5b0c37abf53cd2f197 100644 (file)
@@ -266,6 +266,10 @@ void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
                                              const u8 *sa, const u8 *dev_addr,
                                              const u8 *bssid, int id,
                                              int op_freq);
+void wpas_dbus_signal_p2p_bootstrap_req(struct wpa_supplicant *wpa_s,
+                                       const u8 *src, u16 bootstrap_method);
+void wpas_dbus_signal_p2p_bootstrap_completed(struct wpa_supplicant *wpa_s,
+                                             const u8 *src, int status);
 void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
                                         struct wpa_ssid *ssid);
 void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
@@ -639,6 +643,18 @@ void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
 {
 }
 
+static inline
+void wpas_dbus_signal_p2p_bootstrap_req(struct wpa_supplicant *wpa_s,
+                                       const u8 *src, u16 bootstrap_method)
+{
+}
+
+static inline
+void wpas_dbus_signal_p2p_bootstrap_completed(struct wpa_supplicant *wpa_s,
+                                             const u8 *src, int status)
+{
+}
+
 static inline
 void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
                                         struct wpa_ssid *ssid)
index 24812ffbbdb65eca49daf3ae66b9e6e1370f8e73..b894a4916d092fdea5fcb5ef436ec1cdba9bf30d 100644 (file)
@@ -799,6 +799,18 @@ void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
                                                 id, op_freq);
 }
 
+void wpas_notify_p2p_bootstrap_req(struct wpa_supplicant *wpa_s,
+                                  const u8 *src, u16 bootstrap_method)
+{
+       wpas_dbus_signal_p2p_bootstrap_req(wpa_s, src, bootstrap_method);
+}
+
+void wpas_notify_p2p_bootstrap_completed(struct wpa_supplicant *wpa_s,
+                                        const u8 *src, int status)
+{
+       wpas_dbus_signal_p2p_bootstrap_completed(wpa_s, src, status);
+}
+
 #endif /* CONFIG_P2P */
 
 
index 56fe7c58e2fd90d114e0fb4af20082be711d058a..7f6c345d2db42a6516e9ed0fec3638c68a4f327e 100644 (file)
@@ -156,6 +156,10 @@ 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_p2p_bootstrap_req(struct wpa_supplicant *wpa_s,
+                                  const u8 *src, u16 bootstrap_method);
+void wpas_notify_p2p_bootstrap_completed(struct wpa_supplicant *wpa_s,
+                                        const u8 *src, int status);
 void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
                                    struct wpa_ssid *ssid);
 void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
index 60223926d4d3cc69e85020f9fca82c409174fd9a..3a337d1ac10f0e1254d314f4beb19bd9f3d1d58a 100644 (file)
@@ -5191,6 +5191,8 @@ static void wpas_bootstrap_req_rx(void *ctx, const u8 *addr,
 
        wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_BOOTSTRAP_REQUEST MACSTR
                       " bootstrap_method=%u", MAC2STR(addr), bootstrap_method);
+
+       wpas_notify_p2p_bootstrap_req(wpa_s, addr, bootstrap_method);
 }
 
 
@@ -5199,6 +5201,8 @@ static void wpas_bootstrap_completed(void *ctx, const u8 *addr,
 {
        struct wpa_supplicant *wpa_s = ctx;
 
+       wpas_notify_p2p_bootstrap_completed(wpa_s, addr, status);
+
        if (status) {
                wpa_msg_global(wpa_s, MSG_INFO,
                               P2P_EVENT_BOOTSTRAP_FAILURE MACSTR " status=%d",