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