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" |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 16 | #include "binder/binder.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 17 | #include "dbus/dbus_common.h" |
| 18 | #include "dbus/dbus_old.h" |
| 19 | #include "dbus/dbus_new.h" |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 20 | #include "rsn_supp/wpa.h" |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 21 | #include "fst/fst.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 22 | #include "driver_i.h" |
| 23 | #include "scan.h" |
| 24 | #include "p2p_supplicant.h" |
| 25 | #include "sme.h" |
| 26 | #include "notify.h" |
| 27 | |
| 28 | int wpas_notify_supplicant_initialized(struct wpa_global *global) |
| 29 | { |
| 30 | #ifdef CONFIG_DBUS |
| 31 | if (global->params.dbus_ctrl_interface) { |
| 32 | global->dbus = wpas_dbus_init(global); |
| 33 | if (global->dbus == NULL) |
| 34 | return -1; |
| 35 | } |
| 36 | #endif /* CONFIG_DBUS */ |
| 37 | |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 38 | #ifdef CONFIG_BINDER |
| 39 | global->binder = wpas_binder_init(global); |
| 40 | if (!global->binder) |
| 41 | return -1; |
| 42 | #endif /* CONFIG_BINDER */ |
| 43 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | void wpas_notify_supplicant_deinitialized(struct wpa_global *global) |
| 49 | { |
| 50 | #ifdef CONFIG_DBUS |
| 51 | if (global->dbus) |
| 52 | wpas_dbus_deinit(global->dbus); |
| 53 | #endif /* CONFIG_DBUS */ |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 54 | |
| 55 | #ifdef CONFIG_BINDER |
| 56 | if (global->binder) |
| 57 | wpas_binder_deinit(global->binder); |
| 58 | #endif /* CONFIG_BINDER */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | |
| 62 | int wpas_notify_iface_added(struct wpa_supplicant *wpa_s) |
| 63 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 64 | if (wpa_s->p2p_mgmt) |
| 65 | return 0; |
| 66 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 67 | if (wpas_dbus_register_iface(wpa_s)) |
| 68 | return -1; |
| 69 | |
| 70 | if (wpas_dbus_register_interface(wpa_s)) |
| 71 | return -1; |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s) |
| 78 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 79 | if (wpa_s->p2p_mgmt) |
| 80 | return; |
| 81 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 82 | /* unregister interface in old DBus ctrl iface */ |
| 83 | wpas_dbus_unregister_iface(wpa_s); |
| 84 | |
| 85 | /* unregister interface in new DBus ctrl iface */ |
| 86 | wpas_dbus_unregister_interface(wpa_s); |
| 87 | } |
| 88 | |
| 89 | |
| 90 | void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, |
| 91 | enum wpa_states new_state, |
| 92 | enum wpa_states old_state) |
| 93 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 94 | if (wpa_s->p2p_mgmt) |
| 95 | return; |
| 96 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 97 | /* notify the old DBus API */ |
| 98 | wpa_supplicant_dbus_notify_state_change(wpa_s, new_state, |
| 99 | old_state); |
| 100 | |
| 101 | /* notify the new DBus API */ |
| 102 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE); |
| 103 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 104 | #ifdef CONFIG_FST |
| 105 | if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) { |
| 106 | if (new_state == WPA_COMPLETED) |
| 107 | fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid); |
| 108 | else if (old_state >= WPA_ASSOCIATED && |
| 109 | new_state < WPA_ASSOCIATED) |
| 110 | fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid); |
| 111 | } |
| 112 | #endif /* CONFIG_FST */ |
| 113 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 114 | if (new_state == WPA_COMPLETED) |
| 115 | wpas_p2p_notif_connected(wpa_s); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 116 | else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 117 | wpas_p2p_notif_disconnected(wpa_s); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 118 | |
| 119 | sme_state_changed(wpa_s); |
| 120 | |
| 121 | #ifdef ANDROID |
| 122 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE |
Irfan Sheriff | f20a443 | 2012-04-16 16:48:34 -0700 | [diff] [blame] | 123 | "id=%d state=%d BSSID=" MACSTR " SSID=%s", |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 124 | wpa_s->current_ssid ? wpa_s->current_ssid->id : -1, |
Irfan Sheriff | f20a443 | 2012-04-16 16:48:34 -0700 | [diff] [blame] | 125 | new_state, |
Irfan Sheriff | e78e767 | 2012-08-01 11:10:15 -0700 | [diff] [blame] | 126 | MAC2STR(wpa_s->bssid), |
andy2_kuo | 5b5fb02 | 2012-05-22 11:53:07 -0700 | [diff] [blame] | 127 | wpa_s->current_ssid && wpa_s->current_ssid->ssid ? |
| 128 | wpa_ssid_txt(wpa_s->current_ssid->ssid, |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 129 | wpa_s->current_ssid->ssid_len) : ""); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 130 | #endif /* ANDROID */ |
| 131 | } |
| 132 | |
| 133 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 134 | void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s) |
| 135 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 136 | if (wpa_s->p2p_mgmt) |
| 137 | return; |
| 138 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 139 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON); |
| 140 | } |
| 141 | |
| 142 | |
Dmitry Shmidt | 31a29cc | 2016-03-09 15:58:17 -0800 | [diff] [blame] | 143 | void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s) |
| 144 | { |
| 145 | if (wpa_s->p2p_mgmt) |
| 146 | return; |
| 147 | |
| 148 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE); |
| 149 | } |
| 150 | |
| 151 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 152 | void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) |
| 153 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 154 | if (wpa_s->p2p_mgmt) |
| 155 | return; |
| 156 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 157 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); |
| 158 | } |
| 159 | |
| 160 | |
| 161 | void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) |
| 162 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 163 | if (wpa_s->p2p_mgmt) |
| 164 | return; |
| 165 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 166 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); |
| 167 | } |
| 168 | |
| 169 | |
| 170 | void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) |
| 171 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 172 | if (wpa_s->p2p_mgmt) |
| 173 | return; |
| 174 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 175 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); |
| 176 | } |
| 177 | |
| 178 | |
| 179 | void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s) |
| 180 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 181 | if (wpa_s->p2p_mgmt) |
| 182 | return; |
| 183 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 184 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE); |
| 185 | } |
| 186 | |
| 187 | |
| 188 | void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, |
| 189 | struct wpa_ssid *ssid) |
| 190 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 191 | if (wpa_s->p2p_mgmt) |
| 192 | return; |
| 193 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 194 | wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); |
| 195 | } |
| 196 | |
| 197 | |
| 198 | void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, |
| 199 | struct wpa_ssid *ssid) |
| 200 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 201 | if (wpa_s->p2p_mgmt) |
| 202 | return; |
| 203 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 204 | wpas_dbus_signal_network_selected(wpa_s, ssid->id); |
| 205 | } |
| 206 | |
| 207 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 208 | void wpas_notify_network_request(struct wpa_supplicant *wpa_s, |
| 209 | struct wpa_ssid *ssid, |
| 210 | enum wpa_ctrl_req_type rtype, |
| 211 | const char *default_txt) |
| 212 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 213 | if (wpa_s->p2p_mgmt) |
| 214 | return; |
| 215 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 216 | wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt); |
| 217 | } |
| 218 | |
| 219 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 220 | void wpas_notify_scanning(struct wpa_supplicant *wpa_s) |
| 221 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 222 | if (wpa_s->p2p_mgmt) |
| 223 | return; |
| 224 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 225 | /* notify the old DBus API */ |
| 226 | wpa_supplicant_dbus_notify_scanning(wpa_s); |
| 227 | |
| 228 | /* notify the new DBus API */ |
| 229 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); |
| 230 | } |
| 231 | |
| 232 | |
| 233 | void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) |
| 234 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 235 | if (wpa_s->p2p_mgmt) |
| 236 | return; |
| 237 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 238 | wpas_dbus_signal_scan_done(wpa_s, success); |
| 239 | } |
| 240 | |
| 241 | |
| 242 | void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) |
| 243 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 244 | if (wpa_s->p2p_mgmt) |
| 245 | return; |
| 246 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 247 | /* notify the old DBus API */ |
| 248 | wpa_supplicant_dbus_notify_scan_results(wpa_s); |
| 249 | |
| 250 | wpas_wps_notify_scan_results(wpa_s); |
| 251 | } |
| 252 | |
| 253 | |
| 254 | void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, |
| 255 | const struct wps_credential *cred) |
| 256 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 257 | if (wpa_s->p2p_mgmt) |
| 258 | return; |
| 259 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 260 | #ifdef CONFIG_WPS |
| 261 | /* notify the old DBus API */ |
| 262 | wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); |
| 263 | /* notify the new DBus API */ |
| 264 | wpas_dbus_signal_wps_cred(wpa_s, cred); |
| 265 | #endif /* CONFIG_WPS */ |
| 266 | } |
| 267 | |
| 268 | |
| 269 | void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, |
| 270 | struct wps_event_m2d *m2d) |
| 271 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 272 | if (wpa_s->p2p_mgmt) |
| 273 | return; |
| 274 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 275 | #ifdef CONFIG_WPS |
| 276 | wpas_dbus_signal_wps_event_m2d(wpa_s, m2d); |
| 277 | #endif /* CONFIG_WPS */ |
| 278 | } |
| 279 | |
| 280 | |
| 281 | void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, |
| 282 | struct wps_event_fail *fail) |
| 283 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 284 | if (wpa_s->p2p_mgmt) |
| 285 | return; |
| 286 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 287 | #ifdef CONFIG_WPS |
| 288 | wpas_dbus_signal_wps_event_fail(wpa_s, fail); |
| 289 | #endif /* CONFIG_WPS */ |
| 290 | } |
| 291 | |
| 292 | |
| 293 | void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) |
| 294 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 295 | if (wpa_s->p2p_mgmt) |
| 296 | return; |
| 297 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 298 | #ifdef CONFIG_WPS |
| 299 | wpas_dbus_signal_wps_event_success(wpa_s); |
| 300 | #endif /* CONFIG_WPS */ |
| 301 | } |
| 302 | |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 303 | void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s) |
| 304 | { |
| 305 | if (wpa_s->p2p_mgmt) |
| 306 | return; |
| 307 | |
| 308 | #ifdef CONFIG_WPS |
| 309 | wpas_dbus_signal_wps_event_pbc_overlap(wpa_s); |
| 310 | #endif /* CONFIG_WPS */ |
| 311 | } |
| 312 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 313 | |
| 314 | void wpas_notify_network_added(struct wpa_supplicant *wpa_s, |
| 315 | struct wpa_ssid *ssid) |
| 316 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 317 | if (wpa_s->p2p_mgmt) |
| 318 | return; |
| 319 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 320 | /* |
| 321 | * Networks objects created during any P2P activities should not be |
| 322 | * exposed out. They might/will confuse certain non-P2P aware |
| 323 | * applications since these network objects won't behave like |
| 324 | * regular ones. |
| 325 | */ |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 326 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 327 | wpas_dbus_register_network(wpa_s, ssid); |
| 328 | } |
| 329 | |
| 330 | |
| 331 | void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s, |
| 332 | struct wpa_ssid *ssid) |
| 333 | { |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 334 | #ifdef CONFIG_P2P |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 335 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 336 | #endif /* CONFIG_P2P */ |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | |
| 340 | void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s, |
| 341 | struct wpa_ssid *ssid) |
| 342 | { |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 343 | #ifdef CONFIG_P2P |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 344 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 345 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | |
| 349 | void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, |
| 350 | struct wpa_ssid *ssid) |
| 351 | { |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 352 | if (wpa_s->next_ssid == ssid) |
| 353 | wpa_s->next_ssid = NULL; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 354 | if (wpa_s->wpa) |
| 355 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); |
Dmitry Shmidt | cc00d5d | 2015-05-04 10:34:12 -0700 | [diff] [blame] | 356 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s && |
| 357 | !wpa_s->p2p_mgmt) |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 358 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 359 | if (network_is_persistent_group(ssid)) |
| 360 | wpas_notify_persistent_group_removed(wpa_s, ssid); |
| 361 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 362 | wpas_p2p_network_removed(wpa_s, ssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | |
| 366 | void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, |
| 367 | u8 bssid[], unsigned int id) |
| 368 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 369 | if (wpa_s->p2p_mgmt) |
| 370 | return; |
| 371 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 372 | wpas_dbus_register_bss(wpa_s, bssid, id); |
| 373 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, |
| 374 | id, MAC2STR(bssid)); |
| 375 | } |
| 376 | |
| 377 | |
| 378 | void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, |
| 379 | u8 bssid[], unsigned int id) |
| 380 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 381 | if (wpa_s->p2p_mgmt) |
| 382 | return; |
| 383 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 384 | wpas_dbus_unregister_bss(wpa_s, bssid, id); |
| 385 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, |
| 386 | id, MAC2STR(bssid)); |
| 387 | } |
| 388 | |
| 389 | |
| 390 | void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, |
| 391 | unsigned int id) |
| 392 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 393 | if (wpa_s->p2p_mgmt) |
| 394 | return; |
| 395 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 396 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); |
| 397 | } |
| 398 | |
| 399 | |
| 400 | void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s, |
| 401 | unsigned int id) |
| 402 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 403 | if (wpa_s->p2p_mgmt) |
| 404 | return; |
| 405 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 406 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL, |
| 407 | id); |
| 408 | } |
| 409 | |
| 410 | |
| 411 | void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s, |
| 412 | unsigned int id) |
| 413 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 414 | if (wpa_s->p2p_mgmt) |
| 415 | return; |
| 416 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 417 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY, |
| 418 | id); |
| 419 | } |
| 420 | |
| 421 | |
| 422 | void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s, |
| 423 | unsigned int id) |
| 424 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 425 | if (wpa_s->p2p_mgmt) |
| 426 | return; |
| 427 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 428 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id); |
| 429 | } |
| 430 | |
| 431 | |
| 432 | void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s, |
| 433 | unsigned int id) |
| 434 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 435 | if (wpa_s->p2p_mgmt) |
| 436 | return; |
| 437 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 438 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id); |
| 439 | } |
| 440 | |
| 441 | |
| 442 | void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s, |
| 443 | unsigned int id) |
| 444 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 445 | if (wpa_s->p2p_mgmt) |
| 446 | return; |
| 447 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 448 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id); |
| 449 | } |
| 450 | |
| 451 | |
| 452 | void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s, |
| 453 | unsigned int id) |
| 454 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 455 | if (wpa_s->p2p_mgmt) |
| 456 | return; |
| 457 | |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 458 | #ifdef CONFIG_WPS |
| 459 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id); |
| 460 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | |
| 464 | void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s, |
| 465 | unsigned int id) |
| 466 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 467 | if (wpa_s->p2p_mgmt) |
| 468 | return; |
| 469 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 470 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id); |
| 471 | } |
| 472 | |
| 473 | |
| 474 | void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s, |
| 475 | unsigned int id) |
| 476 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 477 | if (wpa_s->p2p_mgmt) |
| 478 | return; |
| 479 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 480 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id); |
| 481 | } |
| 482 | |
| 483 | |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 484 | void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id) |
| 485 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 486 | if (wpa_s->p2p_mgmt) |
| 487 | return; |
| 488 | |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 489 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id); |
| 490 | } |
| 491 | |
| 492 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 493 | void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) |
| 494 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 495 | if (wpa_s->p2p_mgmt) |
| 496 | return; |
| 497 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 498 | wpas_dbus_signal_blob_added(wpa_s, name); |
| 499 | } |
| 500 | |
| 501 | |
| 502 | void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) |
| 503 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 504 | if (wpa_s->p2p_mgmt) |
| 505 | return; |
| 506 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 507 | wpas_dbus_signal_blob_removed(wpa_s, name); |
| 508 | } |
| 509 | |
| 510 | |
| 511 | void wpas_notify_debug_level_changed(struct wpa_global *global) |
| 512 | { |
| 513 | wpas_dbus_signal_debug_level_changed(global); |
| 514 | } |
| 515 | |
| 516 | |
| 517 | void wpas_notify_debug_timestamp_changed(struct wpa_global *global) |
| 518 | { |
| 519 | wpas_dbus_signal_debug_timestamp_changed(global); |
| 520 | } |
| 521 | |
| 522 | |
| 523 | void wpas_notify_debug_show_keys_changed(struct wpa_global *global) |
| 524 | { |
| 525 | wpas_dbus_signal_debug_show_keys_changed(global); |
| 526 | } |
| 527 | |
| 528 | |
| 529 | void wpas_notify_suspend(struct wpa_global *global) |
| 530 | { |
| 531 | struct wpa_supplicant *wpa_s; |
| 532 | |
| 533 | os_get_time(&global->suspend_time); |
| 534 | wpa_printf(MSG_DEBUG, "System suspend notification"); |
| 535 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) |
| 536 | wpa_drv_suspend(wpa_s); |
| 537 | } |
| 538 | |
| 539 | |
| 540 | void wpas_notify_resume(struct wpa_global *global) |
| 541 | { |
| 542 | struct os_time now; |
| 543 | int slept; |
| 544 | struct wpa_supplicant *wpa_s; |
| 545 | |
| 546 | if (global->suspend_time.sec == 0) |
| 547 | slept = -1; |
| 548 | else { |
| 549 | os_get_time(&now); |
| 550 | slept = now.sec - global->suspend_time.sec; |
| 551 | } |
| 552 | wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)", |
| 553 | slept); |
| 554 | |
| 555 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { |
| 556 | wpa_drv_resume(wpa_s); |
| 557 | if (wpa_s->wpa_state == WPA_DISCONNECTED) |
| 558 | wpa_supplicant_req_scan(wpa_s, 0, 100000); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | |
| 563 | #ifdef CONFIG_P2P |
| 564 | |
Dmitry Shmidt | 8bd70b7 | 2015-05-26 16:02:19 -0700 | [diff] [blame] | 565 | void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s) |
| 566 | { |
| 567 | /* Notify P2P find has stopped */ |
| 568 | wpas_dbus_signal_p2p_find_stopped(wpa_s); |
| 569 | } |
| 570 | |
| 571 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 572 | void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, |
| 573 | const u8 *dev_addr, int new_device) |
| 574 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 575 | if (new_device) { |
| 576 | /* Create the new peer object */ |
| 577 | wpas_dbus_register_peer(wpa_s, dev_addr); |
| 578 | } |
| 579 | |
| 580 | /* Notify a new peer has been detected*/ |
| 581 | wpas_dbus_signal_peer_device_found(wpa_s, dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | |
| 585 | void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, |
| 586 | const u8 *dev_addr) |
| 587 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 588 | wpas_dbus_unregister_peer(wpa_s, dev_addr); |
| 589 | |
| 590 | /* Create signal on interface object*/ |
| 591 | wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | |
| 595 | void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s, |
| 596 | const struct wpa_ssid *ssid, |
| 597 | const char *role) |
| 598 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 599 | wpas_dbus_signal_p2p_group_removed(wpa_s, role); |
Dmitry Shmidt | 0365883 | 2014-08-13 11:03:49 -0700 | [diff] [blame] | 600 | |
| 601 | wpas_dbus_unregister_p2p_group(wpa_s, ssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | |
| 605 | void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 606 | const u8 *src, u16 dev_passwd_id, u8 go_intent) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 607 | { |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 608 | wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 612 | void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, |
| 613 | struct p2p_go_neg_results *res) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 614 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 615 | wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | |
| 619 | void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s, |
| 620 | int status, const u8 *bssid) |
| 621 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 622 | wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | |
| 626 | void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s, |
| 627 | int freq, const u8 *sa, u8 dialog_token, |
| 628 | u16 update_indic, const u8 *tlvs, |
| 629 | size_t tlvs_len) |
| 630 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 631 | wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token, |
| 632 | update_indic, tlvs, tlvs_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | |
| 636 | void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s, |
| 637 | const u8 *sa, u16 update_indic, |
| 638 | const u8 *tlvs, size_t tlvs_len) |
| 639 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 640 | wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic, |
| 641 | tlvs, tlvs_len); |
| 642 | } |
| 643 | |
| 644 | |
| 645 | /** |
| 646 | * wpas_notify_p2p_provision_discovery - Notification of provision discovery |
| 647 | * @dev_addr: Who sent the request or responded to our request. |
| 648 | * @request: Will be 1 if request, 0 for response. |
| 649 | * @status: Valid only in case of response (0 in case of success) |
| 650 | * @config_methods: WPS config methods |
| 651 | * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method |
| 652 | * |
| 653 | * This can be used to notify: |
| 654 | * - Requests or responses |
| 655 | * - Various config methods |
| 656 | * - Failure condition in case of response |
| 657 | */ |
| 658 | void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s, |
| 659 | const u8 *dev_addr, int request, |
| 660 | enum p2p_prov_disc_status status, |
| 661 | u16 config_methods, |
| 662 | unsigned int generated_pin) |
| 663 | { |
| 664 | wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request, |
| 665 | status, config_methods, |
| 666 | generated_pin); |
| 667 | } |
| 668 | |
| 669 | |
| 670 | void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame^] | 671 | struct wpa_ssid *ssid, int persistent, |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 672 | int client) |
| 673 | { |
| 674 | /* Notify a group has been started */ |
| 675 | wpas_dbus_register_p2p_group(wpa_s, ssid); |
| 676 | |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame^] | 677 | wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 681 | void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, |
| 682 | const char *reason) |
| 683 | { |
| 684 | /* Notify a group formation failed */ |
| 685 | wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason); |
| 686 | } |
| 687 | |
| 688 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 689 | void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s, |
| 690 | struct wps_event_fail *fail) |
| 691 | { |
| 692 | wpas_dbus_signal_p2p_wps_failed(wpa_s, fail); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 693 | } |
| 694 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 695 | |
| 696 | void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s, |
| 697 | const u8 *sa, const u8 *go_dev_addr, |
| 698 | const u8 *bssid, int id, int op_freq) |
| 699 | { |
| 700 | /* Notify a P2P Invitation Request */ |
| 701 | wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid, |
| 702 | id, op_freq); |
| 703 | } |
| 704 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 705 | #endif /* CONFIG_P2P */ |
| 706 | |
| 707 | |
| 708 | static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 709 | const u8 *sta, |
| 710 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 711 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 712 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 713 | wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr); |
| 714 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 715 | /* |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 716 | * Create 'peer-joined' signal on group object -- will also |
| 717 | * check P2P itself. |
| 718 | */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 719 | if (p2p_dev_addr) |
| 720 | wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 721 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 722 | |
| 723 | /* Notify listeners a new station has been authorized */ |
| 724 | wpas_dbus_signal_sta_authorized(wpa_s, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | |
| 728 | static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 729 | const u8 *sta, |
| 730 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 731 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 732 | #ifdef CONFIG_P2P |
| 733 | /* |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 734 | * Create 'peer-disconnected' signal on group object if this |
| 735 | * is a P2P group. |
| 736 | */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 737 | if (p2p_dev_addr) |
| 738 | wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 739 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 740 | |
| 741 | /* Notify listeners a station has been deauthorized */ |
| 742 | wpas_dbus_signal_sta_deauthorized(wpa_s, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | |
| 746 | void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 747 | const u8 *mac_addr, int authorized, |
| 748 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 749 | { |
| 750 | if (authorized) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 751 | wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 752 | else |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 753 | wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 754 | } |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 755 | |
| 756 | |
| 757 | void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth, |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 758 | const char *subject, const char *altsubject[], |
| 759 | int num_altsubject, const char *cert_hash, |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 760 | const struct wpabuf *cert) |
| 761 | { |
| 762 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT |
| 763 | "depth=%d subject='%s'%s%s", |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 764 | depth, subject, cert_hash ? " hash=" : "", |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 765 | cert_hash ? cert_hash : ""); |
| 766 | |
| 767 | if (cert) { |
| 768 | char *cert_hex; |
| 769 | size_t len = wpabuf_len(cert) * 2 + 1; |
| 770 | cert_hex = os_malloc(len); |
| 771 | if (cert_hex) { |
| 772 | wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert), |
| 773 | wpabuf_len(cert)); |
| 774 | wpa_msg_ctrl(wpa_s, MSG_INFO, |
| 775 | WPA_EVENT_EAP_PEER_CERT |
| 776 | "depth=%d subject='%s' cert=%s", |
| 777 | depth, subject, cert_hex); |
| 778 | os_free(cert_hex); |
| 779 | } |
| 780 | } |
| 781 | |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 782 | if (altsubject) { |
| 783 | int i; |
| 784 | |
| 785 | for (i = 0; i < num_altsubject; i++) |
| 786 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT |
| 787 | "depth=%d %s", depth, altsubject[i]); |
| 788 | } |
| 789 | |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 790 | /* notify the old DBus API */ |
| 791 | wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject, |
| 792 | cert_hash, cert); |
| 793 | /* notify the new DBus API */ |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 794 | wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject, |
| 795 | num_altsubject, cert_hash, cert); |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 796 | } |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 797 | |
| 798 | |
| 799 | void wpas_notify_preq(struct wpa_supplicant *wpa_s, |
| 800 | const u8 *addr, const u8 *dst, const u8 *bssid, |
| 801 | const u8 *ie, size_t ie_len, u32 ssi_signal) |
| 802 | { |
| 803 | #ifdef CONFIG_AP |
| 804 | wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal); |
| 805 | #endif /* CONFIG_AP */ |
| 806 | } |
| 807 | |
| 808 | |
| 809 | void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status, |
| 810 | const char *parameter) |
| 811 | { |
| 812 | wpas_dbus_signal_eap_status(wpa_s, status, parameter); |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 813 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS |
| 814 | "status='%s' parameter='%s'", |
| 815 | status, parameter); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 816 | } |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 817 | |
| 818 | |
| 819 | void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s, |
| 820 | struct wpa_ssid *ssid) |
| 821 | { |
| 822 | if (wpa_s->current_ssid != ssid) |
| 823 | return; |
| 824 | |
| 825 | wpa_dbg(wpa_s, MSG_DEBUG, |
| 826 | "Network bssid config changed for the current network - within-ESS roaming %s", |
| 827 | ssid->bssid_set ? "disabled" : "enabled"); |
| 828 | |
| 829 | wpa_drv_roaming(wpa_s, !ssid->bssid_set, |
| 830 | ssid->bssid_set ? ssid->bssid : NULL); |
| 831 | } |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 832 | |
| 833 | |
| 834 | void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s, |
| 835 | struct wpa_ssid *ssid) |
| 836 | { |
| 837 | #ifdef CONFIG_P2P |
| 838 | if (ssid->disabled == 2) { |
| 839 | /* Changed from normal network profile to persistent group */ |
| 840 | ssid->disabled = 0; |
| 841 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
| 842 | ssid->disabled = 2; |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 843 | ssid->p2p_persistent_group = 1; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 844 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
| 845 | } else { |
| 846 | /* Changed from persistent group to normal network profile */ |
| 847 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 848 | ssid->p2p_persistent_group = 0; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 849 | wpas_dbus_register_network(wpa_s, ssid); |
| 850 | } |
| 851 | #endif /* CONFIG_P2P */ |
| 852 | } |