blob: 2dc68b0194c8a2a871b69659e82db92205606792 [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{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800125 if (wpa_s->p2p_mgmt)
126 return;
127
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700128 /* notify the new DBus API */
129 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
130
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800131#ifdef CONFIG_FST
132 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
133 if (new_state == WPA_COMPLETED)
134 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
135 else if (old_state >= WPA_ASSOCIATED &&
136 new_state < WPA_ASSOCIATED)
137 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
138 }
139#endif /* CONFIG_FST */
140
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700141 if (new_state == WPA_COMPLETED)
142 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700143 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700144 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700145
146 sme_state_changed(wpa_s);
147
148#ifdef ANDROID
149 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700150 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700151 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700152 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700153 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700154 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
155 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800156 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700157#endif /* ANDROID */
Roshan Piuse8d0d162016-08-01 13:09:26 -0700158
Gabriel Biren57ededa2021-09-03 16:08:50 +0000159 wpas_aidl_notify_state_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700160}
161
162
Dmitry Shmidt04949592012-07-19 12:16:46 -0700163void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
164{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800165 if (wpa_s->p2p_mgmt)
166 return;
167
Dmitry Shmidt04949592012-07-19 12:16:46 -0700168 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
Roshan Pius0974e962016-12-12 17:05:51 -0800169
Gabriel Biren57ededa2021-09-03 16:08:50 +0000170 wpas_aidl_notify_disconnect_reason(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700171}
172
173
Veerendranath Jakkambc2fa492023-05-25 01:26:50 +0530174void wpas_notify_mlo_info_change_reason(struct wpa_supplicant *wpa_s,
175 enum mlo_info_change_reason reason)
176{
177 if (wpa_s->p2p_mgmt)
178 return;
179
180 wpas_aidl_notify_mlo_info_change_reason(wpa_s, reason);
181}
182
183
Hai Shalom74f70d42019-02-11 14:42:39 -0800184void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
185{
186 if (wpa_s->p2p_mgmt)
187 return;
188
189 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
190}
191
192
Sunil Ravi972b2042020-08-14 10:50:48 -0700193void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s,
Sunil Ravie06118e2021-01-03 08:39:46 -0800194 const u8 *bssid, u8 timed_out,
195 const u8 *assoc_resp_ie, size_t assoc_resp_ie_len)
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800196{
197 if (wpa_s->p2p_mgmt)
198 return;
199
200 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
Roshan Pius0974e962016-12-12 17:05:51 -0800201
Gabriel Biren57ededa2021-09-03 16:08:50 +0000202 wpas_aidl_notify_assoc_reject(wpa_s, bssid, timed_out, assoc_resp_ie, assoc_resp_ie_len);
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800203}
204
Roshan Pius38e96762017-01-23 14:52:00 -0800205void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
206 if (wpa_s->p2p_mgmt)
207 return;
208
Gabriel Biren57ededa2021-09-03 16:08:50 +0000209 wpas_aidl_notify_auth_timeout(wpa_s);
Roshan Pius38e96762017-01-23 14:52:00 -0800210}
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800211
Hai Shalom74f70d42019-02-11 14:42:39 -0800212void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
213{
214 if (wpa_s->p2p_mgmt)
215 return;
216
217 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
218}
219
220
221void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
222{
223 if (wpa_s->p2p_mgmt)
224 return;
225
226 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
227}
228
229
Sunil Ravic0f5d412024-09-11 22:12:49 +0000230void wpas_notify_scan_in_progress_6ghz(struct wpa_supplicant *wpa_s)
231{
232 if (wpa_s->p2p_mgmt)
233 return;
234
235 wpas_dbus_signal_prop_changed(wpa_s,
236 WPAS_DBUS_PROP_SCAN_IN_PROGRESS_6GHZ);
237}
238
239
Hai Shalom74f70d42019-02-11 14:42:39 -0800240void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
241{
242 if (wpa_s->p2p_mgmt)
243 return;
244
245 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
246}
247
248
249void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
250{
251 if (wpa_s->p2p_mgmt)
252 return;
253
254 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
Sunil Ravi4018d712019-12-06 18:01:21 -0800255
256#ifdef CONFIG_WNM
Gabriel Biren57ededa2021-09-03 16:08:50 +0000257 wpas_aidl_notify_bss_tm_status(wpa_s);
Sunil Ravi4018d712019-12-06 18:01:21 -0800258#endif
Hai Shalom74f70d42019-02-11 14:42:39 -0800259}
260
261
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700262void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
263{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800264 if (wpa_s->p2p_mgmt)
265 return;
266
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700267 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
268}
269
270
271void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
272{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800273 if (wpa_s->p2p_mgmt)
274 return;
275
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700276 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
277}
278
279
280void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
281{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800282 if (wpa_s->p2p_mgmt)
283 return;
284
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700285 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700286
Gabriel Biren57ededa2021-09-03 16:08:50 +0000287 wpas_aidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700288}
289
290
Sunil Ravi77d572f2023-01-17 23:58:31 +0000291void wpas_notify_mac_address_changed(struct wpa_supplicant *wpa_s)
292{
293 if (wpa_s->p2p_mgmt)
294 return;
295
296 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_MAC_ADDRESS);
297}
298
299
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700300void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
301{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800302 if (wpa_s->p2p_mgmt)
303 return;
304
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700305 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
306}
307
308
309void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
310 struct wpa_ssid *ssid)
311{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800312 if (wpa_s->p2p_mgmt)
313 return;
314
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700315 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
316}
317
318
319void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
320 struct wpa_ssid *ssid)
321{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800322 if (wpa_s->p2p_mgmt)
323 return;
324
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700325 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
326}
327
328
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800329void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
330 struct wpa_ssid *ssid,
331 enum wpa_ctrl_req_type rtype,
332 const char *default_txt)
333{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800334 if (wpa_s->p2p_mgmt)
335 return;
336
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800337 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700338
Gabriel Biren57ededa2021-09-03 16:08:50 +0000339 wpas_aidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800340}
341
342
Steven Liu850c2e02022-11-28 17:26:39 +0000343void wpas_notify_permanent_id_req_denied(struct wpa_supplicant *wpa_s)
344{
345 wpas_aidl_notify_permanent_id_req_denied(wpa_s);
346}
347
348
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700349void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
350{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800351 if (wpa_s->p2p_mgmt)
352 return;
353
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700354 /* notify the new DBus API */
355 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
356}
357
358
359void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
360{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800361 if (wpa_s->p2p_mgmt)
362 return;
363
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700364 wpas_dbus_signal_scan_done(wpa_s, success);
365}
366
367
368void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
369{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800370 if (wpa_s->p2p_mgmt)
371 return;
372
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700373 wpas_wps_notify_scan_results(wpa_s);
374}
375
376
377void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
378 const struct wps_credential *cred)
379{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800380 if (wpa_s->p2p_mgmt)
381 return;
382
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700383#ifdef CONFIG_WPS
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700384 /* notify the new DBus API */
385 wpas_dbus_signal_wps_cred(wpa_s, cred);
386#endif /* CONFIG_WPS */
387}
388
389
390void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
391 struct wps_event_m2d *m2d)
392{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800393 if (wpa_s->p2p_mgmt)
394 return;
395
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700396#ifdef CONFIG_WPS
397 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
398#endif /* CONFIG_WPS */
399}
400
401
402void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
403 struct wps_event_fail *fail)
404{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800405 if (wpa_s->p2p_mgmt)
406 return;
407
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700408#ifdef CONFIG_WPS
409 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800410
Gabriel Biren57ededa2021-09-03 16:08:50 +0000411 wpas_aidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
Roshan Pius14932752017-01-11 09:48:58 -0800412 fail->config_error,
413 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700414#endif /* CONFIG_WPS */
415}
416
417
418void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
419{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800420 if (wpa_s->p2p_mgmt)
421 return;
422
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700423#ifdef CONFIG_WPS
424 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800425
Gabriel Biren57ededa2021-09-03 16:08:50 +0000426 wpas_aidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700427#endif /* CONFIG_WPS */
428}
429
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700430void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
431{
432 if (wpa_s->p2p_mgmt)
433 return;
434
435#ifdef CONFIG_WPS
436 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800437
Gabriel Biren57ededa2021-09-03 16:08:50 +0000438 wpas_aidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700439#endif /* CONFIG_WPS */
440}
441
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700442
443void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
444 struct wpa_ssid *ssid)
445{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800446 if (wpa_s->p2p_mgmt)
447 return;
448
Jouni Malinen75ecf522011-06-27 15:19:46 -0700449 /*
450 * Networks objects created during any P2P activities should not be
451 * exposed out. They might/will confuse certain non-P2P aware
452 * applications since these network objects won't behave like
453 * regular ones.
454 */
Roshan Piusd3854452016-07-07 16:46:41 -0700455 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700456 wpas_dbus_register_network(wpa_s, ssid);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000457 wpas_aidl_register_network(wpa_s, ssid);
Hai Shalomc1a21442022-02-04 13:43:00 -0800458 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d",
459 ssid->id);
Roshan Piusd3854452016-07-07 16:46:41 -0700460 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700461}
462
463
464void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
465 struct wpa_ssid *ssid)
466{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700467#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700468 wpas_dbus_register_persistent_group(wpa_s, ssid);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000469 wpas_aidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700470#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700471}
472
473
474void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
475 struct wpa_ssid *ssid)
476{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700477#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700478 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000479 wpas_aidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700480#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700481}
482
483
484void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
485 struct wpa_ssid *ssid)
486{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800487 if (wpa_s->next_ssid == ssid)
488 wpa_s->next_ssid = NULL;
Sunil Ravia04bd252022-05-02 22:54:18 -0700489 if (wpa_s->last_ssid == ssid)
490 wpa_s->last_ssid = NULL;
491 if (wpa_s->current_ssid == ssid)
492 wpa_s->current_ssid = NULL;
Sunil Ravi2a14cf12023-11-21 00:54:38 +0000493 if (wpa_s->ml_connect_probe_ssid == ssid) {
494 wpa_s->ml_connect_probe_ssid = NULL;
495 wpa_s->ml_connect_probe_bss = NULL;
496 }
Sunil Ravi7f769292024-07-23 22:21:32 +0000497 if (wpa_s->connect_without_scan == ssid)
498 wpa_s->connect_without_scan = NULL;
Sunil Ravi89eba102022-09-13 21:04:37 -0700499#if defined(CONFIG_SME) && defined(CONFIG_SAE)
500 if (wpa_s->sme.ext_auth_wpa_ssid == ssid)
501 wpa_s->sme.ext_auth_wpa_ssid = NULL;
502#endif /* CONFIG_SME && CONFIG_SAE */
Vinayak Yadawad4222acc2023-12-15 17:39:27 +0530503 if (wpa_s->wpa) {
504 if ((wpa_key_mgmt_sae(ssid->key_mgmt) &&
505 (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SAE_OFFLOAD_STA)) ||
506 ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
507 (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA))) {
508 /* For cases when PMK is generated at the driver */
509 struct wpa_pmkid_params params;
510
511 os_memset(&params, 0, sizeof(params));
512 params.ssid = ssid->ssid;
513 params.ssid_len = ssid->ssid_len;
514 wpa_drv_remove_pmkid(wpa_s, &params);
515 }
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800516 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Vinayak Yadawad4222acc2023-12-15 17:39:27 +0530517 }
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700518 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700519 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700520 wpas_dbus_unregister_network(wpa_s, ssid->id);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000521 wpas_aidl_unregister_network(wpa_s, ssid);
Hai Shalomc1a21442022-02-04 13:43:00 -0800522 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d",
523 ssid->id);
Roshan Piusd3854452016-07-07 16:46:41 -0700524 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800525 if (network_is_persistent_group(ssid))
526 wpas_notify_persistent_group_removed(wpa_s, ssid);
527
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800528 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700529}
530
531
532void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
533 u8 bssid[], unsigned int id)
534{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800535 if (wpa_s->p2p_mgmt)
536 return;
537
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700538 wpas_dbus_register_bss(wpa_s, bssid, id);
539 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
540 id, MAC2STR(bssid));
541}
542
543
544void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
545 u8 bssid[], unsigned int id)
546{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800547 if (wpa_s->p2p_mgmt)
548 return;
549
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700550 wpas_dbus_unregister_bss(wpa_s, bssid, id);
551 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
552 id, MAC2STR(bssid));
553}
554
555
556void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
557 unsigned int id)
558{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800559 if (wpa_s->p2p_mgmt)
560 return;
561
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700562 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
563}
564
565
566void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
567 unsigned int id)
568{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800569 if (wpa_s->p2p_mgmt)
570 return;
571
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700572 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
573 id);
574}
575
576
577void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
578 unsigned int id)
579{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800580 if (wpa_s->p2p_mgmt)
581 return;
582
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700583 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
584 id);
585}
586
587
588void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
589 unsigned int id)
590{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800591 if (wpa_s->p2p_mgmt)
592 return;
593
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700594 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
595}
596
597
598void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
599 unsigned int id)
600{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800601 if (wpa_s->p2p_mgmt)
602 return;
603
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700604 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
605}
606
607
608void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
609 unsigned int id)
610{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800611 if (wpa_s->p2p_mgmt)
612 return;
613
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700614 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
615}
616
617
618void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
619 unsigned int id)
620{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800621 if (wpa_s->p2p_mgmt)
622 return;
623
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800624#ifdef CONFIG_WPS
625 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
626#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700627}
628
629
630void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
631 unsigned int id)
632{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800633 if (wpa_s->p2p_mgmt)
634 return;
635
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700636 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
637}
638
639
640void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
641 unsigned int id)
642{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800643 if (wpa_s->p2p_mgmt)
644 return;
645
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700646 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
647}
648
649
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700650void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
651{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800652 if (wpa_s->p2p_mgmt)
653 return;
654
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700655 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
656}
657
658
Sunil Ravi99c035e2024-07-12 01:42:03 +0000659void wpas_notify_bss_anqp_changed(struct wpa_supplicant *wpa_s, unsigned int id)
660{
661 if (wpa_s->p2p_mgmt)
662 return;
663
664 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_ANQP, id);
665}
666
667
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700668void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
669{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800670 if (wpa_s->p2p_mgmt)
671 return;
672
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700673 wpas_dbus_signal_blob_added(wpa_s, name);
674}
675
676
677void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
678{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800679 if (wpa_s->p2p_mgmt)
680 return;
681
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700682 wpas_dbus_signal_blob_removed(wpa_s, name);
683}
684
685
686void wpas_notify_debug_level_changed(struct wpa_global *global)
687{
688 wpas_dbus_signal_debug_level_changed(global);
689}
690
691
692void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
693{
694 wpas_dbus_signal_debug_timestamp_changed(global);
695}
696
697
698void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
699{
700 wpas_dbus_signal_debug_show_keys_changed(global);
701}
702
703
704void wpas_notify_suspend(struct wpa_global *global)
705{
706 struct wpa_supplicant *wpa_s;
707
708 os_get_time(&global->suspend_time);
709 wpa_printf(MSG_DEBUG, "System suspend notification");
710 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
711 wpa_drv_suspend(wpa_s);
712}
713
714
715void wpas_notify_resume(struct wpa_global *global)
716{
717 struct os_time now;
718 int slept;
719 struct wpa_supplicant *wpa_s;
720
721 if (global->suspend_time.sec == 0)
722 slept = -1;
723 else {
724 os_get_time(&now);
725 slept = now.sec - global->suspend_time.sec;
726 }
727 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
728 slept);
729
730 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
731 wpa_drv_resume(wpa_s);
732 if (wpa_s->wpa_state == WPA_DISCONNECTED)
733 wpa_supplicant_req_scan(wpa_s, 0, 100000);
734 }
735}
736
737
738#ifdef CONFIG_P2P
739
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700740void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
741{
742 /* Notify P2P find has stopped */
743 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800744
Gabriel Biren57ededa2021-09-03 16:08:50 +0000745 wpas_aidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700746}
747
748
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700749void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800750 const u8 *addr, const struct p2p_peer_info *info,
751 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
Jimmy Chen0133fc12021-03-04 13:56:11 +0800752 const u8* peer_wfd_r2_device_info, u8 peer_wfd_r2_device_info_len,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800753 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700754{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700755 if (new_device) {
756 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800757 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700758 }
759
760 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800761 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
762
Gabriel Biren57ededa2021-09-03 16:08:50 +0000763 wpas_aidl_notify_p2p_device_found(wpa_s, addr, info,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800764 peer_wfd_device_info,
Jimmy Chen57e19f52021-03-04 14:19:52 +0800765 peer_wfd_device_info_len,
766 peer_wfd_r2_device_info,
767 peer_wfd_r2_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700768}
769
770
771void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
772 const u8 *dev_addr)
773{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700774 wpas_dbus_unregister_peer(wpa_s, dev_addr);
775
776 /* Create signal on interface object*/
777 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800778
Gabriel Biren57ededa2021-09-03 16:08:50 +0000779 wpas_aidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700780}
781
782
783void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
784 const struct wpa_ssid *ssid,
785 const char *role)
786{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700787 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700788
789 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800790
Gabriel Biren57ededa2021-09-03 16:08:50 +0000791 wpas_aidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700792}
793
794
795void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700796 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700797{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700798 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800799
Gabriel Biren57ededa2021-09-03 16:08:50 +0000800 wpas_aidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700801}
802
803
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800804void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
805 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700806{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800807 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800808
Gabriel Biren57ededa2021-09-03 16:08:50 +0000809 wpas_aidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700810}
811
812
813void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
814 int status, const u8 *bssid)
815{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700816 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800817
Gabriel Biren57ededa2021-09-03 16:08:50 +0000818 wpas_aidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700819}
820
821
822void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
823 int freq, const u8 *sa, u8 dialog_token,
824 u16 update_indic, const u8 *tlvs,
825 size_t tlvs_len)
826{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700827 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
828 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700829}
830
831
832void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
833 const u8 *sa, u16 update_indic,
834 const u8 *tlvs, size_t tlvs_len)
835{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700836 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
837 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800838
Gabriel Biren57ededa2021-09-03 16:08:50 +0000839 wpas_aidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800840 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700841}
842
843
844/**
845 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
846 * @dev_addr: Who sent the request or responded to our request.
847 * @request: Will be 1 if request, 0 for response.
848 * @status: Valid only in case of response (0 in case of success)
849 * @config_methods: WPS config methods
850 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
Sunil Ravi8bae4252023-11-16 03:05:19 +0000851 * @group_ifname: Group interface name of the group owner in case the provision
852 * discovery request is received with P2P Group ID attribute.
853 * i.e., valid only when the peer device is joining an
854 * operating P2P group.
Jouni Malinen75ecf522011-06-27 15:19:46 -0700855 *
856 * This can be used to notify:
857 * - Requests or responses
858 * - Various config methods
859 * - Failure condition in case of response
860 */
861void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
862 const u8 *dev_addr, int request,
863 enum p2p_prov_disc_status status,
864 u16 config_methods,
Sunil Ravi8bae4252023-11-16 03:05:19 +0000865 unsigned int generated_pin,
866 const char *group_ifname)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700867{
868 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
869 status, config_methods,
870 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800871
Gabriel Biren57ededa2021-09-03 16:08:50 +0000872 wpas_aidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800873 status, config_methods,
Sunil Ravi8bae4252023-11-16 03:05:19 +0000874 generated_pin, group_ifname);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800875
Jouni Malinen75ecf522011-06-27 15:19:46 -0700876}
877
878
879void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700880 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800881 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700882{
883 /* Notify a group has been started */
884 wpas_dbus_register_p2p_group(wpa_s, ssid);
885
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800886 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800887
Sunil Ravi68c25c22023-02-04 06:17:03 +0000888 wpas_aidl_notify_p2p_group_started(wpa_s, ssid, persistent, client, ip);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700889}
890
891
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800892void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
893 const char *reason)
894{
895 /* Notify a group formation failed */
896 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800897
Gabriel Biren57ededa2021-09-03 16:08:50 +0000898 wpas_aidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800899}
900
901
Jouni Malinen75ecf522011-06-27 15:19:46 -0700902void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
903 struct wps_event_fail *fail)
904{
905 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700906}
907
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800908
909void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
910 const u8 *sa, const u8 *go_dev_addr,
911 const u8 *bssid, int id, int op_freq)
912{
913 /* Notify a P2P Invitation Request */
914 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
915 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800916
Gabriel Biren57ededa2021-09-03 16:08:50 +0000917 wpas_aidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800918 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800919}
920
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700921#endif /* CONFIG_P2P */
922
923
924static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800925 const u8 *sta,
Sunil Ravid8128a22023-11-06 23:53:58 +0000926 const u8 *p2p_dev_addr, const u8 *ip)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700927{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700928#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800929 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
930
Jouni Malinen75ecf522011-06-27 15:19:46 -0700931 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700932 * Create 'peer-joined' signal on group object -- will also
933 * check P2P itself.
934 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800935 if (p2p_dev_addr)
936 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700937#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700938
Hai Shalom74f70d42019-02-11 14:42:39 -0800939 /* Register the station */
940 wpas_dbus_register_sta(wpa_s, sta);
941
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700942 /* Notify listeners a new station has been authorized */
943 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800944
Sunil Ravid8128a22023-11-06 23:53:58 +0000945 wpas_aidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr, ip);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700946}
947
948
949static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700950 const u8 *sta,
951 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700952{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700953#ifdef CONFIG_P2P
954 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700955 * Create 'peer-disconnected' signal on group object if this
956 * is a P2P group.
957 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800958 if (p2p_dev_addr)
959 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700960#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700961
962 /* Notify listeners a station has been deauthorized */
963 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800964
Sunil Ravid8128a22023-11-06 23:53:58 +0000965 wpas_aidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Hai Shalom74f70d42019-02-11 14:42:39 -0800966 /* Unregister the station */
967 wpas_dbus_unregister_sta(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700968}
969
970
971void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800972 const u8 *mac_addr, int authorized,
Sunil Ravid8128a22023-11-06 23:53:58 +0000973 const u8 *p2p_dev_addr, const u8 *ip)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700974{
975 if (authorized)
Sunil Ravi99c035e2024-07-12 01:42:03 +0000976 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr,
977 ip);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700978 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700979 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700980}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700981
982
Hai Shalom81f62d82019-07-22 12:10:00 -0700983void wpas_notify_certification(struct wpa_supplicant *wpa_s,
984 struct tls_cert_data *cert,
985 const char *cert_hash)
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700986{
Hai Shalom81f62d82019-07-22 12:10:00 -0700987 int i;
Hai Shalom878cf7b2019-07-15 14:55:18 -0700988
Hai Shalom81f62d82019-07-22 12:10:00 -0700989 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
Hai Shalomc3565922019-10-28 11:58:20 -0700990 "depth=%d subject='%s'%s%s%s%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700991 cert->depth, cert->subject, cert_hash ? " hash=" : "",
992 cert_hash ? cert_hash : "",
Hai Shalomc3565922019-10-28 11:58:20 -0700993 cert->tod == 2 ? " tod=2" : "",
994 cert->tod == 1 ? " tod=1" : "");
Hai Shalom81f62d82019-07-22 12:10:00 -0700995
996 if (cert->cert) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700997 char *cert_hex;
Hai Shalom81f62d82019-07-22 12:10:00 -0700998 size_t len = wpabuf_len(cert->cert) * 2 + 1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700999 cert_hex = os_malloc(len);
1000 if (cert_hex) {
Hai Shalom81f62d82019-07-22 12:10:00 -07001001 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
1002 wpabuf_len(cert->cert));
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001003 wpa_msg_ctrl(wpa_s, MSG_INFO,
1004 WPA_EVENT_EAP_PEER_CERT
1005 "depth=%d subject='%s' cert=%s",
Hai Shalom81f62d82019-07-22 12:10:00 -07001006 cert->depth, cert->subject, cert_hex);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001007 os_free(cert_hex);
1008 }
1009 }
1010
Hai Shalom81f62d82019-07-22 12:10:00 -07001011 for (i = 0; i < cert->num_altsubject; i++)
1012 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
1013 "depth=%d %s", cert->depth, cert->altsubject[i]);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -08001014
Jimmy Chen429daf92021-10-20 13:27:23 +08001015 wpas_aidl_notify_ceritification(wpa_s, cert->depth, cert->subject,
1016 cert->altsubject, cert->num_altsubject,
1017 cert_hash, cert->cert);
1018
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001019 /* notify the new DBus API */
Hai Shalom81f62d82019-07-22 12:10:00 -07001020 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
1021 cert->altsubject, cert->num_altsubject,
1022 cert_hash, cert->cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001023}
Dmitry Shmidt04949592012-07-19 12:16:46 -07001024
1025
1026void wpas_notify_preq(struct wpa_supplicant *wpa_s,
1027 const u8 *addr, const u8 *dst, const u8 *bssid,
1028 const u8 *ie, size_t ie_len, u32 ssi_signal)
1029{
1030#ifdef CONFIG_AP
1031 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
1032#endif /* CONFIG_AP */
1033}
1034
1035
1036void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
1037 const char *parameter)
1038{
1039 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -07001040 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
1041 "status='%s' parameter='%s'",
1042 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -07001043}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001044
Roshan Pius3a1667e2018-07-03 15:17:14 -07001045
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -07001046void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
1047{
1048 wpa_dbg(wpa_s, MSG_ERROR,
1049 "EAP Error code = %d", error_code);
Gabriel Biren57ededa2021-09-03 16:08:50 +00001050 wpas_aidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -07001051}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001052
Roshan Pius3a1667e2018-07-03 15:17:14 -07001053
Sunil Ravi036cec52023-03-29 11:35:17 -07001054void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
1055{
1056 wpas_dbus_signal_psk_mismatch(wpa_s);
1057}
1058
1059
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001060void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
1061 struct wpa_ssid *ssid)
1062{
1063 if (wpa_s->current_ssid != ssid)
1064 return;
1065
1066 wpa_dbg(wpa_s, MSG_DEBUG,
1067 "Network bssid config changed for the current network - within-ESS roaming %s",
1068 ssid->bssid_set ? "disabled" : "enabled");
1069
1070 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
1071 ssid->bssid_set ? ssid->bssid : NULL);
1072}
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001073
1074
1075void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
1076 struct wpa_ssid *ssid)
1077{
1078#ifdef CONFIG_P2P
1079 if (ssid->disabled == 2) {
1080 /* Changed from normal network profile to persistent group */
1081 ssid->disabled = 0;
1082 wpas_dbus_unregister_network(wpa_s, ssid->id);
1083 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -07001084 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001085 wpas_dbus_register_persistent_group(wpa_s, ssid);
1086 } else {
1087 /* Changed from persistent group to normal network profile */
1088 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -07001089 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001090 wpas_dbus_register_network(wpa_s, ssid);
1091 }
1092#endif /* CONFIG_P2P */
1093}
Roshan Pius04a9d742016-12-12 12:40:46 -08001094
1095void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1096 const char *result,
1097 const struct wpa_bss_anqp *anqp)
1098{
Sunil Ravi99c035e2024-07-12 01:42:03 +00001099 wpa_msg(wpa_s, MSG_INFO, ANQP_QUERY_DONE "addr=" MACSTR " result=%s",
1100 MAC2STR(bssid), result);
Roshan Pius04a9d742016-12-12 12:40:46 -08001101#ifdef CONFIG_INTERWORKING
1102 if (!wpa_s || !bssid || !anqp)
1103 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001104
Gabriel Biren57ededa2021-09-03 16:08:50 +00001105 wpas_aidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Sunil Ravi99c035e2024-07-12 01:42:03 +00001106 wpas_dbus_signal_anqp_query_done(wpa_s, bssid, result);
Roshan Pius04a9d742016-12-12 12:40:46 -08001107#endif /* CONFIG_INTERWORKING */
1108}
1109
1110void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1111 const char* file_name, const u8* image,
1112 u32 image_length)
1113{
1114#ifdef CONFIG_HS20
1115 if (!wpa_s || !bssid || !file_name || !image)
1116 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001117
Gabriel Biren57ededa2021-09-03 16:08:50 +00001118 wpas_aidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
Roshan Pius9322a342016-12-12 14:45:02 -08001119 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -08001120#endif /* CONFIG_HS20 */
1121}
1122
1123void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
1124 const char* url,
1125 u8 osu_method)
1126{
1127#ifdef CONFIG_HS20
1128 if (!wpa_s || !url)
1129 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001130
Gabriel Biren57ededa2021-09-03 16:08:50 +00001131 wpas_aidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -08001132#endif /* CONFIG_HS20 */
1133}
1134
1135void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1136 u8 code, u16 reauth_delay,
1137 const char *url)
1138{
1139#ifdef CONFIG_HS20
Hai Shalomb3a7c702020-10-20 12:22:53 -07001140 if (!wpa_s)
Roshan Pius04a9d742016-12-12 12:40:46 -08001141 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001142
Gabriel Biren57ededa2021-09-03 16:08:50 +00001143 wpas_aidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
Hai Shalom04a4ca62020-10-28 19:04:47 -07001144 url);
Roshan Pius04a9d742016-12-12 12:40:46 -08001145#endif /* CONFIG_HS20 */
1146}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001147
1148
1149#ifdef CONFIG_MESH
1150
1151void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1152 struct wpa_ssid *ssid)
1153{
1154 if (wpa_s->p2p_mgmt)
1155 return;
1156
1157 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1158}
1159
1160
1161void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1162 const u8 *meshid, u8 meshid_len,
Hai Shalom81f62d82019-07-22 12:10:00 -07001163 u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001164{
1165 if (wpa_s->p2p_mgmt)
1166 return;
1167
1168 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1169 reason_code);
1170}
1171
1172
1173void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1174 const u8 *peer_addr)
1175{
1176 if (wpa_s->p2p_mgmt)
1177 return;
1178
Sunil Ravi2a14cf12023-11-21 00:54:38 +00001179 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
1180 MAC2STR(peer_addr));
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001181 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1182}
1183
1184
1185void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
Hai Shalom81f62d82019-07-22 12:10:00 -07001186 const u8 *peer_addr, u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001187{
1188 if (wpa_s->p2p_mgmt)
1189 return;
1190
Sunil Ravi2a14cf12023-11-21 00:54:38 +00001191 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
1192 MAC2STR(peer_addr));
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001193 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1194}
1195
1196#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001197
1198/*
1199 * DPP Notifications
1200 */
1201
1202/* DPP Success notifications */
1203
Hai Shalom706f99b2019-01-08 16:23:37 -08001204void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Sunil Ravi546a7b52022-08-26 22:06:04 +00001205 struct wpa_ssid *ssid, bool conn_status_requested)
Hai Shalom59532852018-12-07 10:32:58 -08001206{
1207#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001208 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001209 return;
1210
Sunil Ravi546a7b52022-08-26 22:06:04 +00001211 wpas_aidl_notify_dpp_config_received(wpa_s, ssid, conn_status_requested);
Hai Shalom59532852018-12-07 10:32:58 -08001212#endif /* CONFIG_DPP */
1213}
1214
Hai Shalom706f99b2019-01-08 16:23:37 -08001215void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001216{
1217#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001218 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001219 return;
1220
Gabriel Biren57ededa2021-09-03 16:08:50 +00001221 wpas_aidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001222#endif /* CONFIG_DPP */
1223}
1224
Matthew Wang53c66322024-12-02 13:59:53 +00001225#ifdef CONFIG_DPP
Sunil Ravi546a7b52022-08-26 22:06:04 +00001226void wpas_notify_dpp_connection_status_sent(struct wpa_supplicant *wpa_s,
1227 enum dpp_status_error result)
1228{
1229#ifdef CONFIG_DPP2
1230 if (!wpa_s)
1231 return;
1232
1233 wpas_aidl_notify_dpp_connection_status_sent(wpa_s, result);
1234#endif /* CONFIG_DPP2 */
1235}
Matthew Wang53c66322024-12-02 13:59:53 +00001236#endif /* CONFIG_DPP */
Sunil Ravi546a7b52022-08-26 22:06:04 +00001237
Hai Shalom59532852018-12-07 10:32:58 -08001238/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001239void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001240{
1241#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001242 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001243 return;
1244
Gabriel Biren57ededa2021-09-03 16:08:50 +00001245 wpas_aidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001246#endif /* CONFIG_DPP */
1247}
1248
Hai Shalom706f99b2019-01-08 16:23:37 -08001249void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001250{
1251#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001252 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001253 return;
1254
Gabriel Biren57ededa2021-09-03 16:08:50 +00001255 wpas_aidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001256#endif /* CONFIG_DPP */
1257}
1258
1259/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001260void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001261{
1262#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001263 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001264 return;
1265
Gabriel Biren57ededa2021-09-03 16:08:50 +00001266 wpas_aidl_notify_dpp_not_compatible(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001267#endif /* CONFIG_DPP */
1268}
1269
Hai Shalom706f99b2019-01-08 16:23:37 -08001270void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001271{
1272#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001273 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001274 return;
1275
Gabriel Biren57ededa2021-09-03 16:08:50 +00001276 wpas_aidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001277#endif /* CONFIG_DPP */
1278}
1279
Hai Shalom706f99b2019-01-08 16:23:37 -08001280void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001281{
1282#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001283 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001284 return;
1285
Gabriel Biren57ededa2021-09-03 16:08:50 +00001286 wpas_aidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001287#endif /* CONFIG_DPP */
1288}
1289
Hai Shalom706f99b2019-01-08 16:23:37 -08001290void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001291{
1292#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001293 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001294 return;
1295
Gabriel Biren57ededa2021-09-03 16:08:50 +00001296 wpas_aidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001297#endif /* CONFIG_DPP */
1298}
1299
Hai Shalom706f99b2019-01-08 16:23:37 -08001300void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001301{
1302#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001303 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001304 return;
1305
Gabriel Biren57ededa2021-09-03 16:08:50 +00001306 wpas_aidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001307#endif /* CONFIG_DPP */
1308}
1309
Hai Shalom706f99b2019-01-08 16:23:37 -08001310void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001311{
1312#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001313 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001314 return;
1315
Gabriel Biren57ededa2021-09-03 16:08:50 +00001316 wpas_aidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001317#endif /* CONFIG_DPP */
1318}
Jimmy Chen126b1702019-08-28 17:59:33 +08001319
Hai Shalom06768112019-12-04 15:49:43 -08001320void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1321{
1322#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001323 wpas_aidl_notify_dpp_config_sent_wait_response(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001324#endif /* CONFIG_DPP2 */
1325}
1326
1327void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1328{
1329#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001330 wpas_aidl_notify_dpp_config_accepted(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001331#endif /* CONFIG_DPP2 */
1332}
1333
Matthew Wang53c66322024-12-02 13:59:53 +00001334#ifdef CONFIG_DPP
Hai Shalom06768112019-12-04 15:49:43 -08001335void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1336 enum dpp_status_error status, const char *ssid,
1337 const char *channel_list, unsigned short band_list[], int size)
1338{
1339#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001340 wpas_aidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
Hai Shalom06768112019-12-04 15:49:43 -08001341#endif /* CONFIG_DPP2 */
1342}
Matthew Wang53c66322024-12-02 13:59:53 +00001343#endif /* CONFIG_DPP */
Hai Shalom06768112019-12-04 15:49:43 -08001344
1345void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1346{
1347#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001348 wpas_aidl_notify_dpp_config_rejected(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001349#endif /* CONFIG_DPP2 */
1350}
1351
Jimmy Chen126b1702019-08-28 17:59:33 +08001352void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1353 struct rsn_pmksa_cache_entry *entry)
1354{
1355 if (!wpa_s)
1356 return;
1357
Gabriel Biren57ededa2021-09-03 16:08:50 +00001358 wpas_aidl_notify_pmk_cache_added(wpa_s, entry);
Jimmy Chen126b1702019-08-28 17:59:33 +08001359}
Jimmy Chen39deead2020-10-14 23:47:20 +08001360
1361void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
1362 struct wpa_ssid *ssid,
1363 u8 bitmap)
1364{
1365 if (!wpa_s)
1366 return;
1367
1368 if (!ssid)
1369 return;
1370
Gabriel Biren57ededa2021-09-03 16:08:50 +00001371 wpas_aidl_notify_transition_disable(wpa_s, ssid, bitmap);
Jimmy Chen39deead2020-10-14 23:47:20 +08001372}
Sunil Ravi07c17622021-01-11 12:00:53 -08001373
1374void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s)
1375{
1376 if (!wpa_s)
1377 return;
1378
Gabriel Biren57ededa2021-09-03 16:08:50 +00001379 wpas_aidl_notify_network_not_found(wpa_s);
Sunil Ravi07c17622021-01-11 12:00:53 -08001380}
Hai Shalomc1a21442022-02-04 13:43:00 -08001381
1382#ifdef CONFIG_INTERWORKING
1383
1384void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
1385 struct wpa_bss *bss,
1386 struct wpa_cred *cred, int excluded,
1387 const char *type, int bh, int bss_load,
1388 int conn_capab)
1389{
1390 wpa_msg(wpa_s, MSG_INFO, "%s" MACSTR " type=%s%s%s%s id=%d priority=%d sp_priority=%d",
1391 excluded ? INTERWORKING_EXCLUDED : INTERWORKING_AP,
1392 MAC2STR(bss->bssid), type,
1393 bh ? " below_min_backhaul=1" : "",
1394 bss_load ? " over_max_bss_load=1" : "",
1395 conn_capab ? " conn_capab_missing=1" : "",
1396 cred->id, cred->priority, cred->sp_priority);
1397
1398 wpas_dbus_signal_interworking_ap_added(wpa_s, bss, cred, type, excluded,
1399 bh, bss_load, conn_capab);
1400}
1401
1402
1403void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
1404{
1405 wpas_dbus_signal_interworking_select_done(wpa_s);
1406}
1407
Sunil Ravi99c035e2024-07-12 01:42:03 +00001408
Hai Shalomc1a21442022-02-04 13:43:00 -08001409#endif /* CONFIG_INTERWORKING */
1410
Gabriel Biren3a2ec2c2022-03-07 17:59:41 +00001411void wpas_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
1412 const char* reason_string)
1413{
1414 wpas_aidl_notify_eap_method_selected(wpa_s, reason_string);
1415}
1416
1417void wpas_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
1418 const char *reason_string)
1419{
1420 wpas_aidl_notify_ssid_temp_disabled(wpa_s, reason_string);
1421}
1422
1423void wpas_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
1424 const char *reason_string)
1425{
1426 wpas_aidl_notify_open_ssl_failure(wpa_s, reason_string);
1427}
Shivani Baranwal84940f82022-02-02 10:21:47 +05301428
1429void wpas_notify_qos_policy_reset(struct wpa_supplicant *wpa_s)
1430{
1431 if (!wpa_s)
1432 return;
1433
1434 wpas_aidl_notify_qos_policy_reset(wpa_s);
1435}
1436
1437void wpas_notify_qos_policy_request(struct wpa_supplicant *wpa_s,
1438 struct dscp_policy_data *policies, int num_policies)
1439{
1440 if (!wpa_s || !policies)
1441 return;
1442
1443 wpas_aidl_notify_qos_policy_request(wpa_s, policies, num_policies);
1444}
Sunil Ravi65a724b2022-05-24 11:06:09 -07001445
1446void wpas_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency)
1447{
1448 if (!wpa_s)
1449 return;
1450
1451 wpas_aidl_notify_frequency_changed(wpa_s, frequency);
1452}
Gabriel Biren93398232022-12-15 19:18:28 +00001453
1454ssize_t wpas_get_certificate(const char *alias, uint8_t** value)
1455{
Gabriel Biren980c48a2023-03-27 21:49:21 +00001456 wpa_printf(MSG_INFO, "wpas_get_certificate");
Gabriel Biren93398232022-12-15 19:18:28 +00001457 return wpas_aidl_get_certificate(alias, value);
1458}
Sunil Ravi77d572f2023-01-17 23:58:31 +00001459
Xinyue Ling1629ad82023-03-24 16:19:51 +08001460ssize_t wpas_list_aliases(const char *prefix, char ***aliases)
1461{
1462 return wpas_aidl_list_aliases(prefix, aliases);
1463}
Sunil Ravi77d572f2023-01-17 23:58:31 +00001464
1465void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
1466{
1467 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
1468}
Swarn Singhc450e7b2023-03-28 17:36:22 +05301469
1470void wpas_notify_qos_policy_scs_response(struct wpa_supplicant *wpa_s,
1471 unsigned int num_scs_resp, int **scs_resp)
1472{
1473 if (!wpa_s || !num_scs_resp || !scs_resp)
1474 return;
1475
1476 wpas_aidl_notify_qos_policy_scs_response(wpa_s, num_scs_resp, scs_resp);
1477}
Sunil Ravib0ac25f2024-07-12 01:42:03 +00001478
1479void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
1480 const char *url)
1481{
1482#ifdef CONFIG_HS20
1483 if (!wpa_s || !url)
1484 return;
1485
1486 wpa_msg(wpa_s, MSG_INFO, HS20_T_C_ACCEPTANCE "%s", url);
1487 wpas_aidl_notify_hs20_rx_terms_and_conditions_acceptance(wpa_s, url);
1488 wpas_dbus_signal_hs20_t_c_acceptance(wpa_s, url);
1489#endif /* CONFIG_HS20 */
1490}
Sunil Ravic0f5d412024-09-11 22:12:49 +00001491
1492#ifdef CONFIG_NAN_USD
1493
1494void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
1495 enum nan_service_protocol_type
1496 srv_proto_type,
1497 int subscribe_id, int peer_publish_id,
1498 const u8 *peer_addr,
1499 bool fsd, bool fsd_gas,
1500 const u8 *ssi, size_t ssi_len)
1501{
1502 char *ssi_hex;
1503
1504 ssi_hex = os_zalloc(2 * ssi_len + 1);
1505 if (!ssi_hex)
1506 return;
1507 if (ssi)
1508 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1509 wpa_msg(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT
1510 "subscribe_id=%d publish_id=%d address=" MACSTR
1511 " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s",
1512 subscribe_id, peer_publish_id, MAC2STR(peer_addr),
1513 fsd, fsd_gas, srv_proto_type, ssi_hex);
1514 os_free(ssi_hex);
1515}
1516
1517
1518void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s,
1519 enum nan_service_protocol_type srv_proto_type,
1520 int publish_id, int peer_subscribe_id,
1521 const u8 *peer_addr,
1522 const u8 *ssi, size_t ssi_len)
1523{
1524 char *ssi_hex;
1525
1526 ssi_hex = os_zalloc(2 * ssi_len + 1);
1527 if (!ssi_hex)
1528 return;
1529 if (ssi)
1530 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1531 wpa_msg(wpa_s, MSG_INFO, NAN_REPLIED
1532 "publish_id=%d address=" MACSTR
1533 " subscribe_id=%d srv_proto_type=%u ssi=%s",
1534 publish_id, MAC2STR(peer_addr), peer_subscribe_id,
1535 srv_proto_type, ssi_hex);
1536 os_free(ssi_hex);
1537}
1538
1539
1540void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id,
1541 int peer_instance_id, const u8 *peer_addr,
1542 const u8 *ssi, size_t ssi_len)
1543{
1544 char *ssi_hex;
1545
1546 ssi_hex = os_zalloc(2 * ssi_len + 1);
1547 if (!ssi_hex)
1548 return;
1549 if (ssi)
1550 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1551 wpa_msg(wpa_s, MSG_INFO, NAN_RECEIVE
1552 "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s",
1553 id, peer_instance_id, MAC2STR(peer_addr), ssi_hex);
1554 os_free(ssi_hex);
1555}
1556
1557
1558static const char * nan_reason_txt(enum nan_de_reason reason)
1559{
1560 switch (reason) {
1561 case NAN_DE_REASON_TIMEOUT:
1562 return "timeout";
1563 case NAN_DE_REASON_USER_REQUEST:
1564 return "user-request";
1565 case NAN_DE_REASON_FAILURE:
1566 return "failure";
1567 }
1568
1569 return "unknown";
1570}
1571
1572
1573void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s,
1574 int publish_id,
1575 enum nan_de_reason reason)
1576{
1577 wpa_msg(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED
1578 "publish_id=%d reason=%s",
1579 publish_id, nan_reason_txt(reason));
1580}
1581
1582
1583void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s,
1584 int subscribe_id,
1585 enum nan_de_reason reason)
1586{
1587 wpa_msg(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED
1588 "subscribe_id=%d reason=%s",
1589 subscribe_id, nan_reason_txt(reason));
1590}
1591
1592#endif /* CONFIG_NAN_USD */