]>
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 | { | |
51 | if (wpas_dbus_register_iface(wpa_s)) | |
52 | return -1; | |
53 | ||
52bdd880 | 54 | if (wpas_dbus_register_interface(wpa_s)) |
8fc2fb56 WS |
55 | return -1; |
56 | ||
dc461de4 WS |
57 | return 0; |
58 | } | |
59 | ||
60 | ||
dc461de4 WS |
61 | void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s) |
62 | { | |
63 | /* unregister interface in old DBus ctrl iface */ | |
64 | wpas_dbus_unregister_iface(wpa_s); | |
8fc2fb56 WS |
65 | |
66 | /* unregister interface in new DBus ctrl iface */ | |
52bdd880 | 67 | wpas_dbus_unregister_interface(wpa_s); |
dc461de4 WS |
68 | } |
69 | ||
8bac466b JM |
70 | |
71 | void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, | |
71934751 JM |
72 | enum wpa_states new_state, |
73 | enum wpa_states old_state) | |
8bac466b JM |
74 | { |
75 | /* notify the old DBus API */ | |
76 | wpa_supplicant_dbus_notify_state_change(wpa_s, new_state, | |
77 | old_state); | |
8fc2fb56 WS |
78 | |
79 | /* notify the new DBus API */ | |
27f43d8d | 80 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE); |
72044390 JM |
81 | |
82 | #ifdef CONFIG_P2P | |
83 | if (new_state == WPA_COMPLETED) | |
84 | wpas_p2p_notif_connected(wpa_s); | |
dbe7aa22 | 85 | else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED) |
72044390 JM |
86 | wpas_p2p_notif_disconnected(wpa_s); |
87 | #endif /* CONFIG_P2P */ | |
e29853bb BG |
88 | |
89 | sme_state_changed(wpa_s); | |
4e2ead7a DS |
90 | |
91 | #ifdef ANDROID | |
92 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE | |
93 | "id=%d state=%d BSSID=" MACSTR, | |
94 | wpa_s->current_ssid ? wpa_s->current_ssid->id : -1, | |
95 | new_state, MAC2STR(wpa_s->pending_bssid)); | |
96 | #endif /* ANDROID */ | |
8bac466b JM |
97 | } |
98 | ||
99 | ||
0bb1e425 GM |
100 | void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s) |
101 | { | |
102 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON); | |
103 | } | |
104 | ||
105 | ||
8bac466b JM |
106 | void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) |
107 | { | |
52bdd880 | 108 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); |
8bac466b JM |
109 | } |
110 | ||
111 | ||
112 | void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) | |
113 | { | |
52bdd880 | 114 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); |
8bac466b JM |
115 | } |
116 | ||
117 | ||
118 | void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) | |
119 | { | |
52bdd880 | 120 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); |
8bac466b JM |
121 | } |
122 | ||
123 | ||
5bbf9f10 PS |
124 | void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s) |
125 | { | |
126 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE); | |
127 | } | |
128 | ||
129 | ||
8bac466b JM |
130 | void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, |
131 | struct wpa_ssid *ssid) | |
132 | { | |
52bdd880 | 133 | wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); |
8bac466b JM |
134 | } |
135 | ||
136 | ||
137 | void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, | |
138 | struct wpa_ssid *ssid) | |
139 | { | |
52bdd880 | 140 | wpas_dbus_signal_network_selected(wpa_s, ssid->id); |
8bac466b JM |
141 | } |
142 | ||
143 | ||
a9022616 DW |
144 | void wpas_notify_network_request(struct wpa_supplicant *wpa_s, |
145 | struct wpa_ssid *ssid, | |
146 | enum wpa_ctrl_req_type rtype, | |
147 | const char *default_txt) | |
148 | { | |
149 | wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt); | |
150 | } | |
151 | ||
152 | ||
8bac466b JM |
153 | void wpas_notify_scanning(struct wpa_supplicant *wpa_s) |
154 | { | |
155 | /* notify the old DBus API */ | |
156 | wpa_supplicant_dbus_notify_scanning(wpa_s); | |
27f43d8d | 157 | |
8fc2fb56 | 158 | /* notify the new DBus API */ |
52bdd880 | 159 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); |
8bac466b JM |
160 | } |
161 | ||
162 | ||
163 | void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) | |
164 | { | |
52bdd880 | 165 | wpas_dbus_signal_scan_done(wpa_s, success); |
8bac466b JM |
166 | } |
167 | ||
168 | ||
169 | void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) | |
170 | { | |
171 | /* notify the old DBus API */ | |
172 | wpa_supplicant_dbus_notify_scan_results(wpa_s); | |
173 | ||
174 | wpas_wps_notify_scan_results(wpa_s); | |
175 | } | |
176 | ||
177 | ||
178 | void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, | |
179 | const struct wps_credential *cred) | |
180 | { | |
b99b8e15 | 181 | #ifdef CONFIG_WPS |
8bac466b JM |
182 | /* notify the old DBus API */ |
183 | wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); | |
8fc2fb56 | 184 | /* notify the new DBus API */ |
52bdd880 | 185 | wpas_dbus_signal_wps_cred(wpa_s, cred); |
b99b8e15 | 186 | #endif /* CONFIG_WPS */ |
8bac466b JM |
187 | } |
188 | ||
189 | ||
190 | void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, | |
191 | struct wps_event_m2d *m2d) | |
192 | { | |
b99b8e15 | 193 | #ifdef CONFIG_WPS |
52bdd880 | 194 | wpas_dbus_signal_wps_event_m2d(wpa_s, m2d); |
b99b8e15 | 195 | #endif /* CONFIG_WPS */ |
8bac466b JM |
196 | } |
197 | ||
198 | ||
199 | void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, | |
200 | struct wps_event_fail *fail) | |
201 | { | |
b99b8e15 | 202 | #ifdef CONFIG_WPS |
52bdd880 | 203 | wpas_dbus_signal_wps_event_fail(wpa_s, fail); |
b99b8e15 | 204 | #endif /* CONFIG_WPS */ |
8bac466b JM |
205 | } |
206 | ||
207 | ||
208 | void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) | |
209 | { | |
b99b8e15 | 210 | #ifdef CONFIG_WPS |
52bdd880 | 211 | wpas_dbus_signal_wps_event_success(wpa_s); |
b99b8e15 | 212 | #endif /* CONFIG_WPS */ |
8bac466b JM |
213 | } |
214 | ||
215 | ||
216 | void wpas_notify_network_added(struct wpa_supplicant *wpa_s, | |
217 | struct wpa_ssid *ssid) | |
218 | { | |
c2762e41 JS |
219 | /* |
220 | * Networks objects created during any P2P activities should not be | |
221 | * exposed out. They might/will confuse certain non-P2P aware | |
222 | * applications since these network objects won't behave like | |
223 | * regular ones. | |
224 | */ | |
225 | if (wpa_s->global->p2p_group_formation != wpa_s) | |
226 | wpas_dbus_register_network(wpa_s, ssid); | |
227 | } | |
228 | ||
229 | ||
230 | void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s, | |
231 | struct wpa_ssid *ssid) | |
232 | { | |
7a2b53b4 | 233 | #ifdef CONFIG_P2P |
c2762e41 | 234 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
7a2b53b4 | 235 | #endif /* CONFIG_P2P */ |
8bac466b JM |
236 | } |
237 | ||
238 | ||
28550706 JS |
239 | void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s, |
240 | struct wpa_ssid *ssid) | |
241 | { | |
7a2b53b4 | 242 | #ifdef CONFIG_P2P |
28550706 | 243 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); |
7a2b53b4 | 244 | #endif /* CONFIG_P2P */ |
28550706 JS |
245 | } |
246 | ||
247 | ||
8bac466b JM |
248 | void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, |
249 | struct wpa_ssid *ssid) | |
250 | { | |
8c0d3b4f JM |
251 | if (wpa_s->wpa) |
252 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); | |
c2762e41 JS |
253 | if (wpa_s->global->p2p_group_formation != wpa_s) |
254 | wpas_dbus_unregister_network(wpa_s, ssid->id); | |
502618f7 JM |
255 | #ifdef CONFIG_P2P |
256 | wpas_p2p_network_removed(wpa_s, ssid); | |
257 | #endif /* CONFIG_P2P */ | |
8bac466b JM |
258 | } |
259 | ||
260 | ||
71f6e1f6 | 261 | void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, |
f0d126d3 | 262 | u8 bssid[], unsigned int id) |
71f6e1f6 | 263 | { |
52bdd880 | 264 | wpas_dbus_register_bss(wpa_s, bssid, id); |
f0d126d3 JM |
265 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, |
266 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
267 | } |
268 | ||
269 | ||
270 | void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, | |
f0d126d3 | 271 | u8 bssid[], unsigned int id) |
71f6e1f6 | 272 | { |
52bdd880 | 273 | wpas_dbus_unregister_bss(wpa_s, bssid, id); |
f0d126d3 JM |
274 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, |
275 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
276 | } |
277 | ||
278 | ||
158c6c74 WS |
279 | void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, |
280 | unsigned int id) | |
281 | { | |
282 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); | |
283 | } | |
284 | ||
285 | ||
286 | void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s, | |
287 | unsigned int id) | |
288 | { | |
289 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL, | |
290 | id); | |
291 | } | |
292 | ||
293 | ||
294 | void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s, | |
295 | unsigned int id) | |
296 | { | |
297 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY, | |
298 | id); | |
299 | } | |
300 | ||
301 | ||
302 | void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s, | |
303 | unsigned int id) | |
304 | { | |
305 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id); | |
306 | } | |
307 | ||
308 | ||
309 | void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s, | |
310 | unsigned int id) | |
311 | { | |
7899e2f4 | 312 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id); |
158c6c74 WS |
313 | } |
314 | ||
315 | ||
316 | void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s, | |
317 | unsigned int id) | |
318 | { | |
7899e2f4 | 319 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id); |
158c6c74 WS |
320 | } |
321 | ||
322 | ||
323 | void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s, | |
7899e2f4 WS |
324 | unsigned int id) |
325 | { | |
caff3992 SN |
326 | #ifdef CONFIG_WPS |
327 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id); | |
328 | #endif /* CONFIG_WPS */ | |
7899e2f4 WS |
329 | } |
330 | ||
331 | ||
332 | void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s, | |
158c6c74 WS |
333 | unsigned int id) |
334 | { | |
7899e2f4 | 335 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id); |
158c6c74 WS |
336 | } |
337 | ||
338 | ||
339 | void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s, | |
340 | unsigned int id) | |
341 | { | |
342 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id); | |
343 | } | |
344 | ||
345 | ||
8bac466b JM |
346 | void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) |
347 | { | |
52bdd880 | 348 | wpas_dbus_signal_blob_added(wpa_s, name); |
8bac466b JM |
349 | } |
350 | ||
351 | ||
352 | void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) | |
353 | { | |
52bdd880 | 354 | wpas_dbus_signal_blob_removed(wpa_s, name); |
8bac466b JM |
355 | } |
356 | ||
357 | ||
db9133ac | 358 | void wpas_notify_debug_level_changed(struct wpa_global *global) |
8bac466b | 359 | { |
52bdd880 | 360 | wpas_dbus_signal_debug_level_changed(global); |
db9133ac WS |
361 | } |
362 | ||
363 | ||
364 | void wpas_notify_debug_timestamp_changed(struct wpa_global *global) | |
365 | { | |
52bdd880 | 366 | wpas_dbus_signal_debug_timestamp_changed(global); |
db9133ac WS |
367 | } |
368 | ||
369 | ||
370 | void wpas_notify_debug_show_keys_changed(struct wpa_global *global) | |
371 | { | |
52bdd880 | 372 | wpas_dbus_signal_debug_show_keys_changed(global); |
8bac466b | 373 | } |
207ef3fb JM |
374 | |
375 | ||
376 | void wpas_notify_suspend(struct wpa_global *global) | |
377 | { | |
378 | struct wpa_supplicant *wpa_s; | |
379 | ||
380 | os_get_time(&global->suspend_time); | |
381 | wpa_printf(MSG_DEBUG, "System suspend notification"); | |
382 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) | |
383 | wpa_drv_suspend(wpa_s); | |
384 | } | |
385 | ||
386 | ||
387 | void wpas_notify_resume(struct wpa_global *global) | |
388 | { | |
389 | struct os_time now; | |
390 | int slept; | |
391 | struct wpa_supplicant *wpa_s; | |
392 | ||
393 | if (global->suspend_time.sec == 0) | |
394 | slept = -1; | |
395 | else { | |
396 | os_get_time(&now); | |
397 | slept = now.sec - global->suspend_time.sec; | |
398 | } | |
399 | wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)", | |
400 | slept); | |
401 | ||
402 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { | |
403 | wpa_drv_resume(wpa_s); | |
404 | if (wpa_s->wpa_state == WPA_DISCONNECTED) | |
405 | wpa_supplicant_req_scan(wpa_s, 0, 100000); | |
406 | } | |
407 | } | |
d642d2d2 JB |
408 | |
409 | ||
410 | #ifdef CONFIG_P2P | |
56eeb8f2 | 411 | |
d642d2d2 JB |
412 | void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, |
413 | const u8 *dev_addr, int new_device) | |
414 | { | |
9abafccc JB |
415 | if (new_device) { |
416 | /* Create the new peer object */ | |
417 | wpas_dbus_register_peer(wpa_s, dev_addr); | |
418 | } | |
419 | ||
420 | /* Notify a new peer has been detected*/ | |
421 | wpas_dbus_signal_peer_device_found(wpa_s, dev_addr); | |
d642d2d2 | 422 | } |
56eeb8f2 JB |
423 | |
424 | ||
425 | void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, | |
426 | const u8 *dev_addr) | |
427 | { | |
9abafccc JB |
428 | wpas_dbus_unregister_peer(wpa_s, dev_addr); |
429 | ||
430 | /* Create signal on interface object*/ | |
431 | wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr); | |
56eeb8f2 JB |
432 | } |
433 | ||
408af93e JB |
434 | |
435 | void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s, | |
436 | const struct wpa_ssid *ssid, | |
437 | const char *role) | |
438 | { | |
9abafccc JB |
439 | wpas_dbus_unregister_p2p_group(wpa_s, ssid); |
440 | ||
441 | wpas_dbus_signal_p2p_group_removed(wpa_s, role); | |
408af93e JB |
442 | } |
443 | ||
32d1bce0 KRK |
444 | |
445 | void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s, | |
446 | const u8 *src, u16 dev_passwd_id) | |
447 | { | |
9abafccc | 448 | wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id); |
32d1bce0 KRK |
449 | } |
450 | ||
c2641bf7 | 451 | |
e5a359cf RC |
452 | void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, |
453 | struct p2p_go_neg_results *res) | |
c2641bf7 | 454 | { |
e5a359cf | 455 | wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res); |
c2641bf7 JS |
456 | } |
457 | ||
5ccdf84f JMB |
458 | |
459 | void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s, | |
460 | int status, const u8 *bssid) | |
461 | { | |
9abafccc | 462 | wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid); |
5ccdf84f JMB |
463 | } |
464 | ||
e1653cac KRK |
465 | |
466 | void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s, | |
467 | int freq, const u8 *sa, u8 dialog_token, | |
468 | u16 update_indic, const u8 *tlvs, | |
469 | size_t tlvs_len) | |
470 | { | |
9abafccc JB |
471 | wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token, |
472 | update_indic, tlvs, tlvs_len); | |
e1653cac KRK |
473 | } |
474 | ||
43a26f60 KRK |
475 | |
476 | void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s, | |
477 | const u8 *sa, u16 update_indic, | |
478 | const u8 *tlvs, size_t tlvs_len) | |
479 | { | |
9abafccc JB |
480 | wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic, |
481 | tlvs, tlvs_len); | |
43a26f60 KRK |
482 | } |
483 | ||
dd8a7e05 JB |
484 | |
485 | /** | |
486 | * wpas_notify_p2p_provision_discovery - Notification of provision discovery | |
487 | * @dev_addr: Who sent the request or responded to our request. | |
488 | * @request: Will be 1 if request, 0 for response. | |
489 | * @status: Valid only in case of response (0 in case of success) | |
490 | * @config_methods: WPS config methods | |
491 | * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method | |
492 | * | |
493 | * This can be used to notify: | |
494 | * - Requests or responses | |
495 | * - Various config methods | |
496 | * - Failure condition in case of response | |
497 | */ | |
498 | void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s, | |
499 | const u8 *dev_addr, int request, | |
500 | enum p2p_prov_disc_status status, | |
501 | u16 config_methods, | |
502 | unsigned int generated_pin) | |
503 | { | |
9abafccc JB |
504 | wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request, |
505 | status, config_methods, | |
506 | generated_pin); | |
dd8a7e05 | 507 | } |
4b6baa2f JMB |
508 | |
509 | ||
510 | void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, | |
511 | struct wpa_ssid *ssid, int network_id, | |
512 | int client) | |
513 | { | |
9abafccc JB |
514 | /* Notify a group has been started */ |
515 | wpas_dbus_register_p2p_group(wpa_s, ssid); | |
516 | ||
517 | wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id); | |
4b6baa2f | 518 | } |
3734552f JS |
519 | |
520 | ||
521 | void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s, | |
522 | struct wps_event_fail *fail) | |
523 | { | |
524 | wpas_dbus_signal_p2p_wps_failed(wpa_s, fail); | |
525 | } | |
526 | ||
d642d2d2 | 527 | #endif /* CONFIG_P2P */ |
d8a43924 JB |
528 | |
529 | ||
530 | static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, | |
fbdcfd57 JM |
531 | const u8 *sta, |
532 | const u8 *p2p_dev_addr) | |
d8a43924 | 533 | { |
692cb226 | 534 | #ifdef CONFIG_P2P |
fbdcfd57 JM |
535 | wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr); |
536 | ||
9abafccc JB |
537 | /* |
538 | * Register a group member object corresponding to this peer and | |
539 | * emit a PeerJoined signal. This will check if it really is a | |
540 | * P2P group. | |
541 | */ | |
542 | wpas_dbus_register_p2p_groupmember(wpa_s, sta); | |
543 | ||
544 | /* | |
545 | * Create 'peer-joined' signal on group object -- will also | |
546 | * check P2P itself. | |
547 | */ | |
548 | wpas_dbus_signal_p2p_peer_joined(wpa_s, sta); | |
692cb226 | 549 | #endif /* CONFIG_P2P */ |
d8a43924 JB |
550 | } |
551 | ||
552 | ||
553 | static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, | |
554 | const u8 *sta) | |
555 | { | |
692cb226 | 556 | #ifdef CONFIG_P2P |
9abafccc JB |
557 | /* |
558 | * Unregister a group member object corresponding to this peer | |
559 | * if this is a P2P group. | |
560 | */ | |
561 | wpas_dbus_unregister_p2p_groupmember(wpa_s, sta); | |
562 | ||
563 | /* | |
564 | * Create 'peer-disconnected' signal on group object if this | |
565 | * is a P2P group. | |
566 | */ | |
567 | wpas_dbus_signal_p2p_peer_disconnected(wpa_s, sta); | |
692cb226 | 568 | #endif /* CONFIG_P2P */ |
d8a43924 JB |
569 | } |
570 | ||
571 | ||
572 | void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s, | |
fbdcfd57 JM |
573 | const u8 *mac_addr, int authorized, |
574 | const u8 *p2p_dev_addr) | |
d8a43924 JB |
575 | { |
576 | if (authorized) | |
fbdcfd57 | 577 | wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr); |
d8a43924 JB |
578 | else |
579 | wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr); | |
580 | } | |
ade74830 MC |
581 | |
582 | ||
583 | void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth, | |
584 | const char *subject, const char *cert_hash, | |
585 | const struct wpabuf *cert) | |
586 | { | |
4f525d8e JM |
587 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT |
588 | "depth=%d subject='%s'%s%s", | |
589 | depth, subject, | |
590 | cert_hash ? " hash=" : "", | |
591 | cert_hash ? cert_hash : ""); | |
592 | ||
593 | if (cert) { | |
594 | char *cert_hex; | |
595 | size_t len = wpabuf_len(cert) * 2 + 1; | |
596 | cert_hex = os_malloc(len); | |
597 | if (cert_hex) { | |
598 | wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert), | |
599 | wpabuf_len(cert)); | |
600 | wpa_msg_ctrl(wpa_s, MSG_INFO, | |
601 | WPA_EVENT_EAP_PEER_CERT | |
602 | "depth=%d subject='%s' cert=%s", | |
603 | depth, subject, cert_hex); | |
604 | os_free(cert_hex); | |
605 | } | |
606 | } | |
607 | ||
ade74830 MC |
608 | /* notify the old DBus API */ |
609 | wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject, | |
610 | cert_hash, cert); | |
611 | /* notify the new DBus API */ | |
612 | wpas_dbus_signal_certification(wpa_s, depth, subject, cert_hash, cert); | |
613 | } | |
2d43d37f JB |
614 | |
615 | ||
616 | void wpas_notify_preq(struct wpa_supplicant *wpa_s, | |
617 | const u8 *addr, const u8 *dst, const u8 *bssid, | |
618 | const u8 *ie, size_t ie_len, u32 ssi_signal) | |
619 | { | |
620 | #ifdef CONFIG_AP | |
621 | wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal); | |
622 | #endif /* CONFIG_AP */ | |
623 | } | |
dd7fec1f PS |
624 | |
625 | ||
626 | void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status, | |
627 | const char *parameter) | |
628 | { | |
629 | wpas_dbus_signal_eap_status(wpa_s, status, parameter); | |
630 | } |