blob: 41dc3341735c1e1cbddc4c6193f5a09b89577643 [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"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070020#include "driver_i.h"
21#include "scan.h"
22#include "p2p_supplicant.h"
23#include "sme.h"
24#include "notify.h"
Roshan Piusedd820c2017-05-16 14:21:49 -070025#include "hidl.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070026
27int wpas_notify_supplicant_initialized(struct wpa_global *global)
28{
Hai Shalom021b0b52019-04-10 11:17:58 -070029#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070030 if (global->params.dbus_ctrl_interface) {
31 global->dbus = wpas_dbus_init(global);
32 if (global->dbus == NULL)
33 return -1;
34 }
Hai Shalom021b0b52019-04-10 11:17:58 -070035#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070036
Roshan Pius57ffbcf2016-09-27 09:12:46 -070037#ifdef CONFIG_HIDL
38 global->hidl = wpas_hidl_init(global);
39 if (!global->hidl)
Dmitry Shmidte4663042016-04-04 10:07:49 -070040 return -1;
Roshan Pius57ffbcf2016-09-27 09:12:46 -070041#endif /* CONFIG_HIDL */
Dmitry Shmidte4663042016-04-04 10:07:49 -070042
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070043 return 0;
44}
45
46
47void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
48{
Hai Shalom021b0b52019-04-10 11:17:58 -070049#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070050 if (global->dbus)
51 wpas_dbus_deinit(global->dbus);
Hai Shalom021b0b52019-04-10 11:17:58 -070052#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
Dmitry Shmidte4663042016-04-04 10:07:49 -070053
Roshan Pius57ffbcf2016-09-27 09:12:46 -070054#ifdef CONFIG_HIDL
55 if (global->hidl)
56 wpas_hidl_deinit(global->hidl);
57#endif /* CONFIG_HIDL */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070058}
59
60
61int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
62{
Hai Shalomc4809952019-04-30 14:45:55 -070063 if (!wpa_s->p2p_mgmt) {
64 if (wpas_dbus_register_interface(wpa_s))
65 return -1;
66 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070067
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080068 /* HIDL interface wants to keep track of the P2P mgmt iface. */
Roshan Pius57ffbcf2016-09-27 09:12:46 -070069 if (wpas_hidl_register_interface(wpa_s))
Roshan Pius54e763a2016-07-06 15:41:53 -070070 return -1;
71
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070072 return 0;
73}
74
75
76void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
77{
Hai Shalomc4809952019-04-30 14:45:55 -070078 if (!wpa_s->p2p_mgmt) {
79 /* unregister interface in new DBus ctrl iface */
80 wpas_dbus_unregister_interface(wpa_s);
81 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070082
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080083 /* HIDL interface wants to keep track of the P2P mgmt iface. */
Roshan Pius57ffbcf2016-09-27 09:12:46 -070084 wpas_hidl_unregister_interface(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070085}
86
87
88void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
89 enum wpa_states new_state,
90 enum wpa_states old_state)
91{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080092 if (wpa_s->p2p_mgmt)
93 return;
94
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070095 /* notify the new DBus API */
96 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
97
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080098#ifdef CONFIG_FST
99 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
100 if (new_state == WPA_COMPLETED)
101 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
102 else if (old_state >= WPA_ASSOCIATED &&
103 new_state < WPA_ASSOCIATED)
104 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
105 }
106#endif /* CONFIG_FST */
107
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700108 if (new_state == WPA_COMPLETED)
109 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700110 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700111 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700112
113 sme_state_changed(wpa_s);
114
115#ifdef ANDROID
116 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700117 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700118 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700119 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700120 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700121 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
122 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800123 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700124#endif /* ANDROID */
Roshan Piuse8d0d162016-08-01 13:09:26 -0700125
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700126 wpas_hidl_notify_state_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700127}
128
129
Dmitry Shmidt04949592012-07-19 12:16:46 -0700130void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
131{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800132 if (wpa_s->p2p_mgmt)
133 return;
134
Dmitry Shmidt04949592012-07-19 12:16:46 -0700135 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
Roshan Pius0974e962016-12-12 17:05:51 -0800136
Roshan Piusbe158772017-03-10 17:54:37 -0800137 wpas_hidl_notify_disconnect_reason(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700138}
139
140
Hai Shalom74f70d42019-02-11 14:42:39 -0800141void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
142{
143 if (wpa_s->p2p_mgmt)
144 return;
145
146 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
147}
148
149
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800150void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
151{
152 if (wpa_s->p2p_mgmt)
153 return;
154
155 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
Roshan Pius0974e962016-12-12 17:05:51 -0800156
157 wpas_hidl_notify_assoc_reject(wpa_s);
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800158}
159
Roshan Pius38e96762017-01-23 14:52:00 -0800160void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
161 if (wpa_s->p2p_mgmt)
162 return;
163
164 wpas_hidl_notify_auth_timeout(wpa_s);
165}
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800166
Hai Shalom74f70d42019-02-11 14:42:39 -0800167void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
168{
169 if (wpa_s->p2p_mgmt)
170 return;
171
172 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
173}
174
175
176void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
177{
178 if (wpa_s->p2p_mgmt)
179 return;
180
181 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
182}
183
184
185void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
186{
187 if (wpa_s->p2p_mgmt)
188 return;
189
190 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
191}
192
193
194void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
195{
196 if (wpa_s->p2p_mgmt)
197 return;
198
199 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
200}
201
202
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700203void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
204{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800205 if (wpa_s->p2p_mgmt)
206 return;
207
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700208 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
209}
210
211
212void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
213{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800214 if (wpa_s->p2p_mgmt)
215 return;
216
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700217 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
218}
219
220
221void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
222{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800223 if (wpa_s->p2p_mgmt)
224 return;
225
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700226 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700227
228 wpas_hidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700229}
230
231
232void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
233{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800234 if (wpa_s->p2p_mgmt)
235 return;
236
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700237 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
238}
239
240
241void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
242 struct wpa_ssid *ssid)
243{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800244 if (wpa_s->p2p_mgmt)
245 return;
246
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700247 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
248}
249
250
251void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
252 struct wpa_ssid *ssid)
253{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800254 if (wpa_s->p2p_mgmt)
255 return;
256
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700257 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
258}
259
260
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800261void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
262 struct wpa_ssid *ssid,
263 enum wpa_ctrl_req_type rtype,
264 const char *default_txt)
265{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800266 if (wpa_s->p2p_mgmt)
267 return;
268
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800269 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700270
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700271 wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800272}
273
274
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700275void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
276{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800277 if (wpa_s->p2p_mgmt)
278 return;
279
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700280 /* notify the new DBus API */
281 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
282}
283
284
285void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
286{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800287 if (wpa_s->p2p_mgmt)
288 return;
289
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700290 wpas_dbus_signal_scan_done(wpa_s, success);
291}
292
293
294void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
295{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800296 if (wpa_s->p2p_mgmt)
297 return;
298
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700299 wpas_wps_notify_scan_results(wpa_s);
300}
301
302
303void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
304 const struct wps_credential *cred)
305{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800306 if (wpa_s->p2p_mgmt)
307 return;
308
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700309#ifdef CONFIG_WPS
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700310 /* notify the new DBus API */
311 wpas_dbus_signal_wps_cred(wpa_s, cred);
312#endif /* CONFIG_WPS */
313}
314
315
316void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
317 struct wps_event_m2d *m2d)
318{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800319 if (wpa_s->p2p_mgmt)
320 return;
321
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700322#ifdef CONFIG_WPS
323 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
324#endif /* CONFIG_WPS */
325}
326
327
328void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
329 struct wps_event_fail *fail)
330{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800331 if (wpa_s->p2p_mgmt)
332 return;
333
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700334#ifdef CONFIG_WPS
335 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800336
337 wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
338 fail->config_error,
339 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700340#endif /* CONFIG_WPS */
341}
342
343
344void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
345{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800346 if (wpa_s->p2p_mgmt)
347 return;
348
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700349#ifdef CONFIG_WPS
350 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800351
352 wpas_hidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700353#endif /* CONFIG_WPS */
354}
355
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700356void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
357{
358 if (wpa_s->p2p_mgmt)
359 return;
360
361#ifdef CONFIG_WPS
362 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800363
364 wpas_hidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700365#endif /* CONFIG_WPS */
366}
367
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700368
369void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
370 struct wpa_ssid *ssid)
371{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800372 if (wpa_s->p2p_mgmt)
373 return;
374
Jouni Malinen75ecf522011-06-27 15:19:46 -0700375 /*
376 * Networks objects created during any P2P activities should not be
377 * exposed out. They might/will confuse certain non-P2P aware
378 * applications since these network objects won't behave like
379 * regular ones.
380 */
Roshan Piusd3854452016-07-07 16:46:41 -0700381 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700382 wpas_dbus_register_network(wpa_s, ssid);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700383 wpas_hidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700384 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700385}
386
387
388void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
389 struct wpa_ssid *ssid)
390{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700391#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700392 wpas_dbus_register_persistent_group(wpa_s, ssid);
Glen Kuhne30990d62017-04-19 14:16:48 -0700393 wpas_hidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700394#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700395}
396
397
398void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
399 struct wpa_ssid *ssid)
400{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700401#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700402 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Glen Kuhne30990d62017-04-19 14:16:48 -0700403 wpas_hidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700404#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700405}
406
407
408void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
409 struct wpa_ssid *ssid)
410{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800411 if (wpa_s->next_ssid == ssid)
412 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800413 if (wpa_s->wpa)
414 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700415 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700416 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700417 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700418 wpas_hidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700419 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800420 if (network_is_persistent_group(ssid))
421 wpas_notify_persistent_group_removed(wpa_s, ssid);
422
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800423 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700424}
425
426
427void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
428 u8 bssid[], unsigned int id)
429{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800430 if (wpa_s->p2p_mgmt)
431 return;
432
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700433 wpas_dbus_register_bss(wpa_s, bssid, id);
434 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
435 id, MAC2STR(bssid));
436}
437
438
439void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
440 u8 bssid[], unsigned int id)
441{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800442 if (wpa_s->p2p_mgmt)
443 return;
444
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700445 wpas_dbus_unregister_bss(wpa_s, bssid, id);
446 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
447 id, MAC2STR(bssid));
448}
449
450
451void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
452 unsigned int id)
453{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800454 if (wpa_s->p2p_mgmt)
455 return;
456
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700457 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
458}
459
460
461void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
462 unsigned int id)
463{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800464 if (wpa_s->p2p_mgmt)
465 return;
466
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700467 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
468 id);
469}
470
471
472void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
473 unsigned int id)
474{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800475 if (wpa_s->p2p_mgmt)
476 return;
477
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700478 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
479 id);
480}
481
482
483void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
484 unsigned int id)
485{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800486 if (wpa_s->p2p_mgmt)
487 return;
488
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700489 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
490}
491
492
493void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
494 unsigned int id)
495{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800496 if (wpa_s->p2p_mgmt)
497 return;
498
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700499 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
500}
501
502
503void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
504 unsigned int id)
505{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800506 if (wpa_s->p2p_mgmt)
507 return;
508
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700509 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
510}
511
512
513void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
514 unsigned int id)
515{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800516 if (wpa_s->p2p_mgmt)
517 return;
518
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800519#ifdef CONFIG_WPS
520 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
521#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700522}
523
524
525void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
526 unsigned int id)
527{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800528 if (wpa_s->p2p_mgmt)
529 return;
530
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700531 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
532}
533
534
535void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
536 unsigned int id)
537{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800538 if (wpa_s->p2p_mgmt)
539 return;
540
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700541 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
542}
543
544
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700545void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
546{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800547 if (wpa_s->p2p_mgmt)
548 return;
549
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700550 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
551}
552
553
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700554void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
555{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800556 if (wpa_s->p2p_mgmt)
557 return;
558
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700559 wpas_dbus_signal_blob_added(wpa_s, name);
560}
561
562
563void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
564{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800565 if (wpa_s->p2p_mgmt)
566 return;
567
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700568 wpas_dbus_signal_blob_removed(wpa_s, name);
569}
570
571
572void wpas_notify_debug_level_changed(struct wpa_global *global)
573{
574 wpas_dbus_signal_debug_level_changed(global);
575}
576
577
578void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
579{
580 wpas_dbus_signal_debug_timestamp_changed(global);
581}
582
583
584void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
585{
586 wpas_dbus_signal_debug_show_keys_changed(global);
587}
588
589
590void wpas_notify_suspend(struct wpa_global *global)
591{
592 struct wpa_supplicant *wpa_s;
593
594 os_get_time(&global->suspend_time);
595 wpa_printf(MSG_DEBUG, "System suspend notification");
596 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
597 wpa_drv_suspend(wpa_s);
598}
599
600
601void wpas_notify_resume(struct wpa_global *global)
602{
603 struct os_time now;
604 int slept;
605 struct wpa_supplicant *wpa_s;
606
607 if (global->suspend_time.sec == 0)
608 slept = -1;
609 else {
610 os_get_time(&now);
611 slept = now.sec - global->suspend_time.sec;
612 }
613 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
614 slept);
615
616 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
617 wpa_drv_resume(wpa_s);
618 if (wpa_s->wpa_state == WPA_DISCONNECTED)
619 wpa_supplicant_req_scan(wpa_s, 0, 100000);
620 }
621}
622
623
624#ifdef CONFIG_P2P
625
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700626void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
627{
628 /* Notify P2P find has stopped */
629 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800630
631 wpas_hidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700632}
633
634
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700635void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800636 const u8 *addr, const struct p2p_peer_info *info,
637 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
638 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700639{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700640 if (new_device) {
641 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800642 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700643 }
644
645 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800646 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
647
648 wpas_hidl_notify_p2p_device_found(wpa_s, addr, info,
649 peer_wfd_device_info,
650 peer_wfd_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700651}
652
653
654void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
655 const u8 *dev_addr)
656{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700657 wpas_dbus_unregister_peer(wpa_s, dev_addr);
658
659 /* Create signal on interface object*/
660 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800661
662 wpas_hidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700663}
664
665
666void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
667 const struct wpa_ssid *ssid,
668 const char *role)
669{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700670 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700671
672 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800673
674 wpas_hidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700675}
676
677
678void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700679 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700680{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700681 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800682
683 wpas_hidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700684}
685
686
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800687void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
688 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700689{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800690 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800691
692 wpas_hidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700693}
694
695
696void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
697 int status, const u8 *bssid)
698{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700699 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800700
701 wpas_hidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700702}
703
704
705void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
706 int freq, const u8 *sa, u8 dialog_token,
707 u16 update_indic, const u8 *tlvs,
708 size_t tlvs_len)
709{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700710 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
711 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700712}
713
714
715void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
716 const u8 *sa, u16 update_indic,
717 const u8 *tlvs, size_t tlvs_len)
718{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700719 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
720 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800721
722 wpas_hidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
723 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700724}
725
726
727/**
728 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
729 * @dev_addr: Who sent the request or responded to our request.
730 * @request: Will be 1 if request, 0 for response.
731 * @status: Valid only in case of response (0 in case of success)
732 * @config_methods: WPS config methods
733 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
734 *
735 * This can be used to notify:
736 * - Requests or responses
737 * - Various config methods
738 * - Failure condition in case of response
739 */
740void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
741 const u8 *dev_addr, int request,
742 enum p2p_prov_disc_status status,
743 u16 config_methods,
744 unsigned int generated_pin)
745{
746 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
747 status, config_methods,
748 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800749
750 wpas_hidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
751 status, config_methods,
752 generated_pin);
753
Jouni Malinen75ecf522011-06-27 15:19:46 -0700754}
755
756
757void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700758 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800759 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700760{
761 /* Notify a group has been started */
762 wpas_dbus_register_p2p_group(wpa_s, ssid);
763
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800764 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800765
Roshan Pius7a1c8482017-04-12 17:05:10 -0700766 wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700767}
768
769
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800770void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
771 const char *reason)
772{
773 /* Notify a group formation failed */
774 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800775
776 wpas_hidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800777}
778
779
Jouni Malinen75ecf522011-06-27 15:19:46 -0700780void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
781 struct wps_event_fail *fail)
782{
783 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700784}
785
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800786
787void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
788 const u8 *sa, const u8 *go_dev_addr,
789 const u8 *bssid, int id, int op_freq)
790{
791 /* Notify a P2P Invitation Request */
792 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
793 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800794
795 wpas_hidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
796 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800797}
798
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700799#endif /* CONFIG_P2P */
800
801
802static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800803 const u8 *sta,
804 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700805{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700806#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800807 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
808
Jouni Malinen75ecf522011-06-27 15:19:46 -0700809 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700810 * Create 'peer-joined' signal on group object -- will also
811 * check P2P itself.
812 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800813 if (p2p_dev_addr)
814 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700815#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700816
Hai Shalom74f70d42019-02-11 14:42:39 -0800817 /* Register the station */
818 wpas_dbus_register_sta(wpa_s, sta);
819
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700820 /* Notify listeners a new station has been authorized */
821 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800822
823 wpas_hidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700824}
825
826
827static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700828 const u8 *sta,
829 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700830{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700831#ifdef CONFIG_P2P
832 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700833 * Create 'peer-disconnected' signal on group object if this
834 * is a P2P group.
835 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800836 if (p2p_dev_addr)
837 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700838#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700839
840 /* Notify listeners a station has been deauthorized */
841 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800842
lesl4b7058c2019-02-27 18:45:19 +0800843 wpas_hidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Hai Shalom74f70d42019-02-11 14:42:39 -0800844 /* Unregister the station */
845 wpas_dbus_unregister_sta(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700846}
847
848
849void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800850 const u8 *mac_addr, int authorized,
851 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700852{
853 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800854 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700855 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700856 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700857}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700858
859
Hai Shalomf1c97642019-07-19 23:42:07 +0000860void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
861 const char *subject, const char *altsubject[],
862 int num_altsubject, const char *cert_hash,
863 const struct wpabuf *cert)
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700864{
Hai Shalom878cf7b2019-07-15 14:55:18 -0700865 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
Hai Shalomf1c97642019-07-19 23:42:07 +0000866 "depth=%d subject='%s'%s%s",
867 depth, subject, cert_hash ? " hash=" : "",
868 cert_hash ? cert_hash : "");
Hai Shalom878cf7b2019-07-15 14:55:18 -0700869
Hai Shalomf1c97642019-07-19 23:42:07 +0000870 if (cert) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700871 char *cert_hex;
Hai Shalomf1c97642019-07-19 23:42:07 +0000872 size_t len = wpabuf_len(cert) * 2 + 1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700873 cert_hex = os_malloc(len);
874 if (cert_hex) {
Hai Shalomf1c97642019-07-19 23:42:07 +0000875 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
876 wpabuf_len(cert));
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700877 wpa_msg_ctrl(wpa_s, MSG_INFO,
878 WPA_EVENT_EAP_PEER_CERT
879 "depth=%d subject='%s' cert=%s",
Hai Shalomf1c97642019-07-19 23:42:07 +0000880 depth, subject, cert_hex);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700881 os_free(cert_hex);
882 }
883 }
884
Hai Shalomf1c97642019-07-19 23:42:07 +0000885 if (altsubject) {
886 int i;
887
888 for (i = 0; i < num_altsubject; i++)
889 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
890 "depth=%d %s", depth, altsubject[i]);
891 }
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800892
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700893 /* notify the new DBus API */
Hai Shalomf1c97642019-07-19 23:42:07 +0000894 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
895 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700896}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700897
898
899void wpas_notify_preq(struct wpa_supplicant *wpa_s,
900 const u8 *addr, const u8 *dst, const u8 *bssid,
901 const u8 *ie, size_t ie_len, u32 ssi_signal)
902{
903#ifdef CONFIG_AP
904 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
905#endif /* CONFIG_AP */
906}
907
908
909void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
910 const char *parameter)
911{
912 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700913 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
914 "status='%s' parameter='%s'",
915 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700916}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700917
Roshan Pius3a1667e2018-07-03 15:17:14 -0700918
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700919void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
920{
921 wpa_dbg(wpa_s, MSG_ERROR,
922 "EAP Error code = %d", error_code);
Ahmed ElArabawy30eab622018-03-19 18:36:48 -0700923 wpas_hidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700924}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700925
Roshan Pius3a1667e2018-07-03 15:17:14 -0700926
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700927void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
928 struct wpa_ssid *ssid)
929{
930 if (wpa_s->current_ssid != ssid)
931 return;
932
933 wpa_dbg(wpa_s, MSG_DEBUG,
934 "Network bssid config changed for the current network - within-ESS roaming %s",
935 ssid->bssid_set ? "disabled" : "enabled");
936
937 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
938 ssid->bssid_set ? ssid->bssid : NULL);
939}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800940
941
942void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
943 struct wpa_ssid *ssid)
944{
945#ifdef CONFIG_P2P
946 if (ssid->disabled == 2) {
947 /* Changed from normal network profile to persistent group */
948 ssid->disabled = 0;
949 wpas_dbus_unregister_network(wpa_s, ssid->id);
950 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700951 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800952 wpas_dbus_register_persistent_group(wpa_s, ssid);
953 } else {
954 /* Changed from persistent group to normal network profile */
955 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700956 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800957 wpas_dbus_register_network(wpa_s, ssid);
958 }
959#endif /* CONFIG_P2P */
960}
Roshan Pius04a9d742016-12-12 12:40:46 -0800961
962void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
963 const char *result,
964 const struct wpa_bss_anqp *anqp)
965{
966#ifdef CONFIG_INTERWORKING
967 if (!wpa_s || !bssid || !anqp)
968 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800969
970 wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800971#endif /* CONFIG_INTERWORKING */
972}
973
974void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
975 const char* file_name, const u8* image,
976 u32 image_length)
977{
978#ifdef CONFIG_HS20
979 if (!wpa_s || !bssid || !file_name || !image)
980 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800981
982 wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
983 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -0800984#endif /* CONFIG_HS20 */
985}
986
987void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
988 const char* url,
989 u8 osu_method)
990{
991#ifdef CONFIG_HS20
992 if (!wpa_s || !url)
993 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800994
995 wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -0800996#endif /* CONFIG_HS20 */
997}
998
999void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1000 u8 code, u16 reauth_delay,
1001 const char *url)
1002{
1003#ifdef CONFIG_HS20
1004 if (!wpa_s || !url)
1005 return;
Roshan Pius9322a342016-12-12 14:45:02 -08001006
1007 wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
1008 url);
Roshan Pius04a9d742016-12-12 12:40:46 -08001009#endif /* CONFIG_HS20 */
1010}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001011
1012
1013#ifdef CONFIG_MESH
1014
1015void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1016 struct wpa_ssid *ssid)
1017{
1018 if (wpa_s->p2p_mgmt)
1019 return;
1020
1021 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1022}
1023
1024
1025void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1026 const u8 *meshid, u8 meshid_len,
Hai Shalomf1c97642019-07-19 23:42:07 +00001027 int reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001028{
1029 if (wpa_s->p2p_mgmt)
1030 return;
1031
1032 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1033 reason_code);
1034}
1035
1036
1037void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1038 const u8 *peer_addr)
1039{
1040 if (wpa_s->p2p_mgmt)
1041 return;
1042
1043 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1044}
1045
1046
1047void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
Hai Shalomf1c97642019-07-19 23:42:07 +00001048 const u8 *peer_addr, int reason_code)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001049{
1050 if (wpa_s->p2p_mgmt)
1051 return;
1052
1053 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1054}
1055
1056#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001057
1058/*
1059 * DPP Notifications
1060 */
1061
1062/* DPP Success notifications */
1063
Hai Shalom706f99b2019-01-08 16:23:37 -08001064void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Hai Shalom59532852018-12-07 10:32:58 -08001065 struct wpa_ssid *ssid)
1066{
1067#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001068 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001069 return;
1070
Hai Shalom706f99b2019-01-08 16:23:37 -08001071 wpas_hidl_notify_dpp_config_received(wpa_s, ssid);
Hai Shalom59532852018-12-07 10:32:58 -08001072#endif /* CONFIG_DPP */
1073}
1074
Hai Shalom706f99b2019-01-08 16:23:37 -08001075void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001076{
1077#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001078 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001079 return;
1080
Hai Shalom706f99b2019-01-08 16:23:37 -08001081 wpas_hidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001082#endif /* CONFIG_DPP */
1083}
1084
1085/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001086void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001087{
1088#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001089 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001090 return;
1091
Hai Shalom706f99b2019-01-08 16:23:37 -08001092 wpas_hidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001093#endif /* CONFIG_DPP */
1094}
1095
Hai Shalom706f99b2019-01-08 16:23:37 -08001096void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001097{
1098#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001099 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001100 return;
1101
Hai Shalom706f99b2019-01-08 16:23:37 -08001102 wpas_hidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001103#endif /* CONFIG_DPP */
1104}
1105
1106/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001107void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001108{
1109#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001110 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001111 return;
1112
Hai Shalom706f99b2019-01-08 16:23:37 -08001113 wpas_hidl_notify_dpp_not_compatible(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001114#endif /* CONFIG_DPP */
1115}
1116
Hai Shalom706f99b2019-01-08 16:23:37 -08001117void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001118{
1119#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001120 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001121 return;
1122
Hai Shalom706f99b2019-01-08 16:23:37 -08001123 wpas_hidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001124#endif /* CONFIG_DPP */
1125}
1126
Hai Shalom706f99b2019-01-08 16:23:37 -08001127void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001128{
1129#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001130 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001131 return;
1132
Hai Shalom706f99b2019-01-08 16:23:37 -08001133 wpas_hidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001134#endif /* CONFIG_DPP */
1135}
1136
Hai Shalom706f99b2019-01-08 16:23:37 -08001137void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001138{
1139#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001140 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001141 return;
1142
Hai Shalom706f99b2019-01-08 16:23:37 -08001143 wpas_hidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001144#endif /* CONFIG_DPP */
1145}
1146
Hai Shalom706f99b2019-01-08 16:23:37 -08001147void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001148{
1149#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001150 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001151 return;
1152
Hai Shalom706f99b2019-01-08 16:23:37 -08001153 wpas_hidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001154#endif /* CONFIG_DPP */
1155}
1156
Hai Shalom706f99b2019-01-08 16:23:37 -08001157void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001158{
1159#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001160 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001161 return;
1162
Hai Shalom706f99b2019-01-08 16:23:37 -08001163 wpas_hidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001164#endif /* CONFIG_DPP */
1165}