]>
Commit | Line | Data |
---|---|---|
8bac466b JM |
1 | /* |
2 | * wpa_supplicant - Event notifications | |
207ef3fb | 3 | * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi> |
8bac466b JM |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * Alternatively, this software may be distributed under the terms of BSD | |
10 | * license. | |
11 | * | |
12 | * See README and COPYING for more details. | |
13 | */ | |
14 | ||
f0d126d3 | 15 | #include "utils/includes.h" |
8bac466b | 16 | |
f0d126d3 JM |
17 | #include "utils/common.h" |
18 | #include "common/wpa_ctrl.h" | |
8bac466b JM |
19 | #include "config.h" |
20 | #include "wpa_supplicant_i.h" | |
21 | #include "wps_supplicant.h" | |
8ddef94b | 22 | #include "dbus/dbus_common.h" |
bacfd05f | 23 | #include "dbus/dbus_old.h" |
6d59e14c | 24 | #include "dbus/dbus_new.h" |
207ef3fb JM |
25 | #include "driver_i.h" |
26 | #include "scan.h" | |
72044390 | 27 | #include "p2p_supplicant.h" |
e29853bb | 28 | #include "sme.h" |
8bac466b JM |
29 | #include "notify.h" |
30 | ||
dc461de4 WS |
31 | int wpas_notify_supplicant_initialized(struct wpa_global *global) |
32 | { | |
8ddef94b | 33 | #ifdef CONFIG_DBUS |
dc461de4 | 34 | if (global->params.dbus_ctrl_interface) { |
8ddef94b JM |
35 | global->dbus = wpas_dbus_init(global); |
36 | if (global->dbus == NULL) | |
85d3f273 | 37 | return -1; |
dc461de4 | 38 | } |
8ddef94b | 39 | #endif /* CONFIG_DBUS */ |
dc461de4 WS |
40 | |
41 | return 0; | |
42 | } | |
43 | ||
44 | ||
45 | void wpas_notify_supplicant_deinitialized(struct wpa_global *global) | |
46 | { | |
8ddef94b JM |
47 | #ifdef CONFIG_DBUS |
48 | if (global->dbus) | |
49 | wpas_dbus_deinit(global->dbus); | |
50 | #endif /* CONFIG_DBUS */ | |
dc461de4 WS |
51 | } |
52 | ||
53 | ||
54 | int wpas_notify_iface_added(struct wpa_supplicant *wpa_s) | |
55 | { | |
56 | if (wpas_dbus_register_iface(wpa_s)) | |
57 | return -1; | |
58 | ||
52bdd880 | 59 | if (wpas_dbus_register_interface(wpa_s)) |
8fc2fb56 WS |
60 | return -1; |
61 | ||
dc461de4 WS |
62 | return 0; |
63 | } | |
64 | ||
65 | ||
dc461de4 WS |
66 | void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s) |
67 | { | |
68 | /* unregister interface in old DBus ctrl iface */ | |
69 | wpas_dbus_unregister_iface(wpa_s); | |
8fc2fb56 WS |
70 | |
71 | /* unregister interface in new DBus ctrl iface */ | |
52bdd880 | 72 | wpas_dbus_unregister_interface(wpa_s); |
dc461de4 WS |
73 | } |
74 | ||
8bac466b JM |
75 | |
76 | void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, | |
71934751 JM |
77 | enum wpa_states new_state, |
78 | enum wpa_states old_state) | |
8bac466b JM |
79 | { |
80 | /* notify the old DBus API */ | |
81 | wpa_supplicant_dbus_notify_state_change(wpa_s, new_state, | |
82 | old_state); | |
8fc2fb56 WS |
83 | |
84 | /* notify the new DBus API */ | |
27f43d8d | 85 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE); |
72044390 JM |
86 | |
87 | #ifdef CONFIG_P2P | |
88 | if (new_state == WPA_COMPLETED) | |
89 | wpas_p2p_notif_connected(wpa_s); | |
90 | else if (new_state < WPA_ASSOCIATED) | |
91 | wpas_p2p_notif_disconnected(wpa_s); | |
92 | #endif /* CONFIG_P2P */ | |
e29853bb BG |
93 | |
94 | sme_state_changed(wpa_s); | |
8bac466b JM |
95 | } |
96 | ||
97 | ||
98 | void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) | |
99 | { | |
52bdd880 | 100 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); |
8bac466b JM |
101 | } |
102 | ||
103 | ||
104 | void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) | |
105 | { | |
52bdd880 | 106 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); |
8bac466b JM |
107 | } |
108 | ||
109 | ||
110 | void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) | |
111 | { | |
52bdd880 | 112 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); |
8bac466b JM |
113 | } |
114 | ||
115 | ||
116 | void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, | |
117 | struct wpa_ssid *ssid) | |
118 | { | |
52bdd880 | 119 | wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); |
8bac466b JM |
120 | } |
121 | ||
122 | ||
123 | void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, | |
124 | struct wpa_ssid *ssid) | |
125 | { | |
52bdd880 | 126 | wpas_dbus_signal_network_selected(wpa_s, ssid->id); |
8bac466b JM |
127 | } |
128 | ||
129 | ||
8bac466b JM |
130 | void wpas_notify_scanning(struct wpa_supplicant *wpa_s) |
131 | { | |
132 | /* notify the old DBus API */ | |
133 | wpa_supplicant_dbus_notify_scanning(wpa_s); | |
27f43d8d | 134 | |
8fc2fb56 | 135 | /* notify the new DBus API */ |
52bdd880 | 136 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); |
8bac466b JM |
137 | } |
138 | ||
139 | ||
140 | void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) | |
141 | { | |
52bdd880 | 142 | wpas_dbus_signal_scan_done(wpa_s, success); |
8bac466b JM |
143 | } |
144 | ||
145 | ||
146 | void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) | |
147 | { | |
148 | /* notify the old DBus API */ | |
149 | wpa_supplicant_dbus_notify_scan_results(wpa_s); | |
150 | ||
151 | wpas_wps_notify_scan_results(wpa_s); | |
152 | } | |
153 | ||
154 | ||
155 | void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, | |
156 | const struct wps_credential *cred) | |
157 | { | |
b99b8e15 | 158 | #ifdef CONFIG_WPS |
8bac466b JM |
159 | /* notify the old DBus API */ |
160 | wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); | |
8fc2fb56 | 161 | /* notify the new DBus API */ |
52bdd880 | 162 | wpas_dbus_signal_wps_cred(wpa_s, cred); |
b99b8e15 | 163 | #endif /* CONFIG_WPS */ |
8bac466b JM |
164 | } |
165 | ||
166 | ||
167 | void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, | |
168 | struct wps_event_m2d *m2d) | |
169 | { | |
b99b8e15 | 170 | #ifdef CONFIG_WPS |
52bdd880 | 171 | wpas_dbus_signal_wps_event_m2d(wpa_s, m2d); |
b99b8e15 | 172 | #endif /* CONFIG_WPS */ |
8bac466b JM |
173 | } |
174 | ||
175 | ||
176 | void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, | |
177 | struct wps_event_fail *fail) | |
178 | { | |
b99b8e15 | 179 | #ifdef CONFIG_WPS |
52bdd880 | 180 | wpas_dbus_signal_wps_event_fail(wpa_s, fail); |
b99b8e15 | 181 | #endif /* CONFIG_WPS */ |
8bac466b JM |
182 | } |
183 | ||
184 | ||
185 | void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) | |
186 | { | |
b99b8e15 | 187 | #ifdef CONFIG_WPS |
52bdd880 | 188 | wpas_dbus_signal_wps_event_success(wpa_s); |
b99b8e15 | 189 | #endif /* CONFIG_WPS */ |
8bac466b JM |
190 | } |
191 | ||
192 | ||
193 | void wpas_notify_network_added(struct wpa_supplicant *wpa_s, | |
194 | struct wpa_ssid *ssid) | |
195 | { | |
52bdd880 | 196 | wpas_dbus_register_network(wpa_s, ssid); |
8bac466b JM |
197 | } |
198 | ||
199 | ||
200 | void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, | |
201 | struct wpa_ssid *ssid) | |
202 | { | |
52bdd880 | 203 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
8bac466b JM |
204 | } |
205 | ||
206 | ||
71f6e1f6 | 207 | void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, |
f0d126d3 | 208 | u8 bssid[], unsigned int id) |
71f6e1f6 | 209 | { |
52bdd880 | 210 | wpas_dbus_register_bss(wpa_s, bssid, id); |
f0d126d3 JM |
211 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, |
212 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
213 | } |
214 | ||
215 | ||
216 | void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, | |
f0d126d3 | 217 | u8 bssid[], unsigned int id) |
71f6e1f6 | 218 | { |
52bdd880 | 219 | wpas_dbus_unregister_bss(wpa_s, bssid, id); |
f0d126d3 JM |
220 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, |
221 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
222 | } |
223 | ||
224 | ||
158c6c74 WS |
225 | void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, |
226 | unsigned int id) | |
227 | { | |
228 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); | |
229 | } | |
230 | ||
231 | ||
232 | void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s, | |
233 | unsigned int id) | |
234 | { | |
235 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL, | |
236 | id); | |
237 | } | |
238 | ||
239 | ||
240 | void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s, | |
241 | unsigned int id) | |
242 | { | |
243 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY, | |
244 | id); | |
245 | } | |
246 | ||
247 | ||
248 | void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s, | |
249 | unsigned int id) | |
250 | { | |
251 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id); | |
252 | } | |
253 | ||
254 | ||
255 | void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s, | |
256 | unsigned int id) | |
257 | { | |
7899e2f4 | 258 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id); |
158c6c74 WS |
259 | } |
260 | ||
261 | ||
262 | void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s, | |
263 | unsigned int id) | |
264 | { | |
7899e2f4 | 265 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id); |
158c6c74 WS |
266 | } |
267 | ||
268 | ||
269 | void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s, | |
7899e2f4 WS |
270 | unsigned int id) |
271 | { | |
272 | } | |
273 | ||
274 | ||
275 | void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s, | |
158c6c74 WS |
276 | unsigned int id) |
277 | { | |
7899e2f4 | 278 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id); |
158c6c74 WS |
279 | } |
280 | ||
281 | ||
282 | void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s, | |
283 | unsigned int id) | |
284 | { | |
285 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id); | |
286 | } | |
287 | ||
288 | ||
8bac466b JM |
289 | void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) |
290 | { | |
52bdd880 | 291 | wpas_dbus_signal_blob_added(wpa_s, name); |
8bac466b JM |
292 | } |
293 | ||
294 | ||
295 | void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) | |
296 | { | |
52bdd880 | 297 | wpas_dbus_signal_blob_removed(wpa_s, name); |
8bac466b JM |
298 | } |
299 | ||
300 | ||
db9133ac | 301 | void wpas_notify_debug_level_changed(struct wpa_global *global) |
8bac466b | 302 | { |
52bdd880 | 303 | wpas_dbus_signal_debug_level_changed(global); |
db9133ac WS |
304 | } |
305 | ||
306 | ||
307 | void wpas_notify_debug_timestamp_changed(struct wpa_global *global) | |
308 | { | |
52bdd880 | 309 | wpas_dbus_signal_debug_timestamp_changed(global); |
db9133ac WS |
310 | } |
311 | ||
312 | ||
313 | void wpas_notify_debug_show_keys_changed(struct wpa_global *global) | |
314 | { | |
52bdd880 | 315 | wpas_dbus_signal_debug_show_keys_changed(global); |
8bac466b | 316 | } |
207ef3fb JM |
317 | |
318 | ||
319 | void wpas_notify_suspend(struct wpa_global *global) | |
320 | { | |
321 | struct wpa_supplicant *wpa_s; | |
322 | ||
323 | os_get_time(&global->suspend_time); | |
324 | wpa_printf(MSG_DEBUG, "System suspend notification"); | |
325 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) | |
326 | wpa_drv_suspend(wpa_s); | |
327 | } | |
328 | ||
329 | ||
330 | void wpas_notify_resume(struct wpa_global *global) | |
331 | { | |
332 | struct os_time now; | |
333 | int slept; | |
334 | struct wpa_supplicant *wpa_s; | |
335 | ||
336 | if (global->suspend_time.sec == 0) | |
337 | slept = -1; | |
338 | else { | |
339 | os_get_time(&now); | |
340 | slept = now.sec - global->suspend_time.sec; | |
341 | } | |
342 | wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)", | |
343 | slept); | |
344 | ||
345 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { | |
346 | wpa_drv_resume(wpa_s); | |
347 | if (wpa_s->wpa_state == WPA_DISCONNECTED) | |
348 | wpa_supplicant_req_scan(wpa_s, 0, 100000); | |
349 | } | |
350 | } | |
d642d2d2 JB |
351 | |
352 | ||
353 | #ifdef CONFIG_P2P | |
56eeb8f2 | 354 | |
d642d2d2 JB |
355 | void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, |
356 | const u8 *dev_addr, int new_device) | |
357 | { | |
358 | } | |
56eeb8f2 JB |
359 | |
360 | ||
361 | void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, | |
362 | const u8 *dev_addr) | |
363 | { | |
364 | } | |
365 | ||
408af93e JB |
366 | |
367 | void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s, | |
368 | const struct wpa_ssid *ssid, | |
369 | const char *role) | |
370 | { | |
371 | } | |
372 | ||
32d1bce0 KRK |
373 | |
374 | void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s, | |
375 | const u8 *src, u16 dev_passwd_id) | |
376 | { | |
377 | } | |
378 | ||
c2641bf7 JS |
379 | |
380 | void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, int status) | |
381 | { | |
382 | } | |
383 | ||
5ccdf84f JMB |
384 | |
385 | void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s, | |
386 | int status, const u8 *bssid) | |
387 | { | |
388 | } | |
389 | ||
e1653cac KRK |
390 | |
391 | void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s, | |
392 | int freq, const u8 *sa, u8 dialog_token, | |
393 | u16 update_indic, const u8 *tlvs, | |
394 | size_t tlvs_len) | |
395 | { | |
396 | } | |
397 | ||
43a26f60 KRK |
398 | |
399 | void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s, | |
400 | const u8 *sa, u16 update_indic, | |
401 | const u8 *tlvs, size_t tlvs_len) | |
402 | { | |
403 | } | |
404 | ||
d642d2d2 | 405 | #endif /* CONFIG_P2P */ |