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
);
97 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_STATE_CHANGE
98 "id=%d state=%d BSSID=" MACSTR
,
99 wpa_s
->current_ssid
? wpa_s
->current_ssid
->id
: -1,
100 new_state
, MAC2STR(wpa_s
->pending_bssid
));
105 void wpas_notify_network_changed(struct wpa_supplicant
*wpa_s
)
107 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_CURRENT_NETWORK
);
111 void wpas_notify_ap_scan_changed(struct wpa_supplicant
*wpa_s
)
113 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_AP_SCAN
);
117 void wpas_notify_bssid_changed(struct wpa_supplicant
*wpa_s
)
119 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_CURRENT_BSS
);
123 void wpas_notify_auth_changed(struct wpa_supplicant
*wpa_s
)
125 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_CURRENT_AUTH_MODE
);
129 void wpas_notify_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
130 struct wpa_ssid
*ssid
)
132 wpas_dbus_signal_network_enabled_changed(wpa_s
, ssid
);
136 void wpas_notify_network_selected(struct wpa_supplicant
*wpa_s
,
137 struct wpa_ssid
*ssid
)
139 wpas_dbus_signal_network_selected(wpa_s
, ssid
->id
);
143 void wpas_notify_scanning(struct wpa_supplicant
*wpa_s
)
145 /* notify the old DBus API */
146 wpa_supplicant_dbus_notify_scanning(wpa_s
);
148 /* notify the new DBus API */
149 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_SCANNING
);
153 void wpas_notify_scan_done(struct wpa_supplicant
*wpa_s
, int success
)
155 wpas_dbus_signal_scan_done(wpa_s
, success
);
159 void wpas_notify_scan_results(struct wpa_supplicant
*wpa_s
)
161 /* notify the old DBus API */
162 wpa_supplicant_dbus_notify_scan_results(wpa_s
);
164 wpas_wps_notify_scan_results(wpa_s
);
168 void wpas_notify_wps_credential(struct wpa_supplicant
*wpa_s
,
169 const struct wps_credential
*cred
)
172 /* notify the old DBus API */
173 wpa_supplicant_dbus_notify_wps_cred(wpa_s
, cred
);
174 /* notify the new DBus API */
175 wpas_dbus_signal_wps_cred(wpa_s
, cred
);
176 #endif /* CONFIG_WPS */
180 void wpas_notify_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
181 struct wps_event_m2d
*m2d
)
184 wpas_dbus_signal_wps_event_m2d(wpa_s
, m2d
);
185 #endif /* CONFIG_WPS */
189 void wpas_notify_wps_event_fail(struct wpa_supplicant
*wpa_s
,
190 struct wps_event_fail
*fail
)
193 wpas_dbus_signal_wps_event_fail(wpa_s
, fail
);
194 #endif /* CONFIG_WPS */
198 void wpas_notify_wps_event_success(struct wpa_supplicant
*wpa_s
)
201 wpas_dbus_signal_wps_event_success(wpa_s
);
202 #endif /* CONFIG_WPS */
206 void wpas_notify_network_added(struct wpa_supplicant
*wpa_s
,
207 struct wpa_ssid
*ssid
)
209 wpas_dbus_register_network(wpa_s
, ssid
);
213 void wpas_notify_network_removed(struct wpa_supplicant
*wpa_s
,
214 struct wpa_ssid
*ssid
)
216 wpas_dbus_unregister_network(wpa_s
, ssid
->id
);
220 void wpas_notify_bss_added(struct wpa_supplicant
*wpa_s
,
221 u8 bssid
[], unsigned int id
)
223 wpas_dbus_register_bss(wpa_s
, bssid
, id
);
224 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_BSS_ADDED
"%u " MACSTR
,
229 void wpas_notify_bss_removed(struct wpa_supplicant
*wpa_s
,
230 u8 bssid
[], unsigned int id
)
232 wpas_dbus_unregister_bss(wpa_s
, bssid
, id
);
233 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_BSS_REMOVED
"%u " MACSTR
,
238 void wpas_notify_bss_freq_changed(struct wpa_supplicant
*wpa_s
,
241 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_FREQ
, id
);
245 void wpas_notify_bss_signal_changed(struct wpa_supplicant
*wpa_s
,
248 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_SIGNAL
,
253 void wpas_notify_bss_privacy_changed(struct wpa_supplicant
*wpa_s
,
256 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_PRIVACY
,
261 void wpas_notify_bss_mode_changed(struct wpa_supplicant
*wpa_s
,
264 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_MODE
, id
);
268 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant
*wpa_s
,
271 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_WPA
, id
);
275 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant
*wpa_s
,
278 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_RSN
, id
);
282 void wpas_notify_bss_wps_changed(struct wpa_supplicant
*wpa_s
,
288 void wpas_notify_bss_ies_changed(struct wpa_supplicant
*wpa_s
,
291 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_IES
, id
);
295 void wpas_notify_bss_rates_changed(struct wpa_supplicant
*wpa_s
,
298 wpas_dbus_bss_signal_prop_changed(wpa_s
, WPAS_DBUS_BSS_PROP_RATES
, id
);
302 void wpas_notify_blob_added(struct wpa_supplicant
*wpa_s
, const char *name
)
304 wpas_dbus_signal_blob_added(wpa_s
, name
);
308 void wpas_notify_blob_removed(struct wpa_supplicant
*wpa_s
, const char *name
)
310 wpas_dbus_signal_blob_removed(wpa_s
, name
);
314 void wpas_notify_debug_level_changed(struct wpa_global
*global
)
316 wpas_dbus_signal_debug_level_changed(global
);
320 void wpas_notify_debug_timestamp_changed(struct wpa_global
*global
)
322 wpas_dbus_signal_debug_timestamp_changed(global
);
326 void wpas_notify_debug_show_keys_changed(struct wpa_global
*global
)
328 wpas_dbus_signal_debug_show_keys_changed(global
);
332 void wpas_notify_suspend(struct wpa_global
*global
)
334 struct wpa_supplicant
*wpa_s
;
336 os_get_time(&global
->suspend_time
);
337 wpa_printf(MSG_DEBUG
, "System suspend notification");
338 for (wpa_s
= global
->ifaces
; wpa_s
; wpa_s
= wpa_s
->next
)
339 wpa_drv_suspend(wpa_s
);
343 void wpas_notify_resume(struct wpa_global
*global
)
347 struct wpa_supplicant
*wpa_s
;
349 if (global
->suspend_time
.sec
== 0)
353 slept
= now
.sec
- global
->suspend_time
.sec
;
355 wpa_printf(MSG_DEBUG
, "System resume notification (slept %d seconds)",
358 for (wpa_s
= global
->ifaces
; wpa_s
; wpa_s
= wpa_s
->next
) {
359 wpa_drv_resume(wpa_s
);
360 if (wpa_s
->wpa_state
== WPA_DISCONNECTED
)
361 wpa_supplicant_req_scan(wpa_s
, 0, 100000);
368 void wpas_notify_p2p_device_found(struct wpa_supplicant
*wpa_s
,
369 const u8
*dev_addr
, int new_device
)
374 void wpas_notify_p2p_device_lost(struct wpa_supplicant
*wpa_s
,
380 void wpas_notify_p2p_group_removed(struct wpa_supplicant
*wpa_s
,
381 const struct wpa_ssid
*ssid
,
387 void wpas_notify_p2p_go_neg_req(struct wpa_supplicant
*wpa_s
,
388 const u8
*src
, u16 dev_passwd_id
)
393 void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant
*wpa_s
, int status
)
398 void wpas_notify_p2p_invitation_result(struct wpa_supplicant
*wpa_s
,
399 int status
, const u8
*bssid
)
404 void wpas_notify_p2p_sd_request(struct wpa_supplicant
*wpa_s
,
405 int freq
, const u8
*sa
, u8 dialog_token
,
406 u16 update_indic
, const u8
*tlvs
,
412 void wpas_notify_p2p_sd_response(struct wpa_supplicant
*wpa_s
,
413 const u8
*sa
, u16 update_indic
,
414 const u8
*tlvs
, size_t tlvs_len
)
420 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
421 * @dev_addr: Who sent the request or responded to our request.
422 * @request: Will be 1 if request, 0 for response.
423 * @status: Valid only in case of response (0 in case of success)
424 * @config_methods: WPS config methods
425 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
427 * This can be used to notify:
428 * - Requests or responses
429 * - Various config methods
430 * - Failure condition in case of response
432 void wpas_notify_p2p_provision_discovery(struct wpa_supplicant
*wpa_s
,
433 const u8
*dev_addr
, int request
,
434 enum p2p_prov_disc_status status
,
436 unsigned int generated_pin
)
439 #endif /* CONFIG_P2P */
442 static void wpas_notify_ap_sta_authorized(struct wpa_supplicant
*wpa_s
,
448 static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant
*wpa_s
,
454 void wpas_notify_sta_authorized(struct wpa_supplicant
*wpa_s
,
455 const u8
*mac_addr
, int authorized
)
458 wpas_notify_ap_sta_authorized(wpa_s
, mac_addr
);
460 wpas_notify_ap_sta_deauthorized(wpa_s
, mac_addr
);