Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / network / WirelessManager / wpa_supplicant / notify.c
blobac65b4f0defd35cf3a3fc4137367de5ecc032c46
1 /*
2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
18 #include "common/wpa_ctrl.h"
19 #include "config.h"
20 #include "wpa_supplicant_i.h"
21 #include "wps_supplicant.h"
22 #include "dbus/dbus_common.h"
23 #include "dbus/dbus_old.h"
24 #include "dbus/dbus_new.h"
25 #include "driver_i.h"
26 #include "scan.h"
27 #include "notify.h"
29 int wpas_notify_supplicant_initialized(struct wpa_global *global)
31 #ifdef CONFIG_DBUS
32 if (global->params.dbus_ctrl_interface) {
33 global->dbus = wpas_dbus_init(global);
34 if (global->dbus == NULL)
35 return -1;
37 #endif /* CONFIG_DBUS */
39 return 0;
43 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
45 #ifdef CONFIG_DBUS
46 if (global->dbus)
47 wpas_dbus_deinit(global->dbus);
48 #endif /* CONFIG_DBUS */
52 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
54 if (wpas_dbus_register_iface(wpa_s))
55 return -1;
57 if (wpas_dbus_register_interface(wpa_s))
58 return -1;
60 return 0;
64 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
66 /* unregister interface in old DBus ctrl iface */
67 wpas_dbus_unregister_iface(wpa_s);
69 /* unregister interface in new DBus ctrl iface */
70 wpas_dbus_unregister_interface(wpa_s);
74 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
75 enum wpa_states new_state,
76 enum wpa_states old_state)
78 /* notify the old DBus API */
79 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
80 old_state);
82 /* notify the new DBus API */
83 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
87 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
89 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
93 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
95 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
99 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
101 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
105 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
106 struct wpa_ssid *ssid)
108 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
112 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
113 struct wpa_ssid *ssid)
115 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
119 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
121 /* notify the old DBus API */
122 wpa_supplicant_dbus_notify_scanning(wpa_s);
124 /* notify the new DBus API */
125 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
129 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
131 wpas_dbus_signal_scan_done(wpa_s, success);
135 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
137 /* notify the old DBus API */
138 wpa_supplicant_dbus_notify_scan_results(wpa_s);
140 wpas_wps_notify_scan_results(wpa_s);
144 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
145 const struct wps_credential *cred)
147 #ifdef CONFIG_WPS
148 /* notify the old DBus API */
149 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
150 /* notify the new DBus API */
151 wpas_dbus_signal_wps_cred(wpa_s, cred);
152 #endif /* CONFIG_WPS */
156 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
157 struct wps_event_m2d *m2d)
159 #ifdef CONFIG_WPS
160 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
161 #endif /* CONFIG_WPS */
165 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
166 struct wps_event_fail *fail)
168 #ifdef CONFIG_WPS
169 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
170 #endif /* CONFIG_WPS */
174 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
176 #ifdef CONFIG_WPS
177 wpas_dbus_signal_wps_event_success(wpa_s);
178 #endif /* CONFIG_WPS */
182 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
183 struct wpa_ssid *ssid)
185 wpas_dbus_register_network(wpa_s, ssid);
189 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
190 struct wpa_ssid *ssid)
192 wpas_dbus_unregister_network(wpa_s, ssid->id);
196 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
197 u8 bssid[], unsigned int id)
199 wpas_dbus_register_bss(wpa_s, bssid, id);
200 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
201 id, MAC2STR(bssid));
205 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
206 u8 bssid[], unsigned int id)
208 wpas_dbus_unregister_bss(wpa_s, bssid, id);
209 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
210 id, MAC2STR(bssid));
214 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
215 unsigned int id)
217 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
221 void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
222 unsigned int id)
224 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
225 id);
229 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
230 unsigned int id)
232 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
233 id);
237 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
238 unsigned int id)
240 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
244 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
245 unsigned int id)
247 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
251 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
252 unsigned int id)
254 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
258 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
259 unsigned int id)
264 void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
265 unsigned int id)
267 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
271 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
272 unsigned int id)
274 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
278 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
280 wpas_dbus_signal_blob_added(wpa_s, name);
284 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
286 wpas_dbus_signal_blob_removed(wpa_s, name);
290 void wpas_notify_debug_level_changed(struct wpa_global *global)
292 wpas_dbus_signal_debug_level_changed(global);
296 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
298 wpas_dbus_signal_debug_timestamp_changed(global);
302 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
304 wpas_dbus_signal_debug_show_keys_changed(global);
308 void wpas_notify_suspend(struct wpa_global *global)
310 struct wpa_supplicant *wpa_s;
312 os_get_time(&global->suspend_time);
313 wpa_printf(MSG_DEBUG, "System suspend notification");
314 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
315 wpa_drv_suspend(wpa_s);
319 void wpas_notify_resume(struct wpa_global *global)
321 struct os_time now;
322 int slept;
323 struct wpa_supplicant *wpa_s;
325 if (global->suspend_time.sec == 0)
326 slept = -1;
327 else {
328 os_get_time(&now);
329 slept = now.sec - global->suspend_time.sec;
331 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
332 slept);
334 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
335 wpa_drv_resume(wpa_s);
336 if (wpa_s->wpa_state == WPA_DISCONNECTED)
337 wpa_supplicant_req_scan(wpa_s, 0, 100000);