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