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