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