Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * wpa_supplicant - Event notifications |
| 3 | * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi> |
| 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
| 12 | #include "common/wpa_ctrl.h" |
| 13 | #include "config.h" |
| 14 | #include "wpa_supplicant_i.h" |
| 15 | #include "wps_supplicant.h" |
| 16 | #include "dbus/dbus_common.h" |
| 17 | #include "dbus/dbus_old.h" |
| 18 | #include "dbus/dbus_new.h" |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 19 | #include "rsn_supp/wpa.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 20 | #include "driver_i.h" |
| 21 | #include "scan.h" |
| 22 | #include "p2p_supplicant.h" |
| 23 | #include "sme.h" |
| 24 | #include "notify.h" |
| 25 | |
| 26 | int wpas_notify_supplicant_initialized(struct wpa_global *global) |
| 27 | { |
| 28 | #ifdef CONFIG_DBUS |
| 29 | if (global->params.dbus_ctrl_interface) { |
| 30 | global->dbus = wpas_dbus_init(global); |
| 31 | if (global->dbus == NULL) |
| 32 | return -1; |
| 33 | } |
| 34 | #endif /* CONFIG_DBUS */ |
| 35 | |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | |
| 40 | void wpas_notify_supplicant_deinitialized(struct wpa_global *global) |
| 41 | { |
| 42 | #ifdef CONFIG_DBUS |
| 43 | if (global->dbus) |
| 44 | wpas_dbus_deinit(global->dbus); |
| 45 | #endif /* CONFIG_DBUS */ |
| 46 | } |
| 47 | |
| 48 | |
| 49 | int wpas_notify_iface_added(struct wpa_supplicant *wpa_s) |
| 50 | { |
| 51 | if (wpas_dbus_register_iface(wpa_s)) |
| 52 | return -1; |
| 53 | |
| 54 | if (wpas_dbus_register_interface(wpa_s)) |
| 55 | return -1; |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s) |
| 62 | { |
| 63 | /* unregister interface in old DBus ctrl iface */ |
| 64 | wpas_dbus_unregister_iface(wpa_s); |
| 65 | |
| 66 | /* unregister interface in new DBus ctrl iface */ |
| 67 | wpas_dbus_unregister_interface(wpa_s); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, |
| 72 | enum wpa_states new_state, |
| 73 | enum wpa_states old_state) |
| 74 | { |
| 75 | /* notify the old DBus API */ |
| 76 | wpa_supplicant_dbus_notify_state_change(wpa_s, new_state, |
| 77 | old_state); |
| 78 | |
| 79 | /* notify the new DBus API */ |
| 80 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE); |
| 81 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 82 | if (new_state == WPA_COMPLETED) |
| 83 | wpas_p2p_notif_connected(wpa_s); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 84 | else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 85 | wpas_p2p_notif_disconnected(wpa_s); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 86 | |
| 87 | sme_state_changed(wpa_s); |
| 88 | |
| 89 | #ifdef ANDROID |
| 90 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE |
Irfan Sheriff | f20a443 | 2012-04-16 16:48:34 -0700 | [diff] [blame] | 91 | "id=%d state=%d BSSID=" MACSTR " SSID=%s", |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 92 | wpa_s->current_ssid ? wpa_s->current_ssid->id : -1, |
Irfan Sheriff | f20a443 | 2012-04-16 16:48:34 -0700 | [diff] [blame] | 93 | new_state, |
Irfan Sheriff | e78e767 | 2012-08-01 11:10:15 -0700 | [diff] [blame] | 94 | MAC2STR(wpa_s->bssid), |
andy2_kuo | 5b5fb02 | 2012-05-22 11:53:07 -0700 | [diff] [blame] | 95 | wpa_s->current_ssid && wpa_s->current_ssid->ssid ? |
| 96 | wpa_ssid_txt(wpa_s->current_ssid->ssid, |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 97 | wpa_s->current_ssid->ssid_len) : ""); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 98 | #endif /* ANDROID */ |
| 99 | } |
| 100 | |
| 101 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 102 | void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s) |
| 103 | { |
| 104 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON); |
| 105 | } |
| 106 | |
| 107 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 108 | void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) |
| 109 | { |
| 110 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) |
| 115 | { |
| 116 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); |
| 117 | } |
| 118 | |
| 119 | |
| 120 | void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) |
| 121 | { |
| 122 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); |
| 123 | } |
| 124 | |
| 125 | |
| 126 | void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s) |
| 127 | { |
| 128 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, |
| 133 | struct wpa_ssid *ssid) |
| 134 | { |
| 135 | wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); |
| 136 | } |
| 137 | |
| 138 | |
| 139 | void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, |
| 140 | struct wpa_ssid *ssid) |
| 141 | { |
| 142 | wpas_dbus_signal_network_selected(wpa_s, ssid->id); |
| 143 | } |
| 144 | |
| 145 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 146 | void wpas_notify_network_request(struct wpa_supplicant *wpa_s, |
| 147 | struct wpa_ssid *ssid, |
| 148 | enum wpa_ctrl_req_type rtype, |
| 149 | const char *default_txt) |
| 150 | { |
| 151 | wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt); |
| 152 | } |
| 153 | |
| 154 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 155 | void wpas_notify_scanning(struct wpa_supplicant *wpa_s) |
| 156 | { |
| 157 | /* notify the old DBus API */ |
| 158 | wpa_supplicant_dbus_notify_scanning(wpa_s); |
| 159 | |
| 160 | /* notify the new DBus API */ |
| 161 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); |
| 162 | } |
| 163 | |
| 164 | |
| 165 | void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) |
| 166 | { |
| 167 | wpas_dbus_signal_scan_done(wpa_s, success); |
| 168 | } |
| 169 | |
| 170 | |
| 171 | void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) |
| 172 | { |
| 173 | /* notify the old DBus API */ |
| 174 | wpa_supplicant_dbus_notify_scan_results(wpa_s); |
| 175 | |
| 176 | wpas_wps_notify_scan_results(wpa_s); |
| 177 | } |
| 178 | |
| 179 | |
| 180 | void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, |
| 181 | const struct wps_credential *cred) |
| 182 | { |
| 183 | #ifdef CONFIG_WPS |
| 184 | /* notify the old DBus API */ |
| 185 | wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); |
| 186 | /* notify the new DBus API */ |
| 187 | wpas_dbus_signal_wps_cred(wpa_s, cred); |
| 188 | #endif /* CONFIG_WPS */ |
| 189 | } |
| 190 | |
| 191 | |
| 192 | void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, |
| 193 | struct wps_event_m2d *m2d) |
| 194 | { |
| 195 | #ifdef CONFIG_WPS |
| 196 | wpas_dbus_signal_wps_event_m2d(wpa_s, m2d); |
| 197 | #endif /* CONFIG_WPS */ |
| 198 | } |
| 199 | |
| 200 | |
| 201 | void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, |
| 202 | struct wps_event_fail *fail) |
| 203 | { |
| 204 | #ifdef CONFIG_WPS |
| 205 | wpas_dbus_signal_wps_event_fail(wpa_s, fail); |
| 206 | #endif /* CONFIG_WPS */ |
| 207 | } |
| 208 | |
| 209 | |
| 210 | void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) |
| 211 | { |
| 212 | #ifdef CONFIG_WPS |
| 213 | wpas_dbus_signal_wps_event_success(wpa_s); |
| 214 | #endif /* CONFIG_WPS */ |
| 215 | } |
| 216 | |
| 217 | |
| 218 | void wpas_notify_network_added(struct wpa_supplicant *wpa_s, |
| 219 | struct wpa_ssid *ssid) |
| 220 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 221 | /* |
| 222 | * Networks objects created during any P2P activities should not be |
| 223 | * exposed out. They might/will confuse certain non-P2P aware |
| 224 | * applications since these network objects won't behave like |
| 225 | * regular ones. |
| 226 | */ |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 227 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 228 | wpas_dbus_register_network(wpa_s, ssid); |
| 229 | } |
| 230 | |
| 231 | |
| 232 | void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s, |
| 233 | struct wpa_ssid *ssid) |
| 234 | { |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 235 | #ifdef CONFIG_P2P |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 236 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 237 | #endif /* CONFIG_P2P */ |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | |
| 241 | void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s, |
| 242 | struct wpa_ssid *ssid) |
| 243 | { |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 244 | #ifdef CONFIG_P2P |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 245 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 246 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | |
| 250 | void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, |
| 251 | struct wpa_ssid *ssid) |
| 252 | { |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 253 | if (wpa_s->next_ssid == ssid) |
| 254 | wpa_s->next_ssid = NULL; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 255 | if (wpa_s->wpa) |
| 256 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 257 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 258 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 259 | wpas_p2p_network_removed(wpa_s, ssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | |
| 263 | void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, |
| 264 | u8 bssid[], unsigned int id) |
| 265 | { |
| 266 | wpas_dbus_register_bss(wpa_s, bssid, id); |
| 267 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, |
| 268 | id, MAC2STR(bssid)); |
| 269 | } |
| 270 | |
| 271 | |
| 272 | void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, |
| 273 | u8 bssid[], unsigned int id) |
| 274 | { |
| 275 | wpas_dbus_unregister_bss(wpa_s, bssid, id); |
| 276 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, |
| 277 | id, MAC2STR(bssid)); |
| 278 | } |
| 279 | |
| 280 | |
| 281 | void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, |
| 282 | unsigned int id) |
| 283 | { |
| 284 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); |
| 285 | } |
| 286 | |
| 287 | |
| 288 | void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s, |
| 289 | unsigned int id) |
| 290 | { |
| 291 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL, |
| 292 | id); |
| 293 | } |
| 294 | |
| 295 | |
| 296 | void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s, |
| 297 | unsigned int id) |
| 298 | { |
| 299 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY, |
| 300 | id); |
| 301 | } |
| 302 | |
| 303 | |
| 304 | void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s, |
| 305 | unsigned int id) |
| 306 | { |
| 307 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id); |
| 308 | } |
| 309 | |
| 310 | |
| 311 | void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s, |
| 312 | unsigned int id) |
| 313 | { |
| 314 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id); |
| 315 | } |
| 316 | |
| 317 | |
| 318 | void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s, |
| 319 | unsigned int id) |
| 320 | { |
| 321 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id); |
| 322 | } |
| 323 | |
| 324 | |
| 325 | void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s, |
| 326 | unsigned int id) |
| 327 | { |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 328 | #ifdef CONFIG_WPS |
| 329 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id); |
| 330 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | |
| 334 | void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s, |
| 335 | unsigned int id) |
| 336 | { |
| 337 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id); |
| 338 | } |
| 339 | |
| 340 | |
| 341 | void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s, |
| 342 | unsigned int id) |
| 343 | { |
| 344 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id); |
| 345 | } |
| 346 | |
| 347 | |
| 348 | void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) |
| 349 | { |
| 350 | wpas_dbus_signal_blob_added(wpa_s, name); |
| 351 | } |
| 352 | |
| 353 | |
| 354 | void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) |
| 355 | { |
| 356 | wpas_dbus_signal_blob_removed(wpa_s, name); |
| 357 | } |
| 358 | |
| 359 | |
| 360 | void wpas_notify_debug_level_changed(struct wpa_global *global) |
| 361 | { |
| 362 | wpas_dbus_signal_debug_level_changed(global); |
| 363 | } |
| 364 | |
| 365 | |
| 366 | void wpas_notify_debug_timestamp_changed(struct wpa_global *global) |
| 367 | { |
| 368 | wpas_dbus_signal_debug_timestamp_changed(global); |
| 369 | } |
| 370 | |
| 371 | |
| 372 | void wpas_notify_debug_show_keys_changed(struct wpa_global *global) |
| 373 | { |
| 374 | wpas_dbus_signal_debug_show_keys_changed(global); |
| 375 | } |
| 376 | |
| 377 | |
| 378 | void wpas_notify_suspend(struct wpa_global *global) |
| 379 | { |
| 380 | struct wpa_supplicant *wpa_s; |
| 381 | |
| 382 | os_get_time(&global->suspend_time); |
| 383 | wpa_printf(MSG_DEBUG, "System suspend notification"); |
| 384 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) |
| 385 | wpa_drv_suspend(wpa_s); |
| 386 | } |
| 387 | |
| 388 | |
| 389 | void wpas_notify_resume(struct wpa_global *global) |
| 390 | { |
| 391 | struct os_time now; |
| 392 | int slept; |
| 393 | struct wpa_supplicant *wpa_s; |
| 394 | |
| 395 | if (global->suspend_time.sec == 0) |
| 396 | slept = -1; |
| 397 | else { |
| 398 | os_get_time(&now); |
| 399 | slept = now.sec - global->suspend_time.sec; |
| 400 | } |
| 401 | wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)", |
| 402 | slept); |
| 403 | |
| 404 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { |
| 405 | wpa_drv_resume(wpa_s); |
| 406 | if (wpa_s->wpa_state == WPA_DISCONNECTED) |
| 407 | wpa_supplicant_req_scan(wpa_s, 0, 100000); |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | |
| 412 | #ifdef CONFIG_P2P |
| 413 | |
| 414 | void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, |
| 415 | const u8 *dev_addr, int new_device) |
| 416 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 417 | if (new_device) { |
| 418 | /* Create the new peer object */ |
| 419 | wpas_dbus_register_peer(wpa_s, dev_addr); |
| 420 | } |
| 421 | |
| 422 | /* Notify a new peer has been detected*/ |
| 423 | wpas_dbus_signal_peer_device_found(wpa_s, dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | |
| 427 | void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, |
| 428 | const u8 *dev_addr) |
| 429 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 430 | wpas_dbus_unregister_peer(wpa_s, dev_addr); |
| 431 | |
| 432 | /* Create signal on interface object*/ |
| 433 | wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | |
| 437 | void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s, |
| 438 | const struct wpa_ssid *ssid, |
| 439 | const char *role) |
| 440 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 441 | wpas_dbus_unregister_p2p_group(wpa_s, ssid); |
| 442 | |
| 443 | wpas_dbus_signal_p2p_group_removed(wpa_s, role); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | |
| 447 | void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s, |
| 448 | const u8 *src, u16 dev_passwd_id) |
| 449 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 450 | wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 454 | void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, |
| 455 | struct p2p_go_neg_results *res) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 456 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 457 | wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | |
| 461 | void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s, |
| 462 | int status, const u8 *bssid) |
| 463 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 464 | wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | |
| 468 | void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s, |
| 469 | int freq, const u8 *sa, u8 dialog_token, |
| 470 | u16 update_indic, const u8 *tlvs, |
| 471 | size_t tlvs_len) |
| 472 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 473 | wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token, |
| 474 | update_indic, tlvs, tlvs_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | |
| 478 | void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s, |
| 479 | const u8 *sa, u16 update_indic, |
| 480 | const u8 *tlvs, size_t tlvs_len) |
| 481 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 482 | wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic, |
| 483 | tlvs, tlvs_len); |
| 484 | } |
| 485 | |
| 486 | |
| 487 | /** |
| 488 | * wpas_notify_p2p_provision_discovery - Notification of provision discovery |
| 489 | * @dev_addr: Who sent the request or responded to our request. |
| 490 | * @request: Will be 1 if request, 0 for response. |
| 491 | * @status: Valid only in case of response (0 in case of success) |
| 492 | * @config_methods: WPS config methods |
| 493 | * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method |
| 494 | * |
| 495 | * This can be used to notify: |
| 496 | * - Requests or responses |
| 497 | * - Various config methods |
| 498 | * - Failure condition in case of response |
| 499 | */ |
| 500 | void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s, |
| 501 | const u8 *dev_addr, int request, |
| 502 | enum p2p_prov_disc_status status, |
| 503 | u16 config_methods, |
| 504 | unsigned int generated_pin) |
| 505 | { |
| 506 | wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request, |
| 507 | status, config_methods, |
| 508 | generated_pin); |
| 509 | } |
| 510 | |
| 511 | |
| 512 | void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, |
| 513 | struct wpa_ssid *ssid, int network_id, |
| 514 | int client) |
| 515 | { |
| 516 | /* Notify a group has been started */ |
| 517 | wpas_dbus_register_p2p_group(wpa_s, ssid); |
| 518 | |
| 519 | wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id); |
| 520 | } |
| 521 | |
| 522 | |
| 523 | void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s, |
| 524 | struct wps_event_fail *fail) |
| 525 | { |
| 526 | wpas_dbus_signal_p2p_wps_failed(wpa_s, fail); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | #endif /* CONFIG_P2P */ |
| 530 | |
| 531 | |
| 532 | static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 533 | const u8 *sta, |
| 534 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 535 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 536 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 537 | wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr); |
| 538 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 539 | /* |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 540 | * Create 'peer-joined' signal on group object -- will also |
| 541 | * check P2P itself. |
| 542 | */ |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame^] | 543 | wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 544 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 545 | |
| 546 | /* Notify listeners a new station has been authorized */ |
| 547 | wpas_dbus_signal_sta_authorized(wpa_s, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | |
| 551 | static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame^] | 552 | const u8 *sta, |
| 553 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 554 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 555 | #ifdef CONFIG_P2P |
| 556 | /* |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 557 | * Create 'peer-disconnected' signal on group object if this |
| 558 | * is a P2P group. |
| 559 | */ |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame^] | 560 | wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 561 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 562 | |
| 563 | /* Notify listeners a station has been deauthorized */ |
| 564 | wpas_dbus_signal_sta_deauthorized(wpa_s, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | |
| 568 | void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 569 | const u8 *mac_addr, int authorized, |
| 570 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 571 | { |
| 572 | if (authorized) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 573 | wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 574 | else |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame^] | 575 | wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 576 | } |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 577 | |
| 578 | |
| 579 | void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth, |
| 580 | const char *subject, const char *cert_hash, |
| 581 | const struct wpabuf *cert) |
| 582 | { |
| 583 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT |
| 584 | "depth=%d subject='%s'%s%s", |
| 585 | depth, subject, |
| 586 | cert_hash ? " hash=" : "", |
| 587 | cert_hash ? cert_hash : ""); |
| 588 | |
| 589 | if (cert) { |
| 590 | char *cert_hex; |
| 591 | size_t len = wpabuf_len(cert) * 2 + 1; |
| 592 | cert_hex = os_malloc(len); |
| 593 | if (cert_hex) { |
| 594 | wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert), |
| 595 | wpabuf_len(cert)); |
| 596 | wpa_msg_ctrl(wpa_s, MSG_INFO, |
| 597 | WPA_EVENT_EAP_PEER_CERT |
| 598 | "depth=%d subject='%s' cert=%s", |
| 599 | depth, subject, cert_hex); |
| 600 | os_free(cert_hex); |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | /* notify the old DBus API */ |
| 605 | wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject, |
| 606 | cert_hash, cert); |
| 607 | /* notify the new DBus API */ |
| 608 | wpas_dbus_signal_certification(wpa_s, depth, subject, cert_hash, cert); |
| 609 | } |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 610 | |
| 611 | |
| 612 | void wpas_notify_preq(struct wpa_supplicant *wpa_s, |
| 613 | const u8 *addr, const u8 *dst, const u8 *bssid, |
| 614 | const u8 *ie, size_t ie_len, u32 ssi_signal) |
| 615 | { |
| 616 | #ifdef CONFIG_AP |
| 617 | wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal); |
| 618 | #endif /* CONFIG_AP */ |
| 619 | } |
| 620 | |
| 621 | |
| 622 | void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status, |
| 623 | const char *parameter) |
| 624 | { |
| 625 | wpas_dbus_signal_eap_status(wpa_s, status, parameter); |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 626 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS |
| 627 | "status='%s' parameter='%s'", |
| 628 | status, parameter); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 629 | } |