]>
Commit | Line | Data |
---|---|---|
8bac466b JM |
1 | /* |
2 | * wpa_supplicant - Event notifications | |
3 | * Copyright (c) 2009, Jouni Malinen <j@w1.fi> | |
4 | * | |
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. | |
8 | * | |
9 | * Alternatively, this software may be distributed under the terms of BSD | |
10 | * license. | |
11 | * | |
12 | * See README and COPYING for more details. | |
13 | */ | |
14 | ||
f0d126d3 | 15 | #include "utils/includes.h" |
8bac466b | 16 | |
f0d126d3 JM |
17 | #include "utils/common.h" |
18 | #include "common/wpa_ctrl.h" | |
8bac466b JM |
19 | #include "config.h" |
20 | #include "wpa_supplicant_i.h" | |
21 | #include "wps_supplicant.h" | |
8ddef94b | 22 | #include "dbus/dbus_common.h" |
bacfd05f | 23 | #include "dbus/dbus_old.h" |
6d59e14c | 24 | #include "dbus/dbus_new.h" |
8bac466b JM |
25 | #include "notify.h" |
26 | ||
dc461de4 WS |
27 | int wpas_notify_supplicant_initialized(struct wpa_global *global) |
28 | { | |
8ddef94b | 29 | #ifdef CONFIG_DBUS |
dc461de4 | 30 | if (global->params.dbus_ctrl_interface) { |
8ddef94b JM |
31 | global->dbus = wpas_dbus_init(global); |
32 | if (global->dbus == NULL) | |
85d3f273 | 33 | return -1; |
dc461de4 | 34 | } |
8ddef94b | 35 | #endif /* CONFIG_DBUS */ |
dc461de4 WS |
36 | |
37 | return 0; | |
38 | } | |
39 | ||
40 | ||
41 | void wpas_notify_supplicant_deinitialized(struct wpa_global *global) | |
42 | { | |
8ddef94b JM |
43 | #ifdef CONFIG_DBUS |
44 | if (global->dbus) | |
45 | wpas_dbus_deinit(global->dbus); | |
46 | #endif /* CONFIG_DBUS */ | |
dc461de4 WS |
47 | } |
48 | ||
49 | ||
50 | int wpas_notify_iface_added(struct wpa_supplicant *wpa_s) | |
51 | { | |
52 | if (wpas_dbus_register_iface(wpa_s)) | |
53 | return -1; | |
54 | ||
52bdd880 | 55 | if (wpas_dbus_register_interface(wpa_s)) |
8fc2fb56 WS |
56 | return -1; |
57 | ||
dc461de4 WS |
58 | return 0; |
59 | } | |
60 | ||
61 | ||
dc461de4 WS |
62 | void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s) |
63 | { | |
64 | /* unregister interface in old DBus ctrl iface */ | |
65 | wpas_dbus_unregister_iface(wpa_s); | |
8fc2fb56 WS |
66 | |
67 | /* unregister interface in new DBus ctrl iface */ | |
52bdd880 | 68 | wpas_dbus_unregister_interface(wpa_s); |
dc461de4 WS |
69 | } |
70 | ||
8bac466b JM |
71 | |
72 | void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, | |
71934751 JM |
73 | enum wpa_states new_state, |
74 | enum wpa_states old_state) | |
8bac466b JM |
75 | { |
76 | /* notify the old DBus API */ | |
77 | wpa_supplicant_dbus_notify_state_change(wpa_s, new_state, | |
78 | old_state); | |
8fc2fb56 WS |
79 | |
80 | /* notify the new DBus API */ | |
27f43d8d | 81 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE); |
8bac466b JM |
82 | } |
83 | ||
84 | ||
85 | void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) | |
86 | { | |
52bdd880 | 87 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); |
8bac466b JM |
88 | } |
89 | ||
90 | ||
91 | void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) | |
92 | { | |
52bdd880 | 93 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); |
8bac466b JM |
94 | } |
95 | ||
96 | ||
97 | void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) | |
98 | { | |
52bdd880 | 99 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); |
8bac466b JM |
100 | } |
101 | ||
102 | ||
103 | void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, | |
104 | struct wpa_ssid *ssid) | |
105 | { | |
52bdd880 | 106 | wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); |
8bac466b JM |
107 | } |
108 | ||
109 | ||
110 | void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, | |
111 | struct wpa_ssid *ssid) | |
112 | { | |
52bdd880 | 113 | wpas_dbus_signal_network_selected(wpa_s, ssid->id); |
8bac466b JM |
114 | } |
115 | ||
116 | ||
8bac466b JM |
117 | void wpas_notify_scanning(struct wpa_supplicant *wpa_s) |
118 | { | |
119 | /* notify the old DBus API */ | |
120 | wpa_supplicant_dbus_notify_scanning(wpa_s); | |
27f43d8d | 121 | |
8fc2fb56 | 122 | /* notify the new DBus API */ |
52bdd880 | 123 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); |
8bac466b JM |
124 | } |
125 | ||
126 | ||
127 | void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) | |
128 | { | |
52bdd880 | 129 | wpas_dbus_signal_scan_done(wpa_s, success); |
8bac466b JM |
130 | } |
131 | ||
132 | ||
133 | void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) | |
134 | { | |
135 | /* notify the old DBus API */ | |
136 | wpa_supplicant_dbus_notify_scan_results(wpa_s); | |
137 | ||
138 | wpas_wps_notify_scan_results(wpa_s); | |
139 | } | |
140 | ||
141 | ||
142 | void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, | |
143 | const struct wps_credential *cred) | |
144 | { | |
b99b8e15 | 145 | #ifdef CONFIG_WPS |
8bac466b JM |
146 | /* notify the old DBus API */ |
147 | wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); | |
8fc2fb56 | 148 | /* notify the new DBus API */ |
52bdd880 | 149 | wpas_dbus_signal_wps_cred(wpa_s, cred); |
b99b8e15 | 150 | #endif /* CONFIG_WPS */ |
8bac466b JM |
151 | } |
152 | ||
153 | ||
154 | void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, | |
155 | struct wps_event_m2d *m2d) | |
156 | { | |
b99b8e15 | 157 | #ifdef CONFIG_WPS |
52bdd880 | 158 | wpas_dbus_signal_wps_event_m2d(wpa_s, m2d); |
b99b8e15 | 159 | #endif /* CONFIG_WPS */ |
8bac466b JM |
160 | } |
161 | ||
162 | ||
163 | void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, | |
164 | struct wps_event_fail *fail) | |
165 | { | |
b99b8e15 | 166 | #ifdef CONFIG_WPS |
52bdd880 | 167 | wpas_dbus_signal_wps_event_fail(wpa_s, fail); |
b99b8e15 | 168 | #endif /* CONFIG_WPS */ |
8bac466b JM |
169 | } |
170 | ||
171 | ||
172 | void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) | |
173 | { | |
b99b8e15 | 174 | #ifdef CONFIG_WPS |
52bdd880 | 175 | wpas_dbus_signal_wps_event_success(wpa_s); |
b99b8e15 | 176 | #endif /* CONFIG_WPS */ |
8bac466b JM |
177 | } |
178 | ||
179 | ||
180 | void wpas_notify_network_added(struct wpa_supplicant *wpa_s, | |
181 | struct wpa_ssid *ssid) | |
182 | { | |
52bdd880 | 183 | wpas_dbus_register_network(wpa_s, ssid); |
8bac466b JM |
184 | } |
185 | ||
186 | ||
187 | void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, | |
188 | struct wpa_ssid *ssid) | |
189 | { | |
52bdd880 | 190 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
8bac466b JM |
191 | } |
192 | ||
193 | ||
71f6e1f6 | 194 | void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, |
f0d126d3 | 195 | u8 bssid[], unsigned int id) |
71f6e1f6 | 196 | { |
52bdd880 | 197 | wpas_dbus_register_bss(wpa_s, bssid, id); |
f0d126d3 JM |
198 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, |
199 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
200 | } |
201 | ||
202 | ||
203 | void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, | |
f0d126d3 | 204 | u8 bssid[], unsigned int id) |
71f6e1f6 | 205 | { |
52bdd880 | 206 | wpas_dbus_unregister_bss(wpa_s, bssid, id); |
f0d126d3 JM |
207 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, |
208 | id, MAC2STR(bssid)); | |
71f6e1f6 WS |
209 | } |
210 | ||
211 | ||
8bac466b JM |
212 | void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) |
213 | { | |
52bdd880 | 214 | wpas_dbus_signal_blob_added(wpa_s, name); |
8bac466b JM |
215 | } |
216 | ||
217 | ||
218 | void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) | |
219 | { | |
52bdd880 | 220 | wpas_dbus_signal_blob_removed(wpa_s, name); |
8bac466b JM |
221 | } |
222 | ||
223 | ||
db9133ac | 224 | void wpas_notify_debug_level_changed(struct wpa_global *global) |
8bac466b | 225 | { |
52bdd880 | 226 | wpas_dbus_signal_debug_level_changed(global); |
db9133ac WS |
227 | } |
228 | ||
229 | ||
230 | void wpas_notify_debug_timestamp_changed(struct wpa_global *global) | |
231 | { | |
52bdd880 | 232 | wpas_dbus_signal_debug_timestamp_changed(global); |
db9133ac WS |
233 | } |
234 | ||
235 | ||
236 | void wpas_notify_debug_show_keys_changed(struct wpa_global *global) | |
237 | { | |
52bdd880 | 238 | wpas_dbus_signal_debug_show_keys_changed(global); |
8bac466b | 239 | } |