blob: a2bd48822a9eb39f74411cc83e838ec321133245 [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"
13#include "config.h"
14#include "wpa_supplicant_i.h"
15#include "wps_supplicant.h"
16#include "dbus/dbus_common.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070017#include "dbus/dbus_new.h"
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080018#include "rsn_supp/wpa.h"
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080019#include "fst/fst.h"
Hai Shalom81f62d82019-07-22 12:10:00 -070020#include "crypto/tls.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070021#include "driver_i.h"
22#include "scan.h"
23#include "p2p_supplicant.h"
24#include "sme.h"
25#include "notify.h"
Gabriel Biren57ededa2021-09-03 16:08:50 +000026#include "aidl.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070027
28int wpas_notify_supplicant_initialized(struct wpa_global *global)
29{
Hai Shalom021b0b52019-04-10 11:17:58 -070030#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070031 if (global->params.dbus_ctrl_interface) {
32 global->dbus = wpas_dbus_init(global);
33 if (global->dbus == NULL)
34 return -1;
35 }
Hai Shalom021b0b52019-04-10 11:17:58 -070036#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070037
Gabriel Biren57ededa2021-09-03 16:08:50 +000038#ifdef CONFIG_AIDL
39 global->aidl = wpas_aidl_init(global);
40 if (!global->aidl)
Dmitry Shmidte4663042016-04-04 10:07:49 -070041 return -1;
Gabriel Biren57ededa2021-09-03 16:08:50 +000042#endif /* CONFIG_AIDL */
Dmitry Shmidte4663042016-04-04 10:07:49 -070043
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070044 return 0;
45}
46
47
48void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
49{
Hai Shalom021b0b52019-04-10 11:17:58 -070050#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070051 if (global->dbus)
52 wpas_dbus_deinit(global->dbus);
Hai Shalom021b0b52019-04-10 11:17:58 -070053#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
Dmitry Shmidte4663042016-04-04 10:07:49 -070054
Gabriel Biren57ededa2021-09-03 16:08:50 +000055#ifdef CONFIG_AIDL
56 if (global->aidl)
57 wpas_aidl_deinit(global->aidl);
58#endif /* CONFIG_AIDL */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070059}
60
61
62int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
63{
Hai Shalomc4809952019-04-30 14:45:55 -070064 if (!wpa_s->p2p_mgmt) {
65 if (wpas_dbus_register_interface(wpa_s))
66 return -1;
67 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070068
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080069 /* HIDL interface wants to keep track of the P2P mgmt iface. */
Gabriel Biren57ededa2021-09-03 16:08:50 +000070 if (wpas_aidl_register_interface(wpa_s))
Roshan Pius54e763a2016-07-06 15:41:53 -070071 return -1;
72
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070073 return 0;
74}
75
76
77void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
78{
Hai Shalomc4809952019-04-30 14:45:55 -070079 if (!wpa_s->p2p_mgmt) {
80 /* unregister interface in new DBus ctrl iface */
81 wpas_dbus_unregister_interface(wpa_s);
82 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070083
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080084 /* HIDL interface wants to keep track of the P2P mgmt iface. */
Gabriel Biren57ededa2021-09-03 16:08:50 +000085 wpas_aidl_unregister_interface(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070086}
87
88
89void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
90 enum wpa_states new_state,
91 enum wpa_states old_state)
92{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080093 if (wpa_s->p2p_mgmt)
94 return;
95
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070096 /* notify the new DBus API */
97 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
98
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080099#ifdef CONFIG_FST
100 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
101 if (new_state == WPA_COMPLETED)
102 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
103 else if (old_state >= WPA_ASSOCIATED &&
104 new_state < WPA_ASSOCIATED)
105 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
106 }
107#endif /* CONFIG_FST */
108
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700109 if (new_state == WPA_COMPLETED)
110 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700111 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700112 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700113
114 sme_state_changed(wpa_s);
115
116#ifdef ANDROID
117 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700118 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700119 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700120 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700121 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700122 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
123 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800124 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700125#endif /* ANDROID */
Roshan Piuse8d0d162016-08-01 13:09:26 -0700126
Gabriel Biren57ededa2021-09-03 16:08:50 +0000127 wpas_aidl_notify_state_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700128}
129
130
Dmitry Shmidt04949592012-07-19 12:16:46 -0700131void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
132{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800133 if (wpa_s->p2p_mgmt)
134 return;
135
Dmitry Shmidt04949592012-07-19 12:16:46 -0700136 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
Roshan Pius0974e962016-12-12 17:05:51 -0800137
Gabriel Biren57ededa2021-09-03 16:08:50 +0000138 wpas_aidl_notify_disconnect_reason(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700139}
140
141
Hai Shalom74f70d42019-02-11 14:42:39 -0800142void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
143{
144 if (wpa_s->p2p_mgmt)
145 return;
146
147 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
148}
149
150
Sunil Ravi972b2042020-08-14 10:50:48 -0700151void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s,
Sunil Ravie06118e2021-01-03 08:39:46 -0800152 const u8 *bssid, u8 timed_out,
153 const u8 *assoc_resp_ie, size_t assoc_resp_ie_len)
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800154{
155 if (wpa_s->p2p_mgmt)
156 return;
157
158 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
Roshan Pius0974e962016-12-12 17:05:51 -0800159
Gabriel Biren57ededa2021-09-03 16:08:50 +0000160 wpas_aidl_notify_assoc_reject(wpa_s, bssid, timed_out, assoc_resp_ie, assoc_resp_ie_len);
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800161}
162
Roshan Pius38e96762017-01-23 14:52:00 -0800163void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
164 if (wpa_s->p2p_mgmt)
165 return;
166
Gabriel Biren57ededa2021-09-03 16:08:50 +0000167 wpas_aidl_notify_auth_timeout(wpa_s);
Roshan Pius38e96762017-01-23 14:52:00 -0800168}
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800169
Hai Shalom74f70d42019-02-11 14:42:39 -0800170void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
171{
172 if (wpa_s->p2p_mgmt)
173 return;
174
175 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
176}
177
178
179void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
180{
181 if (wpa_s->p2p_mgmt)
182 return;
183
184 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
185}
186
187
188void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
189{
190 if (wpa_s->p2p_mgmt)
191 return;
192
193 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
194}
195
196
197void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
198{
199 if (wpa_s->p2p_mgmt)
200 return;
201
202 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
Sunil Ravi4018d712019-12-06 18:01:21 -0800203
204#ifdef CONFIG_WNM
Gabriel Biren57ededa2021-09-03 16:08:50 +0000205 wpas_aidl_notify_bss_tm_status(wpa_s);
Sunil Ravi4018d712019-12-06 18:01:21 -0800206#endif
Hai Shalom74f70d42019-02-11 14:42:39 -0800207}
208
209
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700210void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
211{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800212 if (wpa_s->p2p_mgmt)
213 return;
214
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700215 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
216}
217
218
219void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
220{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800221 if (wpa_s->p2p_mgmt)
222 return;
223
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700224 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
225}
226
227
228void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
229{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800230 if (wpa_s->p2p_mgmt)
231 return;
232
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700233 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700234
Gabriel Biren57ededa2021-09-03 16:08:50 +0000235 wpas_aidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700236}
237
238
239void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
240{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800241 if (wpa_s->p2p_mgmt)
242 return;
243
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700244 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
245}
246
247
248void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
249 struct wpa_ssid *ssid)
250{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800251 if (wpa_s->p2p_mgmt)
252 return;
253
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700254 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
255}
256
257
258void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
259 struct wpa_ssid *ssid)
260{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800261 if (wpa_s->p2p_mgmt)
262 return;
263
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700264 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
265}
266
267
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800268void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
269 struct wpa_ssid *ssid,
270 enum wpa_ctrl_req_type rtype,
271 const char *default_txt)
272{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800273 if (wpa_s->p2p_mgmt)
274 return;
275
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800276 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700277
Gabriel Biren57ededa2021-09-03 16:08:50 +0000278 wpas_aidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800279}
280
281
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700282void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
283{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800284 if (wpa_s->p2p_mgmt)
285 return;
286
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700287 /* notify the new DBus API */
288 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
289}
290
291
292void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
293{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800294 if (wpa_s->p2p_mgmt)
295 return;
296
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700297 wpas_dbus_signal_scan_done(wpa_s, success);
298}
299
300
301void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
302{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800303 if (wpa_s->p2p_mgmt)
304 return;
305
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700306 wpas_wps_notify_scan_results(wpa_s);
307}
308
309
310void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
311 const struct wps_credential *cred)
312{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800313 if (wpa_s->p2p_mgmt)
314 return;
315
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700316#ifdef CONFIG_WPS
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700317 /* notify the new DBus API */
318 wpas_dbus_signal_wps_cred(wpa_s, cred);
319#endif /* CONFIG_WPS */
320}
321
322
323void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
324 struct wps_event_m2d *m2d)
325{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800326 if (wpa_s->p2p_mgmt)
327 return;
328
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700329#ifdef CONFIG_WPS
330 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
331#endif /* CONFIG_WPS */
332}
333
334
335void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
336 struct wps_event_fail *fail)
337{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800338 if (wpa_s->p2p_mgmt)
339 return;
340
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700341#ifdef CONFIG_WPS
342 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800343
Gabriel Biren57ededa2021-09-03 16:08:50 +0000344 wpas_aidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
Roshan Pius14932752017-01-11 09:48:58 -0800345 fail->config_error,
346 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700347#endif /* CONFIG_WPS */
348}
349
350
351void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
352{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800353 if (wpa_s->p2p_mgmt)
354 return;
355
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700356#ifdef CONFIG_WPS
357 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800358
Gabriel Biren57ededa2021-09-03 16:08:50 +0000359 wpas_aidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700360#endif /* CONFIG_WPS */
361}
362
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700363void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
364{
365 if (wpa_s->p2p_mgmt)
366 return;
367
368#ifdef CONFIG_WPS
369 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800370
Gabriel Biren57ededa2021-09-03 16:08:50 +0000371 wpas_aidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700372#endif /* CONFIG_WPS */
373}
374
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700375
376void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
377 struct wpa_ssid *ssid)
378{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800379 if (wpa_s->p2p_mgmt)
380 return;
381
Jouni Malinen75ecf522011-06-27 15:19:46 -0700382 /*
383 * Networks objects created during any P2P activities should not be
384 * exposed out. They might/will confuse certain non-P2P aware
385 * applications since these network objects won't behave like
386 * regular ones.
387 */
Roshan Piusd3854452016-07-07 16:46:41 -0700388 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700389 wpas_dbus_register_network(wpa_s, ssid);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000390 wpas_aidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700391 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700392}
393
394
395void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
396 struct wpa_ssid *ssid)
397{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700398#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700399 wpas_dbus_register_persistent_group(wpa_s, ssid);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000400 wpas_aidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700401#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700402}
403
404
405void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
406 struct wpa_ssid *ssid)
407{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700408#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700409 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000410 wpas_aidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700411#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700412}
413
414
415void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
416 struct wpa_ssid *ssid)
417{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800418 if (wpa_s->next_ssid == ssid)
419 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800420 if (wpa_s->wpa)
421 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700422 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700423 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700424 wpas_dbus_unregister_network(wpa_s, ssid->id);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000425 wpas_aidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700426 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800427 if (network_is_persistent_group(ssid))
428 wpas_notify_persistent_group_removed(wpa_s, ssid);
429
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800430 wpas_p2p_network_removed(wpa_s, ssid);
Hai Shalom60840252021-02-19 19:02:11 -0800431
432#ifdef CONFIG_PASN
433 if (wpa_s->pasn.ssid == ssid)
434 wpa_s->pasn.ssid = NULL;
435#endif /* CONFIG_PASN */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700436}
437
438
439void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
440 u8 bssid[], unsigned int id)
441{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800442 if (wpa_s->p2p_mgmt)
443 return;
444
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700445 wpas_dbus_register_bss(wpa_s, bssid, id);
446 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
447 id, MAC2STR(bssid));
448}
449
450
451void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
452 u8 bssid[], unsigned int id)
453{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800454 if (wpa_s->p2p_mgmt)
455 return;
456
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700457 wpas_dbus_unregister_bss(wpa_s, bssid, id);
458 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
459 id, MAC2STR(bssid));
460}
461
462
463void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
464 unsigned int id)
465{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800466 if (wpa_s->p2p_mgmt)
467 return;
468
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700469 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
Sunil Ravi23087aa2021-12-08 19:01:44 -0800470
471 wpas_aidl_notify_bss_freq_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700472}
473
474
475void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
476 unsigned int id)
477{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800478 if (wpa_s->p2p_mgmt)
479 return;
480
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700481 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
482 id);
483}
484
485
486void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
487 unsigned int id)
488{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800489 if (wpa_s->p2p_mgmt)
490 return;
491
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700492 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
493 id);
494}
495
496
497void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
498 unsigned int id)
499{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800500 if (wpa_s->p2p_mgmt)
501 return;
502
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700503 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
504}
505
506
507void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
508 unsigned int id)
509{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800510 if (wpa_s->p2p_mgmt)
511 return;
512
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700513 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
514}
515
516
517void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
518 unsigned int id)
519{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800520 if (wpa_s->p2p_mgmt)
521 return;
522
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700523 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
524}
525
526
527void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
528 unsigned int id)
529{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800530 if (wpa_s->p2p_mgmt)
531 return;
532
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800533#ifdef CONFIG_WPS
534 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
535#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700536}
537
538
539void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
540 unsigned int id)
541{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800542 if (wpa_s->p2p_mgmt)
543 return;
544
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700545 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
546}
547
548
549void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
550 unsigned int id)
551{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800552 if (wpa_s->p2p_mgmt)
553 return;
554
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700555 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
556}
557
558
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700559void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
560{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800561 if (wpa_s->p2p_mgmt)
562 return;
563
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700564 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
565}
566
567
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700568void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
569{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800570 if (wpa_s->p2p_mgmt)
571 return;
572
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700573 wpas_dbus_signal_blob_added(wpa_s, name);
574}
575
576
577void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
578{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800579 if (wpa_s->p2p_mgmt)
580 return;
581
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700582 wpas_dbus_signal_blob_removed(wpa_s, name);
583}
584
585
586void wpas_notify_debug_level_changed(struct wpa_global *global)
587{
588 wpas_dbus_signal_debug_level_changed(global);
589}
590
591
592void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
593{
594 wpas_dbus_signal_debug_timestamp_changed(global);
595}
596
597
598void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
599{
600 wpas_dbus_signal_debug_show_keys_changed(global);
601}
602
603
604void wpas_notify_suspend(struct wpa_global *global)
605{
606 struct wpa_supplicant *wpa_s;
607
608 os_get_time(&global->suspend_time);
609 wpa_printf(MSG_DEBUG, "System suspend notification");
610 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
611 wpa_drv_suspend(wpa_s);
612}
613
614
615void wpas_notify_resume(struct wpa_global *global)
616{
617 struct os_time now;
618 int slept;
619 struct wpa_supplicant *wpa_s;
620
621 if (global->suspend_time.sec == 0)
622 slept = -1;
623 else {
624 os_get_time(&now);
625 slept = now.sec - global->suspend_time.sec;
626 }
627 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
628 slept);
629
630 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
631 wpa_drv_resume(wpa_s);
632 if (wpa_s->wpa_state == WPA_DISCONNECTED)
633 wpa_supplicant_req_scan(wpa_s, 0, 100000);
634 }
635}
636
637
638#ifdef CONFIG_P2P
639
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700640void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
641{
642 /* Notify P2P find has stopped */
643 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800644
Gabriel Biren57ededa2021-09-03 16:08:50 +0000645 wpas_aidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700646}
647
648
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700649void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800650 const u8 *addr, const struct p2p_peer_info *info,
651 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
Jimmy Chen0133fc12021-03-04 13:56:11 +0800652 const u8* peer_wfd_r2_device_info, u8 peer_wfd_r2_device_info_len,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800653 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700654{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700655 if (new_device) {
656 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800657 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700658 }
659
660 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800661 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
662
Gabriel Biren57ededa2021-09-03 16:08:50 +0000663 wpas_aidl_notify_p2p_device_found(wpa_s, addr, info,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800664 peer_wfd_device_info,
Jimmy Chen57e19f52021-03-04 14:19:52 +0800665 peer_wfd_device_info_len,
666 peer_wfd_r2_device_info,
667 peer_wfd_r2_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700668}
669
670
671void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
672 const u8 *dev_addr)
673{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700674 wpas_dbus_unregister_peer(wpa_s, dev_addr);
675
676 /* Create signal on interface object*/
677 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800678
Gabriel Biren57ededa2021-09-03 16:08:50 +0000679 wpas_aidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700680}
681
682
683void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
684 const struct wpa_ssid *ssid,
685 const char *role)
686{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700687 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700688
689 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800690
Gabriel Biren57ededa2021-09-03 16:08:50 +0000691 wpas_aidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700692}
693
694
695void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700696 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700697{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700698 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800699
Gabriel Biren57ededa2021-09-03 16:08:50 +0000700 wpas_aidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700701}
702
703
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800704void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
705 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700706{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800707 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800708
Gabriel Biren57ededa2021-09-03 16:08:50 +0000709 wpas_aidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700710}
711
712
713void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
714 int status, const u8 *bssid)
715{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700716 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800717
Gabriel Biren57ededa2021-09-03 16:08:50 +0000718 wpas_aidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700719}
720
721
722void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
723 int freq, const u8 *sa, u8 dialog_token,
724 u16 update_indic, const u8 *tlvs,
725 size_t tlvs_len)
726{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700727 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
728 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700729}
730
731
732void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
733 const u8 *sa, u16 update_indic,
734 const u8 *tlvs, size_t tlvs_len)
735{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700736 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
737 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800738
Gabriel Biren57ededa2021-09-03 16:08:50 +0000739 wpas_aidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800740 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700741}
742
743
744/**
745 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
746 * @dev_addr: Who sent the request or responded to our request.
747 * @request: Will be 1 if request, 0 for response.
748 * @status: Valid only in case of response (0 in case of success)
749 * @config_methods: WPS config methods
750 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
751 *
752 * This can be used to notify:
753 * - Requests or responses
754 * - Various config methods
755 * - Failure condition in case of response
756 */
757void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
758 const u8 *dev_addr, int request,
759 enum p2p_prov_disc_status status,
760 u16 config_methods,
761 unsigned int generated_pin)
762{
763 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
764 status, config_methods,
765 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800766
Gabriel Biren57ededa2021-09-03 16:08:50 +0000767 wpas_aidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800768 status, config_methods,
769 generated_pin);
770
Jouni Malinen75ecf522011-06-27 15:19:46 -0700771}
772
773
774void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700775 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800776 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700777{
778 /* Notify a group has been started */
779 wpas_dbus_register_p2p_group(wpa_s, ssid);
780
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800781 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800782
Gabriel Biren57ededa2021-09-03 16:08:50 +0000783 wpas_aidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700784}
785
786
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800787void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
788 const char *reason)
789{
790 /* Notify a group formation failed */
791 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800792
Gabriel Biren57ededa2021-09-03 16:08:50 +0000793 wpas_aidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800794}
795
796
Jouni Malinen75ecf522011-06-27 15:19:46 -0700797void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
798 struct wps_event_fail *fail)
799{
800 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700801}
802
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800803
804void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
805 const u8 *sa, const u8 *go_dev_addr,
806 const u8 *bssid, int id, int op_freq)
807{
808 /* Notify a P2P Invitation Request */
809 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
810 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800811
Gabriel Biren57ededa2021-09-03 16:08:50 +0000812 wpas_aidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800813 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800814}
815
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700816#endif /* CONFIG_P2P */
817
818
819static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800820 const u8 *sta,
821 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700822{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700823#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800824 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
825
Jouni Malinen75ecf522011-06-27 15:19:46 -0700826 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700827 * Create 'peer-joined' signal on group object -- will also
828 * check P2P itself.
829 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800830 if (p2p_dev_addr)
831 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700832#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700833
Hai Shalom74f70d42019-02-11 14:42:39 -0800834 /* Register the station */
835 wpas_dbus_register_sta(wpa_s, sta);
836
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700837 /* Notify listeners a new station has been authorized */
838 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800839
Gabriel Biren57ededa2021-09-03 16:08:50 +0000840 wpas_aidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700841}
842
843
844static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700845 const u8 *sta,
846 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700847{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700848#ifdef CONFIG_P2P
849 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700850 * Create 'peer-disconnected' signal on group object if this
851 * is a P2P group.
852 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800853 if (p2p_dev_addr)
854 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700855#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700856
857 /* Notify listeners a station has been deauthorized */
858 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800859
Gabriel Biren57ededa2021-09-03 16:08:50 +0000860 wpas_aidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Hai Shalom74f70d42019-02-11 14:42:39 -0800861 /* Unregister the station */
862 wpas_dbus_unregister_sta(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700863}
864
865
866void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800867 const u8 *mac_addr, int authorized,
868 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700869{
870 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800871 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700872 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700873 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700874}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700875
876
Hai Shalom81f62d82019-07-22 12:10:00 -0700877void wpas_notify_certification(struct wpa_supplicant *wpa_s,
878 struct tls_cert_data *cert,
879 const char *cert_hash)
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700880{
Hai Shalom81f62d82019-07-22 12:10:00 -0700881 int i;
Hai Shalom878cf7b2019-07-15 14:55:18 -0700882
Hai Shalom81f62d82019-07-22 12:10:00 -0700883 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
Hai Shalomc3565922019-10-28 11:58:20 -0700884 "depth=%d subject='%s'%s%s%s%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700885 cert->depth, cert->subject, cert_hash ? " hash=" : "",
886 cert_hash ? cert_hash : "",
Hai Shalomc3565922019-10-28 11:58:20 -0700887 cert->tod == 2 ? " tod=2" : "",
888 cert->tod == 1 ? " tod=1" : "");
Hai Shalom81f62d82019-07-22 12:10:00 -0700889
890 if (cert->cert) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700891 char *cert_hex;
Hai Shalom81f62d82019-07-22 12:10:00 -0700892 size_t len = wpabuf_len(cert->cert) * 2 + 1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700893 cert_hex = os_malloc(len);
894 if (cert_hex) {
Hai Shalom81f62d82019-07-22 12:10:00 -0700895 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
896 wpabuf_len(cert->cert));
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700897 wpa_msg_ctrl(wpa_s, MSG_INFO,
898 WPA_EVENT_EAP_PEER_CERT
899 "depth=%d subject='%s' cert=%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700900 cert->depth, cert->subject, cert_hex);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700901 os_free(cert_hex);
902 }
903 }
904
Hai Shalom81f62d82019-07-22 12:10:00 -0700905 for (i = 0; i < cert->num_altsubject; i++)
906 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
907 "depth=%d %s", cert->depth, cert->altsubject[i]);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800908
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700909 /* notify the new DBus API */
Hai Shalom81f62d82019-07-22 12:10:00 -0700910 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
911 cert->altsubject, cert->num_altsubject,
912 cert_hash, cert->cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700913}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700914
915
916void wpas_notify_preq(struct wpa_supplicant *wpa_s,
917 const u8 *addr, const u8 *dst, const u8 *bssid,
918 const u8 *ie, size_t ie_len, u32 ssi_signal)
919{
920#ifdef CONFIG_AP
921 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
922#endif /* CONFIG_AP */
923}
924
925
926void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
927 const char *parameter)
928{
929 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700930 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
931 "status='%s' parameter='%s'",
932 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700933}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700934
Roshan Pius3a1667e2018-07-03 15:17:14 -0700935
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700936void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
937{
938 wpa_dbg(wpa_s, MSG_ERROR,
939 "EAP Error code = %d", error_code);
Gabriel Biren57ededa2021-09-03 16:08:50 +0000940 wpas_aidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700941}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700942
Roshan Pius3a1667e2018-07-03 15:17:14 -0700943
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700944void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
945 struct wpa_ssid *ssid)
946{
947 if (wpa_s->current_ssid != ssid)
948 return;
949
950 wpa_dbg(wpa_s, MSG_DEBUG,
951 "Network bssid config changed for the current network - within-ESS roaming %s",
952 ssid->bssid_set ? "disabled" : "enabled");
953
954 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
955 ssid->bssid_set ? ssid->bssid : NULL);
956}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800957
958
959void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
960 struct wpa_ssid *ssid)
961{
962#ifdef CONFIG_P2P
963 if (ssid->disabled == 2) {
964 /* Changed from normal network profile to persistent group */
965 ssid->disabled = 0;
966 wpas_dbus_unregister_network(wpa_s, ssid->id);
967 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700968 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800969 wpas_dbus_register_persistent_group(wpa_s, ssid);
970 } else {
971 /* Changed from persistent group to normal network profile */
972 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700973 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800974 wpas_dbus_register_network(wpa_s, ssid);
975 }
976#endif /* CONFIG_P2P */
977}
Roshan Pius04a9d742016-12-12 12:40:46 -0800978
979void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
980 const char *result,
981 const struct wpa_bss_anqp *anqp)
982{
983#ifdef CONFIG_INTERWORKING
984 if (!wpa_s || !bssid || !anqp)
985 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800986
Gabriel Biren57ededa2021-09-03 16:08:50 +0000987 wpas_aidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800988#endif /* CONFIG_INTERWORKING */
989}
990
991void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
992 const char* file_name, const u8* image,
993 u32 image_length)
994{
995#ifdef CONFIG_HS20
996 if (!wpa_s || !bssid || !file_name || !image)
997 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800998
Gabriel Biren57ededa2021-09-03 16:08:50 +0000999 wpas_aidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
Roshan Pius9322a342016-12-12 14:45:02 -08001000 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -08001001#endif /* CONFIG_HS20 */
1002}
1003
1004void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
1005 const char* url,
1006 u8 osu_method)
1007{
1008#ifdef CONFIG_HS20
1009 if (!wpa_s || !url)
1010 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001011
Gabriel Biren57ededa2021-09-03 16:08:50 +00001012 wpas_aidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -08001013#endif /* CONFIG_HS20 */
1014}
1015
1016void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1017 u8 code, u16 reauth_delay,
1018 const char *url)
1019{
1020#ifdef CONFIG_HS20
Hai Shalomb3a7c702020-10-20 12:22:53 -07001021 if (!wpa_s)
Roshan Pius04a9d742016-12-12 12:40:46 -08001022 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001023
Gabriel Biren57ededa2021-09-03 16:08:50 +00001024 wpas_aidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
Hai Shalom04a4ca62020-10-28 19:04:47 -07001025 url);
Roshan Pius04a9d742016-12-12 12:40:46 -08001026#endif /* CONFIG_HS20 */
1027}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001028
Hai Shalom04a4ca62020-10-28 19:04:47 -07001029void wpas_notify_hs20_rx_terms_and_conditions_acceptance(
1030 struct wpa_supplicant *wpa_s, const char *url) {
1031#ifdef CONFIG_HS20
1032 if (!wpa_s || !url)
1033 return;
1034
Gabriel Biren57ededa2021-09-03 16:08:50 +00001035 wpas_aidl_notify_hs20_rx_terms_and_conditions_acceptance(wpa_s, url);
Hai Shalom04a4ca62020-10-28 19:04:47 -07001036#endif /* CONFIG_HS20 */
1037}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001038
1039#ifdef CONFIG_MESH
1040
1041void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1042 struct wpa_ssid *ssid)
1043{
1044 if (wpa_s->p2p_mgmt)
1045 return;
1046
1047 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1048}
1049
1050
1051void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1052 const u8 *meshid, u8 meshid_len,
Hai Shalom81f62d82019-07-22 12:10:00 -07001053 u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001054{
1055 if (wpa_s->p2p_mgmt)
1056 return;
1057
1058 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1059 reason_code);
1060}
1061
1062
1063void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1064 const u8 *peer_addr)
1065{
1066 if (wpa_s->p2p_mgmt)
1067 return;
1068
1069 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1070}
1071
1072
1073void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
Hai Shalom81f62d82019-07-22 12:10:00 -07001074 const u8 *peer_addr, u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001075{
1076 if (wpa_s->p2p_mgmt)
1077 return;
1078
1079 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1080}
1081
1082#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001083
1084/*
1085 * DPP Notifications
1086 */
1087
1088/* DPP Success notifications */
1089
Hai Shalom706f99b2019-01-08 16:23:37 -08001090void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Hai Shalom59532852018-12-07 10:32:58 -08001091 struct wpa_ssid *ssid)
1092{
1093#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001094 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001095 return;
1096
Gabriel Biren57ededa2021-09-03 16:08:50 +00001097 wpas_aidl_notify_dpp_config_received(wpa_s, ssid);
Hai Shalom59532852018-12-07 10:32:58 -08001098#endif /* CONFIG_DPP */
1099}
1100
Hai Shalom706f99b2019-01-08 16:23:37 -08001101void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001102{
1103#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001104 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001105 return;
1106
Gabriel Biren57ededa2021-09-03 16:08:50 +00001107 wpas_aidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001108#endif /* CONFIG_DPP */
1109}
1110
1111/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001112void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001113{
1114#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001115 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001116 return;
1117
Gabriel Biren57ededa2021-09-03 16:08:50 +00001118 wpas_aidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001119#endif /* CONFIG_DPP */
1120}
1121
Hai Shalom706f99b2019-01-08 16:23:37 -08001122void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001123{
1124#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001125 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001126 return;
1127
Gabriel Biren57ededa2021-09-03 16:08:50 +00001128 wpas_aidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001129#endif /* CONFIG_DPP */
1130}
1131
1132/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001133void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001134{
1135#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001136 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001137 return;
1138
Gabriel Biren57ededa2021-09-03 16:08:50 +00001139 wpas_aidl_notify_dpp_not_compatible(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001140#endif /* CONFIG_DPP */
1141}
1142
Hai Shalom706f99b2019-01-08 16:23:37 -08001143void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001144{
1145#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001146 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001147 return;
1148
Gabriel Biren57ededa2021-09-03 16:08:50 +00001149 wpas_aidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001150#endif /* CONFIG_DPP */
1151}
1152
Hai Shalom706f99b2019-01-08 16:23:37 -08001153void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001154{
1155#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001156 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001157 return;
1158
Gabriel Biren57ededa2021-09-03 16:08:50 +00001159 wpas_aidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001160#endif /* CONFIG_DPP */
1161}
1162
Hai Shalom706f99b2019-01-08 16:23:37 -08001163void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001164{
1165#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001166 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001167 return;
1168
Gabriel Biren57ededa2021-09-03 16:08:50 +00001169 wpas_aidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001170#endif /* CONFIG_DPP */
1171}
1172
Hai Shalom706f99b2019-01-08 16:23:37 -08001173void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001174{
1175#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001176 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001177 return;
1178
Gabriel Biren57ededa2021-09-03 16:08:50 +00001179 wpas_aidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001180#endif /* CONFIG_DPP */
1181}
1182
Hai Shalom706f99b2019-01-08 16:23:37 -08001183void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001184{
1185#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001186 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001187 return;
1188
Gabriel Biren57ededa2021-09-03 16:08:50 +00001189 wpas_aidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001190#endif /* CONFIG_DPP */
1191}
Jimmy Chen126b1702019-08-28 17:59:33 +08001192
Hai Shalom06768112019-12-04 15:49:43 -08001193void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1194{
1195#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001196 wpas_aidl_notify_dpp_config_sent_wait_response(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001197#endif /* CONFIG_DPP2 */
1198}
1199
1200void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1201{
1202#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001203 wpas_aidl_notify_dpp_config_accepted(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001204#endif /* CONFIG_DPP2 */
1205}
1206
1207void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1208 enum dpp_status_error status, const char *ssid,
1209 const char *channel_list, unsigned short band_list[], int size)
1210{
1211#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001212 wpas_aidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
Hai Shalom06768112019-12-04 15:49:43 -08001213#endif /* CONFIG_DPP2 */
1214}
1215
1216void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1217{
1218#ifdef CONFIG_DPP2
Gabriel Biren57ededa2021-09-03 16:08:50 +00001219 wpas_aidl_notify_dpp_config_rejected(wpa_s);
Hai Shalom06768112019-12-04 15:49:43 -08001220#endif /* CONFIG_DPP2 */
1221}
1222
Jimmy Chen126b1702019-08-28 17:59:33 +08001223void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1224 struct rsn_pmksa_cache_entry *entry)
1225{
1226 if (!wpa_s)
1227 return;
1228
Gabriel Biren57ededa2021-09-03 16:08:50 +00001229 wpas_aidl_notify_pmk_cache_added(wpa_s, entry);
Jimmy Chen126b1702019-08-28 17:59:33 +08001230}
Jimmy Chen39deead2020-10-14 23:47:20 +08001231
1232void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
1233 struct wpa_ssid *ssid,
1234 u8 bitmap)
1235{
1236 if (!wpa_s)
1237 return;
1238
1239 if (!ssid)
1240 return;
1241
Gabriel Biren57ededa2021-09-03 16:08:50 +00001242 wpas_aidl_notify_transition_disable(wpa_s, ssid, bitmap);
Jimmy Chen39deead2020-10-14 23:47:20 +08001243}
Sunil Ravi07c17622021-01-11 12:00:53 -08001244
1245void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s)
1246{
1247 if (!wpa_s)
1248 return;
1249
Gabriel Biren57ededa2021-09-03 16:08:50 +00001250 wpas_aidl_notify_network_not_found(wpa_s);
Sunil Ravi07c17622021-01-11 12:00:53 -08001251}