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
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
18 #include "common/wpa_ctrl.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"
27 #include "p2p_supplicant.h"
30 int wpas_notify_supplicant_initialized(struct wpa_global *global)
33 if (global->params.dbus_ctrl_interface) {
34 global->dbus = wpas_dbus_init(global);
35 if (global->dbus == NULL)
38 #endif /* CONFIG_DBUS */
44 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
48 wpas_dbus_deinit(global->dbus);
49 #endif /* CONFIG_DBUS */
53 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
55 if (wpas_dbus_register_iface(wpa_s))
58 if (wpas_dbus_register_interface(wpa_s))
65 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
67 /* unregister interface in old DBus ctrl iface */
68 wpas_dbus_unregister_iface(wpa_s);
70 /* unregister interface in new DBus ctrl iface */
71 wpas_dbus_unregister_interface(wpa_s);
75 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
76 enum wpa_states new_state,
77 enum wpa_states old_state)
79 /* notify the old DBus API */
80 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
83 /* notify the new DBus API */
84 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
87 if (new_state == WPA_COMPLETED)
88 wpas_p2p_notif_connected(wpa_s);
89 else if (new_state < WPA_ASSOCIATED)
90 wpas_p2p_notif_disconnected(wpa_s);
91 #endif /* CONFIG_P2P */
95 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
97 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
101 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
103 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
107 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
109 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
113 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
114 struct wpa_ssid *ssid)
116 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
120 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
121 struct wpa_ssid *ssid)
123 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
127 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
129 /* notify the old DBus API */
130 wpa_supplicant_dbus_notify_scanning(wpa_s);
132 /* notify the new DBus API */
133 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
137 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
139 wpas_dbus_signal_scan_done(wpa_s, success);
143 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
145 /* notify the old DBus API */
146 wpa_supplicant_dbus_notify_scan_results(wpa_s);
148 wpas_wps_notify_scan_results(wpa_s);
152 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
153 const struct wps_credential *cred)
156 /* notify the old DBus API */
157 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
158 /* notify the new DBus API */
159 wpas_dbus_signal_wps_cred(wpa_s, cred);
160 #endif /* CONFIG_WPS */
164 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
165 struct wps_event_m2d *m2d)
168 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
169 #endif /* CONFIG_WPS */
173 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
174 struct wps_event_fail *fail)
177 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
178 #endif /* CONFIG_WPS */
182 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
185 wpas_dbus_signal_wps_event_success(wpa_s);
186 #endif /* CONFIG_WPS */
190 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
191 struct wpa_ssid *ssid)
193 wpas_dbus_register_network(wpa_s, ssid);
197 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
198 struct wpa_ssid *ssid)
200 wpas_dbus_unregister_network(wpa_s, ssid->id);
204 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
205 u8 bssid[], unsigned int id)
207 wpas_dbus_register_bss(wpa_s, bssid, id);
208 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
213 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
214 u8 bssid[], unsigned int id)
216 wpas_dbus_unregister_bss(wpa_s, bssid, id);
217 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
222 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
225 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
229 void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
232 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
237 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
240 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
245 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
248 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
252 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
255 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
259 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
262 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
266 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
272 void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
275 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
279 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
282 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
286 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
288 wpas_dbus_signal_blob_added(wpa_s, name);
292 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
294 wpas_dbus_signal_blob_removed(wpa_s, name);
298 void wpas_notify_debug_level_changed(struct wpa_global *global)
300 wpas_dbus_signal_debug_level_changed(global);
304 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
306 wpas_dbus_signal_debug_timestamp_changed(global);
310 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
312 wpas_dbus_signal_debug_show_keys_changed(global);
316 void wpas_notify_suspend(struct wpa_global *global)
318 struct wpa_supplicant *wpa_s;
320 os_get_time(&global->suspend_time);
321 wpa_printf(MSG_DEBUG, "System suspend notification");
322 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
323 wpa_drv_suspend(wpa_s);
327 void wpas_notify_resume(struct wpa_global *global)
331 struct wpa_supplicant *wpa_s;
333 if (global->suspend_time.sec == 0)
337 slept = now.sec - global->suspend_time.sec;
339 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
342 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
343 wpa_drv_resume(wpa_s);
344 if (wpa_s->wpa_state == WPA_DISCONNECTED)
345 wpa_supplicant_req_scan(wpa_s, 0, 100000);