blob: e0965794f309f80d3df069df2b2aff5de0a7fbf3 [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
Sunil Ravi972b2042020-08-14 10:50:48 -0700151void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s,
152 const u8 *bssid, u8 timed_out)
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800153{
154 if (wpa_s->p2p_mgmt)
155 return;
156
157 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
Roshan Pius0974e962016-12-12 17:05:51 -0800158
Sunil Ravi972b2042020-08-14 10:50:48 -0700159 wpas_hidl_notify_assoc_reject(wpa_s, bssid, timed_out);
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800160}
161
Roshan Pius38e96762017-01-23 14:52:00 -0800162void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
163 if (wpa_s->p2p_mgmt)
164 return;
165
166 wpas_hidl_notify_auth_timeout(wpa_s);
167}
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800168
Hai Shalom74f70d42019-02-11 14:42:39 -0800169void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
170{
171 if (wpa_s->p2p_mgmt)
172 return;
173
174 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
175}
176
177
178void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
179{
180 if (wpa_s->p2p_mgmt)
181 return;
182
183 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
184}
185
186
187void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
188{
189 if (wpa_s->p2p_mgmt)
190 return;
191
192 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
193}
194
195
196void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
197{
198 if (wpa_s->p2p_mgmt)
199 return;
200
201 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
Sunil Ravi4018d712019-12-06 18:01:21 -0800202
203#ifdef CONFIG_WNM
204 wpas_hidl_notify_bss_tm_status(wpa_s);
205#endif
Hai Shalom74f70d42019-02-11 14:42:39 -0800206}
207
208
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700209void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
210{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800211 if (wpa_s->p2p_mgmt)
212 return;
213
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700214 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
215}
216
217
218void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
219{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800220 if (wpa_s->p2p_mgmt)
221 return;
222
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700223 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
224}
225
226
227void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
228{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800229 if (wpa_s->p2p_mgmt)
230 return;
231
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700232 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700233
234 wpas_hidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700235}
236
237
238void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
239{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800240 if (wpa_s->p2p_mgmt)
241 return;
242
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700243 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
244}
245
246
247void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
248 struct wpa_ssid *ssid)
249{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800250 if (wpa_s->p2p_mgmt)
251 return;
252
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700253 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
254}
255
256
257void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
258 struct wpa_ssid *ssid)
259{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800260 if (wpa_s->p2p_mgmt)
261 return;
262
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700263 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
264}
265
266
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800267void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
268 struct wpa_ssid *ssid,
269 enum wpa_ctrl_req_type rtype,
270 const char *default_txt)
271{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800272 if (wpa_s->p2p_mgmt)
273 return;
274
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800275 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700276
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700277 wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800278}
279
280
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700281void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
282{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800283 if (wpa_s->p2p_mgmt)
284 return;
285
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700286 /* notify the new DBus API */
287 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
288}
289
290
291void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
292{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800293 if (wpa_s->p2p_mgmt)
294 return;
295
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700296 wpas_dbus_signal_scan_done(wpa_s, success);
297}
298
299
300void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
301{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800302 if (wpa_s->p2p_mgmt)
303 return;
304
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700305 wpas_wps_notify_scan_results(wpa_s);
306}
307
308
309void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
310 const struct wps_credential *cred)
311{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800312 if (wpa_s->p2p_mgmt)
313 return;
314
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700315#ifdef CONFIG_WPS
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700316 /* notify the new DBus API */
317 wpas_dbus_signal_wps_cred(wpa_s, cred);
318#endif /* CONFIG_WPS */
319}
320
321
322void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
323 struct wps_event_m2d *m2d)
324{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800325 if (wpa_s->p2p_mgmt)
326 return;
327
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700328#ifdef CONFIG_WPS
329 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
330#endif /* CONFIG_WPS */
331}
332
333
334void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
335 struct wps_event_fail *fail)
336{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800337 if (wpa_s->p2p_mgmt)
338 return;
339
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700340#ifdef CONFIG_WPS
341 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800342
343 wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
344 fail->config_error,
345 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700346#endif /* CONFIG_WPS */
347}
348
349
350void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
351{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800352 if (wpa_s->p2p_mgmt)
353 return;
354
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700355#ifdef CONFIG_WPS
356 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800357
358 wpas_hidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700359#endif /* CONFIG_WPS */
360}
361
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700362void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
363{
364 if (wpa_s->p2p_mgmt)
365 return;
366
367#ifdef CONFIG_WPS
368 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800369
370 wpas_hidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700371#endif /* CONFIG_WPS */
372}
373
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700374
375void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
376 struct wpa_ssid *ssid)
377{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800378 if (wpa_s->p2p_mgmt)
379 return;
380
Jouni Malinen75ecf522011-06-27 15:19:46 -0700381 /*
382 * Networks objects created during any P2P activities should not be
383 * exposed out. They might/will confuse certain non-P2P aware
384 * applications since these network objects won't behave like
385 * regular ones.
386 */
Roshan Piusd3854452016-07-07 16:46:41 -0700387 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700388 wpas_dbus_register_network(wpa_s, ssid);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700389 wpas_hidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700390 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700391}
392
393
394void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
395 struct wpa_ssid *ssid)
396{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700397#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700398 wpas_dbus_register_persistent_group(wpa_s, ssid);
Glen Kuhne30990d62017-04-19 14:16:48 -0700399 wpas_hidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700400#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700401}
402
403
404void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
405 struct wpa_ssid *ssid)
406{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700407#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700408 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Glen Kuhne30990d62017-04-19 14:16:48 -0700409 wpas_hidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700410#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700411}
412
413
414void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
415 struct wpa_ssid *ssid)
416{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800417 if (wpa_s->next_ssid == ssid)
418 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800419 if (wpa_s->wpa)
420 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700421 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700422 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700423 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700424 wpas_hidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700425 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800426 if (network_is_persistent_group(ssid))
427 wpas_notify_persistent_group_removed(wpa_s, ssid);
428
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800429 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700430}
431
432
433void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
434 u8 bssid[], unsigned int id)
435{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800436 if (wpa_s->p2p_mgmt)
437 return;
438
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700439 wpas_dbus_register_bss(wpa_s, bssid, id);
440 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
441 id, MAC2STR(bssid));
442}
443
444
445void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
446 u8 bssid[], unsigned int id)
447{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800448 if (wpa_s->p2p_mgmt)
449 return;
450
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700451 wpas_dbus_unregister_bss(wpa_s, bssid, id);
452 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
453 id, MAC2STR(bssid));
454}
455
456
457void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
458 unsigned int id)
459{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800460 if (wpa_s->p2p_mgmt)
461 return;
462
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700463 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
464}
465
466
467void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
468 unsigned int id)
469{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800470 if (wpa_s->p2p_mgmt)
471 return;
472
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700473 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
474 id);
475}
476
477
478void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
479 unsigned int id)
480{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800481 if (wpa_s->p2p_mgmt)
482 return;
483
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700484 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
485 id);
486}
487
488
489void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
490 unsigned int id)
491{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800492 if (wpa_s->p2p_mgmt)
493 return;
494
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700495 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
496}
497
498
499void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
500 unsigned int id)
501{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800502 if (wpa_s->p2p_mgmt)
503 return;
504
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700505 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
506}
507
508
509void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
510 unsigned int id)
511{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800512 if (wpa_s->p2p_mgmt)
513 return;
514
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700515 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
516}
517
518
519void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
520 unsigned int id)
521{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800522 if (wpa_s->p2p_mgmt)
523 return;
524
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800525#ifdef CONFIG_WPS
526 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
527#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700528}
529
530
531void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
532 unsigned int id)
533{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800534 if (wpa_s->p2p_mgmt)
535 return;
536
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700537 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
538}
539
540
541void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
542 unsigned int id)
543{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800544 if (wpa_s->p2p_mgmt)
545 return;
546
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700547 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
548}
549
550
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700551void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
552{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800553 if (wpa_s->p2p_mgmt)
554 return;
555
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700556 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
557}
558
559
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700560void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
561{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800562 if (wpa_s->p2p_mgmt)
563 return;
564
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700565 wpas_dbus_signal_blob_added(wpa_s, name);
566}
567
568
569void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
570{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800571 if (wpa_s->p2p_mgmt)
572 return;
573
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700574 wpas_dbus_signal_blob_removed(wpa_s, name);
575}
576
577
578void wpas_notify_debug_level_changed(struct wpa_global *global)
579{
580 wpas_dbus_signal_debug_level_changed(global);
581}
582
583
584void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
585{
586 wpas_dbus_signal_debug_timestamp_changed(global);
587}
588
589
590void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
591{
592 wpas_dbus_signal_debug_show_keys_changed(global);
593}
594
595
596void wpas_notify_suspend(struct wpa_global *global)
597{
598 struct wpa_supplicant *wpa_s;
599
600 os_get_time(&global->suspend_time);
601 wpa_printf(MSG_DEBUG, "System suspend notification");
602 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
603 wpa_drv_suspend(wpa_s);
604}
605
606
607void wpas_notify_resume(struct wpa_global *global)
608{
609 struct os_time now;
610 int slept;
611 struct wpa_supplicant *wpa_s;
612
613 if (global->suspend_time.sec == 0)
614 slept = -1;
615 else {
616 os_get_time(&now);
617 slept = now.sec - global->suspend_time.sec;
618 }
619 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
620 slept);
621
622 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
623 wpa_drv_resume(wpa_s);
624 if (wpa_s->wpa_state == WPA_DISCONNECTED)
625 wpa_supplicant_req_scan(wpa_s, 0, 100000);
626 }
627}
628
629
630#ifdef CONFIG_P2P
631
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700632void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
633{
634 /* Notify P2P find has stopped */
635 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800636
637 wpas_hidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700638}
639
640
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700641void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800642 const u8 *addr, const struct p2p_peer_info *info,
643 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
644 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700645{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700646 if (new_device) {
647 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800648 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700649 }
650
651 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800652 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
653
654 wpas_hidl_notify_p2p_device_found(wpa_s, addr, info,
655 peer_wfd_device_info,
656 peer_wfd_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700657}
658
659
660void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
661 const u8 *dev_addr)
662{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700663 wpas_dbus_unregister_peer(wpa_s, dev_addr);
664
665 /* Create signal on interface object*/
666 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800667
668 wpas_hidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700669}
670
671
672void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
673 const struct wpa_ssid *ssid,
674 const char *role)
675{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700676 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700677
678 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800679
680 wpas_hidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700681}
682
683
684void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700685 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700686{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700687 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800688
689 wpas_hidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700690}
691
692
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800693void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
694 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700695{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800696 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800697
698 wpas_hidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700699}
700
701
702void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
703 int status, const u8 *bssid)
704{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700705 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800706
707 wpas_hidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700708}
709
710
711void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
712 int freq, const u8 *sa, u8 dialog_token,
713 u16 update_indic, const u8 *tlvs,
714 size_t tlvs_len)
715{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700716 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
717 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700718}
719
720
721void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
722 const u8 *sa, u16 update_indic,
723 const u8 *tlvs, size_t tlvs_len)
724{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700725 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
726 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800727
728 wpas_hidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
729 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700730}
731
732
733/**
734 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
735 * @dev_addr: Who sent the request or responded to our request.
736 * @request: Will be 1 if request, 0 for response.
737 * @status: Valid only in case of response (0 in case of success)
738 * @config_methods: WPS config methods
739 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
740 *
741 * This can be used to notify:
742 * - Requests or responses
743 * - Various config methods
744 * - Failure condition in case of response
745 */
746void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
747 const u8 *dev_addr, int request,
748 enum p2p_prov_disc_status status,
749 u16 config_methods,
750 unsigned int generated_pin)
751{
752 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
753 status, config_methods,
754 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800755
756 wpas_hidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
757 status, config_methods,
758 generated_pin);
759
Jouni Malinen75ecf522011-06-27 15:19:46 -0700760}
761
762
763void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700764 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800765 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700766{
767 /* Notify a group has been started */
768 wpas_dbus_register_p2p_group(wpa_s, ssid);
769
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800770 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800771
Roshan Pius7a1c8482017-04-12 17:05:10 -0700772 wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700773}
774
775
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800776void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
777 const char *reason)
778{
779 /* Notify a group formation failed */
780 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800781
782 wpas_hidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800783}
784
785
Jouni Malinen75ecf522011-06-27 15:19:46 -0700786void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
787 struct wps_event_fail *fail)
788{
789 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700790}
791
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800792
793void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
794 const u8 *sa, const u8 *go_dev_addr,
795 const u8 *bssid, int id, int op_freq)
796{
797 /* Notify a P2P Invitation Request */
798 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
799 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800800
801 wpas_hidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
802 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800803}
804
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700805#endif /* CONFIG_P2P */
806
807
808static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800809 const u8 *sta,
810 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700811{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700812#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800813 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
814
Jouni Malinen75ecf522011-06-27 15:19:46 -0700815 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700816 * Create 'peer-joined' signal on group object -- will also
817 * check P2P itself.
818 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800819 if (p2p_dev_addr)
820 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700821#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700822
Hai Shalom74f70d42019-02-11 14:42:39 -0800823 /* Register the station */
824 wpas_dbus_register_sta(wpa_s, sta);
825
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700826 /* Notify listeners a new station has been authorized */
827 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800828
829 wpas_hidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700830}
831
832
833static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700834 const u8 *sta,
835 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700836{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700837#ifdef CONFIG_P2P
838 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700839 * Create 'peer-disconnected' signal on group object if this
840 * is a P2P group.
841 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800842 if (p2p_dev_addr)
843 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700844#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700845
846 /* Notify listeners a station has been deauthorized */
847 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800848
lesl4b7058c2019-02-27 18:45:19 +0800849 wpas_hidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Hai Shalom74f70d42019-02-11 14:42:39 -0800850 /* Unregister the station */
851 wpas_dbus_unregister_sta(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700852}
853
854
855void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800856 const u8 *mac_addr, int authorized,
857 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700858{
859 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800860 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700861 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700862 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700863}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700864
865
Hai Shalom81f62d82019-07-22 12:10:00 -0700866void wpas_notify_certification(struct wpa_supplicant *wpa_s,
867 struct tls_cert_data *cert,
868 const char *cert_hash)
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700869{
Hai Shalom81f62d82019-07-22 12:10:00 -0700870 int i;
Hai Shalom878cf7b2019-07-15 14:55:18 -0700871
Hai Shalom81f62d82019-07-22 12:10:00 -0700872 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
Hai Shalomc3565922019-10-28 11:58:20 -0700873 "depth=%d subject='%s'%s%s%s%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700874 cert->depth, cert->subject, cert_hash ? " hash=" : "",
875 cert_hash ? cert_hash : "",
Hai Shalomc3565922019-10-28 11:58:20 -0700876 cert->tod == 2 ? " tod=2" : "",
877 cert->tod == 1 ? " tod=1" : "");
Hai Shalom81f62d82019-07-22 12:10:00 -0700878
879 if (cert->cert) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700880 char *cert_hex;
Hai Shalom81f62d82019-07-22 12:10:00 -0700881 size_t len = wpabuf_len(cert->cert) * 2 + 1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700882 cert_hex = os_malloc(len);
883 if (cert_hex) {
Hai Shalom81f62d82019-07-22 12:10:00 -0700884 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
885 wpabuf_len(cert->cert));
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700886 wpa_msg_ctrl(wpa_s, MSG_INFO,
887 WPA_EVENT_EAP_PEER_CERT
888 "depth=%d subject='%s' cert=%s",
Hai Shalom81f62d82019-07-22 12:10:00 -0700889 cert->depth, cert->subject, cert_hex);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700890 os_free(cert_hex);
891 }
892 }
893
Hai Shalom81f62d82019-07-22 12:10:00 -0700894 for (i = 0; i < cert->num_altsubject; i++)
895 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
896 "depth=%d %s", cert->depth, cert->altsubject[i]);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800897
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700898 /* notify the new DBus API */
Hai Shalom81f62d82019-07-22 12:10:00 -0700899 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
900 cert->altsubject, cert->num_altsubject,
901 cert_hash, cert->cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700902}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700903
904
905void wpas_notify_preq(struct wpa_supplicant *wpa_s,
906 const u8 *addr, const u8 *dst, const u8 *bssid,
907 const u8 *ie, size_t ie_len, u32 ssi_signal)
908{
909#ifdef CONFIG_AP
910 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
911#endif /* CONFIG_AP */
912}
913
914
915void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
916 const char *parameter)
917{
918 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700919 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
920 "status='%s' parameter='%s'",
921 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700922}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700923
Roshan Pius3a1667e2018-07-03 15:17:14 -0700924
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700925void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
926{
927 wpa_dbg(wpa_s, MSG_ERROR,
928 "EAP Error code = %d", error_code);
Ahmed ElArabawy30eab622018-03-19 18:36:48 -0700929 wpas_hidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700930}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700931
Roshan Pius3a1667e2018-07-03 15:17:14 -0700932
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700933void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
934 struct wpa_ssid *ssid)
935{
936 if (wpa_s->current_ssid != ssid)
937 return;
938
939 wpa_dbg(wpa_s, MSG_DEBUG,
940 "Network bssid config changed for the current network - within-ESS roaming %s",
941 ssid->bssid_set ? "disabled" : "enabled");
942
943 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
944 ssid->bssid_set ? ssid->bssid : NULL);
945}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800946
947
948void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
949 struct wpa_ssid *ssid)
950{
951#ifdef CONFIG_P2P
952 if (ssid->disabled == 2) {
953 /* Changed from normal network profile to persistent group */
954 ssid->disabled = 0;
955 wpas_dbus_unregister_network(wpa_s, ssid->id);
956 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700957 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800958 wpas_dbus_register_persistent_group(wpa_s, ssid);
959 } else {
960 /* Changed from persistent group to normal network profile */
961 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700962 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800963 wpas_dbus_register_network(wpa_s, ssid);
964 }
965#endif /* CONFIG_P2P */
966}
Roshan Pius04a9d742016-12-12 12:40:46 -0800967
968void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
969 const char *result,
970 const struct wpa_bss_anqp *anqp)
971{
972#ifdef CONFIG_INTERWORKING
973 if (!wpa_s || !bssid || !anqp)
974 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800975
976 wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800977#endif /* CONFIG_INTERWORKING */
978}
979
980void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
981 const char* file_name, const u8* image,
982 u32 image_length)
983{
984#ifdef CONFIG_HS20
985 if (!wpa_s || !bssid || !file_name || !image)
986 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800987
988 wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
989 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -0800990#endif /* CONFIG_HS20 */
991}
992
993void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
994 const char* url,
995 u8 osu_method)
996{
997#ifdef CONFIG_HS20
998 if (!wpa_s || !url)
999 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001000
1001 wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -08001002#endif /* CONFIG_HS20 */
1003}
1004
1005void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1006 u8 code, u16 reauth_delay,
1007 const char *url)
1008{
1009#ifdef CONFIG_HS20
Hai Shalomb3a7c702020-10-20 12:22:53 -07001010 if (!wpa_s)
Roshan Pius04a9d742016-12-12 12:40:46 -08001011 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001012
1013 wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
1014 url);
Roshan Pius04a9d742016-12-12 12:40:46 -08001015#endif /* CONFIG_HS20 */
1016}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001017
1018
1019#ifdef CONFIG_MESH
1020
1021void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1022 struct wpa_ssid *ssid)
1023{
1024 if (wpa_s->p2p_mgmt)
1025 return;
1026
1027 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1028}
1029
1030
1031void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1032 const u8 *meshid, u8 meshid_len,
Hai Shalom81f62d82019-07-22 12:10:00 -07001033 u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001034{
1035 if (wpa_s->p2p_mgmt)
1036 return;
1037
1038 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1039 reason_code);
1040}
1041
1042
1043void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1044 const u8 *peer_addr)
1045{
1046 if (wpa_s->p2p_mgmt)
1047 return;
1048
1049 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1050}
1051
1052
1053void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
Hai Shalom81f62d82019-07-22 12:10:00 -07001054 const u8 *peer_addr, u16 reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001055{
1056 if (wpa_s->p2p_mgmt)
1057 return;
1058
1059 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1060}
1061
1062#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001063
1064/*
1065 * DPP Notifications
1066 */
1067
1068/* DPP Success notifications */
1069
Hai Shalom706f99b2019-01-08 16:23:37 -08001070void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Hai Shalom59532852018-12-07 10:32:58 -08001071 struct wpa_ssid *ssid)
1072{
1073#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001074 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001075 return;
1076
Hai Shalom706f99b2019-01-08 16:23:37 -08001077 wpas_hidl_notify_dpp_config_received(wpa_s, ssid);
Hai Shalom59532852018-12-07 10:32:58 -08001078#endif /* CONFIG_DPP */
1079}
1080
Hai Shalom706f99b2019-01-08 16:23:37 -08001081void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001082{
1083#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001084 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001085 return;
1086
Hai Shalom706f99b2019-01-08 16:23:37 -08001087 wpas_hidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001088#endif /* CONFIG_DPP */
1089}
1090
1091/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001092void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001093{
1094#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001095 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001096 return;
1097
Hai Shalom706f99b2019-01-08 16:23:37 -08001098 wpas_hidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001099#endif /* CONFIG_DPP */
1100}
1101
Hai Shalom706f99b2019-01-08 16:23:37 -08001102void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001103{
1104#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001105 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001106 return;
1107
Hai Shalom706f99b2019-01-08 16:23:37 -08001108 wpas_hidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001109#endif /* CONFIG_DPP */
1110}
1111
1112/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001113void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001114{
1115#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001116 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001117 return;
1118
Hai Shalom706f99b2019-01-08 16:23:37 -08001119 wpas_hidl_notify_dpp_not_compatible(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001120#endif /* CONFIG_DPP */
1121}
1122
Hai Shalom706f99b2019-01-08 16:23:37 -08001123void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001124{
1125#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001126 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001127 return;
1128
Hai Shalom706f99b2019-01-08 16:23:37 -08001129 wpas_hidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001130#endif /* CONFIG_DPP */
1131}
1132
Hai Shalom706f99b2019-01-08 16:23:37 -08001133void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001134{
1135#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001136 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001137 return;
1138
Hai Shalom706f99b2019-01-08 16:23:37 -08001139 wpas_hidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001140#endif /* CONFIG_DPP */
1141}
1142
Hai Shalom706f99b2019-01-08 16:23:37 -08001143void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001144{
1145#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001146 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001147 return;
1148
Hai Shalom706f99b2019-01-08 16:23:37 -08001149 wpas_hidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001150#endif /* CONFIG_DPP */
1151}
1152
Hai Shalom706f99b2019-01-08 16:23:37 -08001153void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001154{
1155#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001156 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001157 return;
1158
Hai Shalom706f99b2019-01-08 16:23:37 -08001159 wpas_hidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001160#endif /* CONFIG_DPP */
1161}
1162
Hai Shalom706f99b2019-01-08 16:23:37 -08001163void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001164{
1165#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001166 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001167 return;
1168
Hai Shalom706f99b2019-01-08 16:23:37 -08001169 wpas_hidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001170#endif /* CONFIG_DPP */
1171}
Jimmy Chen126b1702019-08-28 17:59:33 +08001172
Hai Shalom06768112019-12-04 15:49:43 -08001173void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1174{
1175#ifdef CONFIG_DPP2
1176 wpas_hidl_notify_dpp_config_sent_wait_response(wpa_s);
1177#endif /* CONFIG_DPP2 */
1178}
1179
1180void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1181{
1182#ifdef CONFIG_DPP2
1183 wpas_hidl_notify_dpp_config_accepted(wpa_s);
1184#endif /* CONFIG_DPP2 */
1185}
1186
1187void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1188 enum dpp_status_error status, const char *ssid,
1189 const char *channel_list, unsigned short band_list[], int size)
1190{
1191#ifdef CONFIG_DPP2
1192 wpas_hidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
1193#endif /* CONFIG_DPP2 */
1194}
1195
1196void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1197{
1198#ifdef CONFIG_DPP2
1199 wpas_hidl_notify_dpp_config_rejected(wpa_s);
1200#endif /* CONFIG_DPP2 */
1201}
1202
Jimmy Chen126b1702019-08-28 17:59:33 +08001203void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1204 struct rsn_pmksa_cache_entry *entry)
1205{
1206 if (!wpa_s)
1207 return;
1208
1209 wpas_hidl_notify_pmk_cache_added(wpa_s, entry);
1210}
Jimmy Chen39deead2020-10-14 23:47:20 +08001211
1212void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
1213 struct wpa_ssid *ssid,
1214 u8 bitmap)
1215{
1216 if (!wpa_s)
1217 return;
1218
1219 if (!ssid)
1220 return;
1221
1222 wpas_hidl_notify_transition_disable(wpa_s, ssid, bitmap);
1223}