blob: b8fdf29b281ecd12d526ece58976b71c055976d1 [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"
Shivani Baranwalc58b6092022-12-01 11:17:24 +053029#include "aidl/aidl.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070030
31int wpas_notify_supplicant_initialized(struct wpa_global *global)
32{
Hai Shalom021b0b52019-04-10 11:17:58 -070033#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070034 if (global->params.dbus_ctrl_interface) {
35 global->dbus = wpas_dbus_init(global);
36 if (global->dbus == NULL)
37 return -1;
38 }
Hai Shalom021b0b52019-04-10 11:17:58 -070039#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070040
Gabriel Biren7a30e7f2023-06-02 20:11:28 +000041#ifdef CONFIG_AIDL
42 // Initialize AIDL here if daemonize is disabled.
43 // Otherwise initialize it later.
44 if (!global->params.daemonize) {
45 global->aidl = wpas_aidl_init(global);
46 if (!global->aidl)
47 return -1;
48 }
49#endif /* CONFIG_AIDL */
50
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070051 return 0;
52}
53
54
55void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
56{
Hai Shalom021b0b52019-04-10 11:17:58 -070057#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070058 if (global->dbus)
59 wpas_dbus_deinit(global->dbus);
Hai Shalom021b0b52019-04-10 11:17:58 -070060#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
Dmitry Shmidte4663042016-04-04 10:07:49 -070061
Gabriel Biren57ededa2021-09-03 16:08:50 +000062#ifdef CONFIG_AIDL
63 if (global->aidl)
64 wpas_aidl_deinit(global->aidl);
65#endif /* CONFIG_AIDL */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070066}
67
68
69int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
70{
Hai Shalomc4809952019-04-30 14:45:55 -070071 if (!wpa_s->p2p_mgmt) {
72 if (wpas_dbus_register_interface(wpa_s))
73 return -1;
74 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070075
Kiran Kumar Lokerea9f98eb2023-03-17 13:01:12 -070076#ifdef CONFIG_AIDL
Gabriel Biren7a30e7f2023-06-02 20:11:28 +000077 /*
78 * AIDL initialization may not be complete here if daemonize is enabled.
Kiran Kumar Lokerea9f98eb2023-03-17 13:01:12 -070079 * Initialization is done after daemonizing in order to avoid
80 * issues with the file descriptor.
81 */
Gabriel Biren7a30e7f2023-06-02 20:11:28 +000082 if (!wpa_s->global->aidl)
Kiran Kumar Lokerea9f98eb2023-03-17 13:01:12 -070083 return 0;
Gabriel Biren7a30e7f2023-06-02 20:11:28 +000084 /* AIDL interface wants to keep track of the P2P mgmt iface. */
Gabriel Biren57ededa2021-09-03 16:08:50 +000085 if (wpas_aidl_register_interface(wpa_s))
Roshan Pius54e763a2016-07-06 15:41:53 -070086 return -1;
Kiran Kumar Lokerea9f98eb2023-03-17 13:01:12 -070087#endif
Roshan Pius54e763a2016-07-06 15:41:53 -070088
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070089 return 0;
90}
91
92
93void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
94{
Hai Shalomc4809952019-04-30 14:45:55 -070095 if (!wpa_s->p2p_mgmt) {
96 /* unregister interface in new DBus ctrl iface */
97 wpas_dbus_unregister_interface(wpa_s);
98 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070099
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 wpas_aidl_unregister_interface(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700102}
103
104
105void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
106 enum wpa_states new_state,
107 enum wpa_states old_state)
108{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800109 if (wpa_s->p2p_mgmt)
110 return;
111
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700112 /* notify the new DBus API */
113 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
114
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800115#ifdef CONFIG_FST
116 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
117 if (new_state == WPA_COMPLETED)
118 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
119 else if (old_state >= WPA_ASSOCIATED &&
120 new_state < WPA_ASSOCIATED)
121 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
122 }
123#endif /* CONFIG_FST */
124
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700125 if (new_state == WPA_COMPLETED)
126 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700127 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700128 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700129
130 sme_state_changed(wpa_s);
131
132#ifdef ANDROID
133 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700134 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700135 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700136 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700137 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700138 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
139 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800140 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700141#endif /* ANDROID */
Roshan Piuse8d0d162016-08-01 13:09:26 -0700142
Gabriel Biren57ededa2021-09-03 16:08:50 +0000143 wpas_aidl_notify_state_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700144}
145
146
Dmitry Shmidt04949592012-07-19 12:16:46 -0700147void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
148{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800149 if (wpa_s->p2p_mgmt)
150 return;
151
Dmitry Shmidt04949592012-07-19 12:16:46 -0700152 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
Roshan Pius0974e962016-12-12 17:05:51 -0800153
Gabriel Biren57ededa2021-09-03 16:08:50 +0000154 wpas_aidl_notify_disconnect_reason(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700155}
156
157
Veerendranath Jakkambc2fa492023-05-25 01:26:50 +0530158void wpas_notify_mlo_info_change_reason(struct wpa_supplicant *wpa_s,
159 enum mlo_info_change_reason reason)
160{
161 if (wpa_s->p2p_mgmt)
162 return;
163
164 wpas_aidl_notify_mlo_info_change_reason(wpa_s, reason);
165}
166
167
Hai Shalom74f70d42019-02-11 14:42:39 -0800168void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
169{
170 if (wpa_s->p2p_mgmt)
171 return;
172
173 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
174}
175
176
Sunil Ravi972b2042020-08-14 10:50:48 -0700177void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s,
Sunil Ravie06118e2021-01-03 08:39:46 -0800178 const u8 *bssid, u8 timed_out,
179 const u8 *assoc_resp_ie, size_t assoc_resp_ie_len)
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800180{
181 if (wpa_s->p2p_mgmt)
182 return;
183
184 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
Roshan Pius0974e962016-12-12 17:05:51 -0800185
Gabriel Biren57ededa2021-09-03 16:08:50 +0000186 wpas_aidl_notify_assoc_reject(wpa_s, bssid, timed_out, assoc_resp_ie, assoc_resp_ie_len);
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800187}
188
Roshan Pius38e96762017-01-23 14:52:00 -0800189void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
190 if (wpa_s->p2p_mgmt)
191 return;
192
Gabriel Biren57ededa2021-09-03 16:08:50 +0000193 wpas_aidl_notify_auth_timeout(wpa_s);
Roshan Pius38e96762017-01-23 14:52:00 -0800194}
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800195
Hai Shalom74f70d42019-02-11 14:42:39 -0800196void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
197{
198 if (wpa_s->p2p_mgmt)
199 return;
200
201 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
202}
203
204
205void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
206{
207 if (wpa_s->p2p_mgmt)
208 return;
209
210 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
211}
212
213
Sunil Ravic0f5d412024-09-11 22:12:49 +0000214void wpas_notify_scan_in_progress_6ghz(struct wpa_supplicant *wpa_s)
215{
216 if (wpa_s->p2p_mgmt)
217 return;
218
219 wpas_dbus_signal_prop_changed(wpa_s,
220 WPAS_DBUS_PROP_SCAN_IN_PROGRESS_6GHZ);
221}
222
223
Hai Shalom74f70d42019-02-11 14:42:39 -0800224void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
225{
226 if (wpa_s->p2p_mgmt)
227 return;
228
229 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
230}
231
232
233void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
234{
235 if (wpa_s->p2p_mgmt)
236 return;
237
238 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
Sunil Ravi4018d712019-12-06 18:01:21 -0800239
240#ifdef CONFIG_WNM
Gabriel Biren57ededa2021-09-03 16:08:50 +0000241 wpas_aidl_notify_bss_tm_status(wpa_s);
Sunil Ravi4018d712019-12-06 18:01:21 -0800242#endif
Hai Shalom74f70d42019-02-11 14:42:39 -0800243}
244
245
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700246void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
247{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800248 if (wpa_s->p2p_mgmt)
249 return;
250
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700251 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
252}
253
254
255void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
256{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800257 if (wpa_s->p2p_mgmt)
258 return;
259
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700260 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
261}
262
263
264void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
265{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800266 if (wpa_s->p2p_mgmt)
267 return;
268
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700269 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700270
Gabriel Biren57ededa2021-09-03 16:08:50 +0000271 wpas_aidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700272}
273
274
Sunil Ravi77d572f2023-01-17 23:58:31 +0000275void wpas_notify_mac_address_changed(struct wpa_supplicant *wpa_s)
276{
277 if (wpa_s->p2p_mgmt)
278 return;
279
280 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_MAC_ADDRESS);
281}
282
283
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700284void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
285{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800286 if (wpa_s->p2p_mgmt)
287 return;
288
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700289 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
290}
291
292
293void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
294 struct wpa_ssid *ssid)
295{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800296 if (wpa_s->p2p_mgmt)
297 return;
298
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700299 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
300}
301
302
303void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
304 struct wpa_ssid *ssid)
305{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800306 if (wpa_s->p2p_mgmt)
307 return;
308
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700309 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
310}
311
312
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800313void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
314 struct wpa_ssid *ssid,
315 enum wpa_ctrl_req_type rtype,
316 const char *default_txt)
317{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800318 if (wpa_s->p2p_mgmt)
319 return;
320
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800321 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700322
Gabriel Biren57ededa2021-09-03 16:08:50 +0000323 wpas_aidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800324}
325
326
Steven Liu850c2e02022-11-28 17:26:39 +0000327void wpas_notify_permanent_id_req_denied(struct wpa_supplicant *wpa_s)
328{
329 wpas_aidl_notify_permanent_id_req_denied(wpa_s);
330}
331
332
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700333void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
334{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800335 if (wpa_s->p2p_mgmt)
336 return;
337
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700338 /* notify the new DBus API */
339 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
340}
341
342
343void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
344{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800345 if (wpa_s->p2p_mgmt)
346 return;
347
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700348 wpas_dbus_signal_scan_done(wpa_s, success);
349}
350
351
352void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
353{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800354 if (wpa_s->p2p_mgmt)
355 return;
356
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700357 wpas_wps_notify_scan_results(wpa_s);
358}
359
360
361void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
362 const struct wps_credential *cred)
363{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800364 if (wpa_s->p2p_mgmt)
365 return;
366
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700367#ifdef CONFIG_WPS
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700368 /* notify the new DBus API */
369 wpas_dbus_signal_wps_cred(wpa_s, cred);
370#endif /* CONFIG_WPS */
371}
372
373
374void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
375 struct wps_event_m2d *m2d)
376{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800377 if (wpa_s->p2p_mgmt)
378 return;
379
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700380#ifdef CONFIG_WPS
381 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
382#endif /* CONFIG_WPS */
383}
384
385
386void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
387 struct wps_event_fail *fail)
388{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800389 if (wpa_s->p2p_mgmt)
390 return;
391
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700392#ifdef CONFIG_WPS
393 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800394
Gabriel Biren57ededa2021-09-03 16:08:50 +0000395 wpas_aidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
Roshan Pius14932752017-01-11 09:48:58 -0800396 fail->config_error,
397 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700398#endif /* CONFIG_WPS */
399}
400
401
402void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
403{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800404 if (wpa_s->p2p_mgmt)
405 return;
406
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700407#ifdef CONFIG_WPS
408 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800409
Gabriel Biren57ededa2021-09-03 16:08:50 +0000410 wpas_aidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700411#endif /* CONFIG_WPS */
412}
413
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700414void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
415{
416 if (wpa_s->p2p_mgmt)
417 return;
418
419#ifdef CONFIG_WPS
420 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800421
Gabriel Biren57ededa2021-09-03 16:08:50 +0000422 wpas_aidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700423#endif /* CONFIG_WPS */
424}
425
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700426
427void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
428 struct wpa_ssid *ssid)
429{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800430 if (wpa_s->p2p_mgmt)
431 return;
432
Jouni Malinen75ecf522011-06-27 15:19:46 -0700433 /*
434 * Networks objects created during any P2P activities should not be
435 * exposed out. They might/will confuse certain non-P2P aware
436 * applications since these network objects won't behave like
437 * regular ones.
438 */
Roshan Piusd3854452016-07-07 16:46:41 -0700439 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700440 wpas_dbus_register_network(wpa_s, ssid);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000441 wpas_aidl_register_network(wpa_s, ssid);
Hai Shalomc1a21442022-02-04 13:43:00 -0800442 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d",
443 ssid->id);
Roshan Piusd3854452016-07-07 16:46:41 -0700444 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700445}
446
447
448void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
449 struct wpa_ssid *ssid)
450{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700451#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700452 wpas_dbus_register_persistent_group(wpa_s, ssid);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000453 wpas_aidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700454#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700455}
456
457
458void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
459 struct wpa_ssid *ssid)
460{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700461#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700462 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000463 wpas_aidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700464#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700465}
466
467
468void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
469 struct wpa_ssid *ssid)
470{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800471 if (wpa_s->next_ssid == ssid)
472 wpa_s->next_ssid = NULL;
Sunil Ravia04bd252022-05-02 22:54:18 -0700473 if (wpa_s->last_ssid == ssid)
474 wpa_s->last_ssid = NULL;
475 if (wpa_s->current_ssid == ssid)
476 wpa_s->current_ssid = NULL;
Sunil Ravi2a14cf12023-11-21 00:54:38 +0000477 if (wpa_s->ml_connect_probe_ssid == ssid) {
478 wpa_s->ml_connect_probe_ssid = NULL;
479 wpa_s->ml_connect_probe_bss = NULL;
480 }
Sunil Ravi7f769292024-07-23 22:21:32 +0000481 if (wpa_s->connect_without_scan == ssid)
482 wpa_s->connect_without_scan = NULL;
Sunil Ravi89eba102022-09-13 21:04:37 -0700483#if defined(CONFIG_SME) && defined(CONFIG_SAE)
484 if (wpa_s->sme.ext_auth_wpa_ssid == ssid)
485 wpa_s->sme.ext_auth_wpa_ssid = NULL;
486#endif /* CONFIG_SME && CONFIG_SAE */
Vinayak Yadawad4222acc2023-12-15 17:39:27 +0530487 if (wpa_s->wpa) {
488 if ((wpa_key_mgmt_sae(ssid->key_mgmt) &&
489 (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SAE_OFFLOAD_STA)) ||
490 ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
491 (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA))) {
492 /* For cases when PMK is generated at the driver */
493 struct wpa_pmkid_params params;
494
495 os_memset(&params, 0, sizeof(params));
496 params.ssid = ssid->ssid;
497 params.ssid_len = ssid->ssid_len;
498 wpa_drv_remove_pmkid(wpa_s, &params);
499 }
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800500 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Vinayak Yadawad4222acc2023-12-15 17:39:27 +0530501 }
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700502 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700503 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700504 wpas_dbus_unregister_network(wpa_s, ssid->id);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000505 wpas_aidl_unregister_network(wpa_s, ssid);
Hai Shalomc1a21442022-02-04 13:43:00 -0800506 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d",
507 ssid->id);
Roshan Piusd3854452016-07-07 16:46:41 -0700508 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800509 if (network_is_persistent_group(ssid))
510 wpas_notify_persistent_group_removed(wpa_s, ssid);
511
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800512 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700513}
514
515
516void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
517 u8 bssid[], unsigned int id)
518{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800519 if (wpa_s->p2p_mgmt)
520 return;
521
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700522 wpas_dbus_register_bss(wpa_s, bssid, id);
523 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
524 id, MAC2STR(bssid));
525}
526
527
528void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
529 u8 bssid[], unsigned int id)
530{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800531 if (wpa_s->p2p_mgmt)
532 return;
533
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700534 wpas_dbus_unregister_bss(wpa_s, bssid, id);
535 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
536 id, MAC2STR(bssid));
537}
538
539
540void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
541 unsigned int id)
542{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800543 if (wpa_s->p2p_mgmt)
544 return;
545
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700546 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
547}
548
549
550void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
551 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_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
557 id);
558}
559
560
561void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
562 unsigned int id)
563{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800564 if (wpa_s->p2p_mgmt)
565 return;
566
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700567 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
568 id);
569}
570
571
572void wpas_notify_bss_mode_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_MODE, id);
579}
580
581
582void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
583 unsigned int id)
584{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800585 if (wpa_s->p2p_mgmt)
586 return;
587
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700588 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
589}
590
591
592void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
593 unsigned int id)
594{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800595 if (wpa_s->p2p_mgmt)
596 return;
597
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700598 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
599}
600
601
602void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
603 unsigned int id)
604{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800605 if (wpa_s->p2p_mgmt)
606 return;
607
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800608#ifdef CONFIG_WPS
609 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
610#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700611}
612
613
614void wpas_notify_bss_ies_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_IES, id);
621}
622
623
624void wpas_notify_bss_rates_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 Shmidt8d520ff2011-05-09 14:06:53 -0700630 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
631}
632
633
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700634void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
635{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800636 if (wpa_s->p2p_mgmt)
637 return;
638
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700639 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
640}
641
642
Sunil Ravi99c035e2024-07-12 01:42:03 +0000643void wpas_notify_bss_anqp_changed(struct wpa_supplicant *wpa_s, unsigned int id)
644{
645 if (wpa_s->p2p_mgmt)
646 return;
647
648 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_ANQP, id);
649}
650
651
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700652void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
653{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800654 if (wpa_s->p2p_mgmt)
655 return;
656
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700657 wpas_dbus_signal_blob_added(wpa_s, name);
658}
659
660
661void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
662{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800663 if (wpa_s->p2p_mgmt)
664 return;
665
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700666 wpas_dbus_signal_blob_removed(wpa_s, name);
667}
668
669
670void wpas_notify_debug_level_changed(struct wpa_global *global)
671{
672 wpas_dbus_signal_debug_level_changed(global);
673}
674
675
676void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
677{
678 wpas_dbus_signal_debug_timestamp_changed(global);
679}
680
681
682void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
683{
684 wpas_dbus_signal_debug_show_keys_changed(global);
685}
686
687
688void wpas_notify_suspend(struct wpa_global *global)
689{
690 struct wpa_supplicant *wpa_s;
691
692 os_get_time(&global->suspend_time);
693 wpa_printf(MSG_DEBUG, "System suspend notification");
694 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
695 wpa_drv_suspend(wpa_s);
696}
697
698
699void wpas_notify_resume(struct wpa_global *global)
700{
701 struct os_time now;
702 int slept;
703 struct wpa_supplicant *wpa_s;
704
705 if (global->suspend_time.sec == 0)
706 slept = -1;
707 else {
708 os_get_time(&now);
709 slept = now.sec - global->suspend_time.sec;
710 }
711 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
712 slept);
713
714 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
715 wpa_drv_resume(wpa_s);
716 if (wpa_s->wpa_state == WPA_DISCONNECTED)
717 wpa_supplicant_req_scan(wpa_s, 0, 100000);
718 }
719}
720
721
722#ifdef CONFIG_P2P
723
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700724void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
725{
726 /* Notify P2P find has stopped */
727 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800728
Gabriel Biren57ededa2021-09-03 16:08:50 +0000729 wpas_aidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700730}
731
732
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700733void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800734 const u8 *addr, const struct p2p_peer_info *info,
735 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
Jimmy Chen0133fc12021-03-04 13:56:11 +0800736 const u8* peer_wfd_r2_device_info, u8 peer_wfd_r2_device_info_len,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800737 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700738{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700739 if (new_device) {
740 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800741 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700742 }
743
744 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800745 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
746
Gabriel Biren57ededa2021-09-03 16:08:50 +0000747 wpas_aidl_notify_p2p_device_found(wpa_s, addr, info,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800748 peer_wfd_device_info,
Jimmy Chen57e19f52021-03-04 14:19:52 +0800749 peer_wfd_device_info_len,
750 peer_wfd_r2_device_info,
751 peer_wfd_r2_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700752}
753
754
755void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
756 const u8 *dev_addr)
757{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700758 wpas_dbus_unregister_peer(wpa_s, dev_addr);
759
760 /* Create signal on interface object*/
761 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800762
Gabriel Biren57ededa2021-09-03 16:08:50 +0000763 wpas_aidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700764}
765
766
767void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
768 const struct wpa_ssid *ssid,
769 const char *role)
770{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700771 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700772
773 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800774
Gabriel Biren57ededa2021-09-03 16:08:50 +0000775 wpas_aidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700776}
777
778
779void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700780 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700781{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700782 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800783
Gabriel Biren57ededa2021-09-03 16:08:50 +0000784 wpas_aidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700785}
786
787
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800788void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
789 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700790{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800791 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800792
Gabriel Biren57ededa2021-09-03 16:08:50 +0000793 wpas_aidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700794}
795
796
797void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
798 int status, const u8 *bssid)
799{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700800 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800801
Gabriel Biren57ededa2021-09-03 16:08:50 +0000802 wpas_aidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700803}
804
805
806void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
807 int freq, const u8 *sa, u8 dialog_token,
808 u16 update_indic, const u8 *tlvs,
809 size_t tlvs_len)
810{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700811 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
812 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700813}
814
815
816void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
817 const u8 *sa, u16 update_indic,
818 const u8 *tlvs, size_t tlvs_len)
819{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700820 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
821 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800822
Gabriel Biren57ededa2021-09-03 16:08:50 +0000823 wpas_aidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800824 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700825}
826
827
828/**
829 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
830 * @dev_addr: Who sent the request or responded to our request.
831 * @request: Will be 1 if request, 0 for response.
832 * @status: Valid only in case of response (0 in case of success)
833 * @config_methods: WPS config methods
834 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
Sunil Ravi8bae4252023-11-16 03:05:19 +0000835 * @group_ifname: Group interface name of the group owner in case the provision
836 * discovery request is received with P2P Group ID attribute.
837 * i.e., valid only when the peer device is joining an
838 * operating P2P group.
Jouni Malinen75ecf522011-06-27 15:19:46 -0700839 *
840 * This can be used to notify:
841 * - Requests or responses
842 * - Various config methods
843 * - Failure condition in case of response
844 */
845void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
846 const u8 *dev_addr, int request,
847 enum p2p_prov_disc_status status,
848 u16 config_methods,
Sunil Ravi8bae4252023-11-16 03:05:19 +0000849 unsigned int generated_pin,
850 const char *group_ifname)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700851{
852 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
853 status, config_methods,
854 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800855
Gabriel Biren57ededa2021-09-03 16:08:50 +0000856 wpas_aidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800857 status, config_methods,
Sunil Ravi8bae4252023-11-16 03:05:19 +0000858 generated_pin, group_ifname);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800859
Jouni Malinen75ecf522011-06-27 15:19:46 -0700860}
861
862
863void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700864 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800865 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700866{
867 /* Notify a group has been started */
868 wpas_dbus_register_p2p_group(wpa_s, ssid);
869
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800870 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800871
Sunil Ravi68c25c22023-02-04 06:17:03 +0000872 wpas_aidl_notify_p2p_group_started(wpa_s, ssid, persistent, client, ip);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700873}
874
875
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800876void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
877 const char *reason)
878{
879 /* Notify a group formation failed */
880 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800881
Gabriel Biren57ededa2021-09-03 16:08:50 +0000882 wpas_aidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800883}
884
885
Jouni Malinen75ecf522011-06-27 15:19:46 -0700886void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
887 struct wps_event_fail *fail)
888{
889 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700890}
891
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800892
893void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
894 const u8 *sa, const u8 *go_dev_addr,
895 const u8 *bssid, int id, int op_freq)
896{
897 /* Notify a P2P Invitation Request */
898 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
899 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800900
Gabriel Biren57ededa2021-09-03 16:08:50 +0000901 wpas_aidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800902 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800903}
904
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700905#endif /* CONFIG_P2P */
906
907
908static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800909 const u8 *sta,
Sunil Ravid8128a22023-11-06 23:53:58 +0000910 const u8 *p2p_dev_addr, const u8 *ip)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700911{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700912#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800913 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
914
Jouni Malinen75ecf522011-06-27 15:19:46 -0700915 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700916 * Create 'peer-joined' signal on group object -- will also
917 * check P2P itself.
918 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800919 if (p2p_dev_addr)
920 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700921#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700922
Hai Shalom74f70d42019-02-11 14:42:39 -0800923 /* Register the station */
924 wpas_dbus_register_sta(wpa_s, sta);
925
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700926 /* Notify listeners a new station has been authorized */
927 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800928
Sunil Ravid8128a22023-11-06 23:53:58 +0000929 wpas_aidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr, ip);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700930}
931
932
933static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700934 const u8 *sta,
935 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700936{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700937#ifdef CONFIG_P2P
938 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700939 * Create 'peer-disconnected' signal on group object if this
940 * is a P2P group.
941 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800942 if (p2p_dev_addr)
943 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700944#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700945
946 /* Notify listeners a station has been deauthorized */
947 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800948
Sunil Ravid8128a22023-11-06 23:53:58 +0000949 wpas_aidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Hai Shalom74f70d42019-02-11 14:42:39 -0800950 /* Unregister the station */
951 wpas_dbus_unregister_sta(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700952}
953
954
955void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800956 const u8 *mac_addr, int authorized,
Sunil Ravid8128a22023-11-06 23:53:58 +0000957 const u8 *p2p_dev_addr, const u8 *ip)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700958{
959 if (authorized)
Sunil Ravi99c035e2024-07-12 01:42:03 +0000960 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr,
961 ip);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700962 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700963 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700964}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700965
966
Hai Shalom81f62d82019-07-22 12:10:00 -0700967void wpas_notify_certification(struct wpa_supplicant *wpa_s,
968 struct tls_cert_data *cert,
969 const char *cert_hash)
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700970{
Hai Shalom81f62d82019-07-22 12:10:00 -0700971 int i;
Hai Shalom878cf7b2019-07-15 14:55:18 -0700972
Hai Shalom81f62d82019-07-22 12:10:00 -0700973 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
Hai Shalomc3565922019-10-28 11:58:20 -0700974 "depth=%d subject='%s'%s%s%s%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700975 cert->depth, cert->subject, cert_hash ? " hash=" : "",
976 cert_hash ? cert_hash : "",
Hai Shalomc3565922019-10-28 11:58:20 -0700977 cert->tod == 2 ? " tod=2" : "",
978 cert->tod == 1 ? " tod=1" : "");
Hai Shalom81f62d82019-07-22 12:10:00 -0700979
980 if (cert->cert) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700981 char *cert_hex;
Hai Shalom81f62d82019-07-22 12:10:00 -0700982 size_t len = wpabuf_len(cert->cert) * 2 + 1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700983 cert_hex = os_malloc(len);
984 if (cert_hex) {
Hai Shalom81f62d82019-07-22 12:10:00 -0700985 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
986 wpabuf_len(cert->cert));
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700987 wpa_msg_ctrl(wpa_s, MSG_INFO,
988 WPA_EVENT_EAP_PEER_CERT
989 "depth=%d subject='%s' cert=%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700990 cert->depth, cert->subject, cert_hex);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700991 os_free(cert_hex);
992 }
993 }
994
Hai Shalom81f62d82019-07-22 12:10:00 -0700995 for (i = 0; i < cert->num_altsubject; i++)
996 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
997 "depth=%d %s", cert->depth, cert->altsubject[i]);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800998
Jimmy Chen429daf92021-10-20 13:27:23 +0800999 wpas_aidl_notify_ceritification(wpa_s, cert->depth, cert->subject,
1000 cert->altsubject, cert->num_altsubject,
1001 cert_hash, cert->cert);
1002
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001003 /* notify the new DBus API */
Hai Shalom81f62d82019-07-22 12:10:00 -07001004 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
1005 cert->altsubject, cert->num_altsubject,
1006 cert_hash, cert->cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -07001007}
Dmitry Shmidt04949592012-07-19 12:16:46 -07001008
1009
1010void wpas_notify_preq(struct wpa_supplicant *wpa_s,
1011 const u8 *addr, const u8 *dst, const u8 *bssid,
1012 const u8 *ie, size_t ie_len, u32 ssi_signal)
1013{
1014#ifdef CONFIG_AP
1015 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
1016#endif /* CONFIG_AP */
1017}
1018
1019
1020void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
1021 const char *parameter)
1022{
1023 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -07001024 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
1025 "status='%s' parameter='%s'",
1026 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -07001027}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001028
Roshan Pius3a1667e2018-07-03 15:17:14 -07001029
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -07001030void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
1031{
1032 wpa_dbg(wpa_s, MSG_ERROR,
1033 "EAP Error code = %d", error_code);
Gabriel Biren57ededa2021-09-03 16:08:50 +00001034 wpas_aidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -07001035}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001036
Roshan Pius3a1667e2018-07-03 15:17:14 -07001037
Sunil Ravi036cec52023-03-29 11:35:17 -07001038void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
1039{
1040 wpas_dbus_signal_psk_mismatch(wpa_s);
1041}
1042
1043
Dmitry Shmidt661b4f72014-09-29 14:58:27 -07001044void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
1045 struct wpa_ssid *ssid)
1046{
1047 if (wpa_s->current_ssid != ssid)
1048 return;
1049
1050 wpa_dbg(wpa_s, MSG_DEBUG,
1051 "Network bssid config changed for the current network - within-ESS roaming %s",
1052 ssid->bssid_set ? "disabled" : "enabled");
1053
1054 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
1055 ssid->bssid_set ? ssid->bssid : NULL);
1056}
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001057
1058
1059void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
1060 struct wpa_ssid *ssid)
1061{
1062#ifdef CONFIG_P2P
1063 if (ssid->disabled == 2) {
1064 /* Changed from normal network profile to persistent group */
1065 ssid->disabled = 0;
1066 wpas_dbus_unregister_network(wpa_s, ssid->id);
1067 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -07001068 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001069 wpas_dbus_register_persistent_group(wpa_s, ssid);
1070 } else {
1071 /* Changed from persistent group to normal network profile */
1072 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -07001073 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001074 wpas_dbus_register_network(wpa_s, ssid);
1075 }
1076#endif /* CONFIG_P2P */
1077}
Roshan Pius04a9d742016-12-12 12:40:46 -08001078
1079void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1080 const char *result,
1081 const struct wpa_bss_anqp *anqp)
1082{
Sunil Ravi99c035e2024-07-12 01:42:03 +00001083 wpa_msg(wpa_s, MSG_INFO, ANQP_QUERY_DONE "addr=" MACSTR " result=%s",
1084 MAC2STR(bssid), result);
Roshan Pius04a9d742016-12-12 12:40:46 -08001085#ifdef CONFIG_INTERWORKING
1086 if (!wpa_s || !bssid || !anqp)
1087 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001088
Gabriel Biren57ededa2021-09-03 16:08:50 +00001089 wpas_aidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Sunil Ravi99c035e2024-07-12 01:42:03 +00001090 wpas_dbus_signal_anqp_query_done(wpa_s, bssid, result);
Roshan Pius04a9d742016-12-12 12:40:46 -08001091#endif /* CONFIG_INTERWORKING */
1092}
1093
1094void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1095 const char* file_name, const u8* image,
1096 u32 image_length)
1097{
1098#ifdef CONFIG_HS20
1099 if (!wpa_s || !bssid || !file_name || !image)
1100 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001101
Gabriel Biren57ededa2021-09-03 16:08:50 +00001102 wpas_aidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
Roshan Pius9322a342016-12-12 14:45:02 -08001103 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -08001104#endif /* CONFIG_HS20 */
1105}
1106
1107void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
1108 const char* url,
1109 u8 osu_method)
1110{
1111#ifdef CONFIG_HS20
1112 if (!wpa_s || !url)
1113 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001114
Gabriel Biren57ededa2021-09-03 16:08:50 +00001115 wpas_aidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -08001116#endif /* CONFIG_HS20 */
1117}
1118
1119void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1120 u8 code, u16 reauth_delay,
1121 const char *url)
1122{
1123#ifdef CONFIG_HS20
Hai Shalomb3a7c702020-10-20 12:22:53 -07001124 if (!wpa_s)
Roshan Pius04a9d742016-12-12 12:40:46 -08001125 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001126
Gabriel Biren57ededa2021-09-03 16:08:50 +00001127 wpas_aidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
Hai Shalom04a4ca62020-10-28 19:04:47 -07001128 url);
Roshan Pius04a9d742016-12-12 12:40:46 -08001129#endif /* CONFIG_HS20 */
1130}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001131
1132
1133#ifdef CONFIG_MESH
1134
1135void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1136 struct wpa_ssid *ssid)
1137{
1138 if (wpa_s->p2p_mgmt)
1139 return;
1140
1141 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1142}
1143
1144
1145void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1146 const u8 *meshid, u8 meshid_len,
Hai Shalom81f62d82019-07-22 12:10:00 -07001147 u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001148{
1149 if (wpa_s->p2p_mgmt)
1150 return;
1151
1152 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1153 reason_code);
1154}
1155
1156
1157void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1158 const u8 *peer_addr)
1159{
1160 if (wpa_s->p2p_mgmt)
1161 return;
1162
Sunil Ravi2a14cf12023-11-21 00:54:38 +00001163 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
1164 MAC2STR(peer_addr));
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001165 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1166}
1167
1168
1169void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
Hai Shalom81f62d82019-07-22 12:10:00 -07001170 const u8 *peer_addr, u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001171{
1172 if (wpa_s->p2p_mgmt)
1173 return;
1174
Sunil Ravi2a14cf12023-11-21 00:54:38 +00001175 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
1176 MAC2STR(peer_addr));
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001177 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1178}
1179
1180#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001181
1182/*
1183 * DPP Notifications
1184 */
1185
1186/* DPP Success notifications */
1187
Hai Shalom706f99b2019-01-08 16:23:37 -08001188void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Sunil Ravi546a7b52022-08-26 22:06:04 +00001189 struct wpa_ssid *ssid, bool conn_status_requested)
Hai Shalom59532852018-12-07 10:32:58 -08001190{
1191#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001192 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001193 return;
1194
Sunil Ravi546a7b52022-08-26 22:06:04 +00001195 wpas_aidl_notify_dpp_config_received(wpa_s, ssid, conn_status_requested);
Hai Shalom59532852018-12-07 10:32:58 -08001196#endif /* CONFIG_DPP */
1197}
1198
Hai Shalom706f99b2019-01-08 16:23:37 -08001199void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001200{
1201#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001202 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001203 return;
1204
Gabriel Biren57ededa2021-09-03 16:08:50 +00001205 wpas_aidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001206#endif /* CONFIG_DPP */
1207}
1208
Sunil Ravi546a7b52022-08-26 22:06:04 +00001209void wpas_notify_dpp_connection_status_sent(struct wpa_supplicant *wpa_s,
1210 enum dpp_status_error result)
1211{
1212#ifdef CONFIG_DPP2
1213 if (!wpa_s)
1214 return;
1215
1216 wpas_aidl_notify_dpp_connection_status_sent(wpa_s, result);
1217#endif /* CONFIG_DPP2 */
1218}
1219
Hai Shalom59532852018-12-07 10:32:58 -08001220/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001221void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001222{
1223#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001224 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001225 return;
1226
Gabriel Biren57ededa2021-09-03 16:08:50 +00001227 wpas_aidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001228#endif /* CONFIG_DPP */
1229}
1230
Hai Shalom706f99b2019-01-08 16:23:37 -08001231void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001232{
1233#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001234 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001235 return;
1236
Gabriel Biren57ededa2021-09-03 16:08:50 +00001237 wpas_aidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001238#endif /* CONFIG_DPP */
1239}
1240
1241/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001242void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001243{
1244#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001245 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001246 return;
1247
Gabriel Biren57ededa2021-09-03 16:08:50 +00001248 wpas_aidl_notify_dpp_not_compatible(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001249#endif /* CONFIG_DPP */
1250}
1251
Hai Shalom706f99b2019-01-08 16:23:37 -08001252void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001253{
1254#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001255 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001256 return;
1257
Gabriel Biren57ededa2021-09-03 16:08:50 +00001258 wpas_aidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001259#endif /* CONFIG_DPP */
1260}
1261
Hai Shalom706f99b2019-01-08 16:23:37 -08001262void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001263{
1264#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001265 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001266 return;
1267
Gabriel Biren57ededa2021-09-03 16:08:50 +00001268 wpas_aidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001269#endif /* CONFIG_DPP */
1270}
1271
Hai Shalom706f99b2019-01-08 16:23:37 -08001272void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001273{
1274#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001275 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001276 return;
1277
Gabriel Biren57ededa2021-09-03 16:08:50 +00001278 wpas_aidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001279#endif /* CONFIG_DPP */
1280}
1281
Hai Shalom706f99b2019-01-08 16:23:37 -08001282void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001283{
1284#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001285 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001286 return;
1287
Gabriel Biren57ededa2021-09-03 16:08:50 +00001288 wpas_aidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001289#endif /* CONFIG_DPP */
1290}
1291
Hai Shalom706f99b2019-01-08 16:23:37 -08001292void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001293{
1294#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001295 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001296 return;
1297
Gabriel Biren57ededa2021-09-03 16:08:50 +00001298 wpas_aidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001299#endif /* CONFIG_DPP */
1300}
Jimmy Chen126b1702019-08-28 17:59:33 +08001301
Hai Shalom06768112019-12-04 15:49:43 -08001302void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1303{
1304#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001305 wpas_aidl_notify_dpp_config_sent_wait_response(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001306#endif /* CONFIG_DPP2 */
1307}
1308
1309void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1310{
1311#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001312 wpas_aidl_notify_dpp_config_accepted(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001313#endif /* CONFIG_DPP2 */
1314}
1315
1316void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1317 enum dpp_status_error status, const char *ssid,
1318 const char *channel_list, unsigned short band_list[], int size)
1319{
1320#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001321 wpas_aidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
Hai Shalom06768112019-12-04 15:49:43 -08001322#endif /* CONFIG_DPP2 */
1323}
1324
1325void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1326{
1327#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001328 wpas_aidl_notify_dpp_config_rejected(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001329#endif /* CONFIG_DPP2 */
1330}
1331
Jimmy Chen126b1702019-08-28 17:59:33 +08001332void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1333 struct rsn_pmksa_cache_entry *entry)
1334{
1335 if (!wpa_s)
1336 return;
1337
Gabriel Biren57ededa2021-09-03 16:08:50 +00001338 wpas_aidl_notify_pmk_cache_added(wpa_s, entry);
Jimmy Chen126b1702019-08-28 17:59:33 +08001339}
Jimmy Chen39deead2020-10-14 23:47:20 +08001340
1341void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
1342 struct wpa_ssid *ssid,
1343 u8 bitmap)
1344{
1345 if (!wpa_s)
1346 return;
1347
1348 if (!ssid)
1349 return;
1350
Gabriel Biren57ededa2021-09-03 16:08:50 +00001351 wpas_aidl_notify_transition_disable(wpa_s, ssid, bitmap);
Jimmy Chen39deead2020-10-14 23:47:20 +08001352}
Sunil Ravi07c17622021-01-11 12:00:53 -08001353
1354void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s)
1355{
1356 if (!wpa_s)
1357 return;
1358
Gabriel Biren57ededa2021-09-03 16:08:50 +00001359 wpas_aidl_notify_network_not_found(wpa_s);
Sunil Ravi07c17622021-01-11 12:00:53 -08001360}
Hai Shalomc1a21442022-02-04 13:43:00 -08001361
1362#ifdef CONFIG_INTERWORKING
1363
1364void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
1365 struct wpa_bss *bss,
1366 struct wpa_cred *cred, int excluded,
1367 const char *type, int bh, int bss_load,
1368 int conn_capab)
1369{
1370 wpa_msg(wpa_s, MSG_INFO, "%s" MACSTR " type=%s%s%s%s id=%d priority=%d sp_priority=%d",
1371 excluded ? INTERWORKING_EXCLUDED : INTERWORKING_AP,
1372 MAC2STR(bss->bssid), type,
1373 bh ? " below_min_backhaul=1" : "",
1374 bss_load ? " over_max_bss_load=1" : "",
1375 conn_capab ? " conn_capab_missing=1" : "",
1376 cred->id, cred->priority, cred->sp_priority);
1377
1378 wpas_dbus_signal_interworking_ap_added(wpa_s, bss, cred, type, excluded,
1379 bh, bss_load, conn_capab);
1380}
1381
1382
1383void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
1384{
1385 wpas_dbus_signal_interworking_select_done(wpa_s);
1386}
1387
Sunil Ravi99c035e2024-07-12 01:42:03 +00001388
Hai Shalomc1a21442022-02-04 13:43:00 -08001389#endif /* CONFIG_INTERWORKING */
1390
Gabriel Biren3a2ec2c2022-03-07 17:59:41 +00001391void wpas_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
1392 const char* reason_string)
1393{
1394 wpas_aidl_notify_eap_method_selected(wpa_s, reason_string);
1395}
1396
1397void wpas_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
1398 const char *reason_string)
1399{
1400 wpas_aidl_notify_ssid_temp_disabled(wpa_s, reason_string);
1401}
1402
1403void wpas_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
1404 const char *reason_string)
1405{
1406 wpas_aidl_notify_open_ssl_failure(wpa_s, reason_string);
1407}
Shivani Baranwal84940f82022-02-02 10:21:47 +05301408
1409void wpas_notify_qos_policy_reset(struct wpa_supplicant *wpa_s)
1410{
1411 if (!wpa_s)
1412 return;
1413
1414 wpas_aidl_notify_qos_policy_reset(wpa_s);
1415}
1416
1417void wpas_notify_qos_policy_request(struct wpa_supplicant *wpa_s,
1418 struct dscp_policy_data *policies, int num_policies)
1419{
1420 if (!wpa_s || !policies)
1421 return;
1422
1423 wpas_aidl_notify_qos_policy_request(wpa_s, policies, num_policies);
1424}
Sunil Ravi65a724b2022-05-24 11:06:09 -07001425
1426void wpas_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency)
1427{
1428 if (!wpa_s)
1429 return;
1430
1431 wpas_aidl_notify_frequency_changed(wpa_s, frequency);
1432}
Gabriel Biren93398232022-12-15 19:18:28 +00001433
1434ssize_t wpas_get_certificate(const char *alias, uint8_t** value)
1435{
Gabriel Biren980c48a2023-03-27 21:49:21 +00001436 wpa_printf(MSG_INFO, "wpas_get_certificate");
Gabriel Biren93398232022-12-15 19:18:28 +00001437 return wpas_aidl_get_certificate(alias, value);
1438}
Sunil Ravi77d572f2023-01-17 23:58:31 +00001439
Xinyue Ling1629ad82023-03-24 16:19:51 +08001440ssize_t wpas_list_aliases(const char *prefix, char ***aliases)
1441{
1442 return wpas_aidl_list_aliases(prefix, aliases);
1443}
Sunil Ravi77d572f2023-01-17 23:58:31 +00001444
1445void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
1446{
1447 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
1448}
Swarn Singhc450e7b2023-03-28 17:36:22 +05301449
1450void wpas_notify_qos_policy_scs_response(struct wpa_supplicant *wpa_s,
1451 unsigned int num_scs_resp, int **scs_resp)
1452{
1453 if (!wpa_s || !num_scs_resp || !scs_resp)
1454 return;
1455
1456 wpas_aidl_notify_qos_policy_scs_response(wpa_s, num_scs_resp, scs_resp);
1457}
Sunil Ravib0ac25f2024-07-12 01:42:03 +00001458
1459void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
1460 const char *url)
1461{
1462#ifdef CONFIG_HS20
1463 if (!wpa_s || !url)
1464 return;
1465
1466 wpa_msg(wpa_s, MSG_INFO, HS20_T_C_ACCEPTANCE "%s", url);
1467 wpas_aidl_notify_hs20_rx_terms_and_conditions_acceptance(wpa_s, url);
1468 wpas_dbus_signal_hs20_t_c_acceptance(wpa_s, url);
1469#endif /* CONFIG_HS20 */
1470}
Sunil Ravic0f5d412024-09-11 22:12:49 +00001471
1472#ifdef CONFIG_NAN_USD
1473
1474void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
1475 enum nan_service_protocol_type
1476 srv_proto_type,
1477 int subscribe_id, int peer_publish_id,
1478 const u8 *peer_addr,
1479 bool fsd, bool fsd_gas,
1480 const u8 *ssi, size_t ssi_len)
1481{
1482 char *ssi_hex;
1483
1484 ssi_hex = os_zalloc(2 * ssi_len + 1);
1485 if (!ssi_hex)
1486 return;
1487 if (ssi)
1488 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1489 wpa_msg(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT
1490 "subscribe_id=%d publish_id=%d address=" MACSTR
1491 " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s",
1492 subscribe_id, peer_publish_id, MAC2STR(peer_addr),
1493 fsd, fsd_gas, srv_proto_type, ssi_hex);
1494 os_free(ssi_hex);
1495}
1496
1497
1498void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s,
1499 enum nan_service_protocol_type srv_proto_type,
1500 int publish_id, int peer_subscribe_id,
1501 const u8 *peer_addr,
1502 const u8 *ssi, size_t ssi_len)
1503{
1504 char *ssi_hex;
1505
1506 ssi_hex = os_zalloc(2 * ssi_len + 1);
1507 if (!ssi_hex)
1508 return;
1509 if (ssi)
1510 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1511 wpa_msg(wpa_s, MSG_INFO, NAN_REPLIED
1512 "publish_id=%d address=" MACSTR
1513 " subscribe_id=%d srv_proto_type=%u ssi=%s",
1514 publish_id, MAC2STR(peer_addr), peer_subscribe_id,
1515 srv_proto_type, ssi_hex);
1516 os_free(ssi_hex);
1517}
1518
1519
1520void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id,
1521 int peer_instance_id, 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_RECEIVE
1532 "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s",
1533 id, peer_instance_id, MAC2STR(peer_addr), ssi_hex);
1534 os_free(ssi_hex);
1535}
1536
1537
1538static const char * nan_reason_txt(enum nan_de_reason reason)
1539{
1540 switch (reason) {
1541 case NAN_DE_REASON_TIMEOUT:
1542 return "timeout";
1543 case NAN_DE_REASON_USER_REQUEST:
1544 return "user-request";
1545 case NAN_DE_REASON_FAILURE:
1546 return "failure";
1547 }
1548
1549 return "unknown";
1550}
1551
1552
1553void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s,
1554 int publish_id,
1555 enum nan_de_reason reason)
1556{
1557 wpa_msg(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED
1558 "publish_id=%d reason=%s",
1559 publish_id, nan_reason_txt(reason));
1560}
1561
1562
1563void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s,
1564 int subscribe_id,
1565 enum nan_de_reason reason)
1566{
1567 wpa_msg(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED
1568 "subscribe_id=%d reason=%s",
1569 subscribe_id, nan_reason_txt(reason));
1570}
1571
1572#endif /* CONFIG_NAN_USD */