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