blob: 56eb62a042a1935e93aca3293aeda4440fd0cf0f [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"
Roshan Piusedd820c2017-05-16 14:21:49 -070026#include "hidl.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
Roshan Pius57ffbcf2016-09-27 09:12:46 -070038#ifdef CONFIG_HIDL
39 global->hidl = wpas_hidl_init(global);
40 if (!global->hidl)
Dmitry Shmidte4663042016-04-04 10:07:49 -070041 return -1;
Roshan Pius57ffbcf2016-09-27 09:12:46 -070042#endif /* CONFIG_HIDL */
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
Roshan Pius57ffbcf2016-09-27 09:12:46 -070055#ifdef CONFIG_HIDL
56 if (global->hidl)
57 wpas_hidl_deinit(global->hidl);
58#endif /* CONFIG_HIDL */
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. */
Roshan Pius57ffbcf2016-09-27 09:12:46 -070070 if (wpas_hidl_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. */
Roshan Pius57ffbcf2016-09-27 09:12:46 -070085 wpas_hidl_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
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700127 wpas_hidl_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
Roshan Piusbe158772017-03-10 17:54:37 -0800138 wpas_hidl_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
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800151void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
152{
153 if (wpa_s->p2p_mgmt)
154 return;
155
156 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
Roshan Pius0974e962016-12-12 17:05:51 -0800157
158 wpas_hidl_notify_assoc_reject(wpa_s);
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800159}
160
Roshan Pius38e96762017-01-23 14:52:00 -0800161void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
162 if (wpa_s->p2p_mgmt)
163 return;
164
165 wpas_hidl_notify_auth_timeout(wpa_s);
166}
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800167
Hai Shalom74f70d42019-02-11 14:42:39 -0800168void wpas_notify_roam_time(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_ROAM_TIME);
174}
175
176
177void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
178{
179 if (wpa_s->p2p_mgmt)
180 return;
181
182 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
183}
184
185
186void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
187{
188 if (wpa_s->p2p_mgmt)
189 return;
190
191 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
192}
193
194
195void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
196{
197 if (wpa_s->p2p_mgmt)
198 return;
199
200 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
Sunil Ravi4018d712019-12-06 18:01:21 -0800201
202#ifdef CONFIG_WNM
203 wpas_hidl_notify_bss_tm_status(wpa_s);
204#endif
Hai Shalom74f70d42019-02-11 14:42:39 -0800205}
206
207
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700208void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
209{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800210 if (wpa_s->p2p_mgmt)
211 return;
212
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700213 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
214}
215
216
217void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
218{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800219 if (wpa_s->p2p_mgmt)
220 return;
221
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700222 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
223}
224
225
226void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
227{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800228 if (wpa_s->p2p_mgmt)
229 return;
230
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700231 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700232
233 wpas_hidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700234}
235
236
237void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
238{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800239 if (wpa_s->p2p_mgmt)
240 return;
241
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700242 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
243}
244
245
246void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
247 struct wpa_ssid *ssid)
248{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800249 if (wpa_s->p2p_mgmt)
250 return;
251
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700252 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
253}
254
255
256void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
257 struct wpa_ssid *ssid)
258{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800259 if (wpa_s->p2p_mgmt)
260 return;
261
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700262 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
263}
264
265
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800266void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
267 struct wpa_ssid *ssid,
268 enum wpa_ctrl_req_type rtype,
269 const char *default_txt)
270{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800271 if (wpa_s->p2p_mgmt)
272 return;
273
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800274 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700275
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700276 wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800277}
278
279
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700280void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
281{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800282 if (wpa_s->p2p_mgmt)
283 return;
284
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700285 /* notify the new DBus API */
286 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
287}
288
289
290void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
291{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800292 if (wpa_s->p2p_mgmt)
293 return;
294
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700295 wpas_dbus_signal_scan_done(wpa_s, success);
296}
297
298
299void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
300{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800301 if (wpa_s->p2p_mgmt)
302 return;
303
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700304 wpas_wps_notify_scan_results(wpa_s);
305}
306
307
308void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
309 const struct wps_credential *cred)
310{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800311 if (wpa_s->p2p_mgmt)
312 return;
313
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700314#ifdef CONFIG_WPS
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700315 /* notify the new DBus API */
316 wpas_dbus_signal_wps_cred(wpa_s, cred);
317#endif /* CONFIG_WPS */
318}
319
320
321void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
322 struct wps_event_m2d *m2d)
323{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800324 if (wpa_s->p2p_mgmt)
325 return;
326
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700327#ifdef CONFIG_WPS
328 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
329#endif /* CONFIG_WPS */
330}
331
332
333void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
334 struct wps_event_fail *fail)
335{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800336 if (wpa_s->p2p_mgmt)
337 return;
338
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700339#ifdef CONFIG_WPS
340 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800341
342 wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
343 fail->config_error,
344 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700345#endif /* CONFIG_WPS */
346}
347
348
349void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
350{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800351 if (wpa_s->p2p_mgmt)
352 return;
353
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700354#ifdef CONFIG_WPS
355 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800356
357 wpas_hidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700358#endif /* CONFIG_WPS */
359}
360
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700361void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
362{
363 if (wpa_s->p2p_mgmt)
364 return;
365
366#ifdef CONFIG_WPS
367 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800368
369 wpas_hidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700370#endif /* CONFIG_WPS */
371}
372
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700373
374void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
375 struct wpa_ssid *ssid)
376{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800377 if (wpa_s->p2p_mgmt)
378 return;
379
Jouni Malinen75ecf522011-06-27 15:19:46 -0700380 /*
381 * Networks objects created during any P2P activities should not be
382 * exposed out. They might/will confuse certain non-P2P aware
383 * applications since these network objects won't behave like
384 * regular ones.
385 */
Roshan Piusd3854452016-07-07 16:46:41 -0700386 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700387 wpas_dbus_register_network(wpa_s, ssid);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700388 wpas_hidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700389 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700390}
391
392
393void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
394 struct wpa_ssid *ssid)
395{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700396#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700397 wpas_dbus_register_persistent_group(wpa_s, ssid);
Glen Kuhne30990d62017-04-19 14:16:48 -0700398 wpas_hidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700399#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700400}
401
402
403void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
404 struct wpa_ssid *ssid)
405{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700406#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700407 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Glen Kuhne30990d62017-04-19 14:16:48 -0700408 wpas_hidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700409#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700410}
411
412
413void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
414 struct wpa_ssid *ssid)
415{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800416 if (wpa_s->next_ssid == ssid)
417 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800418 if (wpa_s->wpa)
419 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700420 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700421 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700422 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700423 wpas_hidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700424 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800425 if (network_is_persistent_group(ssid))
426 wpas_notify_persistent_group_removed(wpa_s, ssid);
427
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800428 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700429}
430
431
432void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
433 u8 bssid[], unsigned int id)
434{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800435 if (wpa_s->p2p_mgmt)
436 return;
437
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700438 wpas_dbus_register_bss(wpa_s, bssid, id);
439 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
440 id, MAC2STR(bssid));
441}
442
443
444void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
445 u8 bssid[], unsigned int id)
446{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800447 if (wpa_s->p2p_mgmt)
448 return;
449
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700450 wpas_dbus_unregister_bss(wpa_s, bssid, id);
451 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
452 id, MAC2STR(bssid));
453}
454
455
456void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
457 unsigned int id)
458{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800459 if (wpa_s->p2p_mgmt)
460 return;
461
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700462 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
463}
464
465
466void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
467 unsigned int id)
468{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800469 if (wpa_s->p2p_mgmt)
470 return;
471
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700472 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
473 id);
474}
475
476
477void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
478 unsigned int id)
479{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800480 if (wpa_s->p2p_mgmt)
481 return;
482
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700483 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
484 id);
485}
486
487
488void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
489 unsigned int id)
490{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800491 if (wpa_s->p2p_mgmt)
492 return;
493
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700494 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
495}
496
497
498void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
499 unsigned int id)
500{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800501 if (wpa_s->p2p_mgmt)
502 return;
503
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700504 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
505}
506
507
508void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
509 unsigned int id)
510{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800511 if (wpa_s->p2p_mgmt)
512 return;
513
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700514 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
515}
516
517
518void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
519 unsigned int id)
520{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800521 if (wpa_s->p2p_mgmt)
522 return;
523
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800524#ifdef CONFIG_WPS
525 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
526#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700527}
528
529
530void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
531 unsigned int id)
532{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800533 if (wpa_s->p2p_mgmt)
534 return;
535
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700536 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
537}
538
539
540void wpas_notify_bss_rates_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_RATES, id);
547}
548
549
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700550void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
551{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800552 if (wpa_s->p2p_mgmt)
553 return;
554
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700555 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
556}
557
558
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700559void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
560{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800561 if (wpa_s->p2p_mgmt)
562 return;
563
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700564 wpas_dbus_signal_blob_added(wpa_s, name);
565}
566
567
568void wpas_notify_blob_removed(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_removed(wpa_s, name);
574}
575
576
577void wpas_notify_debug_level_changed(struct wpa_global *global)
578{
579 wpas_dbus_signal_debug_level_changed(global);
580}
581
582
583void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
584{
585 wpas_dbus_signal_debug_timestamp_changed(global);
586}
587
588
589void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
590{
591 wpas_dbus_signal_debug_show_keys_changed(global);
592}
593
594
595void wpas_notify_suspend(struct wpa_global *global)
596{
597 struct wpa_supplicant *wpa_s;
598
599 os_get_time(&global->suspend_time);
600 wpa_printf(MSG_DEBUG, "System suspend notification");
601 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
602 wpa_drv_suspend(wpa_s);
603}
604
605
606void wpas_notify_resume(struct wpa_global *global)
607{
608 struct os_time now;
609 int slept;
610 struct wpa_supplicant *wpa_s;
611
612 if (global->suspend_time.sec == 0)
613 slept = -1;
614 else {
615 os_get_time(&now);
616 slept = now.sec - global->suspend_time.sec;
617 }
618 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
619 slept);
620
621 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
622 wpa_drv_resume(wpa_s);
623 if (wpa_s->wpa_state == WPA_DISCONNECTED)
624 wpa_supplicant_req_scan(wpa_s, 0, 100000);
625 }
626}
627
628
629#ifdef CONFIG_P2P
630
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700631void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
632{
633 /* Notify P2P find has stopped */
634 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800635
636 wpas_hidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700637}
638
639
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700640void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800641 const u8 *addr, const struct p2p_peer_info *info,
642 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
643 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700644{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700645 if (new_device) {
646 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800647 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700648 }
649
650 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800651 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
652
653 wpas_hidl_notify_p2p_device_found(wpa_s, addr, info,
654 peer_wfd_device_info,
655 peer_wfd_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700656}
657
658
659void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
660 const u8 *dev_addr)
661{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700662 wpas_dbus_unregister_peer(wpa_s, dev_addr);
663
664 /* Create signal on interface object*/
665 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800666
667 wpas_hidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700668}
669
670
671void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
672 const struct wpa_ssid *ssid,
673 const char *role)
674{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700675 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700676
677 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800678
679 wpas_hidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700680}
681
682
683void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700684 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700685{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700686 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800687
688 wpas_hidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700689}
690
691
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800692void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
693 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700694{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800695 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800696
697 wpas_hidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700698}
699
700
701void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
702 int status, const u8 *bssid)
703{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700704 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800705
706 wpas_hidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700707}
708
709
710void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
711 int freq, const u8 *sa, u8 dialog_token,
712 u16 update_indic, const u8 *tlvs,
713 size_t tlvs_len)
714{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700715 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
716 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700717}
718
719
720void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
721 const u8 *sa, u16 update_indic,
722 const u8 *tlvs, size_t tlvs_len)
723{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700724 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
725 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800726
727 wpas_hidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
728 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700729}
730
731
732/**
733 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
734 * @dev_addr: Who sent the request or responded to our request.
735 * @request: Will be 1 if request, 0 for response.
736 * @status: Valid only in case of response (0 in case of success)
737 * @config_methods: WPS config methods
738 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
739 *
740 * This can be used to notify:
741 * - Requests or responses
742 * - Various config methods
743 * - Failure condition in case of response
744 */
745void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
746 const u8 *dev_addr, int request,
747 enum p2p_prov_disc_status status,
748 u16 config_methods,
749 unsigned int generated_pin)
750{
751 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
752 status, config_methods,
753 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800754
755 wpas_hidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
756 status, config_methods,
757 generated_pin);
758
Jouni Malinen75ecf522011-06-27 15:19:46 -0700759}
760
761
762void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700763 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800764 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700765{
766 /* Notify a group has been started */
767 wpas_dbus_register_p2p_group(wpa_s, ssid);
768
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800769 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800770
Roshan Pius7a1c8482017-04-12 17:05:10 -0700771 wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700772}
773
774
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800775void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
776 const char *reason)
777{
778 /* Notify a group formation failed */
779 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800780
781 wpas_hidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800782}
783
784
Jouni Malinen75ecf522011-06-27 15:19:46 -0700785void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
786 struct wps_event_fail *fail)
787{
788 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700789}
790
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800791
792void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
793 const u8 *sa, const u8 *go_dev_addr,
794 const u8 *bssid, int id, int op_freq)
795{
796 /* Notify a P2P Invitation Request */
797 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
798 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800799
800 wpas_hidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
801 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800802}
803
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700804#endif /* CONFIG_P2P */
805
806
807static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800808 const u8 *sta,
809 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700810{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700811#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800812 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
813
Jouni Malinen75ecf522011-06-27 15:19:46 -0700814 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700815 * Create 'peer-joined' signal on group object -- will also
816 * check P2P itself.
817 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800818 if (p2p_dev_addr)
819 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700820#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700821
Hai Shalom74f70d42019-02-11 14:42:39 -0800822 /* Register the station */
823 wpas_dbus_register_sta(wpa_s, sta);
824
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700825 /* Notify listeners a new station has been authorized */
826 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800827
828 wpas_hidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700829}
830
831
832static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700833 const u8 *sta,
834 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700835{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700836#ifdef CONFIG_P2P
837 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700838 * Create 'peer-disconnected' signal on group object if this
839 * is a P2P group.
840 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800841 if (p2p_dev_addr)
842 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700843#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700844
845 /* Notify listeners a station has been deauthorized */
846 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800847
lesl4b7058c2019-02-27 18:45:19 +0800848 wpas_hidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Hai Shalom74f70d42019-02-11 14:42:39 -0800849 /* Unregister the station */
850 wpas_dbus_unregister_sta(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700851}
852
853
854void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800855 const u8 *mac_addr, int authorized,
856 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700857{
858 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800859 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700860 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700861 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700862}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700863
864
Hai Shalom81f62d82019-07-22 12:10:00 -0700865void wpas_notify_certification(struct wpa_supplicant *wpa_s,
866 struct tls_cert_data *cert,
867 const char *cert_hash)
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700868{
Hai Shalom81f62d82019-07-22 12:10:00 -0700869 int i;
Hai Shalom878cf7b2019-07-15 14:55:18 -0700870
Hai Shalom81f62d82019-07-22 12:10:00 -0700871 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
Hai Shalomc3565922019-10-28 11:58:20 -0700872 "depth=%d subject='%s'%s%s%s%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700873 cert->depth, cert->subject, cert_hash ? " hash=" : "",
874 cert_hash ? cert_hash : "",
Hai Shalomc3565922019-10-28 11:58:20 -0700875 cert->tod == 2 ? " tod=2" : "",
876 cert->tod == 1 ? " tod=1" : "");
Hai Shalom81f62d82019-07-22 12:10:00 -0700877
878 if (cert->cert) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700879 char *cert_hex;
Hai Shalom81f62d82019-07-22 12:10:00 -0700880 size_t len = wpabuf_len(cert->cert) * 2 + 1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700881 cert_hex = os_malloc(len);
882 if (cert_hex) {
Hai Shalom81f62d82019-07-22 12:10:00 -0700883 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
884 wpabuf_len(cert->cert));
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700885 wpa_msg_ctrl(wpa_s, MSG_INFO,
886 WPA_EVENT_EAP_PEER_CERT
887 "depth=%d subject='%s' cert=%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700888 cert->depth, cert->subject, cert_hex);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700889 os_free(cert_hex);
890 }
891 }
892
Hai Shalom81f62d82019-07-22 12:10:00 -0700893 for (i = 0; i < cert->num_altsubject; i++)
894 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
895 "depth=%d %s", cert->depth, cert->altsubject[i]);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800896
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700897 /* notify the new DBus API */
Hai Shalom81f62d82019-07-22 12:10:00 -0700898 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
899 cert->altsubject, cert->num_altsubject,
900 cert_hash, cert->cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700901}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700902
903
904void wpas_notify_preq(struct wpa_supplicant *wpa_s,
905 const u8 *addr, const u8 *dst, const u8 *bssid,
906 const u8 *ie, size_t ie_len, u32 ssi_signal)
907{
908#ifdef CONFIG_AP
909 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
910#endif /* CONFIG_AP */
911}
912
913
914void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
915 const char *parameter)
916{
917 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700918 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
919 "status='%s' parameter='%s'",
920 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700921}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700922
Roshan Pius3a1667e2018-07-03 15:17:14 -0700923
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700924void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
925{
926 wpa_dbg(wpa_s, MSG_ERROR,
927 "EAP Error code = %d", error_code);
Ahmed ElArabawy30eab622018-03-19 18:36:48 -0700928 wpas_hidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700929}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700930
Roshan Pius3a1667e2018-07-03 15:17:14 -0700931
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700932void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
933 struct wpa_ssid *ssid)
934{
935 if (wpa_s->current_ssid != ssid)
936 return;
937
938 wpa_dbg(wpa_s, MSG_DEBUG,
939 "Network bssid config changed for the current network - within-ESS roaming %s",
940 ssid->bssid_set ? "disabled" : "enabled");
941
942 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
943 ssid->bssid_set ? ssid->bssid : NULL);
944}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800945
946
947void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
948 struct wpa_ssid *ssid)
949{
950#ifdef CONFIG_P2P
951 if (ssid->disabled == 2) {
952 /* Changed from normal network profile to persistent group */
953 ssid->disabled = 0;
954 wpas_dbus_unregister_network(wpa_s, ssid->id);
955 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700956 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800957 wpas_dbus_register_persistent_group(wpa_s, ssid);
958 } else {
959 /* Changed from persistent group to normal network profile */
960 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700961 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800962 wpas_dbus_register_network(wpa_s, ssid);
963 }
964#endif /* CONFIG_P2P */
965}
Roshan Pius04a9d742016-12-12 12:40:46 -0800966
967void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
968 const char *result,
969 const struct wpa_bss_anqp *anqp)
970{
971#ifdef CONFIG_INTERWORKING
972 if (!wpa_s || !bssid || !anqp)
973 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800974
975 wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800976#endif /* CONFIG_INTERWORKING */
977}
978
979void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
980 const char* file_name, const u8* image,
981 u32 image_length)
982{
983#ifdef CONFIG_HS20
984 if (!wpa_s || !bssid || !file_name || !image)
985 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800986
987 wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
988 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -0800989#endif /* CONFIG_HS20 */
990}
991
992void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
993 const char* url,
994 u8 osu_method)
995{
996#ifdef CONFIG_HS20
997 if (!wpa_s || !url)
998 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800999
1000 wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -08001001#endif /* CONFIG_HS20 */
1002}
1003
1004void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1005 u8 code, u16 reauth_delay,
1006 const char *url)
1007{
1008#ifdef CONFIG_HS20
1009 if (!wpa_s || !url)
1010 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001011
1012 wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
1013 url);
Roshan Pius04a9d742016-12-12 12:40:46 -08001014#endif /* CONFIG_HS20 */
1015}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001016
1017
1018#ifdef CONFIG_MESH
1019
1020void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1021 struct wpa_ssid *ssid)
1022{
1023 if (wpa_s->p2p_mgmt)
1024 return;
1025
1026 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1027}
1028
1029
1030void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1031 const u8 *meshid, u8 meshid_len,
Hai Shalom81f62d82019-07-22 12:10:00 -07001032 u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001033{
1034 if (wpa_s->p2p_mgmt)
1035 return;
1036
1037 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1038 reason_code);
1039}
1040
1041
1042void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1043 const u8 *peer_addr)
1044{
1045 if (wpa_s->p2p_mgmt)
1046 return;
1047
1048 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1049}
1050
1051
1052void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
Hai Shalom81f62d82019-07-22 12:10:00 -07001053 const u8 *peer_addr, 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_peer_disconnected(wpa_s, peer_addr, reason_code);
1059}
1060
1061#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001062
1063/*
1064 * DPP Notifications
1065 */
1066
1067/* DPP Success notifications */
1068
Hai Shalom706f99b2019-01-08 16:23:37 -08001069void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Hai Shalom59532852018-12-07 10:32:58 -08001070 struct wpa_ssid *ssid)
1071{
1072#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001073 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001074 return;
1075
Hai Shalom706f99b2019-01-08 16:23:37 -08001076 wpas_hidl_notify_dpp_config_received(wpa_s, ssid);
Hai Shalom59532852018-12-07 10:32:58 -08001077#endif /* CONFIG_DPP */
1078}
1079
Hai Shalom706f99b2019-01-08 16:23:37 -08001080void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001081{
1082#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001083 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001084 return;
1085
Hai Shalom706f99b2019-01-08 16:23:37 -08001086 wpas_hidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001087#endif /* CONFIG_DPP */
1088}
1089
1090/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001091void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001092{
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
Hai Shalom706f99b2019-01-08 16:23:37 -08001097 wpas_hidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001098#endif /* CONFIG_DPP */
1099}
1100
Hai Shalom706f99b2019-01-08 16:23:37 -08001101void wpas_notify_dpp_resp_pending(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
Hai Shalom706f99b2019-01-08 16:23:37 -08001107 wpas_hidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001108#endif /* CONFIG_DPP */
1109}
1110
1111/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001112void wpas_notify_dpp_not_compatible(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
Hai Shalom706f99b2019-01-08 16:23:37 -08001118 wpas_hidl_notify_dpp_not_compatible(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_missing_auth(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
Hai Shalom706f99b2019-01-08 16:23:37 -08001128 wpas_hidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001129#endif /* CONFIG_DPP */
1130}
1131
Hai Shalom706f99b2019-01-08 16:23:37 -08001132void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001133{
1134#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001135 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001136 return;
1137
Hai Shalom706f99b2019-01-08 16:23:37 -08001138 wpas_hidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001139#endif /* CONFIG_DPP */
1140}
1141
Hai Shalom706f99b2019-01-08 16:23:37 -08001142void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001143{
1144#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001145 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001146 return;
1147
Hai Shalom706f99b2019-01-08 16:23:37 -08001148 wpas_hidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001149#endif /* CONFIG_DPP */
1150}
1151
Hai Shalom706f99b2019-01-08 16:23:37 -08001152void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001153{
1154#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001155 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001156 return;
1157
Hai Shalom706f99b2019-01-08 16:23:37 -08001158 wpas_hidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001159#endif /* CONFIG_DPP */
1160}
1161
Hai Shalom706f99b2019-01-08 16:23:37 -08001162void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001163{
1164#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001165 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001166 return;
1167
Hai Shalom706f99b2019-01-08 16:23:37 -08001168 wpas_hidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001169#endif /* CONFIG_DPP */
1170}
Jimmy Chen126b1702019-08-28 17:59:33 +08001171
Hai Shalom06768112019-12-04 15:49:43 -08001172void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1173{
1174#ifdef CONFIG_DPP2
1175 wpas_hidl_notify_dpp_config_sent_wait_response(wpa_s);
1176#endif /* CONFIG_DPP2 */
1177}
1178
1179void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1180{
1181#ifdef CONFIG_DPP2
1182 wpas_hidl_notify_dpp_config_accepted(wpa_s);
1183#endif /* CONFIG_DPP2 */
1184}
1185
1186void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1187 enum dpp_status_error status, const char *ssid,
1188 const char *channel_list, unsigned short band_list[], int size)
1189{
1190#ifdef CONFIG_DPP2
1191 wpas_hidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
1192#endif /* CONFIG_DPP2 */
1193}
1194
1195void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1196{
1197#ifdef CONFIG_DPP2
1198 wpas_hidl_notify_dpp_config_rejected(wpa_s);
1199#endif /* CONFIG_DPP2 */
1200}
1201
Jimmy Chen126b1702019-08-28 17:59:33 +08001202void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1203 struct rsn_pmksa_cache_entry *entry)
1204{
1205 if (!wpa_s)
1206 return;
1207
1208 wpas_hidl_notify_pmk_cache_added(wpa_s, entry);
1209}