blob: 822db74decb92c6dfff0238eac3877d7f5a8a970 [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 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"
25
26int wpas_notify_supplicant_initialized(struct wpa_global *global)
27{
28#ifdef CONFIG_DBUS
29 if (global->params.dbus_ctrl_interface) {
30 global->dbus = wpas_dbus_init(global);
31 if (global->dbus == NULL)
32 return -1;
33 }
34#endif /* CONFIG_DBUS */
35
36 return 0;
37}
38
39
40void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
41{
42#ifdef CONFIG_DBUS
43 if (global->dbus)
44 wpas_dbus_deinit(global->dbus);
45#endif /* CONFIG_DBUS */
46}
47
48
49int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
50{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080051 if (wpa_s->p2p_mgmt)
52 return 0;
53
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070054 if (wpas_dbus_register_iface(wpa_s))
55 return -1;
56
57 if (wpas_dbus_register_interface(wpa_s))
58 return -1;
59
60 return 0;
61}
62
63
64void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
65{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080066 if (wpa_s->p2p_mgmt)
67 return;
68
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070069 /* unregister interface in old DBus ctrl iface */
70 wpas_dbus_unregister_iface(wpa_s);
71
72 /* unregister interface in new DBus ctrl iface */
73 wpas_dbus_unregister_interface(wpa_s);
74}
75
76
77void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
78 enum wpa_states new_state,
79 enum wpa_states old_state)
80{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080081 if (wpa_s->p2p_mgmt)
82 return;
83
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070084 /* notify the old DBus API */
85 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
86 old_state);
87
88 /* notify the new DBus API */
89 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
90
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070091 if (new_state == WPA_COMPLETED)
92 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -070093 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070094 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070095
96 sme_state_changed(wpa_s);
97
98#ifdef ANDROID
99 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700100 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700101 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700102 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700103 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700104 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
105 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800106 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700107#endif /* ANDROID */
108}
109
110
Dmitry Shmidt04949592012-07-19 12:16:46 -0700111void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
112{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800113 if (wpa_s->p2p_mgmt)
114 return;
115
Dmitry Shmidt04949592012-07-19 12:16:46 -0700116 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
117}
118
119
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700120void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
121{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800122 if (wpa_s->p2p_mgmt)
123 return;
124
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700125 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
126}
127
128
129void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
130{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800131 if (wpa_s->p2p_mgmt)
132 return;
133
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700134 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
135}
136
137
138void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
139{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800140 if (wpa_s->p2p_mgmt)
141 return;
142
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700143 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
144}
145
146
147void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
148{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800149 if (wpa_s->p2p_mgmt)
150 return;
151
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700152 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
153}
154
155
156void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
157 struct wpa_ssid *ssid)
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_network_enabled_changed(wpa_s, ssid);
163}
164
165
166void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
167 struct wpa_ssid *ssid)
168{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800169 if (wpa_s->p2p_mgmt)
170 return;
171
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700172 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
173}
174
175
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800176void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
177 struct wpa_ssid *ssid,
178 enum wpa_ctrl_req_type rtype,
179 const char *default_txt)
180{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800181 if (wpa_s->p2p_mgmt)
182 return;
183
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800184 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
185}
186
187
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700188void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
189{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800190 if (wpa_s->p2p_mgmt)
191 return;
192
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700193 /* notify the old DBus API */
194 wpa_supplicant_dbus_notify_scanning(wpa_s);
195
196 /* notify the new DBus API */
197 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
198}
199
200
201void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
202{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800203 if (wpa_s->p2p_mgmt)
204 return;
205
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700206 wpas_dbus_signal_scan_done(wpa_s, success);
207}
208
209
210void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
211{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800212 if (wpa_s->p2p_mgmt)
213 return;
214
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700215 /* notify the old DBus API */
216 wpa_supplicant_dbus_notify_scan_results(wpa_s);
217
218 wpas_wps_notify_scan_results(wpa_s);
219}
220
221
222void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
223 const struct wps_credential *cred)
224{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800225 if (wpa_s->p2p_mgmt)
226 return;
227
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700228#ifdef CONFIG_WPS
229 /* notify the old DBus API */
230 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
231 /* notify the new DBus API */
232 wpas_dbus_signal_wps_cred(wpa_s, cred);
233#endif /* CONFIG_WPS */
234}
235
236
237void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
238 struct wps_event_m2d *m2d)
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#ifdef CONFIG_WPS
244 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
245#endif /* CONFIG_WPS */
246}
247
248
249void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
250 struct wps_event_fail *fail)
251{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800252 if (wpa_s->p2p_mgmt)
253 return;
254
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700255#ifdef CONFIG_WPS
256 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
257#endif /* CONFIG_WPS */
258}
259
260
261void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
262{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800263 if (wpa_s->p2p_mgmt)
264 return;
265
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700266#ifdef CONFIG_WPS
267 wpas_dbus_signal_wps_event_success(wpa_s);
268#endif /* CONFIG_WPS */
269}
270
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700271void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
272{
273 if (wpa_s->p2p_mgmt)
274 return;
275
276#ifdef CONFIG_WPS
277 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
278#endif /* CONFIG_WPS */
279}
280
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700281
282void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
283 struct wpa_ssid *ssid)
284{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800285 if (wpa_s->p2p_mgmt)
286 return;
287
Jouni Malinen75ecf522011-06-27 15:19:46 -0700288 /*
289 * Networks objects created during any P2P activities should not be
290 * exposed out. They might/will confuse certain non-P2P aware
291 * applications since these network objects won't behave like
292 * regular ones.
293 */
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700294 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700295 wpas_dbus_register_network(wpa_s, ssid);
296}
297
298
299void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
300 struct wpa_ssid *ssid)
301{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700302#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700303 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700304#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700305}
306
307
308void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
309 struct wpa_ssid *ssid)
310{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700311#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700312 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700313#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700314}
315
316
317void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
318 struct wpa_ssid *ssid)
319{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800320 if (wpa_s->next_ssid == ssid)
321 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800322 if (wpa_s->wpa)
323 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700324 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
325 !wpa_s->p2p_mgmt)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700326 wpas_dbus_unregister_network(wpa_s, ssid->id);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800327 if (network_is_persistent_group(ssid))
328 wpas_notify_persistent_group_removed(wpa_s, ssid);
329
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800330 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700331}
332
333
334void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
335 u8 bssid[], unsigned int id)
336{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800337 if (wpa_s->p2p_mgmt)
338 return;
339
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700340 wpas_dbus_register_bss(wpa_s, bssid, id);
341 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
342 id, MAC2STR(bssid));
343}
344
345
346void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
347 u8 bssid[], unsigned int id)
348{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800349 if (wpa_s->p2p_mgmt)
350 return;
351
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700352 wpas_dbus_unregister_bss(wpa_s, bssid, id);
353 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
354 id, MAC2STR(bssid));
355}
356
357
358void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
359 unsigned int id)
360{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800361 if (wpa_s->p2p_mgmt)
362 return;
363
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700364 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
365}
366
367
368void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
369 unsigned int id)
370{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800371 if (wpa_s->p2p_mgmt)
372 return;
373
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700374 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
375 id);
376}
377
378
379void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
380 unsigned int id)
381{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800382 if (wpa_s->p2p_mgmt)
383 return;
384
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700385 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
386 id);
387}
388
389
390void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
391 unsigned int id)
392{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800393 if (wpa_s->p2p_mgmt)
394 return;
395
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700396 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
397}
398
399
400void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
401 unsigned int id)
402{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800403 if (wpa_s->p2p_mgmt)
404 return;
405
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700406 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
407}
408
409
410void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
411 unsigned int id)
412{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800413 if (wpa_s->p2p_mgmt)
414 return;
415
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700416 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
417}
418
419
420void wpas_notify_bss_wps_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 Shmidtd5e49232012-12-03 15:08:10 -0800426#ifdef CONFIG_WPS
427 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
428#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700429}
430
431
432void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
433 unsigned int id)
434{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800435 if (wpa_s->p2p_mgmt)
436 return;
437
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700438 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
439}
440
441
442void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
443 unsigned int id)
444{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800445 if (wpa_s->p2p_mgmt)
446 return;
447
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700448 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
449}
450
451
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700452void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
453{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800454 if (wpa_s->p2p_mgmt)
455 return;
456
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700457 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
458}
459
460
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700461void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
462{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800463 if (wpa_s->p2p_mgmt)
464 return;
465
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700466 wpas_dbus_signal_blob_added(wpa_s, name);
467}
468
469
470void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
471{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800472 if (wpa_s->p2p_mgmt)
473 return;
474
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700475 wpas_dbus_signal_blob_removed(wpa_s, name);
476}
477
478
479void wpas_notify_debug_level_changed(struct wpa_global *global)
480{
481 wpas_dbus_signal_debug_level_changed(global);
482}
483
484
485void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
486{
487 wpas_dbus_signal_debug_timestamp_changed(global);
488}
489
490
491void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
492{
493 wpas_dbus_signal_debug_show_keys_changed(global);
494}
495
496
497void wpas_notify_suspend(struct wpa_global *global)
498{
499 struct wpa_supplicant *wpa_s;
500
501 os_get_time(&global->suspend_time);
502 wpa_printf(MSG_DEBUG, "System suspend notification");
503 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
504 wpa_drv_suspend(wpa_s);
505}
506
507
508void wpas_notify_resume(struct wpa_global *global)
509{
510 struct os_time now;
511 int slept;
512 struct wpa_supplicant *wpa_s;
513
514 if (global->suspend_time.sec == 0)
515 slept = -1;
516 else {
517 os_get_time(&now);
518 slept = now.sec - global->suspend_time.sec;
519 }
520 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
521 slept);
522
523 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
524 wpa_drv_resume(wpa_s);
525 if (wpa_s->wpa_state == WPA_DISCONNECTED)
526 wpa_supplicant_req_scan(wpa_s, 0, 100000);
527 }
528}
529
530
531#ifdef CONFIG_P2P
532
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700533void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
534{
535 /* Notify P2P find has stopped */
536 wpas_dbus_signal_p2p_find_stopped(wpa_s);
537}
538
539
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700540void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
541 const u8 *dev_addr, int new_device)
542{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700543 if (new_device) {
544 /* Create the new peer object */
545 wpas_dbus_register_peer(wpa_s, dev_addr);
546 }
547
548 /* Notify a new peer has been detected*/
549 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700550}
551
552
553void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
554 const u8 *dev_addr)
555{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700556 wpas_dbus_unregister_peer(wpa_s, dev_addr);
557
558 /* Create signal on interface object*/
559 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700560}
561
562
563void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
564 const struct wpa_ssid *ssid,
565 const char *role)
566{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700567 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700568
569 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700570}
571
572
573void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700574 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700575{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700576 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700577}
578
579
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800580void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
581 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700582{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800583 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700584}
585
586
587void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
588 int status, const u8 *bssid)
589{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700590 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700591}
592
593
594void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
595 int freq, const u8 *sa, u8 dialog_token,
596 u16 update_indic, const u8 *tlvs,
597 size_t tlvs_len)
598{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700599 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
600 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700601}
602
603
604void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
605 const u8 *sa, u16 update_indic,
606 const u8 *tlvs, size_t tlvs_len)
607{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700608 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
609 tlvs, tlvs_len);
610}
611
612
613/**
614 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
615 * @dev_addr: Who sent the request or responded to our request.
616 * @request: Will be 1 if request, 0 for response.
617 * @status: Valid only in case of response (0 in case of success)
618 * @config_methods: WPS config methods
619 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
620 *
621 * This can be used to notify:
622 * - Requests or responses
623 * - Various config methods
624 * - Failure condition in case of response
625 */
626void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
627 const u8 *dev_addr, int request,
628 enum p2p_prov_disc_status status,
629 u16 config_methods,
630 unsigned int generated_pin)
631{
632 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
633 status, config_methods,
634 generated_pin);
635}
636
637
638void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
639 struct wpa_ssid *ssid, int network_id,
640 int client)
641{
642 /* Notify a group has been started */
643 wpas_dbus_register_p2p_group(wpa_s, ssid);
644
645 wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
646}
647
648
649void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
650 struct wps_event_fail *fail)
651{
652 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700653}
654
655#endif /* CONFIG_P2P */
656
657
658static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800659 const u8 *sta,
660 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700661{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700662#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800663 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
664
Jouni Malinen75ecf522011-06-27 15:19:46 -0700665 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700666 * Create 'peer-joined' signal on group object -- will also
667 * check P2P itself.
668 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800669 if (p2p_dev_addr)
670 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700671#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700672
673 /* Notify listeners a new station has been authorized */
674 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700675}
676
677
678static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700679 const u8 *sta,
680 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700681{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700682#ifdef CONFIG_P2P
683 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700684 * Create 'peer-disconnected' signal on group object if this
685 * is a P2P group.
686 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800687 if (p2p_dev_addr)
688 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700689#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700690
691 /* Notify listeners a station has been deauthorized */
692 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700693}
694
695
696void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800697 const u8 *mac_addr, int authorized,
698 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700699{
700 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800701 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700702 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700703 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700704}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700705
706
707void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800708 const char *subject, const char *altsubject[],
709 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700710 const struct wpabuf *cert)
711{
712 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
713 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800714 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700715 cert_hash ? cert_hash : "");
716
717 if (cert) {
718 char *cert_hex;
719 size_t len = wpabuf_len(cert) * 2 + 1;
720 cert_hex = os_malloc(len);
721 if (cert_hex) {
722 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
723 wpabuf_len(cert));
724 wpa_msg_ctrl(wpa_s, MSG_INFO,
725 WPA_EVENT_EAP_PEER_CERT
726 "depth=%d subject='%s' cert=%s",
727 depth, subject, cert_hex);
728 os_free(cert_hex);
729 }
730 }
731
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800732 if (altsubject) {
733 int i;
734
735 for (i = 0; i < num_altsubject; i++)
736 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
737 "depth=%d %s", depth, altsubject[i]);
738 }
739
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700740 /* notify the old DBus API */
741 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
742 cert_hash, cert);
743 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800744 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
745 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700746}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700747
748
749void wpas_notify_preq(struct wpa_supplicant *wpa_s,
750 const u8 *addr, const u8 *dst, const u8 *bssid,
751 const u8 *ie, size_t ie_len, u32 ssi_signal)
752{
753#ifdef CONFIG_AP
754 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
755#endif /* CONFIG_AP */
756}
757
758
759void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
760 const char *parameter)
761{
762 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700763 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
764 "status='%s' parameter='%s'",
765 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700766}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700767
768
769void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
770 struct wpa_ssid *ssid)
771{
772 if (wpa_s->current_ssid != ssid)
773 return;
774
775 wpa_dbg(wpa_s, MSG_DEBUG,
776 "Network bssid config changed for the current network - within-ESS roaming %s",
777 ssid->bssid_set ? "disabled" : "enabled");
778
779 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
780 ssid->bssid_set ? ssid->bssid : NULL);
781}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800782
783
784void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
785 struct wpa_ssid *ssid)
786{
787#ifdef CONFIG_P2P
788 if (ssid->disabled == 2) {
789 /* Changed from normal network profile to persistent group */
790 ssid->disabled = 0;
791 wpas_dbus_unregister_network(wpa_s, ssid->id);
792 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700793 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800794 wpas_dbus_register_persistent_group(wpa_s, ssid);
795 } else {
796 /* Changed from persistent group to normal network profile */
797 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700798 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800799 wpas_dbus_register_network(wpa_s, ssid);
800 }
801#endif /* CONFIG_P2P */
802}