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