blob: 45d06bf3574464adcb98a90826d66b9777e1c1a9 [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"
26
27int wpas_notify_supplicant_initialized(struct wpa_global *global)
28{
29#ifdef CONFIG_DBUS
30 if (global->params.dbus_ctrl_interface) {
31 global->dbus = wpas_dbus_init(global);
32 if (global->dbus == NULL)
33 return -1;
34 }
35#endif /* CONFIG_DBUS */
36
37 return 0;
38}
39
40
41void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
42{
43#ifdef CONFIG_DBUS
44 if (global->dbus)
45 wpas_dbus_deinit(global->dbus);
46#endif /* CONFIG_DBUS */
47}
48
49
50int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
51{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080052 if (wpa_s->p2p_mgmt)
53 return 0;
54
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070055 if (wpas_dbus_register_iface(wpa_s))
56 return -1;
57
58 if (wpas_dbus_register_interface(wpa_s))
59 return -1;
60
61 return 0;
62}
63
64
65void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
66{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080067 if (wpa_s->p2p_mgmt)
68 return;
69
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070070 /* unregister interface in old DBus ctrl iface */
71 wpas_dbus_unregister_iface(wpa_s);
72
73 /* unregister interface in new DBus ctrl iface */
74 wpas_dbus_unregister_interface(wpa_s);
75}
76
77
78void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
79 enum wpa_states new_state,
80 enum wpa_states old_state)
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 /* notify the old DBus API */
86 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
87 old_state);
88
89 /* notify the new DBus API */
90 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
91
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080092#ifdef CONFIG_FST
93 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
94 if (new_state == WPA_COMPLETED)
95 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
96 else if (old_state >= WPA_ASSOCIATED &&
97 new_state < WPA_ASSOCIATED)
98 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
99 }
100#endif /* CONFIG_FST */
101
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700102 if (new_state == WPA_COMPLETED)
103 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700104 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700105 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700106
107 sme_state_changed(wpa_s);
108
109#ifdef ANDROID
110 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700111 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700112 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700113 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700114 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700115 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
116 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800117 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700118#endif /* ANDROID */
119}
120
121
Dmitry Shmidt04949592012-07-19 12:16:46 -0700122void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
123{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800124 if (wpa_s->p2p_mgmt)
125 return;
126
Dmitry Shmidt04949592012-07-19 12:16:46 -0700127 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
128}
129
130
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700131void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
132{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800133 if (wpa_s->p2p_mgmt)
134 return;
135
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700136 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
137}
138
139
140void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
141{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800142 if (wpa_s->p2p_mgmt)
143 return;
144
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700145 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
146}
147
148
149void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
150{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800151 if (wpa_s->p2p_mgmt)
152 return;
153
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700154 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
155}
156
157
158void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
159{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800160 if (wpa_s->p2p_mgmt)
161 return;
162
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700163 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
164}
165
166
167void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
168 struct wpa_ssid *ssid)
169{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800170 if (wpa_s->p2p_mgmt)
171 return;
172
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700173 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
174}
175
176
177void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
178 struct wpa_ssid *ssid)
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_network_selected(wpa_s, ssid->id);
184}
185
186
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800187void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
188 struct wpa_ssid *ssid,
189 enum wpa_ctrl_req_type rtype,
190 const char *default_txt)
191{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800192 if (wpa_s->p2p_mgmt)
193 return;
194
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800195 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
196}
197
198
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700199void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
200{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800201 if (wpa_s->p2p_mgmt)
202 return;
203
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700204 /* notify the old DBus API */
205 wpa_supplicant_dbus_notify_scanning(wpa_s);
206
207 /* notify the new DBus API */
208 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
209}
210
211
212void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
213{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800214 if (wpa_s->p2p_mgmt)
215 return;
216
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700217 wpas_dbus_signal_scan_done(wpa_s, success);
218}
219
220
221void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
222{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800223 if (wpa_s->p2p_mgmt)
224 return;
225
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700226 /* notify the old DBus API */
227 wpa_supplicant_dbus_notify_scan_results(wpa_s);
228
229 wpas_wps_notify_scan_results(wpa_s);
230}
231
232
233void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
234 const struct wps_credential *cred)
235{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800236 if (wpa_s->p2p_mgmt)
237 return;
238
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700239#ifdef CONFIG_WPS
240 /* notify the old DBus API */
241 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
242 /* notify the new DBus API */
243 wpas_dbus_signal_wps_cred(wpa_s, cred);
244#endif /* CONFIG_WPS */
245}
246
247
248void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
249 struct wps_event_m2d *m2d)
250{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800251 if (wpa_s->p2p_mgmt)
252 return;
253
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700254#ifdef CONFIG_WPS
255 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
256#endif /* CONFIG_WPS */
257}
258
259
260void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
261 struct wps_event_fail *fail)
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_fail(wpa_s, fail);
268#endif /* CONFIG_WPS */
269}
270
271
272void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
273{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800274 if (wpa_s->p2p_mgmt)
275 return;
276
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700277#ifdef CONFIG_WPS
278 wpas_dbus_signal_wps_event_success(wpa_s);
279#endif /* CONFIG_WPS */
280}
281
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700282void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
283{
284 if (wpa_s->p2p_mgmt)
285 return;
286
287#ifdef CONFIG_WPS
288 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
289#endif /* CONFIG_WPS */
290}
291
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700292
293void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
294 struct wpa_ssid *ssid)
295{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800296 if (wpa_s->p2p_mgmt)
297 return;
298
Jouni Malinen75ecf522011-06-27 15:19:46 -0700299 /*
300 * Networks objects created during any P2P activities should not be
301 * exposed out. They might/will confuse certain non-P2P aware
302 * applications since these network objects won't behave like
303 * regular ones.
304 */
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700305 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700306 wpas_dbus_register_network(wpa_s, ssid);
307}
308
309
310void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
311 struct wpa_ssid *ssid)
312{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700313#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700314 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700315#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700316}
317
318
319void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
320 struct wpa_ssid *ssid)
321{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700322#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700323 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700324#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700325}
326
327
328void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
329 struct wpa_ssid *ssid)
330{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800331 if (wpa_s->next_ssid == ssid)
332 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800333 if (wpa_s->wpa)
334 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700335 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
336 !wpa_s->p2p_mgmt)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700337 wpas_dbus_unregister_network(wpa_s, ssid->id);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800338 if (network_is_persistent_group(ssid))
339 wpas_notify_persistent_group_removed(wpa_s, ssid);
340
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800341 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700342}
343
344
345void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
346 u8 bssid[], unsigned int id)
347{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800348 if (wpa_s->p2p_mgmt)
349 return;
350
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700351 wpas_dbus_register_bss(wpa_s, bssid, id);
352 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
353 id, MAC2STR(bssid));
354}
355
356
357void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
358 u8 bssid[], unsigned int id)
359{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800360 if (wpa_s->p2p_mgmt)
361 return;
362
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700363 wpas_dbus_unregister_bss(wpa_s, bssid, id);
364 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
365 id, MAC2STR(bssid));
366}
367
368
369void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
370 unsigned int id)
371{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800372 if (wpa_s->p2p_mgmt)
373 return;
374
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700375 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
376}
377
378
379void wpas_notify_bss_signal_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_SIGNAL,
386 id);
387}
388
389
390void wpas_notify_bss_privacy_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_PRIVACY,
397 id);
398}
399
400
401void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
402 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_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
408}
409
410
411void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
412 unsigned int id)
413{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800414 if (wpa_s->p2p_mgmt)
415 return;
416
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700417 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
418}
419
420
421void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
422 unsigned int id)
423{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800424 if (wpa_s->p2p_mgmt)
425 return;
426
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700427 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
428}
429
430
431void wpas_notify_bss_wps_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 Shmidtd5e49232012-12-03 15:08:10 -0800437#ifdef CONFIG_WPS
438 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
439#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700440}
441
442
443void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
444 unsigned int id)
445{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800446 if (wpa_s->p2p_mgmt)
447 return;
448
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700449 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
450}
451
452
453void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
454 unsigned int id)
455{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800456 if (wpa_s->p2p_mgmt)
457 return;
458
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700459 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
460}
461
462
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700463void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
464{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800465 if (wpa_s->p2p_mgmt)
466 return;
467
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700468 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
469}
470
471
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700472void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
473{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800474 if (wpa_s->p2p_mgmt)
475 return;
476
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700477 wpas_dbus_signal_blob_added(wpa_s, name);
478}
479
480
481void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
482{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800483 if (wpa_s->p2p_mgmt)
484 return;
485
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700486 wpas_dbus_signal_blob_removed(wpa_s, name);
487}
488
489
490void wpas_notify_debug_level_changed(struct wpa_global *global)
491{
492 wpas_dbus_signal_debug_level_changed(global);
493}
494
495
496void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
497{
498 wpas_dbus_signal_debug_timestamp_changed(global);
499}
500
501
502void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
503{
504 wpas_dbus_signal_debug_show_keys_changed(global);
505}
506
507
508void wpas_notify_suspend(struct wpa_global *global)
509{
510 struct wpa_supplicant *wpa_s;
511
512 os_get_time(&global->suspend_time);
513 wpa_printf(MSG_DEBUG, "System suspend notification");
514 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
515 wpa_drv_suspend(wpa_s);
516}
517
518
519void wpas_notify_resume(struct wpa_global *global)
520{
521 struct os_time now;
522 int slept;
523 struct wpa_supplicant *wpa_s;
524
525 if (global->suspend_time.sec == 0)
526 slept = -1;
527 else {
528 os_get_time(&now);
529 slept = now.sec - global->suspend_time.sec;
530 }
531 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
532 slept);
533
534 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
535 wpa_drv_resume(wpa_s);
536 if (wpa_s->wpa_state == WPA_DISCONNECTED)
537 wpa_supplicant_req_scan(wpa_s, 0, 100000);
538 }
539}
540
541
542#ifdef CONFIG_P2P
543
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700544void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
545{
546 /* Notify P2P find has stopped */
547 wpas_dbus_signal_p2p_find_stopped(wpa_s);
548}
549
550
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700551void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
552 const u8 *dev_addr, int new_device)
553{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700554 if (new_device) {
555 /* Create the new peer object */
556 wpas_dbus_register_peer(wpa_s, dev_addr);
557 }
558
559 /* Notify a new peer has been detected*/
560 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700561}
562
563
564void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
565 const u8 *dev_addr)
566{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700567 wpas_dbus_unregister_peer(wpa_s, dev_addr);
568
569 /* Create signal on interface object*/
570 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700571}
572
573
574void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
575 const struct wpa_ssid *ssid,
576 const char *role)
577{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700578 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700579
580 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700581}
582
583
584void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700585 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700586{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700587 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700588}
589
590
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800591void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
592 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700593{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800594 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700595}
596
597
598void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
599 int status, const u8 *bssid)
600{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700601 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700602}
603
604
605void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
606 int freq, const u8 *sa, u8 dialog_token,
607 u16 update_indic, const u8 *tlvs,
608 size_t tlvs_len)
609{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700610 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
611 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700612}
613
614
615void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
616 const u8 *sa, u16 update_indic,
617 const u8 *tlvs, size_t tlvs_len)
618{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700619 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
620 tlvs, tlvs_len);
621}
622
623
624/**
625 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
626 * @dev_addr: Who sent the request or responded to our request.
627 * @request: Will be 1 if request, 0 for response.
628 * @status: Valid only in case of response (0 in case of success)
629 * @config_methods: WPS config methods
630 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
631 *
632 * This can be used to notify:
633 * - Requests or responses
634 * - Various config methods
635 * - Failure condition in case of response
636 */
637void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
638 const u8 *dev_addr, int request,
639 enum p2p_prov_disc_status status,
640 u16 config_methods,
641 unsigned int generated_pin)
642{
643 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
644 status, config_methods,
645 generated_pin);
646}
647
648
649void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
650 struct wpa_ssid *ssid, int network_id,
651 int client)
652{
653 /* Notify a group has been started */
654 wpas_dbus_register_p2p_group(wpa_s, ssid);
655
656 wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
657}
658
659
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800660void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
661 const char *reason)
662{
663 /* Notify a group formation failed */
664 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
665}
666
667
Jouni Malinen75ecf522011-06-27 15:19:46 -0700668void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
669 struct wps_event_fail *fail)
670{
671 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700672}
673
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800674
675void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
676 const u8 *sa, const u8 *go_dev_addr,
677 const u8 *bssid, int id, int op_freq)
678{
679 /* Notify a P2P Invitation Request */
680 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
681 id, op_freq);
682}
683
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700684#endif /* CONFIG_P2P */
685
686
687static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800688 const u8 *sta,
689 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700690{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700691#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800692 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
693
Jouni Malinen75ecf522011-06-27 15:19:46 -0700694 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700695 * Create 'peer-joined' signal on group object -- will also
696 * check P2P itself.
697 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800698 if (p2p_dev_addr)
699 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700700#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700701
702 /* Notify listeners a new station has been authorized */
703 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700704}
705
706
707static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700708 const u8 *sta,
709 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700710{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700711#ifdef CONFIG_P2P
712 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700713 * Create 'peer-disconnected' signal on group object if this
714 * is a P2P group.
715 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800716 if (p2p_dev_addr)
717 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700718#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700719
720 /* Notify listeners a station has been deauthorized */
721 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700722}
723
724
725void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800726 const u8 *mac_addr, int authorized,
727 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700728{
729 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800730 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700731 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700732 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700733}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700734
735
736void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800737 const char *subject, const char *altsubject[],
738 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700739 const struct wpabuf *cert)
740{
741 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
742 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800743 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700744 cert_hash ? cert_hash : "");
745
746 if (cert) {
747 char *cert_hex;
748 size_t len = wpabuf_len(cert) * 2 + 1;
749 cert_hex = os_malloc(len);
750 if (cert_hex) {
751 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
752 wpabuf_len(cert));
753 wpa_msg_ctrl(wpa_s, MSG_INFO,
754 WPA_EVENT_EAP_PEER_CERT
755 "depth=%d subject='%s' cert=%s",
756 depth, subject, cert_hex);
757 os_free(cert_hex);
758 }
759 }
760
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800761 if (altsubject) {
762 int i;
763
764 for (i = 0; i < num_altsubject; i++)
765 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
766 "depth=%d %s", depth, altsubject[i]);
767 }
768
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700769 /* notify the old DBus API */
770 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
771 cert_hash, cert);
772 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800773 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
774 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700775}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700776
777
778void wpas_notify_preq(struct wpa_supplicant *wpa_s,
779 const u8 *addr, const u8 *dst, const u8 *bssid,
780 const u8 *ie, size_t ie_len, u32 ssi_signal)
781{
782#ifdef CONFIG_AP
783 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
784#endif /* CONFIG_AP */
785}
786
787
788void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
789 const char *parameter)
790{
791 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700792 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
793 "status='%s' parameter='%s'",
794 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700795}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700796
797
798void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
799 struct wpa_ssid *ssid)
800{
801 if (wpa_s->current_ssid != ssid)
802 return;
803
804 wpa_dbg(wpa_s, MSG_DEBUG,
805 "Network bssid config changed for the current network - within-ESS roaming %s",
806 ssid->bssid_set ? "disabled" : "enabled");
807
808 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
809 ssid->bssid_set ? ssid->bssid : NULL);
810}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800811
812
813void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
814 struct wpa_ssid *ssid)
815{
816#ifdef CONFIG_P2P
817 if (ssid->disabled == 2) {
818 /* Changed from normal network profile to persistent group */
819 ssid->disabled = 0;
820 wpas_dbus_unregister_network(wpa_s, ssid->id);
821 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700822 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800823 wpas_dbus_register_persistent_group(wpa_s, ssid);
824 } else {
825 /* Changed from persistent group to normal network profile */
826 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700827 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800828 wpas_dbus_register_network(wpa_s, ssid);
829 }
830#endif /* CONFIG_P2P */
831}