Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * wpa_supplicant - Event notifications |
| 3 | * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi> |
| 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
| 12 | #include "common/wpa_ctrl.h" |
| 13 | #include "config.h" |
| 14 | #include "wpa_supplicant_i.h" |
| 15 | #include "wps_supplicant.h" |
| 16 | #include "dbus/dbus_common.h" |
| 17 | #include "dbus/dbus_old.h" |
| 18 | #include "dbus/dbus_new.h" |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 19 | #include "rsn_supp/wpa.h" |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 20 | #include "fst/fst.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 21 | #include "driver_i.h" |
| 22 | #include "scan.h" |
| 23 | #include "p2p_supplicant.h" |
| 24 | #include "sme.h" |
| 25 | #include "notify.h" |
Roshan Pius | 9322a34 | 2016-12-12 14:45:02 -0800 | [diff] [blame] | 26 | #include "hidl/hidl.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 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 | |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 38 | #ifdef CONFIG_HIDL |
| 39 | global->hidl = wpas_hidl_init(global); |
| 40 | if (!global->hidl) |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 41 | return -1; |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 42 | #endif /* CONFIG_HIDL */ |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 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 | |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 55 | #ifdef CONFIG_HIDL |
| 56 | if (global->hidl) |
| 57 | wpas_hidl_deinit(global->hidl); |
| 58 | #endif /* CONFIG_HIDL */ |
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 | { |
Roshan Pius | d6d8b8d | 2016-11-08 14:45:26 -0800 | [diff] [blame] | 64 | if (!wpa_s->p2p_mgmt) { |
| 65 | if (wpas_dbus_register_iface(wpa_s)) |
| 66 | return -1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 67 | |
Roshan Pius | d6d8b8d | 2016-11-08 14:45:26 -0800 | [diff] [blame] | 68 | if (wpas_dbus_register_interface(wpa_s)) |
| 69 | return -1; |
| 70 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 71 | |
Roshan Pius | d6d8b8d | 2016-11-08 14:45:26 -0800 | [diff] [blame] | 72 | /* HIDL interface wants to keep track of the P2P mgmt iface. */ |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 73 | if (wpas_hidl_register_interface(wpa_s)) |
Roshan Pius | 54e763a | 2016-07-06 15:41:53 -0700 | [diff] [blame] | 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 | { |
Roshan Pius | d6d8b8d | 2016-11-08 14:45:26 -0800 | [diff] [blame] | 82 | if (!wpa_s->p2p_mgmt) { |
| 83 | /* unregister interface in old DBus ctrl iface */ |
| 84 | wpas_dbus_unregister_iface(wpa_s); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 85 | |
Roshan Pius | d6d8b8d | 2016-11-08 14:45:26 -0800 | [diff] [blame] | 86 | /* unregister interface in new DBus ctrl iface */ |
| 87 | wpas_dbus_unregister_interface(wpa_s); |
| 88 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 89 | |
Roshan Pius | d6d8b8d | 2016-11-08 14:45:26 -0800 | [diff] [blame] | 90 | /* HIDL interface wants to keep track of the P2P mgmt iface. */ |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 91 | wpas_hidl_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 | |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 137 | wpas_hidl_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); |
Roshan Pius | 0974e96 | 2016-12-12 17:05:51 -0800 | [diff] [blame] | 147 | |
Roshan Pius | be15877 | 2017-03-10 17:54:37 -0800 | [diff] [blame] | 148 | wpas_hidl_notify_disconnect_reason(wpa_s); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | |
Dmitry Shmidt | 31a29cc | 2016-03-09 15:58:17 -0800 | [diff] [blame] | 152 | void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s) |
| 153 | { |
| 154 | if (wpa_s->p2p_mgmt) |
| 155 | return; |
| 156 | |
| 157 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE); |
Roshan Pius | 0974e96 | 2016-12-12 17:05:51 -0800 | [diff] [blame] | 158 | |
| 159 | wpas_hidl_notify_assoc_reject(wpa_s); |
Dmitry Shmidt | 31a29cc | 2016-03-09 15:58:17 -0800 | [diff] [blame] | 160 | } |
| 161 | |
Roshan Pius | 38e9676 | 2017-01-23 14:52:00 -0800 | [diff] [blame] | 162 | void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) { |
| 163 | if (wpa_s->p2p_mgmt) |
| 164 | return; |
| 165 | |
| 166 | wpas_hidl_notify_auth_timeout(wpa_s); |
| 167 | } |
Dmitry Shmidt | 31a29cc | 2016-03-09 15:58:17 -0800 | [diff] [blame] | 168 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 169 | void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) |
| 170 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 171 | if (wpa_s->p2p_mgmt) |
| 172 | return; |
| 173 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 174 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); |
| 175 | } |
| 176 | |
| 177 | |
| 178 | void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) |
| 179 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 180 | if (wpa_s->p2p_mgmt) |
| 181 | return; |
| 182 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 183 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); |
| 184 | } |
| 185 | |
| 186 | |
| 187 | void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) |
| 188 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 189 | if (wpa_s->p2p_mgmt) |
| 190 | return; |
| 191 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 192 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); |
Roshan Pius | e746d6b | 2017-03-21 08:53:04 -0700 | [diff] [blame^] | 193 | |
| 194 | wpas_hidl_notify_bssid_changed(wpa_s); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | |
| 198 | void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s) |
| 199 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 200 | if (wpa_s->p2p_mgmt) |
| 201 | return; |
| 202 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 203 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE); |
| 204 | } |
| 205 | |
| 206 | |
| 207 | void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, |
| 208 | struct wpa_ssid *ssid) |
| 209 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 210 | if (wpa_s->p2p_mgmt) |
| 211 | return; |
| 212 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 213 | wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); |
| 214 | } |
| 215 | |
| 216 | |
| 217 | void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, |
| 218 | struct wpa_ssid *ssid) |
| 219 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 220 | if (wpa_s->p2p_mgmt) |
| 221 | return; |
| 222 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 223 | wpas_dbus_signal_network_selected(wpa_s, ssid->id); |
| 224 | } |
| 225 | |
| 226 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 227 | void wpas_notify_network_request(struct wpa_supplicant *wpa_s, |
| 228 | struct wpa_ssid *ssid, |
| 229 | enum wpa_ctrl_req_type rtype, |
| 230 | const char *default_txt) |
| 231 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 232 | if (wpa_s->p2p_mgmt) |
| 233 | return; |
| 234 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 235 | wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt); |
Roshan Pius | 65628ce | 2016-08-17 13:10:23 -0700 | [diff] [blame] | 236 | |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 237 | wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 241 | void wpas_notify_scanning(struct wpa_supplicant *wpa_s) |
| 242 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 243 | if (wpa_s->p2p_mgmt) |
| 244 | return; |
| 245 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 246 | /* notify the old DBus API */ |
| 247 | wpa_supplicant_dbus_notify_scanning(wpa_s); |
| 248 | |
| 249 | /* notify the new DBus API */ |
| 250 | wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); |
| 251 | } |
| 252 | |
| 253 | |
| 254 | void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) |
| 255 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 256 | if (wpa_s->p2p_mgmt) |
| 257 | return; |
| 258 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 259 | wpas_dbus_signal_scan_done(wpa_s, success); |
| 260 | } |
| 261 | |
| 262 | |
| 263 | void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) |
| 264 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 265 | if (wpa_s->p2p_mgmt) |
| 266 | return; |
| 267 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 268 | /* notify the old DBus API */ |
| 269 | wpa_supplicant_dbus_notify_scan_results(wpa_s); |
| 270 | |
| 271 | wpas_wps_notify_scan_results(wpa_s); |
| 272 | } |
| 273 | |
| 274 | |
| 275 | void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, |
| 276 | const struct wps_credential *cred) |
| 277 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 278 | if (wpa_s->p2p_mgmt) |
| 279 | return; |
| 280 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 281 | #ifdef CONFIG_WPS |
| 282 | /* notify the old DBus API */ |
| 283 | wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); |
| 284 | /* notify the new DBus API */ |
| 285 | wpas_dbus_signal_wps_cred(wpa_s, cred); |
| 286 | #endif /* CONFIG_WPS */ |
| 287 | } |
| 288 | |
| 289 | |
| 290 | void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, |
| 291 | struct wps_event_m2d *m2d) |
| 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_m2d(wpa_s, m2d); |
| 298 | #endif /* CONFIG_WPS */ |
| 299 | } |
| 300 | |
| 301 | |
| 302 | void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, |
| 303 | struct wps_event_fail *fail) |
| 304 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 305 | if (wpa_s->p2p_mgmt) |
| 306 | return; |
| 307 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 308 | #ifdef CONFIG_WPS |
| 309 | wpas_dbus_signal_wps_event_fail(wpa_s, fail); |
Roshan Pius | 1493275 | 2017-01-11 09:48:58 -0800 | [diff] [blame] | 310 | |
| 311 | wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr, |
| 312 | fail->config_error, |
| 313 | fail->error_indication); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 314 | #endif /* CONFIG_WPS */ |
| 315 | } |
| 316 | |
| 317 | |
| 318 | void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) |
| 319 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 320 | if (wpa_s->p2p_mgmt) |
| 321 | return; |
| 322 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 323 | #ifdef CONFIG_WPS |
| 324 | wpas_dbus_signal_wps_event_success(wpa_s); |
Roshan Pius | 1493275 | 2017-01-11 09:48:58 -0800 | [diff] [blame] | 325 | |
| 326 | wpas_hidl_notify_wps_event_success(wpa_s); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 327 | #endif /* CONFIG_WPS */ |
| 328 | } |
| 329 | |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 330 | void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s) |
| 331 | { |
| 332 | if (wpa_s->p2p_mgmt) |
| 333 | return; |
| 334 | |
| 335 | #ifdef CONFIG_WPS |
| 336 | wpas_dbus_signal_wps_event_pbc_overlap(wpa_s); |
Roshan Pius | 1493275 | 2017-01-11 09:48:58 -0800 | [diff] [blame] | 337 | |
| 338 | wpas_hidl_notify_wps_event_pbc_overlap(wpa_s); |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 339 | #endif /* CONFIG_WPS */ |
| 340 | } |
| 341 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 342 | |
| 343 | void wpas_notify_network_added(struct wpa_supplicant *wpa_s, |
| 344 | struct wpa_ssid *ssid) |
| 345 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 346 | if (wpa_s->p2p_mgmt) |
| 347 | return; |
| 348 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 349 | /* |
| 350 | * Networks objects created during any P2P activities should not be |
| 351 | * exposed out. They might/will confuse certain non-P2P aware |
| 352 | * applications since these network objects won't behave like |
| 353 | * regular ones. |
| 354 | */ |
Roshan Pius | d385445 | 2016-07-07 16:46:41 -0700 | [diff] [blame] | 355 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 356 | wpas_dbus_register_network(wpa_s, ssid); |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 357 | wpas_hidl_register_network(wpa_s, ssid); |
Roshan Pius | d385445 | 2016-07-07 16:46:41 -0700 | [diff] [blame] | 358 | } |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | |
| 362 | void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s, |
| 363 | struct wpa_ssid *ssid) |
| 364 | { |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 365 | #ifdef CONFIG_P2P |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 366 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 367 | #endif /* CONFIG_P2P */ |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | |
| 371 | void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s, |
| 372 | struct wpa_ssid *ssid) |
| 373 | { |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 374 | #ifdef CONFIG_P2P |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 375 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 376 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | |
| 380 | void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, |
| 381 | struct wpa_ssid *ssid) |
| 382 | { |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 383 | if (wpa_s->next_ssid == ssid) |
| 384 | wpa_s->next_ssid = NULL; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 385 | if (wpa_s->wpa) |
| 386 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); |
Dmitry Shmidt | cc00d5d | 2015-05-04 10:34:12 -0700 | [diff] [blame] | 387 | if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s && |
Roshan Pius | d385445 | 2016-07-07 16:46:41 -0700 | [diff] [blame] | 388 | !wpa_s->p2p_mgmt) { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 389 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
Roshan Pius | 57ffbcf | 2016-09-27 09:12:46 -0700 | [diff] [blame] | 390 | wpas_hidl_unregister_network(wpa_s, ssid); |
Roshan Pius | d385445 | 2016-07-07 16:46:41 -0700 | [diff] [blame] | 391 | } |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 392 | if (network_is_persistent_group(ssid)) |
| 393 | wpas_notify_persistent_group_removed(wpa_s, ssid); |
| 394 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 395 | wpas_p2p_network_removed(wpa_s, ssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | |
| 399 | void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, |
| 400 | u8 bssid[], 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_register_bss(wpa_s, bssid, id); |
| 406 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, |
| 407 | id, MAC2STR(bssid)); |
| 408 | } |
| 409 | |
| 410 | |
| 411 | void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, |
| 412 | u8 bssid[], 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_unregister_bss(wpa_s, bssid, id); |
| 418 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, |
| 419 | id, MAC2STR(bssid)); |
| 420 | } |
| 421 | |
| 422 | |
| 423 | void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, |
| 424 | unsigned int id) |
| 425 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 426 | if (wpa_s->p2p_mgmt) |
| 427 | return; |
| 428 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 429 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); |
| 430 | } |
| 431 | |
| 432 | |
| 433 | void wpas_notify_bss_signal_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_SIGNAL, |
| 440 | id); |
| 441 | } |
| 442 | |
| 443 | |
| 444 | void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s, |
| 445 | unsigned int id) |
| 446 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 447 | if (wpa_s->p2p_mgmt) |
| 448 | return; |
| 449 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 450 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY, |
| 451 | id); |
| 452 | } |
| 453 | |
| 454 | |
| 455 | void wpas_notify_bss_mode_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_MODE, id); |
| 462 | } |
| 463 | |
| 464 | |
| 465 | void wpas_notify_bss_wpaie_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 | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 471 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id); |
| 472 | } |
| 473 | |
| 474 | |
| 475 | void wpas_notify_bss_rsnie_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_RSN, id); |
| 482 | } |
| 483 | |
| 484 | |
| 485 | void wpas_notify_bss_wps_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 | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 491 | #ifdef CONFIG_WPS |
| 492 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id); |
| 493 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | |
| 497 | void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s, |
| 498 | unsigned int id) |
| 499 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 500 | if (wpa_s->p2p_mgmt) |
| 501 | return; |
| 502 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 503 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id); |
| 504 | } |
| 505 | |
| 506 | |
| 507 | void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s, |
| 508 | unsigned int id) |
| 509 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 510 | if (wpa_s->p2p_mgmt) |
| 511 | return; |
| 512 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 513 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id); |
| 514 | } |
| 515 | |
| 516 | |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 517 | void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id) |
| 518 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 519 | if (wpa_s->p2p_mgmt) |
| 520 | return; |
| 521 | |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 522 | wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id); |
| 523 | } |
| 524 | |
| 525 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 526 | void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) |
| 527 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 528 | if (wpa_s->p2p_mgmt) |
| 529 | return; |
| 530 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 531 | wpas_dbus_signal_blob_added(wpa_s, name); |
| 532 | } |
| 533 | |
| 534 | |
| 535 | void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) |
| 536 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 537 | if (wpa_s->p2p_mgmt) |
| 538 | return; |
| 539 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 540 | wpas_dbus_signal_blob_removed(wpa_s, name); |
| 541 | } |
| 542 | |
| 543 | |
| 544 | void wpas_notify_debug_level_changed(struct wpa_global *global) |
| 545 | { |
| 546 | wpas_dbus_signal_debug_level_changed(global); |
| 547 | } |
| 548 | |
| 549 | |
| 550 | void wpas_notify_debug_timestamp_changed(struct wpa_global *global) |
| 551 | { |
| 552 | wpas_dbus_signal_debug_timestamp_changed(global); |
| 553 | } |
| 554 | |
| 555 | |
| 556 | void wpas_notify_debug_show_keys_changed(struct wpa_global *global) |
| 557 | { |
| 558 | wpas_dbus_signal_debug_show_keys_changed(global); |
| 559 | } |
| 560 | |
| 561 | |
| 562 | void wpas_notify_suspend(struct wpa_global *global) |
| 563 | { |
| 564 | struct wpa_supplicant *wpa_s; |
| 565 | |
| 566 | os_get_time(&global->suspend_time); |
| 567 | wpa_printf(MSG_DEBUG, "System suspend notification"); |
| 568 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) |
| 569 | wpa_drv_suspend(wpa_s); |
| 570 | } |
| 571 | |
| 572 | |
| 573 | void wpas_notify_resume(struct wpa_global *global) |
| 574 | { |
| 575 | struct os_time now; |
| 576 | int slept; |
| 577 | struct wpa_supplicant *wpa_s; |
| 578 | |
| 579 | if (global->suspend_time.sec == 0) |
| 580 | slept = -1; |
| 581 | else { |
| 582 | os_get_time(&now); |
| 583 | slept = now.sec - global->suspend_time.sec; |
| 584 | } |
| 585 | wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)", |
| 586 | slept); |
| 587 | |
| 588 | for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { |
| 589 | wpa_drv_resume(wpa_s); |
| 590 | if (wpa_s->wpa_state == WPA_DISCONNECTED) |
| 591 | wpa_supplicant_req_scan(wpa_s, 0, 100000); |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | |
| 596 | #ifdef CONFIG_P2P |
| 597 | |
Dmitry Shmidt | 8bd70b7 | 2015-05-26 16:02:19 -0700 | [diff] [blame] | 598 | void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s) |
| 599 | { |
| 600 | /* Notify P2P find has stopped */ |
| 601 | wpas_dbus_signal_p2p_find_stopped(wpa_s); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 602 | |
| 603 | wpas_hidl_notify_p2p_find_stopped(wpa_s); |
Dmitry Shmidt | 8bd70b7 | 2015-05-26 16:02:19 -0700 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 607 | void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 608 | const u8 *addr, const struct p2p_peer_info *info, |
| 609 | const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len, |
| 610 | int new_device) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 611 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 612 | if (new_device) { |
| 613 | /* Create the new peer object */ |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 614 | wpas_dbus_register_peer(wpa_s, info->p2p_device_addr); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | /* Notify a new peer has been detected*/ |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 618 | wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr); |
| 619 | |
| 620 | wpas_hidl_notify_p2p_device_found(wpa_s, addr, info, |
| 621 | peer_wfd_device_info, |
| 622 | peer_wfd_device_info_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | |
| 626 | void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, |
| 627 | const u8 *dev_addr) |
| 628 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 629 | wpas_dbus_unregister_peer(wpa_s, dev_addr); |
| 630 | |
| 631 | /* Create signal on interface object*/ |
| 632 | wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 633 | |
| 634 | wpas_hidl_notify_p2p_device_lost(wpa_s, dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | |
| 638 | void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s, |
| 639 | const struct wpa_ssid *ssid, |
| 640 | const char *role) |
| 641 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 642 | wpas_dbus_signal_p2p_group_removed(wpa_s, role); |
Dmitry Shmidt | 0365883 | 2014-08-13 11:03:49 -0700 | [diff] [blame] | 643 | |
| 644 | wpas_dbus_unregister_p2p_group(wpa_s, ssid); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 645 | |
| 646 | wpas_hidl_notify_p2p_group_removed(wpa_s, ssid, role); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | |
| 650 | void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 651 | const u8 *src, u16 dev_passwd_id, u8 go_intent) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 652 | { |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 653 | wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 654 | |
| 655 | wpas_hidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 659 | void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, |
| 660 | struct p2p_go_neg_results *res) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 661 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 662 | wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 663 | |
| 664 | wpas_hidl_notify_p2p_go_neg_completed(wpa_s, res); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | |
| 668 | void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s, |
| 669 | int status, const u8 *bssid) |
| 670 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 671 | wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 672 | |
| 673 | wpas_hidl_notify_p2p_invitation_result(wpa_s, status, bssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | |
| 677 | void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s, |
| 678 | int freq, const u8 *sa, u8 dialog_token, |
| 679 | u16 update_indic, const u8 *tlvs, |
| 680 | size_t tlvs_len) |
| 681 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 682 | wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token, |
| 683 | update_indic, tlvs, tlvs_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | |
| 687 | void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s, |
| 688 | const u8 *sa, u16 update_indic, |
| 689 | const u8 *tlvs, size_t tlvs_len) |
| 690 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 691 | wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic, |
| 692 | tlvs, tlvs_len); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 693 | |
| 694 | wpas_hidl_notify_p2p_sd_response(wpa_s, sa, update_indic, |
| 695 | tlvs, tlvs_len); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | |
| 699 | /** |
| 700 | * wpas_notify_p2p_provision_discovery - Notification of provision discovery |
| 701 | * @dev_addr: Who sent the request or responded to our request. |
| 702 | * @request: Will be 1 if request, 0 for response. |
| 703 | * @status: Valid only in case of response (0 in case of success) |
| 704 | * @config_methods: WPS config methods |
| 705 | * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method |
| 706 | * |
| 707 | * This can be used to notify: |
| 708 | * - Requests or responses |
| 709 | * - Various config methods |
| 710 | * - Failure condition in case of response |
| 711 | */ |
| 712 | void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s, |
| 713 | const u8 *dev_addr, int request, |
| 714 | enum p2p_prov_disc_status status, |
| 715 | u16 config_methods, |
| 716 | unsigned int generated_pin) |
| 717 | { |
| 718 | wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request, |
| 719 | status, config_methods, |
| 720 | generated_pin); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 721 | |
| 722 | wpas_hidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request, |
| 723 | status, config_methods, |
| 724 | generated_pin); |
| 725 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | |
| 729 | void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 730 | struct wpa_ssid *ssid, int persistent, |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 731 | int client, const u8 *ip) |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 732 | { |
| 733 | /* Notify a group has been started */ |
| 734 | wpas_dbus_register_p2p_group(wpa_s, ssid); |
| 735 | |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 736 | wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 737 | |
| 738 | wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client, ip); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 742 | void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, |
| 743 | const char *reason) |
| 744 | { |
| 745 | /* Notify a group formation failed */ |
| 746 | wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 747 | |
| 748 | wpas_hidl_notify_p2p_group_formation_failure(wpa_s, reason); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 752 | void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s, |
| 753 | struct wps_event_fail *fail) |
| 754 | { |
| 755 | wpas_dbus_signal_p2p_wps_failed(wpa_s, fail); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 756 | } |
| 757 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 758 | |
| 759 | void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s, |
| 760 | const u8 *sa, const u8 *go_dev_addr, |
| 761 | const u8 *bssid, int id, int op_freq) |
| 762 | { |
| 763 | /* Notify a P2P Invitation Request */ |
| 764 | wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid, |
| 765 | id, op_freq); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 766 | |
| 767 | wpas_hidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid, |
| 768 | id, op_freq); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 769 | } |
| 770 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 771 | #endif /* CONFIG_P2P */ |
| 772 | |
| 773 | |
| 774 | static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 775 | const u8 *sta, |
| 776 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 777 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 778 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 779 | wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr); |
| 780 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 781 | /* |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 782 | * Create 'peer-joined' signal on group object -- will also |
| 783 | * check P2P itself. |
| 784 | */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 785 | if (p2p_dev_addr) |
| 786 | wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 787 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 788 | |
| 789 | /* Notify listeners a new station has been authorized */ |
| 790 | wpas_dbus_signal_sta_authorized(wpa_s, sta); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 791 | |
| 792 | wpas_hidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | |
| 796 | static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 797 | const u8 *sta, |
| 798 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 799 | { |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 800 | #ifdef CONFIG_P2P |
| 801 | /* |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 802 | * Create 'peer-disconnected' signal on group object if this |
| 803 | * is a P2P group. |
| 804 | */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 805 | if (p2p_dev_addr) |
| 806 | wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr); |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 807 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 808 | |
| 809 | /* Notify listeners a station has been deauthorized */ |
| 810 | wpas_dbus_signal_sta_deauthorized(wpa_s, sta); |
Roshan Pius | fd2fd66 | 2017-01-23 13:41:57 -0800 | [diff] [blame] | 811 | |
| 812 | wpas_hidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | |
| 816 | void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 817 | const u8 *mac_addr, int authorized, |
| 818 | const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 819 | { |
| 820 | if (authorized) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 821 | wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 822 | else |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 823 | wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 824 | } |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 825 | |
| 826 | |
| 827 | void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth, |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 828 | const char *subject, const char *altsubject[], |
| 829 | int num_altsubject, const char *cert_hash, |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 830 | const struct wpabuf *cert) |
| 831 | { |
| 832 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT |
| 833 | "depth=%d subject='%s'%s%s", |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 834 | depth, subject, cert_hash ? " hash=" : "", |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 835 | cert_hash ? cert_hash : ""); |
| 836 | |
| 837 | if (cert) { |
| 838 | char *cert_hex; |
| 839 | size_t len = wpabuf_len(cert) * 2 + 1; |
| 840 | cert_hex = os_malloc(len); |
| 841 | if (cert_hex) { |
| 842 | wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert), |
| 843 | wpabuf_len(cert)); |
| 844 | wpa_msg_ctrl(wpa_s, MSG_INFO, |
| 845 | WPA_EVENT_EAP_PEER_CERT |
| 846 | "depth=%d subject='%s' cert=%s", |
| 847 | depth, subject, cert_hex); |
| 848 | os_free(cert_hex); |
| 849 | } |
| 850 | } |
| 851 | |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 852 | if (altsubject) { |
| 853 | int i; |
| 854 | |
| 855 | for (i = 0; i < num_altsubject; i++) |
| 856 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT |
| 857 | "depth=%d %s", depth, altsubject[i]); |
| 858 | } |
| 859 | |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 860 | /* notify the old DBus API */ |
| 861 | wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject, |
| 862 | cert_hash, cert); |
| 863 | /* notify the new DBus API */ |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 864 | wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject, |
| 865 | num_altsubject, cert_hash, cert); |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 866 | } |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 867 | |
| 868 | |
| 869 | void wpas_notify_preq(struct wpa_supplicant *wpa_s, |
| 870 | const u8 *addr, const u8 *dst, const u8 *bssid, |
| 871 | const u8 *ie, size_t ie_len, u32 ssi_signal) |
| 872 | { |
| 873 | #ifdef CONFIG_AP |
| 874 | wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal); |
| 875 | #endif /* CONFIG_AP */ |
| 876 | } |
| 877 | |
| 878 | |
| 879 | void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status, |
| 880 | const char *parameter) |
| 881 | { |
| 882 | wpas_dbus_signal_eap_status(wpa_s, status, parameter); |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 883 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS |
| 884 | "status='%s' parameter='%s'", |
| 885 | status, parameter); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 886 | } |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 887 | |
| 888 | |
| 889 | void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s, |
| 890 | struct wpa_ssid *ssid) |
| 891 | { |
| 892 | if (wpa_s->current_ssid != ssid) |
| 893 | return; |
| 894 | |
| 895 | wpa_dbg(wpa_s, MSG_DEBUG, |
| 896 | "Network bssid config changed for the current network - within-ESS roaming %s", |
| 897 | ssid->bssid_set ? "disabled" : "enabled"); |
| 898 | |
| 899 | wpa_drv_roaming(wpa_s, !ssid->bssid_set, |
| 900 | ssid->bssid_set ? ssid->bssid : NULL); |
| 901 | } |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 902 | |
| 903 | |
| 904 | void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s, |
| 905 | struct wpa_ssid *ssid) |
| 906 | { |
| 907 | #ifdef CONFIG_P2P |
| 908 | if (ssid->disabled == 2) { |
| 909 | /* Changed from normal network profile to persistent group */ |
| 910 | ssid->disabled = 0; |
| 911 | wpas_dbus_unregister_network(wpa_s, ssid->id); |
| 912 | ssid->disabled = 2; |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 913 | ssid->p2p_persistent_group = 1; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 914 | wpas_dbus_register_persistent_group(wpa_s, ssid); |
| 915 | } else { |
| 916 | /* Changed from persistent group to normal network profile */ |
| 917 | wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 918 | ssid->p2p_persistent_group = 0; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 919 | wpas_dbus_register_network(wpa_s, ssid); |
| 920 | } |
| 921 | #endif /* CONFIG_P2P */ |
| 922 | } |
Roshan Pius | 04a9d74 | 2016-12-12 12:40:46 -0800 | [diff] [blame] | 923 | |
| 924 | void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid, |
| 925 | const char *result, |
| 926 | const struct wpa_bss_anqp *anqp) |
| 927 | { |
| 928 | #ifdef CONFIG_INTERWORKING |
| 929 | if (!wpa_s || !bssid || !anqp) |
| 930 | return; |
Roshan Pius | 9322a34 | 2016-12-12 14:45:02 -0800 | [diff] [blame] | 931 | |
| 932 | wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp); |
Roshan Pius | 04a9d74 | 2016-12-12 12:40:46 -0800 | [diff] [blame] | 933 | #endif /* CONFIG_INTERWORKING */ |
| 934 | } |
| 935 | |
| 936 | void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid, |
| 937 | const char* file_name, const u8* image, |
| 938 | u32 image_length) |
| 939 | { |
| 940 | #ifdef CONFIG_HS20 |
| 941 | if (!wpa_s || !bssid || !file_name || !image) |
| 942 | return; |
Roshan Pius | 9322a34 | 2016-12-12 14:45:02 -0800 | [diff] [blame] | 943 | |
| 944 | wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image, |
| 945 | image_length); |
Roshan Pius | 04a9d74 | 2016-12-12 12:40:46 -0800 | [diff] [blame] | 946 | #endif /* CONFIG_HS20 */ |
| 947 | } |
| 948 | |
| 949 | void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s, |
| 950 | const char* url, |
| 951 | u8 osu_method) |
| 952 | { |
| 953 | #ifdef CONFIG_HS20 |
| 954 | if (!wpa_s || !url) |
| 955 | return; |
Roshan Pius | 9322a34 | 2016-12-12 14:45:02 -0800 | [diff] [blame] | 956 | |
| 957 | wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method); |
Roshan Pius | 04a9d74 | 2016-12-12 12:40:46 -0800 | [diff] [blame] | 958 | #endif /* CONFIG_HS20 */ |
| 959 | } |
| 960 | |
| 961 | void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s, |
| 962 | u8 code, u16 reauth_delay, |
| 963 | const char *url) |
| 964 | { |
| 965 | #ifdef CONFIG_HS20 |
| 966 | if (!wpa_s || !url) |
| 967 | return; |
Roshan Pius | 9322a34 | 2016-12-12 14:45:02 -0800 | [diff] [blame] | 968 | |
| 969 | wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay, |
| 970 | url); |
Roshan Pius | 04a9d74 | 2016-12-12 12:40:46 -0800 | [diff] [blame] | 971 | #endif /* CONFIG_HS20 */ |
| 972 | } |