]>
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" | |
7b4bbb9f | 16 | #include "binder/binder.h" |
8ddef94b | 17 | #include "dbus/dbus_common.h" |
bacfd05f | 18 | #include "dbus/dbus_old.h" |
6d59e14c | 19 | #include "dbus/dbus_new.h" |
d8a790b9 | 20 | #include "rsn_supp/wpa.h" |
b36a3a65 | 21 | #include "fst/fst.h" |
207ef3fb JM |
22 | #include "driver_i.h" |
23 | #include "scan.h" | |
72044390 | 24 | #include "p2p_supplicant.h" |
e29853bb | 25 | #include "sme.h" |
8bac466b JM |
26 | #include "notify.h" |
27 | ||
dc461de4 WS |
28 | int wpas_notify_supplicant_initialized(struct wpa_global *global) |
29 | { | |
8ddef94b | 30 | #ifdef CONFIG_DBUS |
dc461de4 | 31 | if (global->params.dbus_ctrl_interface) { |
8ddef94b JM |
32 | global->dbus = wpas_dbus_init(global); |
33 | if (global->dbus == NULL) | |
85d3f273 | 34 | return -1; |
dc461de4 | 35 | } |
8ddef94b | 36 | #endif /* CONFIG_DBUS */ |
dc461de4 | 37 | |
7b4bbb9f RP |
38 | #ifdef CONFIG_BINDER |
39 | global->binder = wpas_binder_init(global); | |
40 | if (!global->binder) | |
41 | return -1; | |
42 | #endif /* CONFIG_BINDER */ | |
43 | ||
dc461de4 WS |
44 | return 0; |
45 | } | |
46 | ||
47 | ||
48 | void wpas_notify_supplicant_deinitialized(struct wpa_global *global) | |
49 | { | |
8ddef94b JM |
50 | #ifdef CONFIG_DBUS |
51 | if (global->dbus) | |
52 | wpas_dbus_deinit(global->dbus); | |
53 | #endif /* CONFIG_DBUS */ | |
7b4bbb9f RP |
54 | |
55 | #ifdef CONFIG_BINDER | |
56 | if (global->binder) | |
57 | wpas_binder_deinit(global->binder); | |
58 | #endif /* CONFIG_BINDER */ | |
dc461de4 WS |
59 | } |
60 | ||
61 | ||
62 | int wpas_notify_iface_added(struct wpa_supplicant *wpa_s) | |
63 | { | |
bb3df9a5 TB |
64 | if (wpa_s->p2p_mgmt) |
65 | return 0; | |
66 | ||
dc461de4 WS |
67 | if (wpas_dbus_register_iface(wpa_s)) |
68 | return -1; | |
69 | ||
52bdd880 | 70 | if (wpas_dbus_register_interface(wpa_s)) |
8fc2fb56 WS |
71 | return -1; |
72 | ||
dc461de4 WS |
73 | return 0; |
74 | } | |
75 | ||
76 | ||
dc461de4 WS |
77 | void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s) |
78 | { | |
bb3df9a5 TB |
79 | if (wpa_s->p2p_mgmt) |
80 | return; | |
81 | ||
dc461de4 WS |
82 | /* unregister interface in old DBus ctrl iface */ |
83 | wpas_dbus_unregister_iface(wpa_s); | |
8fc2fb56 WS |
84 | |
85 | /* unregister interface in new DBus ctrl iface */ | |
52bdd880 | 86 | wpas_dbus_unregister_interface(wpa_s); |
dc461de4 WS |
87 | } |
88 | ||
8bac466b JM |
89 | |
90 | void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, | |
71934751 JM |
91 | enum wpa_states new_state, |
92 | enum wpa_states old_state) | |
8bac466b | 93 | { |
bb3df9a5 TB |
94 | if (wpa_s->p2p_mgmt) |
95 | return; | |
96 | ||
8bac466b JM |
97 | /* notify the old DBus API */ |
98 | wpa_supplicant_dbus_notify_state_change(wpa_s, new_state, | |
99 | old_state); | |
8fc2fb56 WS |
100 | |
101 | /* notify the new DBus API */ | |
27f43d8d | 102 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE); |
72044390 | 103 | |
b36a3a65 AN |
104 | #ifdef CONFIG_FST |
105 | if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) { | |
106 | if (new_state == WPA_COMPLETED) | |
107 | fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid); | |
108 | else if (old_state >= WPA_ASSOCIATED && | |
109 | new_state < WPA_ASSOCIATED) | |
110 | fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid); | |
111 | } | |
112 | #endif /* CONFIG_FST */ | |
113 | ||
72044390 JM |
114 | if (new_state == WPA_COMPLETED) |
115 | wpas_p2p_notif_connected(wpa_s); | |
dbe7aa22 | 116 | else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED) |
72044390 | 117 | wpas_p2p_notif_disconnected(wpa_s); |
e29853bb BG |
118 | |
119 | sme_state_changed(wpa_s); | |
4e2ead7a DS |
120 | |
121 | #ifdef ANDROID | |
122 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE | |
6b499076 | 123 | "id=%d state=%d BSSID=" MACSTR " SSID=%s", |
4e2ead7a | 124 | wpa_s->current_ssid ? wpa_s->current_ssid->id : -1, |
6b499076 DS |
125 | new_state, |
126 | MAC2STR(wpa_s->bssid), | |
127 | wpa_s->current_ssid && wpa_s->current_ssid->ssid ? | |
128 | wpa_ssid_txt(wpa_s->current_ssid->ssid, | |
129 | wpa_s->current_ssid->ssid_len) : ""); | |
4e2ead7a | 130 | #endif /* ANDROID */ |
8bac466b JM |
131 | } |
132 | ||
133 | ||
0bb1e425 GM |
134 | void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s) |
135 | { | |
bb3df9a5 TB |
136 | if (wpa_s->p2p_mgmt) |
137 | return; | |
138 | ||
0bb1e425 GM |
139 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON); |
140 | } | |
141 | ||
142 | ||
38b405c8 AK |
143 | void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s) |
144 | { | |
145 | if (wpa_s->p2p_mgmt) | |
146 | return; | |
147 | ||
148 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE); | |
149 | } | |
150 | ||
151 | ||
c7fb678f NS |
152 | void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s) |
153 | { | |
154 | if (wpa_s->p2p_mgmt) | |
155 | return; | |
156 | ||
157 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE); | |
158 | } | |
159 | ||
160 | ||
2bbad1c7 MW |
161 | void wpas_notify_roam_time(struct wpa_supplicant *wpa_s) |
162 | { | |
163 | if (wpa_s->p2p_mgmt) | |
164 | return; | |
165 | ||
166 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME); | |
167 | } | |
168 | ||
169 | ||
170 | void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s) | |
171 | { | |
172 | if (wpa_s->p2p_mgmt) | |
173 | return; | |
174 | ||
175 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE); | |
176 | } | |
177 | ||
178 | ||
179 | void wpas_notify_session_length(struct wpa_supplicant *wpa_s) | |
180 | { | |
181 | if (wpa_s->p2p_mgmt) | |
182 | return; | |
183 | ||
184 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH); | |
185 | } | |
186 | ||
187 | ||
80d06d0c MW |
188 | void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s) |
189 | { | |
190 | if (wpa_s->p2p_mgmt) | |
191 | return; | |
192 | ||
193 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS); | |
194 | } | |
195 | ||
196 | ||
8bac466b JM |
197 | void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) |
198 | { | |
bb3df9a5 TB |
199 | if (wpa_s->p2p_mgmt) |
200 | return; | |
201 | ||
52bdd880 | 202 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); |
8bac466b JM |
203 | } |
204 | ||
205 | ||
206 | void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) | |
207 | { | |
bb3df9a5 TB |
208 | if (wpa_s->p2p_mgmt) |
209 | return; | |
210 | ||
52bdd880 | 211 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); |
8bac466b JM |
212 | } |
213 | ||
214 | ||
215 | void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) | |
216 | { | |
bb3df9a5 TB |
217 | if (wpa_s->p2p_mgmt) |
218 | return; | |
219 | ||
52bdd880 | 220 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); |
8bac466b JM |
221 | } |
222 | ||
223 | ||
5bbf9f10 PS |
224 | void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s) |
225 | { | |
bb3df9a5 TB |
226 | if (wpa_s->p2p_mgmt) |
227 | return; | |
228 | ||
5bbf9f10 PS |
229 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE); |
230 | } | |
231 | ||
232 | ||
8bac466b JM |
233 | void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, |
234 | struct wpa_ssid *ssid) | |
235 | { | |
bb3df9a5 TB |
236 | if (wpa_s->p2p_mgmt) |
237 | return; | |
238 | ||
52bdd880 | 239 | wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); |
8bac466b JM |
240 | } |
241 | ||
242 | ||
243 | void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, | |
244 | struct wpa_ssid *ssid) | |
245 | { | |
bb3df9a5 TB |
246 | if (wpa_s->p2p_mgmt) |
247 | return; | |
248 | ||
52bdd880 | 249 | wpas_dbus_signal_network_selected(wpa_s, ssid->id); |
8bac466b JM |
250 | } |
251 | ||
252 | ||
a9022616 DW |
253 | void wpas_notify_network_request(struct wpa_supplicant *wpa_s, |
254 | struct wpa_ssid *ssid, | |
255 | enum wpa_ctrl_req_type rtype, | |
256 | const char *default_txt) | |
257 | { | |
bb3df9a5 TB |
258 | if (wpa_s->p2p_mgmt) |
259 | return; | |
260 | ||
a9022616 DW |
261 | wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt); |
262 | } | |
263 | ||
264 | ||
8bac466b JM |
265 | void wpas_notify_scanning(struct wpa_supplicant *wpa_s) |
266 | { | |
bb3df9a5 TB |
267 | if (wpa_s->p2p_mgmt) |
268 | return; | |
269 | ||
8bac466b JM |
270 | /* notify the old DBus API */ |
271 | wpa_supplicant_dbus_notify_scanning(wpa_s); | |
27f43d8d | 272 | |
8fc2fb56 | 273 | /* notify the new DBus API */ |
52bdd880 | 274 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); |
8bac466b JM |
275 | } |
276 | ||
277 | ||
278 | void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) | |
279 | { | |
bb3df9a5 TB |
280 | if (wpa_s->p2p_mgmt) |
281 | return; | |
282 | ||
52bdd880 | 283 | wpas_dbus_signal_scan_done(wpa_s, success); |
8bac466b JM |
284 | } |
285 | ||
286 | ||
287 | void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) | |
288 | { | |
bb3df9a5 TB |
289 | if (wpa_s->p2p_mgmt) |
290 | return; | |
291 | ||
8bac466b JM |
292 | /* notify the old DBus API */ |
293 | wpa_supplicant_dbus_notify_scan_results(wpa_s); | |
294 | ||
295 | wpas_wps_notify_scan_results(wpa_s); | |
296 | } | |
297 | ||
298 | ||
299 | void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, | |
300 | const struct wps_credential *cred) | |
301 | { | |
bb3df9a5 TB |
302 | if (wpa_s->p2p_mgmt) |
303 | return; | |
304 | ||
b99b8e15 | 305 | #ifdef CONFIG_WPS |
8bac466b JM |
306 | /* notify the old DBus API */ |
307 | wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); | |
8fc2fb56 | 308 | /* notify the new DBus API */ |
52bdd880 | 309 | wpas_dbus_signal_wps_cred(wpa_s, cred); |
b99b8e15 | 310 | #endif /* CONFIG_WPS */ |
8bac466b JM |
311 | } |
312 | ||
313 | ||
314 | void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, | |
315 | struct wps_event_m2d *m2d) | |
316 | { | |
bb3df9a5 TB |
317 | if (wpa_s->p2p_mgmt) |
318 | return; | |
319 | ||
b99b8e15 | 320 | #ifdef CONFIG_WPS |
52bdd880 | 321 | wpas_dbus_signal_wps_event_m2d(wpa_s, m2d); |
b99b8e15 | 322 | #endif /* CONFIG_WPS */ |
8bac466b JM |
323 | } |
324 | ||
325 | ||
326 | void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, | |
327 | struct wps_event_fail *fail) | |
328 | { | |
bb3df9a5 TB |
329 | if (wpa_s->p2p_mgmt) |
330 | return; | |
331 | ||
b99b8e15 | 332 | #ifdef CONFIG_WPS |
52bdd880 | 333 | wpas_dbus_signal_wps_event_fail(wpa_s, fail); |
b99b8e15 | 334 | #endif /* CONFIG_WPS */ |
8bac466b JM |
335 | } |
336 | ||
337 | ||
338 | void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) | |
339 | { | |
bb3df9a5 TB |
340 | if (wpa_s->p2p_mgmt) |
341 | return; | |
342 | ||
b99b8e15 | 343 | #ifdef CONFIG_WPS |
52bdd880 | 344 | wpas_dbus_signal_wps_event_success(wpa_s); |
b99b8e15 | 345 | #endif /* CONFIG_WPS */ |
8bac466b JM |
346 | } |
347 | ||
1a2f7ca1 AA |
348 | void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s) |
349 | { | |
350 | if (wpa_s->p2p_mgmt) | |
351 | return; | |
352 | ||
353 | #ifdef CONFIG_WPS | |
354 | wpas_dbus_signal_wps_event_pbc_overlap(wpa_s); | |
355 | #endif /* CONFIG_WPS */ | |
356 | } | |
357 | ||
8bac466b JM |
358 | |
359 | void wpas_notify_network_added(struct wpa_supplicant *wpa_s, | |
360 | struct wpa_ssid *ssid) | |
361 | { | |
bb3df9a5 TB |
362 | if (wpa_s->p2p_mgmt) |
363 | return; | |
364 | ||
c2762e41 JS |
365 | /* |
366 | * Networks objects created during any P2P activities should not be | |
367 | * exposed out. They might/will confuse certain non-P2P aware | |
368 | * applications since these network objects won't behave like | |
369 | * regular ones. | |
370 | */ | |
447969e0 | 371 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) |
c2762e41 JS |
372 | wpas_dbus_register_network(wpa_s, ssid); |
373 | } | |
374 | ||
375 | ||
376 | void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s, | |
377 | struct wpa_ssid *ssid) | |
378 | { | |
7a2b53b4 | 379 | #ifdef CONFIG_P2P |
c2762e41 | 380 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
7a2b53b4 | 381 | #endif /* CONFIG_P2P */ |
8bac466b JM |
382 | } |
383 | ||
384 | ||
28550706 JS |
385 | void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s, |
386 | struct wpa_ssid *ssid) | |
387 | { | |
7a2b53b4 | 388 | #ifdef CONFIG_P2P |
28550706 | 389 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); |
7a2b53b4 | 390 | #endif /* CONFIG_P2P */ |
28550706 JS |
391 | } |
392 | ||
393 | ||
8bac466b JM |
394 | void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, |
395 | struct wpa_ssid *ssid) | |
396 | { | |
3d910ef4 JM |
397 | if (wpa_s->next_ssid == ssid) |
398 | wpa_s->next_ssid = NULL; | |
8c0d3b4f JM |
399 | if (wpa_s->wpa) |
400 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); | |
5441da2b JM |
401 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s && |
402 | !wpa_s->p2p_mgmt) | |
c2762e41 | 403 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
5f136bc1 JM |
404 | if (network_is_persistent_group(ssid)) |
405 | wpas_notify_persistent_group_removed(wpa_s, ssid); | |
406 | ||
502618f7 | 407 | wpas_p2p_network_removed(wpa_s, ssid); |
8bac466b JM |
408 | } |
409 | ||
410 | ||
71f6e1f6 | 411 | void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, |
f0d126d3 | 412 | u8 bssid[], unsigned int id) |
71f6e1f6 | 413 | { |
bb3df9a5 TB |
414 | if (wpa_s->p2p_mgmt) |
415 | return; | |
416 | ||
52bdd880 | 417 | wpas_dbus_register_bss(wpa_s, bssid, id); |
f0d126d3 JM |
418 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, |
419 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
420 | } |
421 | ||
422 | ||
423 | void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, | |
f0d126d3 | 424 | u8 bssid[], unsigned int id) |
71f6e1f6 | 425 | { |
bb3df9a5 TB |
426 | if (wpa_s->p2p_mgmt) |
427 | return; | |
428 | ||
52bdd880 | 429 | wpas_dbus_unregister_bss(wpa_s, bssid, id); |
f0d126d3 JM |
430 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, |
431 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
432 | } |
433 | ||
434 | ||
158c6c74 WS |
435 | void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, |
436 | unsigned int id) | |
437 | { | |
bb3df9a5 TB |
438 | if (wpa_s->p2p_mgmt) |
439 | return; | |
440 | ||
158c6c74 WS |
441 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); |
442 | } | |
443 | ||
444 | ||
445 | void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s, | |
446 | unsigned int id) | |
447 | { | |
bb3df9a5 TB |
448 | if (wpa_s->p2p_mgmt) |
449 | return; | |
450 | ||
158c6c74 WS |
451 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL, |
452 | id); | |
453 | } | |
454 | ||
455 | ||
456 | void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s, | |
457 | unsigned int id) | |
458 | { | |
bb3df9a5 TB |
459 | if (wpa_s->p2p_mgmt) |
460 | return; | |
461 | ||
158c6c74 WS |
462 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY, |
463 | id); | |
464 | } | |
465 | ||
466 | ||
467 | void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s, | |
468 | unsigned int id) | |
469 | { | |
bb3df9a5 TB |
470 | if (wpa_s->p2p_mgmt) |
471 | return; | |
472 | ||
158c6c74 WS |
473 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id); |
474 | } | |
475 | ||
476 | ||
477 | void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s, | |
478 | unsigned int id) | |
479 | { | |
bb3df9a5 TB |
480 | if (wpa_s->p2p_mgmt) |
481 | return; | |
482 | ||
7899e2f4 | 483 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id); |
158c6c74 WS |
484 | } |
485 | ||
486 | ||
487 | void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s, | |
488 | unsigned int id) | |
489 | { | |
bb3df9a5 TB |
490 | if (wpa_s->p2p_mgmt) |
491 | return; | |
492 | ||
7899e2f4 | 493 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id); |
158c6c74 WS |
494 | } |
495 | ||
496 | ||
497 | void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s, | |
7899e2f4 WS |
498 | unsigned int id) |
499 | { | |
bb3df9a5 TB |
500 | if (wpa_s->p2p_mgmt) |
501 | return; | |
502 | ||
caff3992 SN |
503 | #ifdef CONFIG_WPS |
504 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id); | |
505 | #endif /* CONFIG_WPS */ | |
7899e2f4 WS |
506 | } |
507 | ||
508 | ||
509 | void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s, | |
158c6c74 WS |
510 | unsigned int id) |
511 | { | |
bb3df9a5 TB |
512 | if (wpa_s->p2p_mgmt) |
513 | return; | |
514 | ||
7899e2f4 | 515 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id); |
158c6c74 WS |
516 | } |
517 | ||
518 | ||
519 | void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s, | |
520 | unsigned int id) | |
521 | { | |
bb3df9a5 TB |
522 | if (wpa_s->p2p_mgmt) |
523 | return; | |
524 | ||
158c6c74 WS |
525 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id); |
526 | } | |
527 | ||
528 | ||
3bd3257a DW |
529 | void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id) |
530 | { | |
bb3df9a5 TB |
531 | if (wpa_s->p2p_mgmt) |
532 | return; | |
533 | ||
3bd3257a DW |
534 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id); |
535 | } | |
536 | ||
537 | ||
8bac466b JM |
538 | void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) |
539 | { | |
bb3df9a5 TB |
540 | if (wpa_s->p2p_mgmt) |
541 | return; | |
542 | ||
52bdd880 | 543 | wpas_dbus_signal_blob_added(wpa_s, name); |
8bac466b JM |
544 | } |
545 | ||
546 | ||
547 | void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) | |
548 | { | |
bb3df9a5 TB |
549 | if (wpa_s->p2p_mgmt) |
550 | return; | |
551 | ||
52bdd880 | 552 | wpas_dbus_signal_blob_removed(wpa_s, name); |
8bac466b JM |
553 | } |
554 | ||
555 | ||
db9133ac | 556 | void wpas_notify_debug_level_changed(struct wpa_global *global) |
8bac466b | 557 | { |
52bdd880 | 558 | wpas_dbus_signal_debug_level_changed(global); |
db9133ac WS |
559 | } |
560 | ||
561 | ||
562 | void wpas_notify_debug_timestamp_changed(struct wpa_global *global) | |
563 | { | |
52bdd880 | 564 | wpas_dbus_signal_debug_timestamp_changed(global); |
db9133ac WS |
565 | } |
566 | ||
567 | ||
568 | void wpas_notify_debug_show_keys_changed(struct wpa_global *global) | |
569 | { | |
52bdd880 | 570 | wpas_dbus_signal_debug_show_keys_changed(global); |
8bac466b | 571 | } |
207ef3fb JM |
572 | |
573 | ||
574 | void wpas_notify_suspend(struct wpa_global *global) | |
575 | { | |
576 | struct wpa_supplicant *wpa_s; | |
577 | ||
578 | os_get_time(&global->suspend_time); | |
579 | wpa_printf(MSG_DEBUG, "System suspend notification"); | |
580 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) | |
581 | wpa_drv_suspend(wpa_s); | |
582 | } | |
583 | ||
584 | ||
585 | void wpas_notify_resume(struct wpa_global *global) | |
586 | { | |
587 | struct os_time now; | |
588 | int slept; | |
589 | struct wpa_supplicant *wpa_s; | |
590 | ||
591 | if (global->suspend_time.sec == 0) | |
592 | slept = -1; | |
593 | else { | |
594 | os_get_time(&now); | |
595 | slept = now.sec - global->suspend_time.sec; | |
596 | } | |
597 | wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)", | |
598 | slept); | |
599 | ||
600 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { | |
601 | wpa_drv_resume(wpa_s); | |
602 | if (wpa_s->wpa_state == WPA_DISCONNECTED) | |
603 | wpa_supplicant_req_scan(wpa_s, 0, 100000); | |
604 | } | |
605 | } | |
d642d2d2 JB |
606 | |
607 | ||
608 | #ifdef CONFIG_P2P | |
56eeb8f2 | 609 | |
7b642dc8 NC |
610 | void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s) |
611 | { | |
612 | /* Notify P2P find has stopped */ | |
613 | wpas_dbus_signal_p2p_find_stopped(wpa_s); | |
614 | } | |
615 | ||
616 | ||
d642d2d2 JB |
617 | void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, |
618 | const u8 *dev_addr, int new_device) | |
619 | { | |
9abafccc JB |
620 | if (new_device) { |
621 | /* Create the new peer object */ | |
622 | wpas_dbus_register_peer(wpa_s, dev_addr); | |
623 | } | |
624 | ||
625 | /* Notify a new peer has been detected*/ | |
626 | wpas_dbus_signal_peer_device_found(wpa_s, dev_addr); | |
d642d2d2 | 627 | } |
56eeb8f2 JB |
628 | |
629 | ||
630 | void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, | |
631 | const u8 *dev_addr) | |
632 | { | |
9abafccc JB |
633 | wpas_dbus_unregister_peer(wpa_s, dev_addr); |
634 | ||
635 | /* Create signal on interface object*/ | |
636 | wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr); | |
56eeb8f2 JB |
637 | } |
638 | ||
408af93e JB |
639 | |
640 | void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s, | |
641 | const struct wpa_ssid *ssid, | |
642 | const char *role) | |
643 | { | |
9abafccc | 644 | wpas_dbus_signal_p2p_group_removed(wpa_s, role); |
4a0693a4 TB |
645 | |
646 | wpas_dbus_unregister_p2p_group(wpa_s, ssid); | |
408af93e JB |
647 | } |
648 | ||
32d1bce0 KRK |
649 | |
650 | void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s, | |
aa2b1256 | 651 | const u8 *src, u16 dev_passwd_id, u8 go_intent) |
32d1bce0 | 652 | { |
aa2b1256 | 653 | wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent); |
32d1bce0 KRK |
654 | } |
655 | ||
c2641bf7 | 656 | |
e5a359cf RC |
657 | void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, |
658 | struct p2p_go_neg_results *res) | |
c2641bf7 | 659 | { |
e5a359cf | 660 | wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res); |
c2641bf7 JS |
661 | } |
662 | ||
5ccdf84f JMB |
663 | |
664 | void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s, | |
665 | int status, const u8 *bssid) | |
666 | { | |
9abafccc | 667 | wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid); |
5ccdf84f JMB |
668 | } |
669 | ||
e1653cac KRK |
670 | |
671 | void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s, | |
672 | int freq, const u8 *sa, u8 dialog_token, | |
673 | u16 update_indic, const u8 *tlvs, | |
674 | size_t tlvs_len) | |
675 | { | |
9abafccc JB |
676 | wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token, |
677 | update_indic, tlvs, tlvs_len); | |
e1653cac KRK |
678 | } |
679 | ||
43a26f60 KRK |
680 | |
681 | void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s, | |
682 | const u8 *sa, u16 update_indic, | |
683 | const u8 *tlvs, size_t tlvs_len) | |
684 | { | |
9abafccc JB |
685 | wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic, |
686 | tlvs, tlvs_len); | |
43a26f60 KRK |
687 | } |
688 | ||
dd8a7e05 JB |
689 | |
690 | /** | |
691 | * wpas_notify_p2p_provision_discovery - Notification of provision discovery | |
692 | * @dev_addr: Who sent the request or responded to our request. | |
693 | * @request: Will be 1 if request, 0 for response. | |
694 | * @status: Valid only in case of response (0 in case of success) | |
695 | * @config_methods: WPS config methods | |
696 | * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method | |
697 | * | |
698 | * This can be used to notify: | |
699 | * - Requests or responses | |
700 | * - Various config methods | |
701 | * - Failure condition in case of response | |
702 | */ | |
703 | void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s, | |
704 | const u8 *dev_addr, int request, | |
705 | enum p2p_prov_disc_status status, | |
706 | u16 config_methods, | |
707 | unsigned int generated_pin) | |
708 | { | |
9abafccc JB |
709 | wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request, |
710 | status, config_methods, | |
711 | generated_pin); | |
dd8a7e05 | 712 | } |
4b6baa2f JMB |
713 | |
714 | ||
715 | void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, | |
4fe50bbc | 716 | struct wpa_ssid *ssid, int persistent, |
18f16117 | 717 | int client, const u8 *ip) |
4b6baa2f | 718 | { |
9abafccc JB |
719 | /* Notify a group has been started */ |
720 | wpas_dbus_register_p2p_group(wpa_s, ssid); | |
721 | ||
18f16117 | 722 | wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip); |
4b6baa2f | 723 | } |
3734552f JS |
724 | |
725 | ||
2a95fac9 NC |
726 | void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, |
727 | const char *reason) | |
728 | { | |
729 | /* Notify a group formation failed */ | |
730 | wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason); | |
731 | } | |
732 | ||
733 | ||
3734552f JS |
734 | void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s, |
735 | struct wps_event_fail *fail) | |
736 | { | |
737 | wpas_dbus_signal_p2p_wps_failed(wpa_s, fail); | |
738 | } | |
739 | ||
be5ab8d4 MJ |
740 | |
741 | void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s, | |
742 | const u8 *sa, const u8 *go_dev_addr, | |
743 | const u8 *bssid, int id, int op_freq) | |
744 | { | |
745 | /* Notify a P2P Invitation Request */ | |
746 | wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid, | |
747 | id, op_freq); | |
748 | } | |
749 | ||
d642d2d2 | 750 | #endif /* CONFIG_P2P */ |
d8a43924 JB |
751 | |
752 | ||
753 | static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, | |
fbdcfd57 JM |
754 | const u8 *sta, |
755 | const u8 *p2p_dev_addr) | |
d8a43924 | 756 | { |
692cb226 | 757 | #ifdef CONFIG_P2P |
fbdcfd57 JM |
758 | wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr); |
759 | ||
9abafccc JB |
760 | /* |
761 | * Create 'peer-joined' signal on group object -- will also | |
762 | * check P2P itself. | |
763 | */ | |
11973b26 JM |
764 | if (p2p_dev_addr) |
765 | wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr); | |
692cb226 | 766 | #endif /* CONFIG_P2P */ |
8a901d75 | 767 | |
c3f23ad6 AS |
768 | /* Register the station */ |
769 | wpas_dbus_register_sta(wpa_s, sta); | |
770 | ||
8a901d75 CZ |
771 | /* Notify listeners a new station has been authorized */ |
772 | wpas_dbus_signal_sta_authorized(wpa_s, sta); | |
d8a43924 JB |
773 | } |
774 | ||
775 | ||
776 | static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, | |
bf035663 TB |
777 | const u8 *sta, |
778 | const u8 *p2p_dev_addr) | |
d8a43924 | 779 | { |
692cb226 | 780 | #ifdef CONFIG_P2P |
9abafccc JB |
781 | /* |
782 | * Create 'peer-disconnected' signal on group object if this | |
783 | * is a P2P group. | |
784 | */ | |
11973b26 JM |
785 | if (p2p_dev_addr) |
786 | wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr); | |
692cb226 | 787 | #endif /* CONFIG_P2P */ |
8a901d75 CZ |
788 | |
789 | /* Notify listeners a station has been deauthorized */ | |
790 | wpas_dbus_signal_sta_deauthorized(wpa_s, sta); | |
c3f23ad6 AS |
791 | |
792 | /* Unregister the station */ | |
793 | wpas_dbus_unregister_sta(wpa_s, sta); | |
d8a43924 JB |
794 | } |
795 | ||
796 | ||
797 | void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s, | |
fbdcfd57 JM |
798 | const u8 *mac_addr, int authorized, |
799 | const u8 *p2p_dev_addr) | |
d8a43924 JB |
800 | { |
801 | if (authorized) | |
fbdcfd57 | 802 | wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr); |
d8a43924 | 803 | else |
bf035663 | 804 | wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr); |
d8a43924 | 805 | } |
ade74830 MC |
806 | |
807 | ||
808 | void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth, | |
d07d3fbd JM |
809 | const char *subject, const char *altsubject[], |
810 | int num_altsubject, const char *cert_hash, | |
ade74830 MC |
811 | const struct wpabuf *cert) |
812 | { | |
4f525d8e JM |
813 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT |
814 | "depth=%d subject='%s'%s%s", | |
d07d3fbd | 815 | depth, subject, cert_hash ? " hash=" : "", |
4f525d8e JM |
816 | cert_hash ? cert_hash : ""); |
817 | ||
818 | if (cert) { | |
819 | char *cert_hex; | |
820 | size_t len = wpabuf_len(cert) * 2 + 1; | |
821 | cert_hex = os_malloc(len); | |
822 | if (cert_hex) { | |
823 | wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert), | |
824 | wpabuf_len(cert)); | |
825 | wpa_msg_ctrl(wpa_s, MSG_INFO, | |
826 | WPA_EVENT_EAP_PEER_CERT | |
827 | "depth=%d subject='%s' cert=%s", | |
828 | depth, subject, cert_hex); | |
829 | os_free(cert_hex); | |
830 | } | |
831 | } | |
832 | ||
d07d3fbd JM |
833 | if (altsubject) { |
834 | int i; | |
835 | ||
836 | for (i = 0; i < num_altsubject; i++) | |
837 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT | |
838 | "depth=%d %s", depth, altsubject[i]); | |
839 | } | |
840 | ||
ade74830 MC |
841 | /* notify the old DBus API */ |
842 | wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject, | |
843 | cert_hash, cert); | |
844 | /* notify the new DBus API */ | |
d07d3fbd JM |
845 | wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject, |
846 | num_altsubject, cert_hash, cert); | |
ade74830 | 847 | } |
2d43d37f JB |
848 | |
849 | ||
850 | void wpas_notify_preq(struct wpa_supplicant *wpa_s, | |
851 | const u8 *addr, const u8 *dst, const u8 *bssid, | |
852 | const u8 *ie, size_t ie_len, u32 ssi_signal) | |
853 | { | |
854 | #ifdef CONFIG_AP | |
855 | wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal); | |
856 | #endif /* CONFIG_AP */ | |
857 | } | |
dd7fec1f PS |
858 | |
859 | ||
860 | void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status, | |
861 | const char *parameter) | |
862 | { | |
863 | wpas_dbus_signal_eap_status(wpa_s, status, parameter); | |
c7a39ba4 CH |
864 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS |
865 | "status='%s' parameter='%s'", | |
866 | status, parameter); | |
dd7fec1f | 867 | } |
0ef023e4 JM |
868 | |
869 | ||
45f7574d AE |
870 | void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code) |
871 | { | |
872 | wpa_msg(wpa_s, MSG_ERROR, WPA_EVENT_EAP_ERROR_CODE "%d", error_code); | |
873 | } | |
874 | ||
875 | ||
0ef023e4 JM |
876 | void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s, |
877 | struct wpa_ssid *ssid) | |
878 | { | |
879 | if (wpa_s->current_ssid != ssid) | |
880 | return; | |
881 | ||
882 | wpa_dbg(wpa_s, MSG_DEBUG, | |
883 | "Network bssid config changed for the current network - within-ESS roaming %s", | |
884 | ssid->bssid_set ? "disabled" : "enabled"); | |
885 | ||
886 | wpa_drv_roaming(wpa_s, !ssid->bssid_set, | |
887 | ssid->bssid_set ? ssid->bssid : NULL); | |
888 | } | |
1e529832 JM |
889 | |
890 | ||
891 | void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s, | |
892 | struct wpa_ssid *ssid) | |
893 | { | |
894 | #ifdef CONFIG_P2P | |
895 | if (ssid->disabled == 2) { | |
896 | /* Changed from normal network profile to persistent group */ | |
897 | ssid->disabled = 0; | |
898 | wpas_dbus_unregister_network(wpa_s, ssid->id); | |
899 | ssid->disabled = 2; | |
661888be | 900 | ssid->p2p_persistent_group = 1; |
1e529832 JM |
901 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
902 | } else { | |
903 | /* Changed from persistent group to normal network profile */ | |
904 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); | |
661888be | 905 | ssid->p2p_persistent_group = 0; |
1e529832 JM |
906 | wpas_dbus_register_network(wpa_s, ssid); |
907 | } | |
908 | #endif /* CONFIG_P2P */ | |
909 | } | |
89e9cd25 SB |
910 | |
911 | ||
912 | #ifdef CONFIG_MESH | |
a39b040b | 913 | |
89e9cd25 SB |
914 | void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s, |
915 | struct wpa_ssid *ssid) | |
916 | { | |
917 | if (wpa_s->p2p_mgmt) | |
918 | return; | |
919 | ||
920 | wpas_dbus_signal_mesh_group_started(wpa_s, ssid); | |
921 | } | |
a39b040b SB |
922 | |
923 | ||
924 | void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s, | |
925 | const u8 *meshid, u8 meshid_len, | |
926 | int reason_code) | |
927 | { | |
928 | if (wpa_s->p2p_mgmt) | |
929 | return; | |
930 | ||
931 | wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len, | |
932 | reason_code); | |
933 | } | |
934 | ||
9b0701fb SB |
935 | |
936 | void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s, | |
937 | const u8 *peer_addr) | |
938 | { | |
939 | if (wpa_s->p2p_mgmt) | |
940 | return; | |
941 | ||
942 | wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr); | |
943 | } | |
944 | ||
a9de99b1 SB |
945 | |
946 | void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s, | |
947 | const u8 *peer_addr, int reason_code) | |
948 | { | |
949 | if (wpa_s->p2p_mgmt) | |
950 | return; | |
951 | ||
952 | wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code); | |
953 | } | |
954 | ||
89e9cd25 | 955 | #endif /* CONFIG_MESH */ |