blob: 2ebe034cb1e9f98641d93bf5efec439e548b66c5 [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);
201}
202
203
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700204void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
205{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800206 if (wpa_s->p2p_mgmt)
207 return;
208
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700209 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
210}
211
212
213void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
214{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800215 if (wpa_s->p2p_mgmt)
216 return;
217
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700218 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
219}
220
221
222void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
223{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800224 if (wpa_s->p2p_mgmt)
225 return;
226
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700227 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700228
229 wpas_hidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700230}
231
232
233void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
234{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800235 if (wpa_s->p2p_mgmt)
236 return;
237
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700238 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
239}
240
241
242void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
243 struct wpa_ssid *ssid)
244{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800245 if (wpa_s->p2p_mgmt)
246 return;
247
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700248 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
249}
250
251
252void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
253 struct wpa_ssid *ssid)
254{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800255 if (wpa_s->p2p_mgmt)
256 return;
257
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700258 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
259}
260
261
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800262void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
263 struct wpa_ssid *ssid,
264 enum wpa_ctrl_req_type rtype,
265 const char *default_txt)
266{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800267 if (wpa_s->p2p_mgmt)
268 return;
269
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800270 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700271
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700272 wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800273}
274
275
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700276void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
277{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800278 if (wpa_s->p2p_mgmt)
279 return;
280
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700281 /* notify the new DBus API */
282 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
283}
284
285
286void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
287{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800288 if (wpa_s->p2p_mgmt)
289 return;
290
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700291 wpas_dbus_signal_scan_done(wpa_s, success);
292}
293
294
295void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
296{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800297 if (wpa_s->p2p_mgmt)
298 return;
299
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700300 wpas_wps_notify_scan_results(wpa_s);
301}
302
303
304void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
305 const struct wps_credential *cred)
306{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800307 if (wpa_s->p2p_mgmt)
308 return;
309
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700310#ifdef CONFIG_WPS
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700311 /* notify the new DBus API */
312 wpas_dbus_signal_wps_cred(wpa_s, cred);
313#endif /* CONFIG_WPS */
314}
315
316
317void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
318 struct wps_event_m2d *m2d)
319{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800320 if (wpa_s->p2p_mgmt)
321 return;
322
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700323#ifdef CONFIG_WPS
324 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
325#endif /* CONFIG_WPS */
326}
327
328
329void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
330 struct wps_event_fail *fail)
331{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800332 if (wpa_s->p2p_mgmt)
333 return;
334
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700335#ifdef CONFIG_WPS
336 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800337
338 wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
339 fail->config_error,
340 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700341#endif /* CONFIG_WPS */
342}
343
344
345void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
346{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800347 if (wpa_s->p2p_mgmt)
348 return;
349
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700350#ifdef CONFIG_WPS
351 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800352
353 wpas_hidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700354#endif /* CONFIG_WPS */
355}
356
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700357void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
358{
359 if (wpa_s->p2p_mgmt)
360 return;
361
362#ifdef CONFIG_WPS
363 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800364
365 wpas_hidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700366#endif /* CONFIG_WPS */
367}
368
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700369
370void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
371 struct wpa_ssid *ssid)
372{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800373 if (wpa_s->p2p_mgmt)
374 return;
375
Jouni Malinen75ecf522011-06-27 15:19:46 -0700376 /*
377 * Networks objects created during any P2P activities should not be
378 * exposed out. They might/will confuse certain non-P2P aware
379 * applications since these network objects won't behave like
380 * regular ones.
381 */
Roshan Piusd3854452016-07-07 16:46:41 -0700382 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700383 wpas_dbus_register_network(wpa_s, ssid);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700384 wpas_hidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700385 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700386}
387
388
389void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
390 struct wpa_ssid *ssid)
391{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700392#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700393 wpas_dbus_register_persistent_group(wpa_s, ssid);
Glen Kuhne30990d62017-04-19 14:16:48 -0700394 wpas_hidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700395#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700396}
397
398
399void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
400 struct wpa_ssid *ssid)
401{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700402#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700403 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Glen Kuhne30990d62017-04-19 14:16:48 -0700404 wpas_hidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700405#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700406}
407
408
409void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
410 struct wpa_ssid *ssid)
411{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800412 if (wpa_s->next_ssid == ssid)
413 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800414 if (wpa_s->wpa)
415 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700416 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700417 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700418 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700419 wpas_hidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700420 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800421 if (network_is_persistent_group(ssid))
422 wpas_notify_persistent_group_removed(wpa_s, ssid);
423
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800424 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700425}
426
427
428void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
429 u8 bssid[], unsigned int id)
430{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800431 if (wpa_s->p2p_mgmt)
432 return;
433
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700434 wpas_dbus_register_bss(wpa_s, bssid, id);
435 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
436 id, MAC2STR(bssid));
437}
438
439
440void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
441 u8 bssid[], unsigned int id)
442{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800443 if (wpa_s->p2p_mgmt)
444 return;
445
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700446 wpas_dbus_unregister_bss(wpa_s, bssid, id);
447 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
448 id, MAC2STR(bssid));
449}
450
451
452void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
453 unsigned int id)
454{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800455 if (wpa_s->p2p_mgmt)
456 return;
457
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700458 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
459}
460
461
462void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
463 unsigned int id)
464{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800465 if (wpa_s->p2p_mgmt)
466 return;
467
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700468 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
469 id);
470}
471
472
473void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
474 unsigned int id)
475{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800476 if (wpa_s->p2p_mgmt)
477 return;
478
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700479 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
480 id);
481}
482
483
484void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
485 unsigned int id)
486{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800487 if (wpa_s->p2p_mgmt)
488 return;
489
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700490 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
491}
492
493
494void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
495 unsigned int id)
496{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800497 if (wpa_s->p2p_mgmt)
498 return;
499
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700500 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
501}
502
503
504void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
505 unsigned int id)
506{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800507 if (wpa_s->p2p_mgmt)
508 return;
509
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700510 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
511}
512
513
514void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
515 unsigned int id)
516{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800517 if (wpa_s->p2p_mgmt)
518 return;
519
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800520#ifdef CONFIG_WPS
521 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
522#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700523}
524
525
526void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
527 unsigned int id)
528{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800529 if (wpa_s->p2p_mgmt)
530 return;
531
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700532 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
533}
534
535
536void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
537 unsigned int id)
538{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800539 if (wpa_s->p2p_mgmt)
540 return;
541
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700542 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
543}
544
545
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700546void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
547{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800548 if (wpa_s->p2p_mgmt)
549 return;
550
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700551 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
552}
553
554
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700555void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
556{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800557 if (wpa_s->p2p_mgmt)
558 return;
559
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700560 wpas_dbus_signal_blob_added(wpa_s, name);
561}
562
563
564void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
565{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800566 if (wpa_s->p2p_mgmt)
567 return;
568
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700569 wpas_dbus_signal_blob_removed(wpa_s, name);
570}
571
572
573void wpas_notify_debug_level_changed(struct wpa_global *global)
574{
575 wpas_dbus_signal_debug_level_changed(global);
576}
577
578
579void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
580{
581 wpas_dbus_signal_debug_timestamp_changed(global);
582}
583
584
585void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
586{
587 wpas_dbus_signal_debug_show_keys_changed(global);
588}
589
590
591void wpas_notify_suspend(struct wpa_global *global)
592{
593 struct wpa_supplicant *wpa_s;
594
595 os_get_time(&global->suspend_time);
596 wpa_printf(MSG_DEBUG, "System suspend notification");
597 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
598 wpa_drv_suspend(wpa_s);
599}
600
601
602void wpas_notify_resume(struct wpa_global *global)
603{
604 struct os_time now;
605 int slept;
606 struct wpa_supplicant *wpa_s;
607
608 if (global->suspend_time.sec == 0)
609 slept = -1;
610 else {
611 os_get_time(&now);
612 slept = now.sec - global->suspend_time.sec;
613 }
614 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
615 slept);
616
617 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
618 wpa_drv_resume(wpa_s);
619 if (wpa_s->wpa_state == WPA_DISCONNECTED)
620 wpa_supplicant_req_scan(wpa_s, 0, 100000);
621 }
622}
623
624
625#ifdef CONFIG_P2P
626
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700627void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
628{
629 /* Notify P2P find has stopped */
630 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800631
632 wpas_hidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700633}
634
635
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700636void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800637 const u8 *addr, const struct p2p_peer_info *info,
638 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
639 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700640{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700641 if (new_device) {
642 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800643 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700644 }
645
646 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800647 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
648
649 wpas_hidl_notify_p2p_device_found(wpa_s, addr, info,
650 peer_wfd_device_info,
651 peer_wfd_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700652}
653
654
655void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
656 const u8 *dev_addr)
657{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700658 wpas_dbus_unregister_peer(wpa_s, dev_addr);
659
660 /* Create signal on interface object*/
661 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800662
663 wpas_hidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700664}
665
666
667void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
668 const struct wpa_ssid *ssid,
669 const char *role)
670{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700671 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700672
673 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800674
675 wpas_hidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700676}
677
678
679void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700680 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700681{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700682 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800683
684 wpas_hidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700685}
686
687
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800688void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
689 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700690{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800691 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800692
693 wpas_hidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700694}
695
696
697void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
698 int status, const u8 *bssid)
699{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700700 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800701
702 wpas_hidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700703}
704
705
706void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
707 int freq, const u8 *sa, u8 dialog_token,
708 u16 update_indic, const u8 *tlvs,
709 size_t tlvs_len)
710{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700711 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
712 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700713}
714
715
716void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
717 const u8 *sa, u16 update_indic,
718 const u8 *tlvs, size_t tlvs_len)
719{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700720 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
721 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800722
723 wpas_hidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
724 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700725}
726
727
728/**
729 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
730 * @dev_addr: Who sent the request or responded to our request.
731 * @request: Will be 1 if request, 0 for response.
732 * @status: Valid only in case of response (0 in case of success)
733 * @config_methods: WPS config methods
734 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
735 *
736 * This can be used to notify:
737 * - Requests or responses
738 * - Various config methods
739 * - Failure condition in case of response
740 */
741void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
742 const u8 *dev_addr, int request,
743 enum p2p_prov_disc_status status,
744 u16 config_methods,
745 unsigned int generated_pin)
746{
747 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
748 status, config_methods,
749 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800750
751 wpas_hidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
752 status, config_methods,
753 generated_pin);
754
Jouni Malinen75ecf522011-06-27 15:19:46 -0700755}
756
757
758void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700759 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800760 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700761{
762 /* Notify a group has been started */
763 wpas_dbus_register_p2p_group(wpa_s, ssid);
764
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800765 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800766
Roshan Pius7a1c8482017-04-12 17:05:10 -0700767 wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700768}
769
770
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800771void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
772 const char *reason)
773{
774 /* Notify a group formation failed */
775 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800776
777 wpas_hidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800778}
779
780
Jouni Malinen75ecf522011-06-27 15:19:46 -0700781void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
782 struct wps_event_fail *fail)
783{
784 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700785}
786
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800787
788void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
789 const u8 *sa, const u8 *go_dev_addr,
790 const u8 *bssid, int id, int op_freq)
791{
792 /* Notify a P2P Invitation Request */
793 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
794 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800795
796 wpas_hidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
797 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800798}
799
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700800#endif /* CONFIG_P2P */
801
802
803static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800804 const u8 *sta,
805 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700806{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700807#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800808 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
809
Jouni Malinen75ecf522011-06-27 15:19:46 -0700810 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700811 * Create 'peer-joined' signal on group object -- will also
812 * check P2P itself.
813 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800814 if (p2p_dev_addr)
815 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700816#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700817
Hai Shalom74f70d42019-02-11 14:42:39 -0800818 /* Register the station */
819 wpas_dbus_register_sta(wpa_s, sta);
820
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700821 /* Notify listeners a new station has been authorized */
822 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800823
824 wpas_hidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700825}
826
827
828static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700829 const u8 *sta,
830 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700831{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700832#ifdef CONFIG_P2P
833 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700834 * Create 'peer-disconnected' signal on group object if this
835 * is a P2P group.
836 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800837 if (p2p_dev_addr)
838 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700839#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700840
841 /* Notify listeners a station has been deauthorized */
842 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800843
lesl4b7058c2019-02-27 18:45:19 +0800844 wpas_hidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Hai Shalom74f70d42019-02-11 14:42:39 -0800845 /* Unregister the station */
846 wpas_dbus_unregister_sta(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700847}
848
849
850void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800851 const u8 *mac_addr, int authorized,
852 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700853{
854 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800855 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700856 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700857 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700858}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700859
860
Hai Shalom81f62d82019-07-22 12:10:00 -0700861void wpas_notify_certification(struct wpa_supplicant *wpa_s,
862 struct tls_cert_data *cert,
863 const char *cert_hash)
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700864{
Hai Shalom81f62d82019-07-22 12:10:00 -0700865 int i;
Hai Shalom878cf7b2019-07-15 14:55:18 -0700866
Hai Shalom81f62d82019-07-22 12:10:00 -0700867 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
Hai Shalomc3565922019-10-28 11:58:20 -0700868 "depth=%d subject='%s'%s%s%s%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700869 cert->depth, cert->subject, cert_hash ? " hash=" : "",
870 cert_hash ? cert_hash : "",
Hai Shalomc3565922019-10-28 11:58:20 -0700871 cert->tod == 2 ? " tod=2" : "",
872 cert->tod == 1 ? " tod=1" : "");
Hai Shalom81f62d82019-07-22 12:10:00 -0700873
874 if (cert->cert) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700875 char *cert_hex;
Hai Shalom81f62d82019-07-22 12:10:00 -0700876 size_t len = wpabuf_len(cert->cert) * 2 + 1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700877 cert_hex = os_malloc(len);
878 if (cert_hex) {
Hai Shalom81f62d82019-07-22 12:10:00 -0700879 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
880 wpabuf_len(cert->cert));
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700881 wpa_msg_ctrl(wpa_s, MSG_INFO,
882 WPA_EVENT_EAP_PEER_CERT
883 "depth=%d subject='%s' cert=%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700884 cert->depth, cert->subject, cert_hex);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700885 os_free(cert_hex);
886 }
887 }
888
Hai Shalom81f62d82019-07-22 12:10:00 -0700889 for (i = 0; i < cert->num_altsubject; i++)
890 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
891 "depth=%d %s", cert->depth, cert->altsubject[i]);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800892
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700893 /* notify the new DBus API */
Hai Shalom81f62d82019-07-22 12:10:00 -0700894 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
895 cert->altsubject, cert->num_altsubject,
896 cert_hash, cert->cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700897}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700898
899
900void wpas_notify_preq(struct wpa_supplicant *wpa_s,
901 const u8 *addr, const u8 *dst, const u8 *bssid,
902 const u8 *ie, size_t ie_len, u32 ssi_signal)
903{
904#ifdef CONFIG_AP
905 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
906#endif /* CONFIG_AP */
907}
908
909
910void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
911 const char *parameter)
912{
913 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700914 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
915 "status='%s' parameter='%s'",
916 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700917}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700918
Roshan Pius3a1667e2018-07-03 15:17:14 -0700919
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700920void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
921{
922 wpa_dbg(wpa_s, MSG_ERROR,
923 "EAP Error code = %d", error_code);
Ahmed ElArabawy30eab622018-03-19 18:36:48 -0700924 wpas_hidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700925}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700926
Roshan Pius3a1667e2018-07-03 15:17:14 -0700927
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700928void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
929 struct wpa_ssid *ssid)
930{
931 if (wpa_s->current_ssid != ssid)
932 return;
933
934 wpa_dbg(wpa_s, MSG_DEBUG,
935 "Network bssid config changed for the current network - within-ESS roaming %s",
936 ssid->bssid_set ? "disabled" : "enabled");
937
938 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
939 ssid->bssid_set ? ssid->bssid : NULL);
940}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800941
942
943void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
944 struct wpa_ssid *ssid)
945{
946#ifdef CONFIG_P2P
947 if (ssid->disabled == 2) {
948 /* Changed from normal network profile to persistent group */
949 ssid->disabled = 0;
950 wpas_dbus_unregister_network(wpa_s, ssid->id);
951 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700952 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800953 wpas_dbus_register_persistent_group(wpa_s, ssid);
954 } else {
955 /* Changed from persistent group to normal network profile */
956 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700957 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800958 wpas_dbus_register_network(wpa_s, ssid);
959 }
960#endif /* CONFIG_P2P */
961}
Roshan Pius04a9d742016-12-12 12:40:46 -0800962
963void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
964 const char *result,
965 const struct wpa_bss_anqp *anqp)
966{
967#ifdef CONFIG_INTERWORKING
968 if (!wpa_s || !bssid || !anqp)
969 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800970
971 wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800972#endif /* CONFIG_INTERWORKING */
973}
974
975void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
976 const char* file_name, const u8* image,
977 u32 image_length)
978{
979#ifdef CONFIG_HS20
980 if (!wpa_s || !bssid || !file_name || !image)
981 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800982
983 wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
984 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -0800985#endif /* CONFIG_HS20 */
986}
987
988void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
989 const char* url,
990 u8 osu_method)
991{
992#ifdef CONFIG_HS20
993 if (!wpa_s || !url)
994 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800995
996 wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -0800997#endif /* CONFIG_HS20 */
998}
999
1000void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1001 u8 code, u16 reauth_delay,
1002 const char *url)
1003{
1004#ifdef CONFIG_HS20
1005 if (!wpa_s || !url)
1006 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001007
1008 wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
1009 url);
Roshan Pius04a9d742016-12-12 12:40:46 -08001010#endif /* CONFIG_HS20 */
1011}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001012
1013
1014#ifdef CONFIG_MESH
1015
1016void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1017 struct wpa_ssid *ssid)
1018{
1019 if (wpa_s->p2p_mgmt)
1020 return;
1021
1022 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1023}
1024
1025
1026void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1027 const u8 *meshid, u8 meshid_len,
Hai Shalom81f62d82019-07-22 12:10:00 -07001028 u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001029{
1030 if (wpa_s->p2p_mgmt)
1031 return;
1032
1033 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1034 reason_code);
1035}
1036
1037
1038void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1039 const u8 *peer_addr)
1040{
1041 if (wpa_s->p2p_mgmt)
1042 return;
1043
1044 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1045}
1046
1047
1048void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
Hai Shalom81f62d82019-07-22 12:10:00 -07001049 const u8 *peer_addr, u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001050{
1051 if (wpa_s->p2p_mgmt)
1052 return;
1053
1054 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1055}
1056
1057#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001058
1059/*
1060 * DPP Notifications
1061 */
1062
1063/* DPP Success notifications */
1064
Hai Shalom706f99b2019-01-08 16:23:37 -08001065void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Hai Shalom59532852018-12-07 10:32:58 -08001066 struct wpa_ssid *ssid)
1067{
1068#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001069 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001070 return;
1071
Hai Shalom706f99b2019-01-08 16:23:37 -08001072 wpas_hidl_notify_dpp_config_received(wpa_s, ssid);
Hai Shalom59532852018-12-07 10:32:58 -08001073#endif /* CONFIG_DPP */
1074}
1075
Hai Shalom706f99b2019-01-08 16:23:37 -08001076void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001077{
1078#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001079 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001080 return;
1081
Hai Shalom706f99b2019-01-08 16:23:37 -08001082 wpas_hidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001083#endif /* CONFIG_DPP */
1084}
1085
1086/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001087void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001088{
1089#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001090 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001091 return;
1092
Hai Shalom706f99b2019-01-08 16:23:37 -08001093 wpas_hidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001094#endif /* CONFIG_DPP */
1095}
1096
Hai Shalom706f99b2019-01-08 16:23:37 -08001097void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001098{
1099#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001100 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001101 return;
1102
Hai Shalom706f99b2019-01-08 16:23:37 -08001103 wpas_hidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001104#endif /* CONFIG_DPP */
1105}
1106
1107/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001108void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001109{
1110#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001111 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001112 return;
1113
Hai Shalom706f99b2019-01-08 16:23:37 -08001114 wpas_hidl_notify_dpp_not_compatible(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001115#endif /* CONFIG_DPP */
1116}
1117
Hai Shalom706f99b2019-01-08 16:23:37 -08001118void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001119{
1120#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001121 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001122 return;
1123
Hai Shalom706f99b2019-01-08 16:23:37 -08001124 wpas_hidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001125#endif /* CONFIG_DPP */
1126}
1127
Hai Shalom706f99b2019-01-08 16:23:37 -08001128void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001129{
1130#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001131 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001132 return;
1133
Hai Shalom706f99b2019-01-08 16:23:37 -08001134 wpas_hidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001135#endif /* CONFIG_DPP */
1136}
1137
Hai Shalom706f99b2019-01-08 16:23:37 -08001138void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001139{
1140#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001141 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001142 return;
1143
Hai Shalom706f99b2019-01-08 16:23:37 -08001144 wpas_hidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001145#endif /* CONFIG_DPP */
1146}
1147
Hai Shalom706f99b2019-01-08 16:23:37 -08001148void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001149{
1150#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001151 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001152 return;
1153
Hai Shalom706f99b2019-01-08 16:23:37 -08001154 wpas_hidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001155#endif /* CONFIG_DPP */
1156}
1157
Hai Shalom706f99b2019-01-08 16:23:37 -08001158void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001159{
1160#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001161 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001162 return;
1163
Hai Shalom706f99b2019-01-08 16:23:37 -08001164 wpas_hidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001165#endif /* CONFIG_DPP */
1166}
Jimmy Chen126b1702019-08-28 17:59:33 +08001167
1168void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1169 struct rsn_pmksa_cache_entry *entry)
1170{
1171 if (!wpa_s)
1172 return;
1173
1174 wpas_hidl_notify_pmk_cache_added(wpa_s, entry);
1175}