blob: d5a34c58450f3c94dd76a221d9728a0f94f092b9 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
4 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#include "utils/includes.h"
10
11#include "utils/common.h"
12#include "common/wpa_ctrl.h"
Sunil Ravic0f5d412024-09-11 22:12:49 +000013#include "common/nan_de.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070014#include "config.h"
15#include "wpa_supplicant_i.h"
16#include "wps_supplicant.h"
17#include "dbus/dbus_common.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070018#include "dbus/dbus_new.h"
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080019#include "rsn_supp/wpa.h"
Sunil Ravi77d572f2023-01-17 23:58:31 +000020#include "rsn_supp/pmksa_cache.h"
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080021#include "fst/fst.h"
Hai Shalom81f62d82019-07-22 12:10:00 -070022#include "crypto/tls.h"
Hai Shalomc1a21442022-02-04 13:43:00 -080023#include "bss.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070024#include "driver_i.h"
25#include "scan.h"
26#include "p2p_supplicant.h"
27#include "sme.h"
28#include "notify.h"
Gabriel Biren3c401c52024-10-10 20:11:18 +000029#include "aidl/vendor/aidl.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070030
Gabriel Biren8c60fc22024-10-23 23:33:06 +000031#ifdef MAINLINE_SUPPLICANT
32#include "aidl/mainline/service.h"
33#endif
34
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070035int wpas_notify_supplicant_initialized(struct wpa_global *global)
36{
Hai Shalom021b0b52019-04-10 11:17:58 -070037#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070038 if (global->params.dbus_ctrl_interface) {
39 global->dbus = wpas_dbus_init(global);
40 if (global->dbus == NULL)
41 return -1;
42 }
Hai Shalom021b0b52019-04-10 11:17:58 -070043#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070044
Gabriel Biren7a30e7f2023-06-02 20:11:28 +000045#ifdef CONFIG_AIDL
46 // Initialize AIDL here if daemonize is disabled.
47 // Otherwise initialize it later.
48 if (!global->params.daemonize) {
49 global->aidl = wpas_aidl_init(global);
50 if (!global->aidl)
51 return -1;
52 }
53#endif /* CONFIG_AIDL */
54
Gabriel Biren8c60fc22024-10-23 23:33:06 +000055#ifdef MAINLINE_SUPPLICANT
56 global->aidl = mainline_aidl_init(global);
57 if (!global->aidl)
58 return -1;
59#endif /* MAINLINE_SUPPLICANT */
60
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070061 return 0;
62}
63
64
65void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
66{
Hai Shalom021b0b52019-04-10 11:17:58 -070067#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070068 if (global->dbus)
69 wpas_dbus_deinit(global->dbus);
Hai Shalom021b0b52019-04-10 11:17:58 -070070#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
Dmitry Shmidte4663042016-04-04 10:07:49 -070071
Gabriel Biren57ededa2021-09-03 16:08:50 +000072#ifdef CONFIG_AIDL
73 if (global->aidl)
74 wpas_aidl_deinit(global->aidl);
75#endif /* CONFIG_AIDL */
Gabriel Biren8c60fc22024-10-23 23:33:06 +000076
77#ifdef MAINLINE_SUPPLICANT
78 if (global->aidl)
79 mainline_aidl_deinit(global->aidl);
80#endif /* MAINLINE_SUPPLICANT */
81
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070082}
83
84
85int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
86{
Hai Shalomc4809952019-04-30 14:45:55 -070087 if (!wpa_s->p2p_mgmt) {
88 if (wpas_dbus_register_interface(wpa_s))
89 return -1;
90 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070091
Kiran Kumar Lokerea9f98eb2023-03-17 13:01:12 -070092#ifdef CONFIG_AIDL
Gabriel Biren7a30e7f2023-06-02 20:11:28 +000093 /*
94 * AIDL initialization may not be complete here if daemonize is enabled.
Kiran Kumar Lokerea9f98eb2023-03-17 13:01:12 -070095 * Initialization is done after daemonizing in order to avoid
96 * issues with the file descriptor.
97 */
Gabriel Biren7a30e7f2023-06-02 20:11:28 +000098 if (!wpa_s->global->aidl)
Kiran Kumar Lokerea9f98eb2023-03-17 13:01:12 -070099 return 0;
Gabriel Biren7a30e7f2023-06-02 20:11:28 +0000100 /* AIDL interface wants to keep track of the P2P mgmt iface. */
Gabriel Biren57ededa2021-09-03 16:08:50 +0000101 if (wpas_aidl_register_interface(wpa_s))
Roshan Pius54e763a2016-07-06 15:41:53 -0700102 return -1;
Kiran Kumar Lokerea9f98eb2023-03-17 13:01:12 -0700103#endif
Roshan Pius54e763a2016-07-06 15:41:53 -0700104
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700105 return 0;
106}
107
108
109void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
110{
Hai Shalomc4809952019-04-30 14:45:55 -0700111 if (!wpa_s->p2p_mgmt) {
112 /* unregister interface in new DBus ctrl iface */
113 wpas_dbus_unregister_interface(wpa_s);
114 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700115
Gabriel Biren7a30e7f2023-06-02 20:11:28 +0000116 /* AIDL interface wants to keep track of the P2P mgmt iface. */
Gabriel Biren57ededa2021-09-03 16:08:50 +0000117 wpas_aidl_unregister_interface(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700118}
119
120
121void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
122 enum wpa_states new_state,
123 enum wpa_states old_state)
124{
Sunil Ravi79e6c4f2025-01-04 00:47:06 +0000125 struct wpa_ssid *ssid = wpa_s->current_ssid;
126
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800127 if (wpa_s->p2p_mgmt)
128 return;
129
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700130 /* notify the new DBus API */
131 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
132
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800133#ifdef CONFIG_FST
134 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
135 if (new_state == WPA_COMPLETED)
136 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
137 else if (old_state >= WPA_ASSOCIATED &&
138 new_state < WPA_ASSOCIATED)
139 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
140 }
141#endif /* CONFIG_FST */
142
Sunil Ravi79e6c4f2025-01-04 00:47:06 +0000143 if (new_state == WPA_COMPLETED) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700144 wpas_p2p_notif_connected(wpa_s);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +0000145 if (ssid)
146 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
147 ssid->bssid_set ? ssid->bssid : NULL);
148 } else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700149 wpas_p2p_notif_disconnected(wpa_s);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +0000150 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700151
152 sme_state_changed(wpa_s);
153
154#ifdef ANDROID
155 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700156 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700157 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700158 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700159 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700160 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
161 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800162 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700163#endif /* ANDROID */
Roshan Piuse8d0d162016-08-01 13:09:26 -0700164
Gabriel Biren57ededa2021-09-03 16:08:50 +0000165 wpas_aidl_notify_state_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700166}
167
168
Dmitry Shmidt04949592012-07-19 12:16:46 -0700169void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
170{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800171 if (wpa_s->p2p_mgmt)
172 return;
173
Dmitry Shmidt04949592012-07-19 12:16:46 -0700174 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
Roshan Pius0974e962016-12-12 17:05:51 -0800175
Gabriel Biren57ededa2021-09-03 16:08:50 +0000176 wpas_aidl_notify_disconnect_reason(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700177}
178
179
Veerendranath Jakkambc2fa492023-05-25 01:26:50 +0530180void wpas_notify_mlo_info_change_reason(struct wpa_supplicant *wpa_s,
181 enum mlo_info_change_reason reason)
182{
183 if (wpa_s->p2p_mgmt)
184 return;
185
186 wpas_aidl_notify_mlo_info_change_reason(wpa_s, reason);
187}
188
189
Hai Shalom74f70d42019-02-11 14:42:39 -0800190void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
191{
192 if (wpa_s->p2p_mgmt)
193 return;
194
195 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
196}
197
198
Sunil Ravi972b2042020-08-14 10:50:48 -0700199void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s,
Sunil Ravie06118e2021-01-03 08:39:46 -0800200 const u8 *bssid, u8 timed_out,
201 const u8 *assoc_resp_ie, size_t assoc_resp_ie_len)
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800202{
203 if (wpa_s->p2p_mgmt)
204 return;
205
206 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
Roshan Pius0974e962016-12-12 17:05:51 -0800207
Gabriel Biren57ededa2021-09-03 16:08:50 +0000208 wpas_aidl_notify_assoc_reject(wpa_s, bssid, timed_out, assoc_resp_ie, assoc_resp_ie_len);
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800209}
210
Roshan Pius38e96762017-01-23 14:52:00 -0800211void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
212 if (wpa_s->p2p_mgmt)
213 return;
214
Gabriel Biren57ededa2021-09-03 16:08:50 +0000215 wpas_aidl_notify_auth_timeout(wpa_s);
Roshan Pius38e96762017-01-23 14:52:00 -0800216}
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800217
Hai Shalom74f70d42019-02-11 14:42:39 -0800218void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
219{
220 if (wpa_s->p2p_mgmt)
221 return;
222
223 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
224}
225
226
227void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
228{
229 if (wpa_s->p2p_mgmt)
230 return;
231
232 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
233}
234
235
Sunil Ravic0f5d412024-09-11 22:12:49 +0000236void wpas_notify_scan_in_progress_6ghz(struct wpa_supplicant *wpa_s)
237{
238 if (wpa_s->p2p_mgmt)
239 return;
240
241 wpas_dbus_signal_prop_changed(wpa_s,
242 WPAS_DBUS_PROP_SCAN_IN_PROGRESS_6GHZ);
243}
244
245
Hai Shalom74f70d42019-02-11 14:42:39 -0800246void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
247{
248 if (wpa_s->p2p_mgmt)
249 return;
250
251 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
252}
253
254
255void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
256{
257 if (wpa_s->p2p_mgmt)
258 return;
259
260 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
Sunil Ravi4018d712019-12-06 18:01:21 -0800261
262#ifdef CONFIG_WNM
Gabriel Biren57ededa2021-09-03 16:08:50 +0000263 wpas_aidl_notify_bss_tm_status(wpa_s);
Sunil Ravi4018d712019-12-06 18:01:21 -0800264#endif
Hai Shalom74f70d42019-02-11 14:42:39 -0800265}
266
267
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700268void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
269{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800270 if (wpa_s->p2p_mgmt)
271 return;
272
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700273 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
274}
275
276
277void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
278{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800279 if (wpa_s->p2p_mgmt)
280 return;
281
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700282 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
283}
284
285
286void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
287{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800288 if (wpa_s->p2p_mgmt)
289 return;
290
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700291 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700292
Gabriel Biren57ededa2021-09-03 16:08:50 +0000293 wpas_aidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700294}
295
296
Sunil Ravi77d572f2023-01-17 23:58:31 +0000297void wpas_notify_mac_address_changed(struct wpa_supplicant *wpa_s)
298{
299 if (wpa_s->p2p_mgmt)
300 return;
301
302 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_MAC_ADDRESS);
303}
304
305
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700306void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
307{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800308 if (wpa_s->p2p_mgmt)
309 return;
310
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700311 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
312}
313
314
315void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
316 struct wpa_ssid *ssid)
317{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800318 if (wpa_s->p2p_mgmt)
319 return;
320
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700321 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
322}
323
324
325void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
326 struct wpa_ssid *ssid)
327{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800328 if (wpa_s->p2p_mgmt)
329 return;
330
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700331 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
332}
333
334
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800335void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
336 struct wpa_ssid *ssid,
337 enum wpa_ctrl_req_type rtype,
338 const char *default_txt)
339{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800340 if (wpa_s->p2p_mgmt)
341 return;
342
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800343 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700344
Gabriel Biren57ededa2021-09-03 16:08:50 +0000345 wpas_aidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800346}
347
348
Steven Liu850c2e02022-11-28 17:26:39 +0000349void wpas_notify_permanent_id_req_denied(struct wpa_supplicant *wpa_s)
350{
351 wpas_aidl_notify_permanent_id_req_denied(wpa_s);
352}
353
354
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700355void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
356{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800357 if (wpa_s->p2p_mgmt)
358 return;
359
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700360 /* notify the new DBus API */
361 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
362}
363
364
365void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
366{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800367 if (wpa_s->p2p_mgmt)
368 return;
369
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700370 wpas_dbus_signal_scan_done(wpa_s, success);
371}
372
373
374void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
375{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800376 if (wpa_s->p2p_mgmt)
377 return;
378
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700379 wpas_wps_notify_scan_results(wpa_s);
380}
381
382
383void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
384 const struct wps_credential *cred)
385{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800386 if (wpa_s->p2p_mgmt)
387 return;
388
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700389#ifdef CONFIG_WPS
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700390 /* notify the new DBus API */
391 wpas_dbus_signal_wps_cred(wpa_s, cred);
392#endif /* CONFIG_WPS */
393}
394
395
396void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
397 struct wps_event_m2d *m2d)
398{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800399 if (wpa_s->p2p_mgmt)
400 return;
401
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700402#ifdef CONFIG_WPS
403 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
404#endif /* CONFIG_WPS */
405}
406
407
408void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
409 struct wps_event_fail *fail)
410{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800411 if (wpa_s->p2p_mgmt)
412 return;
413
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700414#ifdef CONFIG_WPS
415 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800416
Gabriel Biren57ededa2021-09-03 16:08:50 +0000417 wpas_aidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
Roshan Pius14932752017-01-11 09:48:58 -0800418 fail->config_error,
419 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700420#endif /* CONFIG_WPS */
421}
422
423
424void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
425{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800426 if (wpa_s->p2p_mgmt)
427 return;
428
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700429#ifdef CONFIG_WPS
430 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800431
Gabriel Biren57ededa2021-09-03 16:08:50 +0000432 wpas_aidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700433#endif /* CONFIG_WPS */
434}
435
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700436void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
437{
438 if (wpa_s->p2p_mgmt)
439 return;
440
441#ifdef CONFIG_WPS
442 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800443
Gabriel Biren57ededa2021-09-03 16:08:50 +0000444 wpas_aidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700445#endif /* CONFIG_WPS */
446}
447
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700448
449void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
450 struct wpa_ssid *ssid)
451{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800452 if (wpa_s->p2p_mgmt)
453 return;
454
Jouni Malinen75ecf522011-06-27 15:19:46 -0700455 /*
456 * Networks objects created during any P2P activities should not be
457 * exposed out. They might/will confuse certain non-P2P aware
458 * applications since these network objects won't behave like
459 * regular ones.
460 */
Roshan Piusd3854452016-07-07 16:46:41 -0700461 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700462 wpas_dbus_register_network(wpa_s, ssid);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000463 wpas_aidl_register_network(wpa_s, ssid);
Hai Shalomc1a21442022-02-04 13:43:00 -0800464 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d",
465 ssid->id);
Roshan Piusd3854452016-07-07 16:46:41 -0700466 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700467}
468
469
470void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
471 struct wpa_ssid *ssid)
472{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700473#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700474 wpas_dbus_register_persistent_group(wpa_s, ssid);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000475 wpas_aidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700476#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700477}
478
479
480void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
481 struct wpa_ssid *ssid)
482{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700483#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700484 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000485 wpas_aidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700486#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700487}
488
489
490void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
491 struct wpa_ssid *ssid)
492{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800493 if (wpa_s->next_ssid == ssid)
494 wpa_s->next_ssid = NULL;
Sunil Ravia04bd252022-05-02 22:54:18 -0700495 if (wpa_s->last_ssid == ssid)
496 wpa_s->last_ssid = NULL;
497 if (wpa_s->current_ssid == ssid)
498 wpa_s->current_ssid = NULL;
Sunil Ravi2a14cf12023-11-21 00:54:38 +0000499 if (wpa_s->ml_connect_probe_ssid == ssid) {
500 wpa_s->ml_connect_probe_ssid = NULL;
501 wpa_s->ml_connect_probe_bss = NULL;
502 }
Sunil Ravi7f769292024-07-23 22:21:32 +0000503 if (wpa_s->connect_without_scan == ssid)
504 wpa_s->connect_without_scan = NULL;
Sunil Ravi89eba102022-09-13 21:04:37 -0700505#if defined(CONFIG_SME) && defined(CONFIG_SAE)
506 if (wpa_s->sme.ext_auth_wpa_ssid == ssid)
507 wpa_s->sme.ext_auth_wpa_ssid = NULL;
508#endif /* CONFIG_SME && CONFIG_SAE */
Vinayak Yadawad4222acc2023-12-15 17:39:27 +0530509 if (wpa_s->wpa) {
510 if ((wpa_key_mgmt_sae(ssid->key_mgmt) &&
511 (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SAE_OFFLOAD_STA)) ||
512 ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
513 (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA))) {
514 /* For cases when PMK is generated at the driver */
515 struct wpa_pmkid_params params;
516
517 os_memset(&params, 0, sizeof(params));
518 params.ssid = ssid->ssid;
519 params.ssid_len = ssid->ssid_len;
520 wpa_drv_remove_pmkid(wpa_s, &params);
521 }
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800522 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Vinayak Yadawad4222acc2023-12-15 17:39:27 +0530523 }
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700524 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700525 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700526 wpas_dbus_unregister_network(wpa_s, ssid->id);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000527 wpas_aidl_unregister_network(wpa_s, ssid);
Hai Shalomc1a21442022-02-04 13:43:00 -0800528 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d",
529 ssid->id);
Roshan Piusd3854452016-07-07 16:46:41 -0700530 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800531 if (network_is_persistent_group(ssid))
532 wpas_notify_persistent_group_removed(wpa_s, ssid);
533
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800534 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700535}
536
537
538void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
539 u8 bssid[], unsigned int id)
540{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800541 if (wpa_s->p2p_mgmt)
542 return;
543
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700544 wpas_dbus_register_bss(wpa_s, bssid, id);
545 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
546 id, MAC2STR(bssid));
547}
548
549
550void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
551 u8 bssid[], unsigned int id)
552{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800553 if (wpa_s->p2p_mgmt)
554 return;
555
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700556 wpas_dbus_unregister_bss(wpa_s, bssid, id);
557 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
558 id, MAC2STR(bssid));
559}
560
561
562void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
563 unsigned int id)
564{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800565 if (wpa_s->p2p_mgmt)
566 return;
567
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700568 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
569}
570
571
572void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
573 unsigned int id)
574{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800575 if (wpa_s->p2p_mgmt)
576 return;
577
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700578 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
579 id);
580}
581
582
583void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
584 unsigned int id)
585{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800586 if (wpa_s->p2p_mgmt)
587 return;
588
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700589 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
590 id);
591}
592
593
594void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
595 unsigned int id)
596{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800597 if (wpa_s->p2p_mgmt)
598 return;
599
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700600 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
601}
602
603
604void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
605 unsigned int id)
606{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800607 if (wpa_s->p2p_mgmt)
608 return;
609
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700610 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
611}
612
613
614void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
615 unsigned int id)
616{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800617 if (wpa_s->p2p_mgmt)
618 return;
619
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700620 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
621}
622
623
624void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
625 unsigned int id)
626{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800627 if (wpa_s->p2p_mgmt)
628 return;
629
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800630#ifdef CONFIG_WPS
631 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
632#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700633}
634
635
636void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
637 unsigned int id)
638{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800639 if (wpa_s->p2p_mgmt)
640 return;
641
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700642 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
643}
644
645
646void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
647 unsigned int id)
648{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800649 if (wpa_s->p2p_mgmt)
650 return;
651
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700652 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
653}
654
655
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700656void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
657{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800658 if (wpa_s->p2p_mgmt)
659 return;
660
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700661 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
662}
663
664
Sunil Ravi99c035e2024-07-12 01:42:03 +0000665void wpas_notify_bss_anqp_changed(struct wpa_supplicant *wpa_s, unsigned int id)
666{
667 if (wpa_s->p2p_mgmt)
668 return;
669
670 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_ANQP, id);
671}
672
673
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700674void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
675{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800676 if (wpa_s->p2p_mgmt)
677 return;
678
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700679 wpas_dbus_signal_blob_added(wpa_s, name);
680}
681
682
683void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
684{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800685 if (wpa_s->p2p_mgmt)
686 return;
687
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700688 wpas_dbus_signal_blob_removed(wpa_s, name);
689}
690
691
692void wpas_notify_debug_level_changed(struct wpa_global *global)
693{
694 wpas_dbus_signal_debug_level_changed(global);
695}
696
697
698void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
699{
700 wpas_dbus_signal_debug_timestamp_changed(global);
701}
702
703
704void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
705{
706 wpas_dbus_signal_debug_show_keys_changed(global);
707}
708
709
710void wpas_notify_suspend(struct wpa_global *global)
711{
712 struct wpa_supplicant *wpa_s;
713
714 os_get_time(&global->suspend_time);
715 wpa_printf(MSG_DEBUG, "System suspend notification");
716 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
717 wpa_drv_suspend(wpa_s);
718}
719
720
721void wpas_notify_resume(struct wpa_global *global)
722{
723 struct os_time now;
724 int slept;
725 struct wpa_supplicant *wpa_s;
726
727 if (global->suspend_time.sec == 0)
728 slept = -1;
729 else {
730 os_get_time(&now);
731 slept = now.sec - global->suspend_time.sec;
732 }
733 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
734 slept);
735
736 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
737 wpa_drv_resume(wpa_s);
738 if (wpa_s->wpa_state == WPA_DISCONNECTED)
739 wpa_supplicant_req_scan(wpa_s, 0, 100000);
740 }
741}
742
743
744#ifdef CONFIG_P2P
745
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700746void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
747{
748 /* Notify P2P find has stopped */
749 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800750
Gabriel Biren57ededa2021-09-03 16:08:50 +0000751 wpas_aidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700752}
753
754
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700755void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800756 const u8 *addr, const struct p2p_peer_info *info,
757 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
Jimmy Chen0133fc12021-03-04 13:56:11 +0800758 const u8* peer_wfd_r2_device_info, u8 peer_wfd_r2_device_info_len,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800759 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700760{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700761 if (new_device) {
762 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800763 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700764 }
765
766 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800767 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
768
Gabriel Biren57ededa2021-09-03 16:08:50 +0000769 wpas_aidl_notify_p2p_device_found(wpa_s, addr, info,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800770 peer_wfd_device_info,
Jimmy Chen57e19f52021-03-04 14:19:52 +0800771 peer_wfd_device_info_len,
772 peer_wfd_r2_device_info,
773 peer_wfd_r2_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700774}
775
776
777void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
778 const u8 *dev_addr)
779{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700780 wpas_dbus_unregister_peer(wpa_s, dev_addr);
781
782 /* Create signal on interface object*/
783 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800784
Gabriel Biren57ededa2021-09-03 16:08:50 +0000785 wpas_aidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700786}
787
788
789void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
790 const struct wpa_ssid *ssid,
791 const char *role)
792{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700793 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700794
795 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800796
Gabriel Biren57ededa2021-09-03 16:08:50 +0000797 wpas_aidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700798}
799
800
801void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700802 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700803{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700804 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800805
Gabriel Biren57ededa2021-09-03 16:08:50 +0000806 wpas_aidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700807}
808
809
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800810void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
811 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700812{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800813 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800814
Gabriel Biren57ededa2021-09-03 16:08:50 +0000815 wpas_aidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700816}
817
818
819void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
820 int status, const u8 *bssid)
821{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700822 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800823
Gabriel Biren57ededa2021-09-03 16:08:50 +0000824 wpas_aidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700825}
826
827
828void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
829 int freq, const u8 *sa, u8 dialog_token,
830 u16 update_indic, const u8 *tlvs,
831 size_t tlvs_len)
832{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700833 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
834 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700835}
836
837
838void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
839 const u8 *sa, u16 update_indic,
840 const u8 *tlvs, size_t tlvs_len)
841{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700842 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
843 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800844
Gabriel Biren57ededa2021-09-03 16:08:50 +0000845 wpas_aidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800846 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700847}
848
849
850/**
851 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
852 * @dev_addr: Who sent the request or responded to our request.
853 * @request: Will be 1 if request, 0 for response.
854 * @status: Valid only in case of response (0 in case of success)
855 * @config_methods: WPS config methods
856 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
Sunil Ravi8bae4252023-11-16 03:05:19 +0000857 * @group_ifname: Group interface name of the group owner in case the provision
858 * discovery request is received with P2P Group ID attribute.
859 * i.e., valid only when the peer device is joining an
860 * operating P2P group.
Jouni Malinen75ecf522011-06-27 15:19:46 -0700861 *
862 * This can be used to notify:
863 * - Requests or responses
864 * - Various config methods
865 * - Failure condition in case of response
866 */
867void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
868 const u8 *dev_addr, int request,
869 enum p2p_prov_disc_status status,
870 u16 config_methods,
Sunil Ravi8bae4252023-11-16 03:05:19 +0000871 unsigned int generated_pin,
872 const char *group_ifname)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700873{
874 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
875 status, config_methods,
876 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800877
Gabriel Biren57ededa2021-09-03 16:08:50 +0000878 wpas_aidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800879 status, config_methods,
Sunil Ravi8bae4252023-11-16 03:05:19 +0000880 generated_pin, group_ifname);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800881
Jouni Malinen75ecf522011-06-27 15:19:46 -0700882}
883
884
885void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700886 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800887 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700888{
889 /* Notify a group has been started */
890 wpas_dbus_register_p2p_group(wpa_s, ssid);
891
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800892 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800893
Sunil Ravi68c25c22023-02-04 06:17:03 +0000894 wpas_aidl_notify_p2p_group_started(wpa_s, ssid, persistent, client, ip);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700895}
896
897
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800898void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
899 const char *reason)
900{
901 /* Notify a group formation failed */
902 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800903
Gabriel Biren57ededa2021-09-03 16:08:50 +0000904 wpas_aidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800905}
906
907
Jouni Malinen75ecf522011-06-27 15:19:46 -0700908void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
909 struct wps_event_fail *fail)
910{
911 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700912}
913
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800914
915void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
916 const u8 *sa, const u8 *go_dev_addr,
917 const u8 *bssid, int id, int op_freq)
918{
919 /* Notify a P2P Invitation Request */
920 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
921 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800922
Gabriel Biren57ededa2021-09-03 16:08:50 +0000923 wpas_aidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800924 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800925}
926
Sunil Ravi79e6c4f2025-01-04 00:47:06 +0000927void wpas_notify_p2p_bootstrap_req(struct wpa_supplicant *wpa_s,
928 const u8 *src, u16 bootstrap_method)
929{
930 wpas_dbus_signal_p2p_bootstrap_req(wpa_s, src, bootstrap_method);
931}
932
933void wpas_notify_p2p_bootstrap_completed(struct wpa_supplicant *wpa_s,
934 const u8 *src, int status)
935{
936 wpas_dbus_signal_p2p_bootstrap_completed(wpa_s, src, status);
937}
938
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700939#endif /* CONFIG_P2P */
940
941
942static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800943 const u8 *sta,
Sunil Ravid8128a22023-11-06 23:53:58 +0000944 const u8 *p2p_dev_addr, const u8 *ip)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700945{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700946#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800947 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
948
Jouni Malinen75ecf522011-06-27 15:19:46 -0700949 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700950 * Create 'peer-joined' signal on group object -- will also
951 * check P2P itself.
952 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800953 if (p2p_dev_addr)
954 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700955#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700956
Hai Shalom74f70d42019-02-11 14:42:39 -0800957 /* Register the station */
958 wpas_dbus_register_sta(wpa_s, sta);
959
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700960 /* Notify listeners a new station has been authorized */
961 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800962
Sunil Ravid8128a22023-11-06 23:53:58 +0000963 wpas_aidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr, ip);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700964}
965
966
967static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700968 const u8 *sta,
969 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700970{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700971#ifdef CONFIG_P2P
972 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700973 * Create 'peer-disconnected' signal on group object if this
974 * is a P2P group.
975 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800976 if (p2p_dev_addr)
977 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700978#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700979
980 /* Notify listeners a station has been deauthorized */
981 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800982
Sunil Ravid8128a22023-11-06 23:53:58 +0000983 wpas_aidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Hai Shalom74f70d42019-02-11 14:42:39 -0800984 /* Unregister the station */
985 wpas_dbus_unregister_sta(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700986}
987
988
989void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800990 const u8 *mac_addr, int authorized,
Sunil Ravid8128a22023-11-06 23:53:58 +0000991 const u8 *p2p_dev_addr, const u8 *ip)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700992{
993 if (authorized)
Sunil Ravi99c035e2024-07-12 01:42:03 +0000994 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr,
995 ip);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700996 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700997 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700998}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700999
1000
Hai Shalom81f62d82019-07-22 12:10:00 -07001001void wpas_notify_certification(struct wpa_supplicant *wpa_s,
1002 struct tls_cert_data *cert,
1003 const char *cert_hash)
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001004{
Hai Shalom81f62d82019-07-22 12:10:00 -07001005 int i;
Hai Shalom878cf7b2019-07-15 14:55:18 -07001006
Hai Shalom81f62d82019-07-22 12:10:00 -07001007 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
Hai Shalomc3565922019-10-28 11:58:20 -07001008 "depth=%d subject='%s'%s%s%s%s",
Hai Shalom81f62d82019-07-22 12:10:00 -07001009 cert->depth, cert->subject, cert_hash ? " hash=" : "",
1010 cert_hash ? cert_hash : "",
Hai Shalomc3565922019-10-28 11:58:20 -07001011 cert->tod == 2 ? " tod=2" : "",
1012 cert->tod == 1 ? " tod=1" : "");
Hai Shalom81f62d82019-07-22 12:10:00 -07001013
1014 if (cert->cert) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001015 char *cert_hex;
Hai Shalom81f62d82019-07-22 12:10:00 -07001016 size_t len = wpabuf_len(cert->cert) * 2 + 1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001017 cert_hex = os_malloc(len);
1018 if (cert_hex) {
Hai Shalom81f62d82019-07-22 12:10:00 -07001019 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
1020 wpabuf_len(cert->cert));
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001021 wpa_msg_ctrl(wpa_s, MSG_INFO,
1022 WPA_EVENT_EAP_PEER_CERT
1023 "depth=%d subject='%s' cert=%s",
Hai Shalom81f62d82019-07-22 12:10:00 -07001024 cert->depth, cert->subject, cert_hex);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001025 os_free(cert_hex);
1026 }
1027 }
1028
Hai Shalom81f62d82019-07-22 12:10:00 -07001029 for (i = 0; i < cert->num_altsubject; i++)
1030 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
1031 "depth=%d %s", cert->depth, cert->altsubject[i]);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -08001032
Jimmy Chen429daf92021-10-20 13:27:23 +08001033 wpas_aidl_notify_ceritification(wpa_s, cert->depth, cert->subject,
1034 cert->altsubject, cert->num_altsubject,
1035 cert_hash, cert->cert);
1036
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001037 /* notify the new DBus API */
Hai Shalom81f62d82019-07-22 12:10:00 -07001038 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
1039 cert->altsubject, cert->num_altsubject,
1040 cert_hash, cert->cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001041}
Dmitry Shmidt04949592012-07-19 12:16:46 -07001042
1043
1044void wpas_notify_preq(struct wpa_supplicant *wpa_s,
1045 const u8 *addr, const u8 *dst, const u8 *bssid,
1046 const u8 *ie, size_t ie_len, u32 ssi_signal)
1047{
1048#ifdef CONFIG_AP
1049 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
1050#endif /* CONFIG_AP */
1051}
1052
1053
1054void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
1055 const char *parameter)
1056{
1057 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -07001058 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
1059 "status='%s' parameter='%s'",
1060 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -07001061}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001062
Roshan Pius3a1667e2018-07-03 15:17:14 -07001063
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -07001064void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
1065{
1066 wpa_dbg(wpa_s, MSG_ERROR,
1067 "EAP Error code = %d", error_code);
Gabriel Biren57ededa2021-09-03 16:08:50 +00001068 wpas_aidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -07001069}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001070
Roshan Pius3a1667e2018-07-03 15:17:14 -07001071
Sunil Ravi036cec52023-03-29 11:35:17 -07001072void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
1073{
1074 wpas_dbus_signal_psk_mismatch(wpa_s);
1075}
1076
1077
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001078void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
1079 struct wpa_ssid *ssid)
1080{
1081 if (wpa_s->current_ssid != ssid)
1082 return;
1083
1084 wpa_dbg(wpa_s, MSG_DEBUG,
1085 "Network bssid config changed for the current network - within-ESS roaming %s",
1086 ssid->bssid_set ? "disabled" : "enabled");
1087
1088 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
1089 ssid->bssid_set ? ssid->bssid : NULL);
1090}
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001091
1092
1093void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
1094 struct wpa_ssid *ssid)
1095{
1096#ifdef CONFIG_P2P
1097 if (ssid->disabled == 2) {
1098 /* Changed from normal network profile to persistent group */
1099 ssid->disabled = 0;
1100 wpas_dbus_unregister_network(wpa_s, ssid->id);
1101 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -07001102 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001103 wpas_dbus_register_persistent_group(wpa_s, ssid);
1104 } else {
1105 /* Changed from persistent group to normal network profile */
1106 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -07001107 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001108 wpas_dbus_register_network(wpa_s, ssid);
1109 }
1110#endif /* CONFIG_P2P */
1111}
Roshan Pius04a9d742016-12-12 12:40:46 -08001112
1113void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1114 const char *result,
1115 const struct wpa_bss_anqp *anqp)
1116{
Sunil Ravi99c035e2024-07-12 01:42:03 +00001117 wpa_msg(wpa_s, MSG_INFO, ANQP_QUERY_DONE "addr=" MACSTR " result=%s",
1118 MAC2STR(bssid), result);
Roshan Pius04a9d742016-12-12 12:40:46 -08001119#ifdef CONFIG_INTERWORKING
1120 if (!wpa_s || !bssid || !anqp)
1121 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001122
Gabriel Biren57ededa2021-09-03 16:08:50 +00001123 wpas_aidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Sunil Ravi99c035e2024-07-12 01:42:03 +00001124 wpas_dbus_signal_anqp_query_done(wpa_s, bssid, result);
Roshan Pius04a9d742016-12-12 12:40:46 -08001125#endif /* CONFIG_INTERWORKING */
1126}
1127
1128void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1129 const char* file_name, const u8* image,
1130 u32 image_length)
1131{
1132#ifdef CONFIG_HS20
1133 if (!wpa_s || !bssid || !file_name || !image)
1134 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001135
Gabriel Biren57ededa2021-09-03 16:08:50 +00001136 wpas_aidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
Roshan Pius9322a342016-12-12 14:45:02 -08001137 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -08001138#endif /* CONFIG_HS20 */
1139}
1140
1141void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
1142 const char* url,
1143 u8 osu_method)
1144{
1145#ifdef CONFIG_HS20
1146 if (!wpa_s || !url)
1147 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001148
Gabriel Biren57ededa2021-09-03 16:08:50 +00001149 wpas_aidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -08001150#endif /* CONFIG_HS20 */
1151}
1152
1153void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1154 u8 code, u16 reauth_delay,
1155 const char *url)
1156{
1157#ifdef CONFIG_HS20
Hai Shalomb3a7c702020-10-20 12:22:53 -07001158 if (!wpa_s)
Roshan Pius04a9d742016-12-12 12:40:46 -08001159 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001160
Gabriel Biren57ededa2021-09-03 16:08:50 +00001161 wpas_aidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
Hai Shalom04a4ca62020-10-28 19:04:47 -07001162 url);
Roshan Pius04a9d742016-12-12 12:40:46 -08001163#endif /* CONFIG_HS20 */
1164}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001165
1166
1167#ifdef CONFIG_MESH
1168
1169void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1170 struct wpa_ssid *ssid)
1171{
1172 if (wpa_s->p2p_mgmt)
1173 return;
1174
1175 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1176}
1177
1178
1179void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1180 const u8 *meshid, u8 meshid_len,
Hai Shalom81f62d82019-07-22 12:10:00 -07001181 u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001182{
1183 if (wpa_s->p2p_mgmt)
1184 return;
1185
1186 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1187 reason_code);
1188}
1189
1190
1191void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1192 const u8 *peer_addr)
1193{
1194 if (wpa_s->p2p_mgmt)
1195 return;
1196
Sunil Ravi2a14cf12023-11-21 00:54:38 +00001197 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
1198 MAC2STR(peer_addr));
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001199 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1200}
1201
1202
1203void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
Hai Shalom81f62d82019-07-22 12:10:00 -07001204 const u8 *peer_addr, u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001205{
1206 if (wpa_s->p2p_mgmt)
1207 return;
1208
Sunil Ravi2a14cf12023-11-21 00:54:38 +00001209 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
1210 MAC2STR(peer_addr));
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001211 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1212}
1213
1214#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001215
1216/*
1217 * DPP Notifications
1218 */
1219
1220/* DPP Success notifications */
1221
Hai Shalom706f99b2019-01-08 16:23:37 -08001222void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Sunil Ravi546a7b52022-08-26 22:06:04 +00001223 struct wpa_ssid *ssid, bool conn_status_requested)
Hai Shalom59532852018-12-07 10:32:58 -08001224{
1225#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001226 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001227 return;
1228
Sunil Ravi546a7b52022-08-26 22:06:04 +00001229 wpas_aidl_notify_dpp_config_received(wpa_s, ssid, conn_status_requested);
Hai Shalom59532852018-12-07 10:32:58 -08001230#endif /* CONFIG_DPP */
1231}
1232
Hai Shalom706f99b2019-01-08 16:23:37 -08001233void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001234{
1235#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001236 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001237 return;
1238
Gabriel Biren57ededa2021-09-03 16:08:50 +00001239 wpas_aidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001240#endif /* CONFIG_DPP */
1241}
1242
Matthew Wang53c66322024-12-02 13:59:53 +00001243#ifdef CONFIG_DPP
Sunil Ravi546a7b52022-08-26 22:06:04 +00001244void wpas_notify_dpp_connection_status_sent(struct wpa_supplicant *wpa_s,
1245 enum dpp_status_error result)
1246{
1247#ifdef CONFIG_DPP2
1248 if (!wpa_s)
1249 return;
1250
1251 wpas_aidl_notify_dpp_connection_status_sent(wpa_s, result);
1252#endif /* CONFIG_DPP2 */
1253}
Matthew Wang53c66322024-12-02 13:59:53 +00001254#endif /* CONFIG_DPP */
Sunil Ravi546a7b52022-08-26 22:06:04 +00001255
Hai Shalom59532852018-12-07 10:32:58 -08001256/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001257void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001258{
1259#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001260 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001261 return;
1262
Gabriel Biren57ededa2021-09-03 16:08:50 +00001263 wpas_aidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001264#endif /* CONFIG_DPP */
1265}
1266
Hai Shalom706f99b2019-01-08 16:23:37 -08001267void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001268{
1269#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001270 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001271 return;
1272
Gabriel Biren57ededa2021-09-03 16:08:50 +00001273 wpas_aidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001274#endif /* CONFIG_DPP */
1275}
1276
1277/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001278void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001279{
1280#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001281 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001282 return;
1283
Gabriel Biren57ededa2021-09-03 16:08:50 +00001284 wpas_aidl_notify_dpp_not_compatible(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001285#endif /* CONFIG_DPP */
1286}
1287
Hai Shalom706f99b2019-01-08 16:23:37 -08001288void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001289{
1290#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001291 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001292 return;
1293
Gabriel Biren57ededa2021-09-03 16:08:50 +00001294 wpas_aidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001295#endif /* CONFIG_DPP */
1296}
1297
Hai Shalom706f99b2019-01-08 16:23:37 -08001298void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001299{
1300#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001301 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001302 return;
1303
Gabriel Biren57ededa2021-09-03 16:08:50 +00001304 wpas_aidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001305#endif /* CONFIG_DPP */
1306}
1307
Hai Shalom706f99b2019-01-08 16:23:37 -08001308void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001309{
1310#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001311 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001312 return;
1313
Gabriel Biren57ededa2021-09-03 16:08:50 +00001314 wpas_aidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001315#endif /* CONFIG_DPP */
1316}
1317
Hai Shalom706f99b2019-01-08 16:23:37 -08001318void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001319{
1320#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001321 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001322 return;
1323
Gabriel Biren57ededa2021-09-03 16:08:50 +00001324 wpas_aidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001325#endif /* CONFIG_DPP */
1326}
1327
Hai Shalom706f99b2019-01-08 16:23:37 -08001328void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001329{
1330#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001331 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001332 return;
1333
Gabriel Biren57ededa2021-09-03 16:08:50 +00001334 wpas_aidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001335#endif /* CONFIG_DPP */
1336}
Jimmy Chen126b1702019-08-28 17:59:33 +08001337
Hai Shalom06768112019-12-04 15:49:43 -08001338void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1339{
1340#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001341 wpas_aidl_notify_dpp_config_sent_wait_response(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001342#endif /* CONFIG_DPP2 */
1343}
1344
1345void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1346{
1347#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001348 wpas_aidl_notify_dpp_config_accepted(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001349#endif /* CONFIG_DPP2 */
1350}
1351
Matthew Wang53c66322024-12-02 13:59:53 +00001352#ifdef CONFIG_DPP
Hai Shalom06768112019-12-04 15:49:43 -08001353void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1354 enum dpp_status_error status, const char *ssid,
1355 const char *channel_list, unsigned short band_list[], int size)
1356{
1357#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001358 wpas_aidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
Hai Shalom06768112019-12-04 15:49:43 -08001359#endif /* CONFIG_DPP2 */
1360}
Matthew Wang53c66322024-12-02 13:59:53 +00001361#endif /* CONFIG_DPP */
Hai Shalom06768112019-12-04 15:49:43 -08001362
1363void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1364{
1365#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001366 wpas_aidl_notify_dpp_config_rejected(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001367#endif /* CONFIG_DPP2 */
1368}
1369
Jimmy Chen126b1702019-08-28 17:59:33 +08001370void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1371 struct rsn_pmksa_cache_entry *entry)
1372{
1373 if (!wpa_s)
1374 return;
1375
Gabriel Biren57ededa2021-09-03 16:08:50 +00001376 wpas_aidl_notify_pmk_cache_added(wpa_s, entry);
Jimmy Chen126b1702019-08-28 17:59:33 +08001377}
Jimmy Chen39deead2020-10-14 23:47:20 +08001378
1379void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
1380 struct wpa_ssid *ssid,
1381 u8 bitmap)
1382{
1383 if (!wpa_s)
1384 return;
1385
1386 if (!ssid)
1387 return;
1388
Gabriel Biren57ededa2021-09-03 16:08:50 +00001389 wpas_aidl_notify_transition_disable(wpa_s, ssid, bitmap);
Jimmy Chen39deead2020-10-14 23:47:20 +08001390}
Sunil Ravi07c17622021-01-11 12:00:53 -08001391
1392void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s)
1393{
1394 if (!wpa_s)
1395 return;
1396
Gabriel Biren57ededa2021-09-03 16:08:50 +00001397 wpas_aidl_notify_network_not_found(wpa_s);
Sunil Ravi07c17622021-01-11 12:00:53 -08001398}
Hai Shalomc1a21442022-02-04 13:43:00 -08001399
1400#ifdef CONFIG_INTERWORKING
1401
1402void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
1403 struct wpa_bss *bss,
1404 struct wpa_cred *cred, int excluded,
1405 const char *type, int bh, int bss_load,
1406 int conn_capab)
1407{
1408 wpa_msg(wpa_s, MSG_INFO, "%s" MACSTR " type=%s%s%s%s id=%d priority=%d sp_priority=%d",
1409 excluded ? INTERWORKING_EXCLUDED : INTERWORKING_AP,
1410 MAC2STR(bss->bssid), type,
1411 bh ? " below_min_backhaul=1" : "",
1412 bss_load ? " over_max_bss_load=1" : "",
1413 conn_capab ? " conn_capab_missing=1" : "",
1414 cred->id, cred->priority, cred->sp_priority);
1415
1416 wpas_dbus_signal_interworking_ap_added(wpa_s, bss, cred, type, excluded,
1417 bh, bss_load, conn_capab);
1418}
1419
1420
1421void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
1422{
1423 wpas_dbus_signal_interworking_select_done(wpa_s);
1424}
1425
Sunil Ravi99c035e2024-07-12 01:42:03 +00001426
Hai Shalomc1a21442022-02-04 13:43:00 -08001427#endif /* CONFIG_INTERWORKING */
1428
Gabriel Biren3a2ec2c2022-03-07 17:59:41 +00001429void wpas_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
1430 const char* reason_string)
1431{
1432 wpas_aidl_notify_eap_method_selected(wpa_s, reason_string);
1433}
1434
1435void wpas_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
1436 const char *reason_string)
1437{
1438 wpas_aidl_notify_ssid_temp_disabled(wpa_s, reason_string);
1439}
1440
1441void wpas_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
1442 const char *reason_string)
1443{
1444 wpas_aidl_notify_open_ssl_failure(wpa_s, reason_string);
1445}
Shivani Baranwal84940f82022-02-02 10:21:47 +05301446
1447void wpas_notify_qos_policy_reset(struct wpa_supplicant *wpa_s)
1448{
1449 if (!wpa_s)
1450 return;
1451
1452 wpas_aidl_notify_qos_policy_reset(wpa_s);
1453}
1454
1455void wpas_notify_qos_policy_request(struct wpa_supplicant *wpa_s,
1456 struct dscp_policy_data *policies, int num_policies)
1457{
1458 if (!wpa_s || !policies)
1459 return;
1460
1461 wpas_aidl_notify_qos_policy_request(wpa_s, policies, num_policies);
1462}
Sunil Ravi65a724b2022-05-24 11:06:09 -07001463
1464void wpas_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency)
1465{
1466 if (!wpa_s)
1467 return;
1468
1469 wpas_aidl_notify_frequency_changed(wpa_s, frequency);
1470}
Gabriel Biren93398232022-12-15 19:18:28 +00001471
1472ssize_t wpas_get_certificate(const char *alias, uint8_t** value)
1473{
Gabriel Biren980c48a2023-03-27 21:49:21 +00001474 wpa_printf(MSG_INFO, "wpas_get_certificate");
Gabriel Biren93398232022-12-15 19:18:28 +00001475 return wpas_aidl_get_certificate(alias, value);
1476}
Sunil Ravi77d572f2023-01-17 23:58:31 +00001477
Xinyue Ling1629ad82023-03-24 16:19:51 +08001478ssize_t wpas_list_aliases(const char *prefix, char ***aliases)
1479{
1480 return wpas_aidl_list_aliases(prefix, aliases);
1481}
Sunil Ravi77d572f2023-01-17 23:58:31 +00001482
1483void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
1484{
1485 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
1486}
Swarn Singhc450e7b2023-03-28 17:36:22 +05301487
1488void wpas_notify_qos_policy_scs_response(struct wpa_supplicant *wpa_s,
1489 unsigned int num_scs_resp, int **scs_resp)
1490{
1491 if (!wpa_s || !num_scs_resp || !scs_resp)
1492 return;
1493
1494 wpas_aidl_notify_qos_policy_scs_response(wpa_s, num_scs_resp, scs_resp);
1495}
Sunil Ravib0ac25f2024-07-12 01:42:03 +00001496
1497void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
1498 const char *url)
1499{
1500#ifdef CONFIG_HS20
1501 if (!wpa_s || !url)
1502 return;
1503
1504 wpa_msg(wpa_s, MSG_INFO, HS20_T_C_ACCEPTANCE "%s", url);
1505 wpas_aidl_notify_hs20_rx_terms_and_conditions_acceptance(wpa_s, url);
1506 wpas_dbus_signal_hs20_t_c_acceptance(wpa_s, url);
1507#endif /* CONFIG_HS20 */
1508}
Sunil Ravic0f5d412024-09-11 22:12:49 +00001509
1510#ifdef CONFIG_NAN_USD
1511
1512void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
1513 enum nan_service_protocol_type
1514 srv_proto_type,
1515 int subscribe_id, int peer_publish_id,
1516 const u8 *peer_addr,
1517 bool fsd, bool fsd_gas,
1518 const u8 *ssi, size_t ssi_len)
1519{
1520 char *ssi_hex;
1521
1522 ssi_hex = os_zalloc(2 * ssi_len + 1);
1523 if (!ssi_hex)
1524 return;
1525 if (ssi)
1526 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001527 wpa_msg_global(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT
1528 "subscribe_id=%d publish_id=%d address=" MACSTR
1529 " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s",
1530 subscribe_id, peer_publish_id, MAC2STR(peer_addr),
1531 fsd, fsd_gas, srv_proto_type, ssi_hex);
Sunil Ravic0f5d412024-09-11 22:12:49 +00001532 os_free(ssi_hex);
Gabriel Biren073f12b2024-12-12 01:05:58 +00001533
1534 wpas_aidl_notify_usd_service_discovered(wpa_s, srv_proto_type,
1535 subscribe_id, peer_publish_id, peer_addr, fsd, ssi, ssi_len);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001536
1537 wpas_dbus_signal_nan_discovery_result(wpa_s, srv_proto_type,
1538 subscribe_id, peer_publish_id,
1539 peer_addr, fsd, fsd_gas,
1540 ssi, ssi_len);
Sunil Ravic0f5d412024-09-11 22:12:49 +00001541}
1542
1543
1544void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s,
1545 enum nan_service_protocol_type srv_proto_type,
1546 int publish_id, int peer_subscribe_id,
1547 const u8 *peer_addr,
1548 const u8 *ssi, size_t ssi_len)
1549{
1550 char *ssi_hex;
1551
1552 ssi_hex = os_zalloc(2 * ssi_len + 1);
1553 if (!ssi_hex)
1554 return;
1555 if (ssi)
1556 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001557 wpa_msg_global(wpa_s, MSG_INFO, NAN_REPLIED
1558 "publish_id=%d address=" MACSTR
1559 " subscribe_id=%d srv_proto_type=%u ssi=%s",
1560 publish_id, MAC2STR(peer_addr), peer_subscribe_id,
1561 srv_proto_type, ssi_hex);
Sunil Ravic0f5d412024-09-11 22:12:49 +00001562 os_free(ssi_hex);
Gabriel Biren073f12b2024-12-12 01:05:58 +00001563
1564 wpas_aidl_notify_usd_publish_replied(wpa_s, srv_proto_type,
1565 publish_id, peer_subscribe_id, peer_addr, ssi, ssi_len);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001566
1567 wpas_dbus_signal_nan_replied(wpa_s, srv_proto_type, publish_id,
1568 peer_subscribe_id, peer_addr,
1569 ssi, ssi_len);
Sunil Ravic0f5d412024-09-11 22:12:49 +00001570}
1571
1572
1573void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id,
1574 int peer_instance_id, const u8 *peer_addr,
1575 const u8 *ssi, size_t ssi_len)
1576{
1577 char *ssi_hex;
1578
1579 ssi_hex = os_zalloc(2 * ssi_len + 1);
1580 if (!ssi_hex)
1581 return;
1582 if (ssi)
1583 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001584 wpa_msg_global(wpa_s, MSG_INFO, NAN_RECEIVE
1585 "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s",
1586 id, peer_instance_id, MAC2STR(peer_addr), ssi_hex);
Sunil Ravic0f5d412024-09-11 22:12:49 +00001587 os_free(ssi_hex);
Gabriel Biren073f12b2024-12-12 01:05:58 +00001588
1589 wpas_aidl_notify_usd_message_received(wpa_s, id, peer_instance_id,
1590 peer_addr, ssi, ssi_len);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001591
1592 wpas_dbus_signal_nan_receive(wpa_s, id, peer_instance_id, peer_addr,
1593 ssi, ssi_len);
Sunil Ravic0f5d412024-09-11 22:12:49 +00001594}
1595
1596
1597static const char * nan_reason_txt(enum nan_de_reason reason)
1598{
1599 switch (reason) {
1600 case NAN_DE_REASON_TIMEOUT:
1601 return "timeout";
1602 case NAN_DE_REASON_USER_REQUEST:
1603 return "user-request";
1604 case NAN_DE_REASON_FAILURE:
1605 return "failure";
1606 }
1607
1608 return "unknown";
1609}
1610
1611
1612void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s,
1613 int publish_id,
1614 enum nan_de_reason reason)
1615{
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001616 wpa_msg_global(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED
1617 "publish_id=%d reason=%s",
1618 publish_id, nan_reason_txt(reason));
1619
Gabriel Biren073f12b2024-12-12 01:05:58 +00001620 wpas_aidl_notify_usd_publish_terminated(wpa_s, publish_id, reason);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001621
1622 wpas_dbus_signal_nan_publish_terminated(wpa_s, publish_id,
1623 nan_reason_txt(reason));
Sunil Ravic0f5d412024-09-11 22:12:49 +00001624}
1625
1626
1627void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s,
1628 int subscribe_id,
1629 enum nan_de_reason reason)
1630{
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001631 wpa_msg_global(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED
1632 "subscribe_id=%d reason=%s",
1633 subscribe_id, nan_reason_txt(reason));
1634
Gabriel Biren073f12b2024-12-12 01:05:58 +00001635 wpas_aidl_notify_usd_subscribe_terminated(wpa_s, subscribe_id, reason);
Sunil Ravi79e6c4f2025-01-04 00:47:06 +00001636
1637 wpas_dbus_signal_nan_subscribe_terminated(wpa_s, subscribe_id,
1638 nan_reason_txt(reason));
Sunil Ravic0f5d412024-09-11 22:12:49 +00001639}
1640
1641#endif /* CONFIG_NAN_USD */