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"
31 int wpas_notify_supplicant_initialized(struct wpa_global
*global
)
34 if (global
->params
.dbus_ctrl_interface
) {
35 global
->dbus
= wpas_dbus_init(global
);
36 if (global
->dbus
== NULL
)
39 #endif /* CONFIG_DBUS */
45 void wpas_notify_supplicant_deinitialized(struct wpa_global
*global
)
49 wpas_dbus_deinit(global
->dbus
);
50 #endif /* CONFIG_DBUS */
54 int wpas_notify_iface_added(struct wpa_supplicant
*wpa_s
)
56 if (wpas_dbus_register_iface(wpa_s
))
59 if (wpas_dbus_register_interface(wpa_s
))
66 void wpas_notify_iface_removed(struct wpa_supplicant
*wpa_s
)
68 /* unregister interface in old DBus ctrl iface */
69 wpas_dbus_unregister_iface(wpa_s
);
71 /* unregister interface in new DBus ctrl iface */
72 wpas_dbus_unregister_interface(wpa_s
);
76 void wpas_notify_state_changed(struct wpa_supplicant
*wpa_s
,
77 enum wpa_states new_state
,
78 enum wpa_states old_state
)
80 /* notify the old DBus API */
81 wpa_supplicant_dbus_notify_state_change(wpa_s
, new_state
,
84 /* notify the new DBus API */
85 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_STATE
);
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 */
94 sme_state_changed(wpa_s
);
98 void wpas_notify_network_changed(struct wpa_supplicant
*wpa_s
)
100 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_CURRENT_NETWORK
);
104 void wpas_notify_ap_scan_changed(struct wpa_supplicant
*wpa_s
)
106 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_AP_SCAN
);
110 void wpas_notify_bssid_changed(struct wpa_supplicant
*wpa_s
)
112 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_CURRENT_BSS
);
116 void wpas_notify_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
117 struct wpa_ssid
*ssid
)
119 wpas_dbus_signal_network_enabled_changed(wpa_s
, ssid
);
123 void wpas_notify_network_selected(struct wpa_supplicant
*wpa_s
,
124 struct wpa_ssid
*ssid
)
126 wpas_dbus_signal_network_selected(wpa_s
, ssid
->id
);
130 void wpas_notify_scanning(struct wpa_supplicant
*wpa_s
)
132 /* notify the old DBus API */
133 wpa_supplicant_dbus_notify_scanning(wpa_s
);
135 /* notify the new DBus API */
136 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_SCANNING
);
140 void wpas_notify_scan_done(struct wpa_supplicant
*wpa_s
, int success
)
142 wpas_dbus_signal_scan_done(wpa_s
, success
);
146 void wpas_notify_scan_results(struct wpa_supplicant
*wpa_s
)
148 /* notify the old DBus API */
149 wpa_supplicant_dbus_notify_scan_results(wpa_s
);
151 wpas_wps_notify_scan_results(wpa_s
);
155 void wpas_notify_wps_credential(struct wpa_supplicant
*wpa_s
,
156 const struct wps_credential
*cred
)
159 /* notify the old DBus API */
160 wpa_supplicant_dbus_notify_wps_cred(wpa_s
, cred
);
161 /* notify the new DBus API */
162 wpas_dbus_signal_wps_cred(wpa_s
, cred
);
163 #endif /* CONFIG_WPS */
167 void wpas_notify_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
168 struct wps_event_m2d
*m2d
)
171 wpas_dbus_signal_wps_event_m2d(wpa_s
, m2d
);
172 #endif /* CONFIG_WPS */
176 void wpas_notify_wps_event_fail(struct wpa_supplicant
*wpa_s
,
177 struct wps_event_fail
*fail
)
180 wpas_dbus_signal_wps_event_fail(wpa_s
, fail
);
181 #endif /* CONFIG_WPS */
185 void wpas_notify_wps_event_success(struct wpa_supplicant
*wpa_s
)
188 wpas_dbus_signal_wps_event_success(wpa_s
);
189 #endif /* CONFIG_WPS */
193 void wpas_notify_network_added(struct wpa_supplicant
*wpa_s
,
194 struct wpa_ssid
*ssid
)
196 wpas_dbus_register_network(wpa_s
, ssid
);
200 void wpas_notify_network_removed(struct wpa_supplicant
*wpa_s
,
201 struct wpa_ssid
*ssid
)
203 wpas_dbus_unregister_network(wpa_s
, ssid
->id
);
207 void wpas_notify_bss_added(struct wpa_supplicant
*wpa_s
,
208 u8 bssid
[], unsigned int id
)
210 wpas_dbus_register_bss(wpa_s
, bssid
, id
);
211 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_BSS_ADDED
"%u " MACSTR
,
216 void wpas_notify_bss_removed(struct wpa_supplicant
*wpa_s
,
217 u8 bssid
[], unsigned int id
)
219 wpas_dbus_unregister_bss(wpa_s
, bssid
, id
);
220 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_BSS_REMOVED
"%u " MACSTR
,
225 void wpas_notify_bss_freq_changed(struct wpa_supplicant
*wpa_s
,
228 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_FREQ
, id
);
232 void wpas_notify_bss_signal_changed(struct wpa_supplicant
*wpa_s
,
235 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_SIGNAL
,
240 void wpas_notify_bss_privacy_changed(struct wpa_supplicant
*wpa_s
,
243 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_PRIVACY
,
248 void wpas_notify_bss_mode_changed(struct wpa_supplicant
*wpa_s
,
251 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_MODE
, id
);
255 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant
*wpa_s
,
258 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_WPA
, id
);
262 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant
*wpa_s
,
265 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_RSN
, id
);
269 void wpas_notify_bss_wps_changed(struct wpa_supplicant
*wpa_s
,
275 void wpas_notify_bss_ies_changed(struct wpa_supplicant
*wpa_s
,
278 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_IES
, id
);
282 void wpas_notify_bss_rates_changed(struct wpa_supplicant
*wpa_s
,
285 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_RATES
, id
);
289 void wpas_notify_blob_added(struct wpa_supplicant
*wpa_s
, const char *name
)
291 wpas_dbus_signal_blob_added(wpa_s
, name
);
295 void wpas_notify_blob_removed(struct wpa_supplicant
*wpa_s
, const char *name
)
297 wpas_dbus_signal_blob_removed(wpa_s
, name
);
301 void wpas_notify_debug_level_changed(struct wpa_global
*global
)
303 wpas_dbus_signal_debug_level_changed(global
);
307 void wpas_notify_debug_timestamp_changed(struct wpa_global
*global
)
309 wpas_dbus_signal_debug_timestamp_changed(global
);
313 void wpas_notify_debug_show_keys_changed(struct wpa_global
*global
)
315 wpas_dbus_signal_debug_show_keys_changed(global
);
319 void wpas_notify_suspend(struct wpa_global
*global
)
321 struct wpa_supplicant
*wpa_s
;
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
);
330 void wpas_notify_resume(struct wpa_global
*global
)
334 struct wpa_supplicant
*wpa_s
;
336 if (global
->suspend_time
.sec
== 0)
340 slept
= now
.sec
- global
->suspend_time
.sec
;
342 wpa_printf(MSG_DEBUG
, "System resume notification (slept %d seconds)",
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);
355 void wpas_notify_p2p_device_found(struct wpa_supplicant
*wpa_s
,
356 const u8
*dev_addr
, int new_device
)
361 void wpas_notify_p2p_device_lost(struct wpa_supplicant
*wpa_s
,
367 void wpas_notify_p2p_group_removed(struct wpa_supplicant
*wpa_s
,
368 const struct wpa_ssid
*ssid
,
374 void wpas_notify_p2p_go_neg_req(struct wpa_supplicant
*wpa_s
,
375 const u8
*src
, u16 dev_passwd_id
)
380 void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant
*wpa_s
, int status
)
385 void wpas_notify_p2p_invitation_result(struct wpa_supplicant
*wpa_s
,
386 int status
, const u8
*bssid
)
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
,
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
)
405 #endif /* CONFIG_P2P */