]>
Commit | Line | Data |
---|---|---|
8bac466b JM |
1 | /* |
2 | * wpa_supplicant - Event notifications | |
207ef3fb | 3 | * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi> |
8bac466b | 4 | * |
0f3d578e JM |
5 | * This software may be distributed under the terms of the BSD license. |
6 | * See README for more details. | |
8bac466b JM |
7 | */ |
8 | ||
f0d126d3 | 9 | #include "utils/includes.h" |
8bac466b | 10 | |
f0d126d3 JM |
11 | #include "utils/common.h" |
12 | #include "common/wpa_ctrl.h" | |
8bac466b JM |
13 | #include "config.h" |
14 | #include "wpa_supplicant_i.h" | |
15 | #include "wps_supplicant.h" | |
8ddef94b | 16 | #include "dbus/dbus_common.h" |
bacfd05f | 17 | #include "dbus/dbus_old.h" |
6d59e14c | 18 | #include "dbus/dbus_new.h" |
d8a790b9 | 19 | #include "rsn_supp/wpa.h" |
207ef3fb JM |
20 | #include "driver_i.h" |
21 | #include "scan.h" | |
72044390 | 22 | #include "p2p_supplicant.h" |
e29853bb | 23 | #include "sme.h" |
8bac466b JM |
24 | #include "notify.h" |
25 | ||
dc461de4 WS |
26 | int wpas_notify_supplicant_initialized(struct wpa_global *global) |
27 | { | |
8ddef94b | 28 | #ifdef CONFIG_DBUS |
dc461de4 | 29 | if (global->params.dbus_ctrl_interface) { |
8ddef94b JM |
30 | global->dbus = wpas_dbus_init(global); |
31 | if (global->dbus == NULL) | |
85d3f273 | 32 | return -1; |
dc461de4 | 33 | } |
8ddef94b | 34 | #endif /* CONFIG_DBUS */ |
dc461de4 WS |
35 | |
36 | return 0; | |
37 | } | |
38 | ||
39 | ||
40 | void wpas_notify_supplicant_deinitialized(struct wpa_global *global) | |
41 | { | |
8ddef94b JM |
42 | #ifdef CONFIG_DBUS |
43 | if (global->dbus) | |
44 | wpas_dbus_deinit(global->dbus); | |
45 | #endif /* CONFIG_DBUS */ | |
dc461de4 WS |
46 | } |
47 | ||
48 | ||
49 | int wpas_notify_iface_added(struct wpa_supplicant *wpa_s) | |
50 | { | |
bb3df9a5 TB |
51 | if (wpa_s->p2p_mgmt) |
52 | return 0; | |
53 | ||
dc461de4 WS |
54 | if (wpas_dbus_register_iface(wpa_s)) |
55 | return -1; | |
56 | ||
52bdd880 | 57 | if (wpas_dbus_register_interface(wpa_s)) |
8fc2fb56 WS |
58 | return -1; |
59 | ||
dc461de4 WS |
60 | return 0; |
61 | } | |
62 | ||
63 | ||
dc461de4 WS |
64 | void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s) |
65 | { | |
bb3df9a5 TB |
66 | if (wpa_s->p2p_mgmt) |
67 | return; | |
68 | ||
dc461de4 WS |
69 | /* unregister interface in old DBus ctrl iface */ |
70 | wpas_dbus_unregister_iface(wpa_s); | |
8fc2fb56 WS |
71 | |
72 | /* unregister interface in new DBus ctrl iface */ | |
52bdd880 | 73 | wpas_dbus_unregister_interface(wpa_s); |
dc461de4 WS |
74 | } |
75 | ||
8bac466b JM |
76 | |
77 | void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, | |
71934751 JM |
78 | enum wpa_states new_state, |
79 | enum wpa_states old_state) | |
8bac466b | 80 | { |
bb3df9a5 TB |
81 | if (wpa_s->p2p_mgmt) |
82 | return; | |
83 | ||
8bac466b JM |
84 | /* notify the old DBus API */ |
85 | wpa_supplicant_dbus_notify_state_change(wpa_s, new_state, | |
86 | old_state); | |
8fc2fb56 WS |
87 | |
88 | /* notify the new DBus API */ | |
27f43d8d | 89 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE); |
72044390 | 90 | |
72044390 JM |
91 | if (new_state == WPA_COMPLETED) |
92 | wpas_p2p_notif_connected(wpa_s); | |
dbe7aa22 | 93 | else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED) |
72044390 | 94 | wpas_p2p_notif_disconnected(wpa_s); |
e29853bb BG |
95 | |
96 | sme_state_changed(wpa_s); | |
4e2ead7a DS |
97 | |
98 | #ifdef ANDROID | |
99 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE | |
6b499076 | 100 | "id=%d state=%d BSSID=" MACSTR " SSID=%s", |
4e2ead7a | 101 | wpa_s->current_ssid ? wpa_s->current_ssid->id : -1, |
6b499076 DS |
102 | new_state, |
103 | MAC2STR(wpa_s->bssid), | |
104 | wpa_s->current_ssid && wpa_s->current_ssid->ssid ? | |
105 | wpa_ssid_txt(wpa_s->current_ssid->ssid, | |
106 | wpa_s->current_ssid->ssid_len) : ""); | |
4e2ead7a | 107 | #endif /* ANDROID */ |
8bac466b JM |
108 | } |
109 | ||
110 | ||
0bb1e425 GM |
111 | void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s) |
112 | { | |
bb3df9a5 TB |
113 | if (wpa_s->p2p_mgmt) |
114 | return; | |
115 | ||
0bb1e425 GM |
116 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON); |
117 | } | |
118 | ||
119 | ||
8bac466b JM |
120 | void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) |
121 | { | |
bb3df9a5 TB |
122 | if (wpa_s->p2p_mgmt) |
123 | return; | |
124 | ||
52bdd880 | 125 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); |
8bac466b JM |
126 | } |
127 | ||
128 | ||
129 | void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) | |
130 | { | |
bb3df9a5 TB |
131 | if (wpa_s->p2p_mgmt) |
132 | return; | |
133 | ||
52bdd880 | 134 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); |
8bac466b JM |
135 | } |
136 | ||
137 | ||
138 | void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) | |
139 | { | |
bb3df9a5 TB |
140 | if (wpa_s->p2p_mgmt) |
141 | return; | |
142 | ||
52bdd880 | 143 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); |
8bac466b JM |
144 | } |
145 | ||
146 | ||
5bbf9f10 PS |
147 | void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s) |
148 | { | |
bb3df9a5 TB |
149 | if (wpa_s->p2p_mgmt) |
150 | return; | |
151 | ||
5bbf9f10 PS |
152 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE); |
153 | } | |
154 | ||
155 | ||
8bac466b JM |
156 | void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, |
157 | struct wpa_ssid *ssid) | |
158 | { | |
bb3df9a5 TB |
159 | if (wpa_s->p2p_mgmt) |
160 | return; | |
161 | ||
52bdd880 | 162 | wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); |
8bac466b JM |
163 | } |
164 | ||
165 | ||
166 | void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, | |
167 | struct wpa_ssid *ssid) | |
168 | { | |
bb3df9a5 TB |
169 | if (wpa_s->p2p_mgmt) |
170 | return; | |
171 | ||
52bdd880 | 172 | wpas_dbus_signal_network_selected(wpa_s, ssid->id); |
8bac466b JM |
173 | } |
174 | ||
175 | ||
a9022616 DW |
176 | void 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 | { | |
bb3df9a5 TB |
181 | if (wpa_s->p2p_mgmt) |
182 | return; | |
183 | ||
a9022616 DW |
184 | wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt); |
185 | } | |
186 | ||
187 | ||
8bac466b JM |
188 | void wpas_notify_scanning(struct wpa_supplicant *wpa_s) |
189 | { | |
bb3df9a5 TB |
190 | if (wpa_s->p2p_mgmt) |
191 | return; | |
192 | ||
8bac466b JM |
193 | /* notify the old DBus API */ |
194 | wpa_supplicant_dbus_notify_scanning(wpa_s); | |
27f43d8d | 195 | |
8fc2fb56 | 196 | /* notify the new DBus API */ |
52bdd880 | 197 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); |
8bac466b JM |
198 | } |
199 | ||
200 | ||
201 | void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) | |
202 | { | |
bb3df9a5 TB |
203 | if (wpa_s->p2p_mgmt) |
204 | return; | |
205 | ||
52bdd880 | 206 | wpas_dbus_signal_scan_done(wpa_s, success); |
8bac466b JM |
207 | } |
208 | ||
209 | ||
210 | void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) | |
211 | { | |
bb3df9a5 TB |
212 | if (wpa_s->p2p_mgmt) |
213 | return; | |
214 | ||
8bac466b JM |
215 | /* 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 | ||
222 | void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, | |
223 | const struct wps_credential *cred) | |
224 | { | |
bb3df9a5 TB |
225 | if (wpa_s->p2p_mgmt) |
226 | return; | |
227 | ||
b99b8e15 | 228 | #ifdef CONFIG_WPS |
8bac466b JM |
229 | /* notify the old DBus API */ |
230 | wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); | |
8fc2fb56 | 231 | /* notify the new DBus API */ |
52bdd880 | 232 | wpas_dbus_signal_wps_cred(wpa_s, cred); |
b99b8e15 | 233 | #endif /* CONFIG_WPS */ |
8bac466b JM |
234 | } |
235 | ||
236 | ||
237 | void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, | |
238 | struct wps_event_m2d *m2d) | |
239 | { | |
bb3df9a5 TB |
240 | if (wpa_s->p2p_mgmt) |
241 | return; | |
242 | ||
b99b8e15 | 243 | #ifdef CONFIG_WPS |
52bdd880 | 244 | wpas_dbus_signal_wps_event_m2d(wpa_s, m2d); |
b99b8e15 | 245 | #endif /* CONFIG_WPS */ |
8bac466b JM |
246 | } |
247 | ||
248 | ||
249 | void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, | |
250 | struct wps_event_fail *fail) | |
251 | { | |
bb3df9a5 TB |
252 | if (wpa_s->p2p_mgmt) |
253 | return; | |
254 | ||
b99b8e15 | 255 | #ifdef CONFIG_WPS |
52bdd880 | 256 | wpas_dbus_signal_wps_event_fail(wpa_s, fail); |
b99b8e15 | 257 | #endif /* CONFIG_WPS */ |
8bac466b JM |
258 | } |
259 | ||
260 | ||
261 | void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) | |
262 | { | |
bb3df9a5 TB |
263 | if (wpa_s->p2p_mgmt) |
264 | return; | |
265 | ||
b99b8e15 | 266 | #ifdef CONFIG_WPS |
52bdd880 | 267 | wpas_dbus_signal_wps_event_success(wpa_s); |
b99b8e15 | 268 | #endif /* CONFIG_WPS */ |
8bac466b JM |
269 | } |
270 | ||
271 | ||
272 | void wpas_notify_network_added(struct wpa_supplicant *wpa_s, | |
273 | struct wpa_ssid *ssid) | |
274 | { | |
bb3df9a5 TB |
275 | if (wpa_s->p2p_mgmt) |
276 | return; | |
277 | ||
c2762e41 JS |
278 | /* |
279 | * Networks objects created during any P2P activities should not be | |
280 | * exposed out. They might/will confuse certain non-P2P aware | |
281 | * applications since these network objects won't behave like | |
282 | * regular ones. | |
283 | */ | |
447969e0 | 284 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) |
c2762e41 JS |
285 | wpas_dbus_register_network(wpa_s, ssid); |
286 | } | |
287 | ||
288 | ||
289 | void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s, | |
290 | struct wpa_ssid *ssid) | |
291 | { | |
7a2b53b4 | 292 | #ifdef CONFIG_P2P |
c2762e41 | 293 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
7a2b53b4 | 294 | #endif /* CONFIG_P2P */ |
8bac466b JM |
295 | } |
296 | ||
297 | ||
28550706 JS |
298 | void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s, |
299 | struct wpa_ssid *ssid) | |
300 | { | |
7a2b53b4 | 301 | #ifdef CONFIG_P2P |
28550706 | 302 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); |
7a2b53b4 | 303 | #endif /* CONFIG_P2P */ |
28550706 JS |
304 | } |
305 | ||
306 | ||
8bac466b JM |
307 | void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, |
308 | struct wpa_ssid *ssid) | |
309 | { | |
bb3df9a5 TB |
310 | if (wpa_s->p2p_mgmt) |
311 | return; | |
312 | ||
3d910ef4 JM |
313 | if (wpa_s->next_ssid == ssid) |
314 | wpa_s->next_ssid = NULL; | |
8c0d3b4f JM |
315 | if (wpa_s->wpa) |
316 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); | |
447969e0 | 317 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) |
c2762e41 | 318 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
502618f7 | 319 | wpas_p2p_network_removed(wpa_s, ssid); |
8bac466b JM |
320 | } |
321 | ||
322 | ||
71f6e1f6 | 323 | void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, |
f0d126d3 | 324 | u8 bssid[], unsigned int id) |
71f6e1f6 | 325 | { |
bb3df9a5 TB |
326 | if (wpa_s->p2p_mgmt) |
327 | return; | |
328 | ||
52bdd880 | 329 | wpas_dbus_register_bss(wpa_s, bssid, id); |
f0d126d3 JM |
330 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, |
331 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
332 | } |
333 | ||
334 | ||
335 | void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, | |
f0d126d3 | 336 | u8 bssid[], unsigned int id) |
71f6e1f6 | 337 | { |
bb3df9a5 TB |
338 | if (wpa_s->p2p_mgmt) |
339 | return; | |
340 | ||
52bdd880 | 341 | wpas_dbus_unregister_bss(wpa_s, bssid, id); |
f0d126d3 JM |
342 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, |
343 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
344 | } |
345 | ||
346 | ||
158c6c74 WS |
347 | void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, |
348 | unsigned int id) | |
349 | { | |
bb3df9a5 TB |
350 | if (wpa_s->p2p_mgmt) |
351 | return; | |
352 | ||
158c6c74 WS |
353 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); |
354 | } | |
355 | ||
356 | ||
357 | void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s, | |
358 | unsigned int id) | |
359 | { | |
bb3df9a5 TB |
360 | if (wpa_s->p2p_mgmt) |
361 | return; | |
362 | ||
158c6c74 WS |
363 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL, |
364 | id); | |
365 | } | |
366 | ||
367 | ||
368 | void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s, | |
369 | unsigned int id) | |
370 | { | |
bb3df9a5 TB |
371 | if (wpa_s->p2p_mgmt) |
372 | return; | |
373 | ||
158c6c74 WS |
374 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY, |
375 | id); | |
376 | } | |
377 | ||
378 | ||
379 | void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s, | |
380 | unsigned int id) | |
381 | { | |
bb3df9a5 TB |
382 | if (wpa_s->p2p_mgmt) |
383 | return; | |
384 | ||
158c6c74 WS |
385 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id); |
386 | } | |
387 | ||
388 | ||
389 | void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s, | |
390 | unsigned int id) | |
391 | { | |
bb3df9a5 TB |
392 | if (wpa_s->p2p_mgmt) |
393 | return; | |
394 | ||
7899e2f4 | 395 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id); |
158c6c74 WS |
396 | } |
397 | ||
398 | ||
399 | void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s, | |
400 | unsigned int id) | |
401 | { | |
bb3df9a5 TB |
402 | if (wpa_s->p2p_mgmt) |
403 | return; | |
404 | ||
7899e2f4 | 405 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id); |
158c6c74 WS |
406 | } |
407 | ||
408 | ||
409 | void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s, | |
7899e2f4 WS |
410 | unsigned int id) |
411 | { | |
bb3df9a5 TB |
412 | if (wpa_s->p2p_mgmt) |
413 | return; | |
414 | ||
caff3992 SN |
415 | #ifdef CONFIG_WPS |
416 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id); | |
417 | #endif /* CONFIG_WPS */ | |
7899e2f4 WS |
418 | } |
419 | ||
420 | ||
421 | void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s, | |
158c6c74 WS |
422 | unsigned int id) |
423 | { | |
bb3df9a5 TB |
424 | if (wpa_s->p2p_mgmt) |
425 | return; | |
426 | ||
7899e2f4 | 427 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id); |
158c6c74 WS |
428 | } |
429 | ||
430 | ||
431 | void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s, | |
432 | unsigned int id) | |
433 | { | |
bb3df9a5 TB |
434 | if (wpa_s->p2p_mgmt) |
435 | return; | |
436 | ||
158c6c74 WS |
437 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id); |
438 | } | |
439 | ||
440 | ||
3bd3257a DW |
441 | void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id) |
442 | { | |
bb3df9a5 TB |
443 | if (wpa_s->p2p_mgmt) |
444 | return; | |
445 | ||
3bd3257a DW |
446 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id); |
447 | } | |
448 | ||
449 | ||
8bac466b JM |
450 | void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) |
451 | { | |
bb3df9a5 TB |
452 | if (wpa_s->p2p_mgmt) |
453 | return; | |
454 | ||
52bdd880 | 455 | wpas_dbus_signal_blob_added(wpa_s, name); |
8bac466b JM |
456 | } |
457 | ||
458 | ||
459 | void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) | |
460 | { | |
bb3df9a5 TB |
461 | if (wpa_s->p2p_mgmt) |
462 | return; | |
463 | ||
52bdd880 | 464 | wpas_dbus_signal_blob_removed(wpa_s, name); |
8bac466b JM |
465 | } |
466 | ||
467 | ||
db9133ac | 468 | void wpas_notify_debug_level_changed(struct wpa_global *global) |
8bac466b | 469 | { |
52bdd880 | 470 | wpas_dbus_signal_debug_level_changed(global); |
db9133ac WS |
471 | } |
472 | ||
473 | ||
474 | void wpas_notify_debug_timestamp_changed(struct wpa_global *global) | |
475 | { | |
52bdd880 | 476 | wpas_dbus_signal_debug_timestamp_changed(global); |
db9133ac WS |
477 | } |
478 | ||
479 | ||
480 | void wpas_notify_debug_show_keys_changed(struct wpa_global *global) | |
481 | { | |
52bdd880 | 482 | wpas_dbus_signal_debug_show_keys_changed(global); |
8bac466b | 483 | } |
207ef3fb JM |
484 | |
485 | ||
486 | void wpas_notify_suspend(struct wpa_global *global) | |
487 | { | |
488 | struct wpa_supplicant *wpa_s; | |
489 | ||
490 | os_get_time(&global->suspend_time); | |
491 | wpa_printf(MSG_DEBUG, "System suspend notification"); | |
492 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) | |
493 | wpa_drv_suspend(wpa_s); | |
494 | } | |
495 | ||
496 | ||
497 | void wpas_notify_resume(struct wpa_global *global) | |
498 | { | |
499 | struct os_time now; | |
500 | int slept; | |
501 | struct wpa_supplicant *wpa_s; | |
502 | ||
503 | if (global->suspend_time.sec == 0) | |
504 | slept = -1; | |
505 | else { | |
506 | os_get_time(&now); | |
507 | slept = now.sec - global->suspend_time.sec; | |
508 | } | |
509 | wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)", | |
510 | slept); | |
511 | ||
512 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { | |
513 | wpa_drv_resume(wpa_s); | |
514 | if (wpa_s->wpa_state == WPA_DISCONNECTED) | |
515 | wpa_supplicant_req_scan(wpa_s, 0, 100000); | |
516 | } | |
517 | } | |
d642d2d2 JB |
518 | |
519 | ||
520 | #ifdef CONFIG_P2P | |
56eeb8f2 | 521 | |
d642d2d2 JB |
522 | void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, |
523 | const u8 *dev_addr, int new_device) | |
524 | { | |
9abafccc JB |
525 | if (new_device) { |
526 | /* Create the new peer object */ | |
527 | wpas_dbus_register_peer(wpa_s, dev_addr); | |
528 | } | |
529 | ||
530 | /* Notify a new peer has been detected*/ | |
531 | wpas_dbus_signal_peer_device_found(wpa_s, dev_addr); | |
d642d2d2 | 532 | } |
56eeb8f2 JB |
533 | |
534 | ||
535 | void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, | |
536 | const u8 *dev_addr) | |
537 | { | |
9abafccc JB |
538 | wpas_dbus_unregister_peer(wpa_s, dev_addr); |
539 | ||
540 | /* Create signal on interface object*/ | |
541 | wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr); | |
56eeb8f2 JB |
542 | } |
543 | ||
408af93e JB |
544 | |
545 | void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s, | |
546 | const struct wpa_ssid *ssid, | |
547 | const char *role) | |
548 | { | |
9abafccc | 549 | wpas_dbus_signal_p2p_group_removed(wpa_s, role); |
4a0693a4 TB |
550 | |
551 | wpas_dbus_unregister_p2p_group(wpa_s, ssid); | |
408af93e JB |
552 | } |
553 | ||
32d1bce0 KRK |
554 | |
555 | void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s, | |
556 | const u8 *src, u16 dev_passwd_id) | |
557 | { | |
9abafccc | 558 | wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id); |
32d1bce0 KRK |
559 | } |
560 | ||
c2641bf7 | 561 | |
e5a359cf RC |
562 | void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, |
563 | struct p2p_go_neg_results *res) | |
c2641bf7 | 564 | { |
e5a359cf | 565 | wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res); |
c2641bf7 JS |
566 | } |
567 | ||
5ccdf84f JMB |
568 | |
569 | void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s, | |
570 | int status, const u8 *bssid) | |
571 | { | |
9abafccc | 572 | wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid); |
5ccdf84f JMB |
573 | } |
574 | ||
e1653cac KRK |
575 | |
576 | void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s, | |
577 | int freq, const u8 *sa, u8 dialog_token, | |
578 | u16 update_indic, const u8 *tlvs, | |
579 | size_t tlvs_len) | |
580 | { | |
9abafccc JB |
581 | wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token, |
582 | update_indic, tlvs, tlvs_len); | |
e1653cac KRK |
583 | } |
584 | ||
43a26f60 KRK |
585 | |
586 | void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s, | |
587 | const u8 *sa, u16 update_indic, | |
588 | const u8 *tlvs, size_t tlvs_len) | |
589 | { | |
9abafccc JB |
590 | wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic, |
591 | tlvs, tlvs_len); | |
43a26f60 KRK |
592 | } |
593 | ||
dd8a7e05 JB |
594 | |
595 | /** | |
596 | * wpas_notify_p2p_provision_discovery - Notification of provision discovery | |
597 | * @dev_addr: Who sent the request or responded to our request. | |
598 | * @request: Will be 1 if request, 0 for response. | |
599 | * @status: Valid only in case of response (0 in case of success) | |
600 | * @config_methods: WPS config methods | |
601 | * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method | |
602 | * | |
603 | * This can be used to notify: | |
604 | * - Requests or responses | |
605 | * - Various config methods | |
606 | * - Failure condition in case of response | |
607 | */ | |
608 | void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s, | |
609 | const u8 *dev_addr, int request, | |
610 | enum p2p_prov_disc_status status, | |
611 | u16 config_methods, | |
612 | unsigned int generated_pin) | |
613 | { | |
9abafccc JB |
614 | wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request, |
615 | status, config_methods, | |
616 | generated_pin); | |
dd8a7e05 | 617 | } |
4b6baa2f JMB |
618 | |
619 | ||
620 | void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, | |
621 | struct wpa_ssid *ssid, int network_id, | |
622 | int client) | |
623 | { | |
9abafccc JB |
624 | /* Notify a group has been started */ |
625 | wpas_dbus_register_p2p_group(wpa_s, ssid); | |
626 | ||
627 | wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id); | |
4b6baa2f | 628 | } |
3734552f JS |
629 | |
630 | ||
631 | void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s, | |
632 | struct wps_event_fail *fail) | |
633 | { | |
634 | wpas_dbus_signal_p2p_wps_failed(wpa_s, fail); | |
635 | } | |
636 | ||
d642d2d2 | 637 | #endif /* CONFIG_P2P */ |
d8a43924 JB |
638 | |
639 | ||
640 | static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, | |
fbdcfd57 JM |
641 | const u8 *sta, |
642 | const u8 *p2p_dev_addr) | |
d8a43924 | 643 | { |
692cb226 | 644 | #ifdef CONFIG_P2P |
fbdcfd57 JM |
645 | wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr); |
646 | ||
9abafccc JB |
647 | /* |
648 | * Create 'peer-joined' signal on group object -- will also | |
649 | * check P2P itself. | |
650 | */ | |
bf035663 | 651 | wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr); |
692cb226 | 652 | #endif /* CONFIG_P2P */ |
8a901d75 CZ |
653 | |
654 | /* Notify listeners a new station has been authorized */ | |
655 | wpas_dbus_signal_sta_authorized(wpa_s, sta); | |
d8a43924 JB |
656 | } |
657 | ||
658 | ||
659 | static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, | |
bf035663 TB |
660 | const u8 *sta, |
661 | const u8 *p2p_dev_addr) | |
d8a43924 | 662 | { |
692cb226 | 663 | #ifdef CONFIG_P2P |
9abafccc JB |
664 | /* |
665 | * Create 'peer-disconnected' signal on group object if this | |
666 | * is a P2P group. | |
667 | */ | |
bf035663 | 668 | wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr); |
692cb226 | 669 | #endif /* CONFIG_P2P */ |
8a901d75 CZ |
670 | |
671 | /* Notify listeners a station has been deauthorized */ | |
672 | wpas_dbus_signal_sta_deauthorized(wpa_s, sta); | |
d8a43924 JB |
673 | } |
674 | ||
675 | ||
676 | void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s, | |
fbdcfd57 JM |
677 | const u8 *mac_addr, int authorized, |
678 | const u8 *p2p_dev_addr) | |
d8a43924 JB |
679 | { |
680 | if (authorized) | |
fbdcfd57 | 681 | wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr); |
d8a43924 | 682 | else |
bf035663 | 683 | wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr); |
d8a43924 | 684 | } |
ade74830 MC |
685 | |
686 | ||
687 | void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth, | |
688 | const char *subject, const char *cert_hash, | |
689 | const struct wpabuf *cert) | |
690 | { | |
4f525d8e JM |
691 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT |
692 | "depth=%d subject='%s'%s%s", | |
693 | depth, subject, | |
694 | cert_hash ? " hash=" : "", | |
695 | cert_hash ? cert_hash : ""); | |
696 | ||
697 | if (cert) { | |
698 | char *cert_hex; | |
699 | size_t len = wpabuf_len(cert) * 2 + 1; | |
700 | cert_hex = os_malloc(len); | |
701 | if (cert_hex) { | |
702 | wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert), | |
703 | wpabuf_len(cert)); | |
704 | wpa_msg_ctrl(wpa_s, MSG_INFO, | |
705 | WPA_EVENT_EAP_PEER_CERT | |
706 | "depth=%d subject='%s' cert=%s", | |
707 | depth, subject, cert_hex); | |
708 | os_free(cert_hex); | |
709 | } | |
710 | } | |
711 | ||
ade74830 MC |
712 | /* notify the old DBus API */ |
713 | wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject, | |
714 | cert_hash, cert); | |
715 | /* notify the new DBus API */ | |
716 | wpas_dbus_signal_certification(wpa_s, depth, subject, cert_hash, cert); | |
717 | } | |
2d43d37f JB |
718 | |
719 | ||
720 | void wpas_notify_preq(struct wpa_supplicant *wpa_s, | |
721 | const u8 *addr, const u8 *dst, const u8 *bssid, | |
722 | const u8 *ie, size_t ie_len, u32 ssi_signal) | |
723 | { | |
724 | #ifdef CONFIG_AP | |
725 | wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal); | |
726 | #endif /* CONFIG_AP */ | |
727 | } | |
dd7fec1f PS |
728 | |
729 | ||
730 | void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status, | |
731 | const char *parameter) | |
732 | { | |
733 | wpas_dbus_signal_eap_status(wpa_s, status, parameter); | |
c7a39ba4 CH |
734 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS |
735 | "status='%s' parameter='%s'", | |
736 | status, parameter); | |
dd7fec1f | 737 | } |
0ef023e4 JM |
738 | |
739 | ||
740 | void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s, | |
741 | struct wpa_ssid *ssid) | |
742 | { | |
743 | if (wpa_s->current_ssid != ssid) | |
744 | return; | |
745 | ||
746 | wpa_dbg(wpa_s, MSG_DEBUG, | |
747 | "Network bssid config changed for the current network - within-ESS roaming %s", | |
748 | ssid->bssid_set ? "disabled" : "enabled"); | |
749 | ||
750 | wpa_drv_roaming(wpa_s, !ssid->bssid_set, | |
751 | ssid->bssid_set ? ssid->bssid : NULL); | |
752 | } |