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