blob: 30bdb6de89dda37834a40065d5d4ae304b46290d [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"
17#include "dbus/dbus_old.h"
18#include "dbus/dbus_new.h"
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080019#include "rsn_supp/wpa.h"
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080020#include "fst/fst.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{
30#ifdef CONFIG_DBUS
31 if (global->params.dbus_ctrl_interface) {
32 global->dbus = wpas_dbus_init(global);
33 if (global->dbus == NULL)
34 return -1;
35 }
36#endif /* CONFIG_DBUS */
37
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{
50#ifdef CONFIG_DBUS
51 if (global->dbus)
52 wpas_dbus_deinit(global->dbus);
53#endif /* CONFIG_DBUS */
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{
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080064 if (!wpa_s->p2p_mgmt) {
65 if (wpas_dbus_register_iface(wpa_s))
66 return -1;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080067
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080068 if (wpas_dbus_register_interface(wpa_s))
69 return -1;
70 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070071
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080072 /* HIDL interface wants to keep track of the P2P mgmt iface. */
Roshan Pius57ffbcf2016-09-27 09:12:46 -070073 if (wpas_hidl_register_interface(wpa_s))
Roshan Pius54e763a2016-07-06 15:41:53 -070074 return -1;
75
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070076 return 0;
77}
78
79
80void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
81{
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080082 if (!wpa_s->p2p_mgmt) {
83 /* unregister interface in old DBus ctrl iface */
84 wpas_dbus_unregister_iface(wpa_s);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080085
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080086 /* unregister interface in new DBus ctrl iface */
87 wpas_dbus_unregister_interface(wpa_s);
88 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070089
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080090 /* HIDL interface wants to keep track of the P2P mgmt iface. */
Roshan Pius57ffbcf2016-09-27 09:12:46 -070091 wpas_hidl_unregister_interface(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070092}
93
94
95void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
96 enum wpa_states new_state,
97 enum wpa_states old_state)
98{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080099 if (wpa_s->p2p_mgmt)
100 return;
101
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700102 /* notify the old DBus API */
103 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
104 old_state);
105
106 /* notify the new DBus API */
107 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
108
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800109#ifdef CONFIG_FST
110 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
111 if (new_state == WPA_COMPLETED)
112 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
113 else if (old_state >= WPA_ASSOCIATED &&
114 new_state < WPA_ASSOCIATED)
115 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
116 }
117#endif /* CONFIG_FST */
118
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700119 if (new_state == WPA_COMPLETED)
120 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700121 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700122 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700123
124 sme_state_changed(wpa_s);
125
126#ifdef ANDROID
127 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700128 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700129 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700130 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700131 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700132 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
133 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800134 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700135#endif /* ANDROID */
Roshan Piuse8d0d162016-08-01 13:09:26 -0700136
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700137 wpas_hidl_notify_state_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700138}
139
140
Dmitry Shmidt04949592012-07-19 12:16:46 -0700141void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
142{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800143 if (wpa_s->p2p_mgmt)
144 return;
145
Dmitry Shmidt04949592012-07-19 12:16:46 -0700146 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
Roshan Pius0974e962016-12-12 17:05:51 -0800147
Roshan Piusbe158772017-03-10 17:54:37 -0800148 wpas_hidl_notify_disconnect_reason(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700149}
150
151
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800152void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
153{
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
159 wpas_hidl_notify_assoc_reject(wpa_s);
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
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700169void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
170{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800171 if (wpa_s->p2p_mgmt)
172 return;
173
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700174 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
175}
176
177
178void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
179{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800180 if (wpa_s->p2p_mgmt)
181 return;
182
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700183 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
184}
185
186
187void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
188{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800189 if (wpa_s->p2p_mgmt)
190 return;
191
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700192 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
Roshan Piuse746d6b2017-03-21 08:53:04 -0700193
194 wpas_hidl_notify_bssid_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700195}
196
197
198void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
199{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800200 if (wpa_s->p2p_mgmt)
201 return;
202
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700203 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
204}
205
206
207void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
208 struct wpa_ssid *ssid)
209{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800210 if (wpa_s->p2p_mgmt)
211 return;
212
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700213 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
214}
215
216
217void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
218 struct wpa_ssid *ssid)
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_network_selected(wpa_s, ssid->id);
224}
225
226
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800227void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
228 struct wpa_ssid *ssid,
229 enum wpa_ctrl_req_type rtype,
230 const char *default_txt)
231{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800232 if (wpa_s->p2p_mgmt)
233 return;
234
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800235 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700236
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700237 wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800238}
239
240
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700241void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
242{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800243 if (wpa_s->p2p_mgmt)
244 return;
245
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700246 /* notify the old DBus API */
247 wpa_supplicant_dbus_notify_scanning(wpa_s);
248
249 /* notify the new DBus API */
250 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
251}
252
253
254void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
255{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800256 if (wpa_s->p2p_mgmt)
257 return;
258
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700259 wpas_dbus_signal_scan_done(wpa_s, success);
260}
261
262
263void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
264{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800265 if (wpa_s->p2p_mgmt)
266 return;
267
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700268 /* notify the old DBus API */
269 wpa_supplicant_dbus_notify_scan_results(wpa_s);
270
271 wpas_wps_notify_scan_results(wpa_s);
272}
273
274
275void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
276 const struct wps_credential *cred)
277{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800278 if (wpa_s->p2p_mgmt)
279 return;
280
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700281#ifdef CONFIG_WPS
282 /* notify the old DBus API */
283 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
284 /* notify the new DBus API */
285 wpas_dbus_signal_wps_cred(wpa_s, cred);
286#endif /* CONFIG_WPS */
287}
288
289
290void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
291 struct wps_event_m2d *m2d)
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#ifdef CONFIG_WPS
297 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
298#endif /* CONFIG_WPS */
299}
300
301
302void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
303 struct wps_event_fail *fail)
304{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800305 if (wpa_s->p2p_mgmt)
306 return;
307
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700308#ifdef CONFIG_WPS
309 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800310
311 wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
312 fail->config_error,
313 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700314#endif /* CONFIG_WPS */
315}
316
317
318void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
319{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800320 if (wpa_s->p2p_mgmt)
321 return;
322
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700323#ifdef CONFIG_WPS
324 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800325
326 wpas_hidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700327#endif /* CONFIG_WPS */
328}
329
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700330void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
331{
332 if (wpa_s->p2p_mgmt)
333 return;
334
335#ifdef CONFIG_WPS
336 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800337
338 wpas_hidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700339#endif /* CONFIG_WPS */
340}
341
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700342
343void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
344 struct wpa_ssid *ssid)
345{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800346 if (wpa_s->p2p_mgmt)
347 return;
348
Jouni Malinen75ecf522011-06-27 15:19:46 -0700349 /*
350 * Networks objects created during any P2P activities should not be
351 * exposed out. They might/will confuse certain non-P2P aware
352 * applications since these network objects won't behave like
353 * regular ones.
354 */
Roshan Piusd3854452016-07-07 16:46:41 -0700355 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700356 wpas_dbus_register_network(wpa_s, ssid);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700357 wpas_hidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700358 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700359}
360
361
362void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
363 struct wpa_ssid *ssid)
364{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700365#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700366 wpas_dbus_register_persistent_group(wpa_s, ssid);
Glen Kuhne30990d62017-04-19 14:16:48 -0700367 wpas_hidl_register_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700368#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700369}
370
371
372void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
373 struct wpa_ssid *ssid)
374{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700375#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700376 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Glen Kuhne30990d62017-04-19 14:16:48 -0700377 wpas_hidl_unregister_network(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700378#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700379}
380
381
382void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
383 struct wpa_ssid *ssid)
384{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800385 if (wpa_s->next_ssid == ssid)
386 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800387 if (wpa_s->wpa)
388 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700389 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700390 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700391 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700392 wpas_hidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700393 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800394 if (network_is_persistent_group(ssid))
395 wpas_notify_persistent_group_removed(wpa_s, ssid);
396
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800397 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700398}
399
400
401void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
402 u8 bssid[], unsigned int id)
403{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800404 if (wpa_s->p2p_mgmt)
405 return;
406
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700407 wpas_dbus_register_bss(wpa_s, bssid, id);
408 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
409 id, MAC2STR(bssid));
410}
411
412
413void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
414 u8 bssid[], unsigned int id)
415{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800416 if (wpa_s->p2p_mgmt)
417 return;
418
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700419 wpas_dbus_unregister_bss(wpa_s, bssid, id);
420 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
421 id, MAC2STR(bssid));
422}
423
424
425void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
426 unsigned int id)
427{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800428 if (wpa_s->p2p_mgmt)
429 return;
430
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700431 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
432}
433
434
435void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
436 unsigned int id)
437{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800438 if (wpa_s->p2p_mgmt)
439 return;
440
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700441 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
442 id);
443}
444
445
446void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
447 unsigned int id)
448{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800449 if (wpa_s->p2p_mgmt)
450 return;
451
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700452 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
453 id);
454}
455
456
457void wpas_notify_bss_mode_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_MODE, id);
464}
465
466
467void wpas_notify_bss_wpaie_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_WPA, id);
474}
475
476
477void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
478 unsigned int id)
479{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800480 if (wpa_s->p2p_mgmt)
481 return;
482
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700483 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
484}
485
486
487void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
488 unsigned int id)
489{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800490 if (wpa_s->p2p_mgmt)
491 return;
492
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800493#ifdef CONFIG_WPS
494 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
495#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700496}
497
498
499void wpas_notify_bss_ies_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_IES, id);
506}
507
508
509void wpas_notify_bss_rates_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_RATES, id);
516}
517
518
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700519void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
520{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800521 if (wpa_s->p2p_mgmt)
522 return;
523
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700524 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
525}
526
527
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700528void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
529{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800530 if (wpa_s->p2p_mgmt)
531 return;
532
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700533 wpas_dbus_signal_blob_added(wpa_s, name);
534}
535
536
537void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
538{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800539 if (wpa_s->p2p_mgmt)
540 return;
541
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700542 wpas_dbus_signal_blob_removed(wpa_s, name);
543}
544
545
546void wpas_notify_debug_level_changed(struct wpa_global *global)
547{
548 wpas_dbus_signal_debug_level_changed(global);
549}
550
551
552void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
553{
554 wpas_dbus_signal_debug_timestamp_changed(global);
555}
556
557
558void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
559{
560 wpas_dbus_signal_debug_show_keys_changed(global);
561}
562
563
564void wpas_notify_suspend(struct wpa_global *global)
565{
566 struct wpa_supplicant *wpa_s;
567
568 os_get_time(&global->suspend_time);
569 wpa_printf(MSG_DEBUG, "System suspend notification");
570 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
571 wpa_drv_suspend(wpa_s);
572}
573
574
575void wpas_notify_resume(struct wpa_global *global)
576{
577 struct os_time now;
578 int slept;
579 struct wpa_supplicant *wpa_s;
580
581 if (global->suspend_time.sec == 0)
582 slept = -1;
583 else {
584 os_get_time(&now);
585 slept = now.sec - global->suspend_time.sec;
586 }
587 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
588 slept);
589
590 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
591 wpa_drv_resume(wpa_s);
592 if (wpa_s->wpa_state == WPA_DISCONNECTED)
593 wpa_supplicant_req_scan(wpa_s, 0, 100000);
594 }
595}
596
597
598#ifdef CONFIG_P2P
599
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700600void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
601{
602 /* Notify P2P find has stopped */
603 wpas_dbus_signal_p2p_find_stopped(wpa_s);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800604
605 wpas_hidl_notify_p2p_find_stopped(wpa_s);
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700606}
607
608
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700609void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
Roshan Piusfd2fd662017-01-23 13:41:57 -0800610 const u8 *addr, const struct p2p_peer_info *info,
611 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
612 int new_device)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700613{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700614 if (new_device) {
615 /* Create the new peer object */
Roshan Piusfd2fd662017-01-23 13:41:57 -0800616 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700617 }
618
619 /* Notify a new peer has been detected*/
Roshan Piusfd2fd662017-01-23 13:41:57 -0800620 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
621
622 wpas_hidl_notify_p2p_device_found(wpa_s, addr, info,
623 peer_wfd_device_info,
624 peer_wfd_device_info_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700625}
626
627
628void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
629 const u8 *dev_addr)
630{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700631 wpas_dbus_unregister_peer(wpa_s, dev_addr);
632
633 /* Create signal on interface object*/
634 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800635
636 wpas_hidl_notify_p2p_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700637}
638
639
640void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
641 const struct wpa_ssid *ssid,
642 const char *role)
643{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700644 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700645
646 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800647
648 wpas_hidl_notify_p2p_group_removed(wpa_s, ssid, role);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700649}
650
651
652void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700653 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700654{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700655 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800656
657 wpas_hidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700658}
659
660
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800661void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
662 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700663{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800664 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800665
666 wpas_hidl_notify_p2p_go_neg_completed(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700667}
668
669
670void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
671 int status, const u8 *bssid)
672{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700673 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800674
675 wpas_hidl_notify_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700676}
677
678
679void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
680 int freq, const u8 *sa, u8 dialog_token,
681 u16 update_indic, const u8 *tlvs,
682 size_t tlvs_len)
683{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700684 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
685 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700686}
687
688
689void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
690 const u8 *sa, u16 update_indic,
691 const u8 *tlvs, size_t tlvs_len)
692{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700693 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
694 tlvs, tlvs_len);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800695
696 wpas_hidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
697 tlvs, tlvs_len);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700698}
699
700
701/**
702 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
703 * @dev_addr: Who sent the request or responded to our request.
704 * @request: Will be 1 if request, 0 for response.
705 * @status: Valid only in case of response (0 in case of success)
706 * @config_methods: WPS config methods
707 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
708 *
709 * This can be used to notify:
710 * - Requests or responses
711 * - Various config methods
712 * - Failure condition in case of response
713 */
714void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
715 const u8 *dev_addr, int request,
716 enum p2p_prov_disc_status status,
717 u16 config_methods,
718 unsigned int generated_pin)
719{
720 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
721 status, config_methods,
722 generated_pin);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800723
724 wpas_hidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
725 status, config_methods,
726 generated_pin);
727
Jouni Malinen75ecf522011-06-27 15:19:46 -0700728}
729
730
731void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700732 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800733 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700734{
735 /* Notify a group has been started */
736 wpas_dbus_register_p2p_group(wpa_s, ssid);
737
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800738 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800739
Roshan Pius7a1c8482017-04-12 17:05:10 -0700740 wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700741}
742
743
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800744void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
745 const char *reason)
746{
747 /* Notify a group formation failed */
748 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800749
750 wpas_hidl_notify_p2p_group_formation_failure(wpa_s, reason);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800751}
752
753
Jouni Malinen75ecf522011-06-27 15:19:46 -0700754void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
755 struct wps_event_fail *fail)
756{
757 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700758}
759
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800760
761void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
762 const u8 *sa, const u8 *go_dev_addr,
763 const u8 *bssid, int id, int op_freq)
764{
765 /* Notify a P2P Invitation Request */
766 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
767 id, op_freq);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800768
769 wpas_hidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
770 id, op_freq);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800771}
772
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700773#endif /* CONFIG_P2P */
774
775
776static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800777 const u8 *sta,
778 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700779{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700780#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800781 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
782
Jouni Malinen75ecf522011-06-27 15:19:46 -0700783 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700784 * Create 'peer-joined' signal on group object -- will also
785 * check P2P itself.
786 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800787 if (p2p_dev_addr)
788 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700789#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700790
791 /* Notify listeners a new station has been authorized */
792 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800793
794 wpas_hidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700795}
796
797
798static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700799 const u8 *sta,
800 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700801{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700802#ifdef CONFIG_P2P
803 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700804 * Create 'peer-disconnected' signal on group object if this
805 * is a P2P group.
806 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800807 if (p2p_dev_addr)
808 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700809#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700810
811 /* Notify listeners a station has been deauthorized */
812 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Roshan Piusfd2fd662017-01-23 13:41:57 -0800813
814 wpas_hidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700815}
816
817
818void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800819 const u8 *mac_addr, int authorized,
820 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700821{
822 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800823 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700824 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700825 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700826}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700827
828
829void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800830 const char *subject, const char *altsubject[],
831 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700832 const struct wpabuf *cert)
833{
834 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
835 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800836 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700837 cert_hash ? cert_hash : "");
838
839 if (cert) {
840 char *cert_hex;
841 size_t len = wpabuf_len(cert) * 2 + 1;
842 cert_hex = os_malloc(len);
843 if (cert_hex) {
844 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
845 wpabuf_len(cert));
846 wpa_msg_ctrl(wpa_s, MSG_INFO,
847 WPA_EVENT_EAP_PEER_CERT
848 "depth=%d subject='%s' cert=%s",
849 depth, subject, cert_hex);
850 os_free(cert_hex);
851 }
852 }
853
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800854 if (altsubject) {
855 int i;
856
857 for (i = 0; i < num_altsubject; i++)
858 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
859 "depth=%d %s", depth, altsubject[i]);
860 }
861
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700862 /* notify the old DBus API */
863 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
864 cert_hash, cert);
865 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800866 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
867 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700868}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700869
870
871void wpas_notify_preq(struct wpa_supplicant *wpa_s,
872 const u8 *addr, const u8 *dst, const u8 *bssid,
873 const u8 *ie, size_t ie_len, u32 ssi_signal)
874{
875#ifdef CONFIG_AP
876 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
877#endif /* CONFIG_AP */
878}
879
880
881void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
882 const char *parameter)
883{
884 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700885 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
886 "status='%s' parameter='%s'",
887 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700888}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700889
Roshan Pius3a1667e2018-07-03 15:17:14 -0700890
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700891void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
892{
893 wpa_dbg(wpa_s, MSG_ERROR,
894 "EAP Error code = %d", error_code);
Ahmed ElArabawy30eab622018-03-19 18:36:48 -0700895 wpas_hidl_notify_eap_error(wpa_s, error_code);
Ahmed ElArabawy9c86a7f2018-03-15 09:00:10 -0700896}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700897
Roshan Pius3a1667e2018-07-03 15:17:14 -0700898
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700899void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
900 struct wpa_ssid *ssid)
901{
902 if (wpa_s->current_ssid != ssid)
903 return;
904
905 wpa_dbg(wpa_s, MSG_DEBUG,
906 "Network bssid config changed for the current network - within-ESS roaming %s",
907 ssid->bssid_set ? "disabled" : "enabled");
908
909 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
910 ssid->bssid_set ? ssid->bssid : NULL);
911}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800912
913
914void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
915 struct wpa_ssid *ssid)
916{
917#ifdef CONFIG_P2P
918 if (ssid->disabled == 2) {
919 /* Changed from normal network profile to persistent group */
920 ssid->disabled = 0;
921 wpas_dbus_unregister_network(wpa_s, ssid->id);
922 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700923 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800924 wpas_dbus_register_persistent_group(wpa_s, ssid);
925 } else {
926 /* Changed from persistent group to normal network profile */
927 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700928 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800929 wpas_dbus_register_network(wpa_s, ssid);
930 }
931#endif /* CONFIG_P2P */
932}
Roshan Pius04a9d742016-12-12 12:40:46 -0800933
934void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
935 const char *result,
936 const struct wpa_bss_anqp *anqp)
937{
938#ifdef CONFIG_INTERWORKING
939 if (!wpa_s || !bssid || !anqp)
940 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800941
942 wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800943#endif /* CONFIG_INTERWORKING */
944}
945
946void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
947 const char* file_name, const u8* image,
948 u32 image_length)
949{
950#ifdef CONFIG_HS20
951 if (!wpa_s || !bssid || !file_name || !image)
952 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800953
954 wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
955 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -0800956#endif /* CONFIG_HS20 */
957}
958
959void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
960 const char* url,
961 u8 osu_method)
962{
963#ifdef CONFIG_HS20
964 if (!wpa_s || !url)
965 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800966
967 wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -0800968#endif /* CONFIG_HS20 */
969}
970
971void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
972 u8 code, u16 reauth_delay,
973 const char *url)
974{
975#ifdef CONFIG_HS20
976 if (!wpa_s || !url)
977 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800978
979 wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
980 url);
Roshan Pius04a9d742016-12-12 12:40:46 -0800981#endif /* CONFIG_HS20 */
982}
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700983
984
985#ifdef CONFIG_MESH
986
987void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
988 struct wpa_ssid *ssid)
989{
990 if (wpa_s->p2p_mgmt)
991 return;
992
993 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
994}
995
996
997void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
998 const u8 *meshid, u8 meshid_len,
999 int reason_code)
1000{
1001 if (wpa_s->p2p_mgmt)
1002 return;
1003
1004 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1005 reason_code);
1006}
1007
1008
1009void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1010 const u8 *peer_addr)
1011{
1012 if (wpa_s->p2p_mgmt)
1013 return;
1014
1015 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1016}
1017
1018
1019void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
1020 const u8 *peer_addr, int reason_code)
1021{
1022 if (wpa_s->p2p_mgmt)
1023 return;
1024
1025 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1026}
1027
1028#endif /* CONFIG_MESH */
Hai Shalom59532852018-12-07 10:32:58 -08001029
1030/*
1031 * DPP Notifications
1032 */
1033
1034/* DPP Success notifications */
1035
Hai Shalom706f99b2019-01-08 16:23:37 -08001036void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
Hai Shalom59532852018-12-07 10:32:58 -08001037 struct wpa_ssid *ssid)
1038{
1039#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001040 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001041 return;
1042
Hai Shalom706f99b2019-01-08 16:23:37 -08001043 wpas_hidl_notify_dpp_config_received(wpa_s, ssid);
Hai Shalom59532852018-12-07 10:32:58 -08001044#endif /* CONFIG_DPP */
1045}
1046
Hai Shalom706f99b2019-01-08 16:23:37 -08001047void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001048{
1049#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001050 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001051 return;
1052
Hai Shalom706f99b2019-01-08 16:23:37 -08001053 wpas_hidl_notify_dpp_config_sent(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001054#endif /* CONFIG_DPP */
1055}
1056
1057/* DPP Progress notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001058void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001059{
1060#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001061 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001062 return;
1063
Hai Shalom706f99b2019-01-08 16:23:37 -08001064 wpas_hidl_notify_dpp_auth_success(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001065#endif /* CONFIG_DPP */
1066}
1067
Hai Shalom706f99b2019-01-08 16:23:37 -08001068void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001069{
1070#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001071 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001072 return;
1073
Hai Shalom706f99b2019-01-08 16:23:37 -08001074 wpas_hidl_notify_dpp_resp_pending(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001075#endif /* CONFIG_DPP */
1076}
1077
1078/* DPP Failure notifications */
Hai Shalom706f99b2019-01-08 16:23:37 -08001079void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001080{
1081#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001082 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001083 return;
1084
Hai Shalom706f99b2019-01-08 16:23:37 -08001085 wpas_hidl_notify_dpp_not_compatible(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001086#endif /* CONFIG_DPP */
1087}
1088
Hai Shalom706f99b2019-01-08 16:23:37 -08001089void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001090{
1091#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001092 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001093 return;
1094
Hai Shalom706f99b2019-01-08 16:23:37 -08001095 wpas_hidl_notify_dpp_missing_auth(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001096#endif /* CONFIG_DPP */
1097}
1098
Hai Shalom706f99b2019-01-08 16:23:37 -08001099void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001100{
1101#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001102 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001103 return;
1104
Hai Shalom706f99b2019-01-08 16:23:37 -08001105 wpas_hidl_notify_dpp_configuration_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001106#endif /* CONFIG_DPP */
1107}
1108
Hai Shalom706f99b2019-01-08 16:23:37 -08001109void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001110{
1111#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001112 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001113 return;
1114
Hai Shalom706f99b2019-01-08 16:23:37 -08001115 wpas_hidl_notify_dpp_timeout(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001116#endif /* CONFIG_DPP */
1117}
1118
Hai Shalom706f99b2019-01-08 16:23:37 -08001119void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001120{
1121#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001122 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001123 return;
1124
Hai Shalom706f99b2019-01-08 16:23:37 -08001125 wpas_hidl_notify_dpp_auth_failure(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001126#endif /* CONFIG_DPP */
1127}
1128
Hai Shalom706f99b2019-01-08 16:23:37 -08001129void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001130{
1131#ifdef CONFIG_DPP
Hai Shalom706f99b2019-01-08 16:23:37 -08001132 if (!wpa_s)
Hai Shalom59532852018-12-07 10:32:58 -08001133 return;
1134
Hai Shalom706f99b2019-01-08 16:23:37 -08001135 wpas_hidl_notify_dpp_fail(wpa_s);
Hai Shalom59532852018-12-07 10:32:58 -08001136#endif /* CONFIG_DPP */
1137}