2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009, 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 int wpas_notify_supplicant_initialized(struct wpa_global
*global
)
30 if (global
->params
.dbus_ctrl_interface
) {
31 global
->dbus
= wpas_dbus_init(global
);
32 if (global
->dbus
== NULL
)
35 #endif /* CONFIG_DBUS */
41 void wpas_notify_supplicant_deinitialized(struct wpa_global
*global
)
45 wpas_dbus_deinit(global
->dbus
);
46 #endif /* CONFIG_DBUS */
50 int wpas_notify_iface_added(struct wpa_supplicant
*wpa_s
)
52 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
54 if (wpas_dbus_register_iface(wpa_s
))
57 if (cbs
&& cbs
->register_interface(wpa_s
))
65 void wpas_notify_iface_removed(struct wpa_supplicant
*wpa_s
)
67 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
69 /* unregister interface in old DBus ctrl iface */
70 wpas_dbus_unregister_iface(wpa_s
);
72 /* unregister interface in new DBus ctrl iface */
74 cbs
->unregister_interface(wpa_s
);
78 void wpas_notify_state_changed(struct wpa_supplicant
*wpa_s
,
79 enum wpa_states new_state
,
80 enum wpa_states old_state
)
82 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
84 /* notify the old DBus API */
85 wpa_supplicant_dbus_notify_state_change(wpa_s
, new_state
,
88 /* notify the new DBus API */
90 cbs
->signal_state_changed(wpa_s
, new_state
, old_state
);
94 void wpas_notify_network_changed(struct wpa_supplicant
*wpa_s
)
96 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
98 cbs
->signal_prop_changed(wpa_s
,
99 WPAS_DBUS_PROP_CURRENT_NETWORK
);
103 void wpas_notify_ap_scan_changed(struct wpa_supplicant
*wpa_s
)
105 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
107 cbs
->signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_AP_SCAN
);
111 void wpas_notify_bssid_changed(struct wpa_supplicant
*wpa_s
)
113 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
115 cbs
->signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_CURRENT_BSS
);
119 void wpas_notify_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
120 struct wpa_ssid
*ssid
)
122 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
124 cbs
->signal_network_enabled_changed(wpa_s
, ssid
);
128 void wpas_notify_network_selected(struct wpa_supplicant
*wpa_s
,
129 struct wpa_ssid
*ssid
)
131 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
133 cbs
->signal_network_selected(wpa_s
, ssid
->id
);
137 void wpas_notify_scanning(struct wpa_supplicant
*wpa_s
)
139 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
140 /* notify the old DBus API */
141 wpa_supplicant_dbus_notify_scanning(wpa_s
);
142 /* notify the new DBus API */
144 cbs
->signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_SCANNING
);
148 void wpas_notify_scan_done(struct wpa_supplicant
*wpa_s
, int success
)
150 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
152 cbs
->signal_scan_done(wpa_s
, success
);
156 void wpas_notify_scan_results(struct wpa_supplicant
*wpa_s
)
158 /* notify the old DBus API */
159 wpa_supplicant_dbus_notify_scan_results(wpa_s
);
161 wpas_wps_notify_scan_results(wpa_s
);
165 void wpas_notify_wps_credential(struct wpa_supplicant
*wpa_s
,
166 const struct wps_credential
*cred
)
169 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
170 #endif /* CONFIG_WPS */
172 /* notify the old DBus API */
173 wpa_supplicant_dbus_notify_wps_cred(wpa_s
, cred
);
174 /* notify the new DBus API */
177 cbs
->signal_wps_credentials(wpa_s
, cred
);
178 #endif /* CONFIG_WPS */
182 void wpas_notify_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
183 struct wps_event_m2d
*m2d
)
186 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
188 cbs
->signal_wps_event_m2d(wpa_s
, m2d
);
189 #endif /* CONFIG_WPS */
193 void wpas_notify_wps_event_fail(struct wpa_supplicant
*wpa_s
,
194 struct wps_event_fail
*fail
)
197 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
199 cbs
->signal_wps_event_fail(wpa_s
, fail
);
200 #endif /* CONFIG_WPS */
204 void wpas_notify_wps_event_success(struct wpa_supplicant
*wpa_s
)
207 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
209 cbs
->signal_wps_event_success(wpa_s
);
210 #endif /* CONFIG_WPS */
214 void wpas_notify_network_added(struct wpa_supplicant
*wpa_s
,
215 struct wpa_ssid
*ssid
)
217 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
218 if (wpa_s
->global
->dbus
&& cbs
)
219 cbs
->register_network(wpa_s
, ssid
);
223 void wpas_notify_network_removed(struct wpa_supplicant
*wpa_s
,
224 struct wpa_ssid
*ssid
)
226 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
227 if (wpa_s
->global
->dbus
&& cbs
)
228 cbs
->unregister_network(wpa_s
, ssid
->id
);
232 void wpas_notify_bss_added(struct wpa_supplicant
*wpa_s
,
233 u8 bssid
[], unsigned int id
)
235 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
237 cbs
->register_bss(wpa_s
, bssid
, id
);
238 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_BSS_ADDED
"%u " MACSTR
,
243 void wpas_notify_bss_removed(struct wpa_supplicant
*wpa_s
,
244 u8 bssid
[], unsigned int id
)
246 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
248 cbs
->unregister_bss(wpa_s
, bssid
, id
);
249 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_BSS_REMOVED
"%u " MACSTR
,
254 void wpas_notify_blob_added(struct wpa_supplicant
*wpa_s
, const char *name
)
256 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
258 cbs
->signal_blob_added(wpa_s
, name
);
262 void wpas_notify_blob_removed(struct wpa_supplicant
*wpa_s
, const char *name
)
264 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
266 cbs
->signal_blob_removed(wpa_s
, name
);
270 void wpas_notify_debug_params_changed(struct wpa_global
*global
)
272 struct wpas_dbus_callbacks
*cbs
= wpas_dbus_get_callbacks();
274 cbs
->signal_debug_params_changed(global
);