blob: b2b4225bec9459d322f065274dbc8987e2aa7254 [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"
Dmitry Shmidte4663042016-04-04 10:07:49 -070016#include "binder/binder.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070017#include "dbus/dbus_common.h"
18#include "dbus/dbus_old.h"
19#include "dbus/dbus_new.h"
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080020#include "rsn_supp/wpa.h"
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080021#include "fst/fst.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070022#include "driver_i.h"
23#include "scan.h"
24#include "p2p_supplicant.h"
25#include "sme.h"
26#include "notify.h"
27
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
Dmitry Shmidte4663042016-04-04 10:07:49 -070038#ifdef CONFIG_BINDER
39 global->binder = wpas_binder_init(global);
40 if (!global->binder)
41 return -1;
42#endif /* CONFIG_BINDER */
43
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
55#ifdef CONFIG_BINDER
56 if (global->binder)
57 wpas_binder_deinit(global->binder);
58#endif /* CONFIG_BINDER */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070059}
60
61
62int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
63{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080064 if (wpa_s->p2p_mgmt)
65 return 0;
66
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070067 if (wpas_dbus_register_iface(wpa_s))
68 return -1;
69
70 if (wpas_dbus_register_interface(wpa_s))
71 return -1;
72
Roshan Pius54e763a2016-07-06 15:41:53 -070073 if (wpas_binder_register_interface(wpa_s))
74 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{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080082 if (wpa_s->p2p_mgmt)
83 return;
84
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070085 /* unregister interface in old DBus ctrl iface */
86 wpas_dbus_unregister_iface(wpa_s);
87
88 /* unregister interface in new DBus ctrl iface */
89 wpas_dbus_unregister_interface(wpa_s);
Roshan Pius54e763a2016-07-06 15:41:53 -070090
91 wpas_binder_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 */
136}
137
138
Dmitry Shmidt04949592012-07-19 12:16:46 -0700139void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
140{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800141 if (wpa_s->p2p_mgmt)
142 return;
143
Dmitry Shmidt04949592012-07-19 12:16:46 -0700144 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
145}
146
147
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800148void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
149{
150 if (wpa_s->p2p_mgmt)
151 return;
152
153 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
154}
155
156
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700157void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
158{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800159 if (wpa_s->p2p_mgmt)
160 return;
161
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700162 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
163}
164
165
166void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
167{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800168 if (wpa_s->p2p_mgmt)
169 return;
170
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700171 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
172}
173
174
175void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
176{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800177 if (wpa_s->p2p_mgmt)
178 return;
179
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700180 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
181}
182
183
184void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
185{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800186 if (wpa_s->p2p_mgmt)
187 return;
188
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700189 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
190}
191
192
193void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
194 struct wpa_ssid *ssid)
195{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800196 if (wpa_s->p2p_mgmt)
197 return;
198
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700199 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
200}
201
202
203void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
204 struct wpa_ssid *ssid)
205{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800206 if (wpa_s->p2p_mgmt)
207 return;
208
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700209 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
210}
211
212
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800213void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
214 struct wpa_ssid *ssid,
215 enum wpa_ctrl_req_type rtype,
216 const char *default_txt)
217{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800218 if (wpa_s->p2p_mgmt)
219 return;
220
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800221 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
222}
223
224
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700225void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
226{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800227 if (wpa_s->p2p_mgmt)
228 return;
229
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700230 /* notify the old DBus API */
231 wpa_supplicant_dbus_notify_scanning(wpa_s);
232
233 /* notify the new DBus API */
234 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
235}
236
237
238void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
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_scan_done(wpa_s, success);
244}
245
246
247void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
248{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800249 if (wpa_s->p2p_mgmt)
250 return;
251
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700252 /* notify the old DBus API */
253 wpa_supplicant_dbus_notify_scan_results(wpa_s);
254
255 wpas_wps_notify_scan_results(wpa_s);
256}
257
258
259void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
260 const struct wps_credential *cred)
261{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800262 if (wpa_s->p2p_mgmt)
263 return;
264
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700265#ifdef CONFIG_WPS
266 /* notify the old DBus API */
267 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
268 /* notify the new DBus API */
269 wpas_dbus_signal_wps_cred(wpa_s, cred);
270#endif /* CONFIG_WPS */
271}
272
273
274void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
275 struct wps_event_m2d *m2d)
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#ifdef CONFIG_WPS
281 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
282#endif /* CONFIG_WPS */
283}
284
285
286void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
287 struct wps_event_fail *fail)
288{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800289 if (wpa_s->p2p_mgmt)
290 return;
291
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700292#ifdef CONFIG_WPS
293 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
294#endif /* CONFIG_WPS */
295}
296
297
298void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
299{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800300 if (wpa_s->p2p_mgmt)
301 return;
302
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700303#ifdef CONFIG_WPS
304 wpas_dbus_signal_wps_event_success(wpa_s);
305#endif /* CONFIG_WPS */
306}
307
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700308void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
309{
310 if (wpa_s->p2p_mgmt)
311 return;
312
313#ifdef CONFIG_WPS
314 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
315#endif /* CONFIG_WPS */
316}
317
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700318
319void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
320 struct wpa_ssid *ssid)
321{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800322 if (wpa_s->p2p_mgmt)
323 return;
324
Jouni Malinen75ecf522011-06-27 15:19:46 -0700325 /*
326 * Networks objects created during any P2P activities should not be
327 * exposed out. They might/will confuse certain non-P2P aware
328 * applications since these network objects won't behave like
329 * regular ones.
330 */
Roshan Piusd3854452016-07-07 16:46:41 -0700331 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700332 wpas_dbus_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700333 wpas_binder_register_network(wpa_s, ssid);
334 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700335}
336
337
338void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
339 struct wpa_ssid *ssid)
340{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700341#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700342 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700343#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700344}
345
346
347void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
348 struct wpa_ssid *ssid)
349{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700350#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700351 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700352#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700353}
354
355
356void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
357 struct wpa_ssid *ssid)
358{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800359 if (wpa_s->next_ssid == ssid)
360 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800361 if (wpa_s->wpa)
362 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700363 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700364 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700365 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Piusd3854452016-07-07 16:46:41 -0700366 wpas_binder_unregister_network(wpa_s, ssid);
367 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800368 if (network_is_persistent_group(ssid))
369 wpas_notify_persistent_group_removed(wpa_s, ssid);
370
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800371 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700372}
373
374
375void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
376 u8 bssid[], unsigned int id)
377{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800378 if (wpa_s->p2p_mgmt)
379 return;
380
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700381 wpas_dbus_register_bss(wpa_s, bssid, id);
382 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
383 id, MAC2STR(bssid));
384}
385
386
387void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
388 u8 bssid[], unsigned int id)
389{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800390 if (wpa_s->p2p_mgmt)
391 return;
392
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700393 wpas_dbus_unregister_bss(wpa_s, bssid, id);
394 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
395 id, MAC2STR(bssid));
396}
397
398
399void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
400 unsigned int id)
401{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800402 if (wpa_s->p2p_mgmt)
403 return;
404
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700405 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
406}
407
408
409void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
410 unsigned int id)
411{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800412 if (wpa_s->p2p_mgmt)
413 return;
414
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700415 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
416 id);
417}
418
419
420void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
421 unsigned int id)
422{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800423 if (wpa_s->p2p_mgmt)
424 return;
425
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700426 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
427 id);
428}
429
430
431void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
432 unsigned int id)
433{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800434 if (wpa_s->p2p_mgmt)
435 return;
436
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700437 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
438}
439
440
441void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
442 unsigned int id)
443{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800444 if (wpa_s->p2p_mgmt)
445 return;
446
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700447 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
448}
449
450
451void wpas_notify_bss_rsnie_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_RSN, id);
458}
459
460
461void wpas_notify_bss_wps_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 Shmidtd5e49232012-12-03 15:08:10 -0800467#ifdef CONFIG_WPS
468 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
469#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700470}
471
472
473void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
474 unsigned int id)
475{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800476 if (wpa_s->p2p_mgmt)
477 return;
478
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700479 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
480}
481
482
483void wpas_notify_bss_rates_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_RATES, id);
490}
491
492
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700493void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
494{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800495 if (wpa_s->p2p_mgmt)
496 return;
497
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700498 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
499}
500
501
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700502void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
503{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800504 if (wpa_s->p2p_mgmt)
505 return;
506
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700507 wpas_dbus_signal_blob_added(wpa_s, name);
508}
509
510
511void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
512{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800513 if (wpa_s->p2p_mgmt)
514 return;
515
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700516 wpas_dbus_signal_blob_removed(wpa_s, name);
517}
518
519
520void wpas_notify_debug_level_changed(struct wpa_global *global)
521{
522 wpas_dbus_signal_debug_level_changed(global);
523}
524
525
526void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
527{
528 wpas_dbus_signal_debug_timestamp_changed(global);
529}
530
531
532void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
533{
534 wpas_dbus_signal_debug_show_keys_changed(global);
535}
536
537
538void wpas_notify_suspend(struct wpa_global *global)
539{
540 struct wpa_supplicant *wpa_s;
541
542 os_get_time(&global->suspend_time);
543 wpa_printf(MSG_DEBUG, "System suspend notification");
544 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
545 wpa_drv_suspend(wpa_s);
546}
547
548
549void wpas_notify_resume(struct wpa_global *global)
550{
551 struct os_time now;
552 int slept;
553 struct wpa_supplicant *wpa_s;
554
555 if (global->suspend_time.sec == 0)
556 slept = -1;
557 else {
558 os_get_time(&now);
559 slept = now.sec - global->suspend_time.sec;
560 }
561 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
562 slept);
563
564 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
565 wpa_drv_resume(wpa_s);
566 if (wpa_s->wpa_state == WPA_DISCONNECTED)
567 wpa_supplicant_req_scan(wpa_s, 0, 100000);
568 }
569}
570
571
572#ifdef CONFIG_P2P
573
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700574void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
575{
576 /* Notify P2P find has stopped */
577 wpas_dbus_signal_p2p_find_stopped(wpa_s);
578}
579
580
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700581void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
582 const u8 *dev_addr, int new_device)
583{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700584 if (new_device) {
585 /* Create the new peer object */
586 wpas_dbus_register_peer(wpa_s, dev_addr);
587 }
588
589 /* Notify a new peer has been detected*/
590 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700591}
592
593
594void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
595 const u8 *dev_addr)
596{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700597 wpas_dbus_unregister_peer(wpa_s, dev_addr);
598
599 /* Create signal on interface object*/
600 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700601}
602
603
604void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
605 const struct wpa_ssid *ssid,
606 const char *role)
607{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700608 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700609
610 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700611}
612
613
614void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700615 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700616{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700617 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700618}
619
620
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800621void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
622 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700623{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800624 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700625}
626
627
628void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
629 int status, const u8 *bssid)
630{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700631 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700632}
633
634
635void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
636 int freq, const u8 *sa, u8 dialog_token,
637 u16 update_indic, const u8 *tlvs,
638 size_t tlvs_len)
639{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700640 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
641 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700642}
643
644
645void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
646 const u8 *sa, u16 update_indic,
647 const u8 *tlvs, size_t tlvs_len)
648{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700649 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
650 tlvs, tlvs_len);
651}
652
653
654/**
655 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
656 * @dev_addr: Who sent the request or responded to our request.
657 * @request: Will be 1 if request, 0 for response.
658 * @status: Valid only in case of response (0 in case of success)
659 * @config_methods: WPS config methods
660 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
661 *
662 * This can be used to notify:
663 * - Requests or responses
664 * - Various config methods
665 * - Failure condition in case of response
666 */
667void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
668 const u8 *dev_addr, int request,
669 enum p2p_prov_disc_status status,
670 u16 config_methods,
671 unsigned int generated_pin)
672{
673 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
674 status, config_methods,
675 generated_pin);
676}
677
678
679void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700680 struct wpa_ssid *ssid, int persistent,
Jouni Malinen75ecf522011-06-27 15:19:46 -0700681 int client)
682{
683 /* Notify a group has been started */
684 wpas_dbus_register_p2p_group(wpa_s, ssid);
685
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700686 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700687}
688
689
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800690void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
691 const char *reason)
692{
693 /* Notify a group formation failed */
694 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
695}
696
697
Jouni Malinen75ecf522011-06-27 15:19:46 -0700698void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
699 struct wps_event_fail *fail)
700{
701 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700702}
703
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800704
705void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
706 const u8 *sa, const u8 *go_dev_addr,
707 const u8 *bssid, int id, int op_freq)
708{
709 /* Notify a P2P Invitation Request */
710 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
711 id, op_freq);
712}
713
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700714#endif /* CONFIG_P2P */
715
716
717static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800718 const u8 *sta,
719 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700720{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700721#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800722 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
723
Jouni Malinen75ecf522011-06-27 15:19:46 -0700724 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700725 * Create 'peer-joined' signal on group object -- will also
726 * check P2P itself.
727 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800728 if (p2p_dev_addr)
729 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700730#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700731
732 /* Notify listeners a new station has been authorized */
733 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700734}
735
736
737static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700738 const u8 *sta,
739 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700740{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700741#ifdef CONFIG_P2P
742 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700743 * Create 'peer-disconnected' signal on group object if this
744 * is a P2P group.
745 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800746 if (p2p_dev_addr)
747 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700748#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700749
750 /* Notify listeners a station has been deauthorized */
751 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700752}
753
754
755void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800756 const u8 *mac_addr, int authorized,
757 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700758{
759 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800760 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700761 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700762 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700763}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700764
765
766void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800767 const char *subject, const char *altsubject[],
768 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700769 const struct wpabuf *cert)
770{
771 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
772 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800773 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700774 cert_hash ? cert_hash : "");
775
776 if (cert) {
777 char *cert_hex;
778 size_t len = wpabuf_len(cert) * 2 + 1;
779 cert_hex = os_malloc(len);
780 if (cert_hex) {
781 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
782 wpabuf_len(cert));
783 wpa_msg_ctrl(wpa_s, MSG_INFO,
784 WPA_EVENT_EAP_PEER_CERT
785 "depth=%d subject='%s' cert=%s",
786 depth, subject, cert_hex);
787 os_free(cert_hex);
788 }
789 }
790
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800791 if (altsubject) {
792 int i;
793
794 for (i = 0; i < num_altsubject; i++)
795 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
796 "depth=%d %s", depth, altsubject[i]);
797 }
798
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700799 /* notify the old DBus API */
800 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
801 cert_hash, cert);
802 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800803 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
804 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700805}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700806
807
808void wpas_notify_preq(struct wpa_supplicant *wpa_s,
809 const u8 *addr, const u8 *dst, const u8 *bssid,
810 const u8 *ie, size_t ie_len, u32 ssi_signal)
811{
812#ifdef CONFIG_AP
813 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
814#endif /* CONFIG_AP */
815}
816
817
818void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
819 const char *parameter)
820{
821 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700822 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
823 "status='%s' parameter='%s'",
824 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700825}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700826
827
828void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
829 struct wpa_ssid *ssid)
830{
831 if (wpa_s->current_ssid != ssid)
832 return;
833
834 wpa_dbg(wpa_s, MSG_DEBUG,
835 "Network bssid config changed for the current network - within-ESS roaming %s",
836 ssid->bssid_set ? "disabled" : "enabled");
837
838 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
839 ssid->bssid_set ? ssid->bssid : NULL);
840}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800841
842
843void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
844 struct wpa_ssid *ssid)
845{
846#ifdef CONFIG_P2P
847 if (ssid->disabled == 2) {
848 /* Changed from normal network profile to persistent group */
849 ssid->disabled = 0;
850 wpas_dbus_unregister_network(wpa_s, ssid->id);
851 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700852 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800853 wpas_dbus_register_persistent_group(wpa_s, ssid);
854 } else {
855 /* Changed from persistent group to normal network profile */
856 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700857 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800858 wpas_dbus_register_network(wpa_s, ssid);
859 }
860#endif /* CONFIG_P2P */
861}