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