notify.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. /*
  2. * wpa_supplicant - Event notifications
  3. * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #include "utils/includes.h"
  9. #include "utils/common.h"
  10. #include "common/wpa_ctrl.h"
  11. #include "config.h"
  12. #include "wpa_supplicant_i.h"
  13. #include "wps_supplicant.h"
  14. #include "dbus/dbus_common.h"
  15. #include "dbus/dbus_old.h"
  16. #include "dbus/dbus_new.h"
  17. #include "rsn_supp/wpa.h"
  18. #include "driver_i.h"
  19. #include "scan.h"
  20. #include "p2p_supplicant.h"
  21. #include "sme.h"
  22. #include "notify.h"
  23. int wpas_notify_supplicant_initialized(struct wpa_global *global)
  24. {
  25. #ifdef CONFIG_DBUS
  26. if (global->params.dbus_ctrl_interface) {
  27. global->dbus = wpas_dbus_init(global);
  28. if (global->dbus == NULL)
  29. return -1;
  30. }
  31. #endif /* CONFIG_DBUS */
  32. return 0;
  33. }
  34. void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
  35. {
  36. #ifdef CONFIG_DBUS
  37. if (global->dbus)
  38. wpas_dbus_deinit(global->dbus);
  39. #endif /* CONFIG_DBUS */
  40. }
  41. int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
  42. {
  43. if (wpa_s->p2p_mgmt)
  44. return 0;
  45. if (wpas_dbus_register_iface(wpa_s))
  46. return -1;
  47. if (wpas_dbus_register_interface(wpa_s))
  48. return -1;
  49. return 0;
  50. }
  51. void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
  52. {
  53. if (wpa_s->p2p_mgmt)
  54. return;
  55. /* unregister interface in old DBus ctrl iface */
  56. wpas_dbus_unregister_iface(wpa_s);
  57. /* unregister interface in new DBus ctrl iface */
  58. wpas_dbus_unregister_interface(wpa_s);
  59. }
  60. void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
  61. enum wpa_states new_state,
  62. enum wpa_states old_state)
  63. {
  64. if (wpa_s->p2p_mgmt)
  65. return;
  66. /* notify the old DBus API */
  67. wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
  68. old_state);
  69. /* notify the new DBus API */
  70. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
  71. if (new_state == WPA_COMPLETED)
  72. wpas_p2p_notif_connected(wpa_s);
  73. else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
  74. wpas_p2p_notif_disconnected(wpa_s);
  75. sme_state_changed(wpa_s);
  76. #ifdef ANDROID
  77. wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
  78. "id=%d state=%d BSSID=" MACSTR " SSID=%s",
  79. wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
  80. new_state,
  81. MAC2STR(wpa_s->bssid),
  82. wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
  83. wpa_ssid_txt(wpa_s->current_ssid->ssid,
  84. wpa_s->current_ssid->ssid_len) : "");
  85. #endif /* ANDROID */
  86. }
  87. void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
  88. {
  89. if (wpa_s->p2p_mgmt)
  90. return;
  91. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
  92. }
  93. void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
  94. {
  95. if (wpa_s->p2p_mgmt)
  96. return;
  97. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
  98. }
  99. void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
  100. {
  101. if (wpa_s->p2p_mgmt)
  102. return;
  103. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
  104. }
  105. void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
  106. {
  107. if (wpa_s->p2p_mgmt)
  108. return;
  109. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
  110. }
  111. void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
  112. {
  113. if (wpa_s->p2p_mgmt)
  114. return;
  115. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
  116. }
  117. void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
  118. struct wpa_ssid *ssid)
  119. {
  120. if (wpa_s->p2p_mgmt)
  121. return;
  122. wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
  123. }
  124. void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
  125. struct wpa_ssid *ssid)
  126. {
  127. if (wpa_s->p2p_mgmt)
  128. return;
  129. wpas_dbus_signal_network_selected(wpa_s, ssid->id);
  130. }
  131. void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
  132. struct wpa_ssid *ssid,
  133. enum wpa_ctrl_req_type rtype,
  134. const char *default_txt)
  135. {
  136. if (wpa_s->p2p_mgmt)
  137. return;
  138. wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
  139. }
  140. void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
  141. {
  142. if (wpa_s->p2p_mgmt)
  143. return;
  144. /* notify the old DBus API */
  145. wpa_supplicant_dbus_notify_scanning(wpa_s);
  146. /* notify the new DBus API */
  147. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
  148. }
  149. void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
  150. {
  151. if (wpa_s->p2p_mgmt)
  152. return;
  153. wpas_dbus_signal_scan_done(wpa_s, success);
  154. }
  155. void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
  156. {
  157. if (wpa_s->p2p_mgmt)
  158. return;
  159. /* notify the old DBus API */
  160. wpa_supplicant_dbus_notify_scan_results(wpa_s);
  161. wpas_wps_notify_scan_results(wpa_s);
  162. }
  163. void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
  164. const struct wps_credential *cred)
  165. {
  166. if (wpa_s->p2p_mgmt)
  167. return;
  168. #ifdef CONFIG_WPS
  169. /* notify the old DBus API */
  170. wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
  171. /* notify the new DBus API */
  172. wpas_dbus_signal_wps_cred(wpa_s, cred);
  173. #endif /* CONFIG_WPS */
  174. }
  175. void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
  176. struct wps_event_m2d *m2d)
  177. {
  178. if (wpa_s->p2p_mgmt)
  179. return;
  180. #ifdef CONFIG_WPS
  181. wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
  182. #endif /* CONFIG_WPS */
  183. }
  184. void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
  185. struct wps_event_fail *fail)
  186. {
  187. if (wpa_s->p2p_mgmt)
  188. return;
  189. #ifdef CONFIG_WPS
  190. wpas_dbus_signal_wps_event_fail(wpa_s, fail);
  191. #endif /* CONFIG_WPS */
  192. }
  193. void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
  194. {
  195. if (wpa_s->p2p_mgmt)
  196. return;
  197. #ifdef CONFIG_WPS
  198. wpas_dbus_signal_wps_event_success(wpa_s);
  199. #endif /* CONFIG_WPS */
  200. }
  201. void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
  202. struct wpa_ssid *ssid)
  203. {
  204. if (wpa_s->p2p_mgmt)
  205. return;
  206. /*
  207. * Networks objects created during any P2P activities should not be
  208. * exposed out. They might/will confuse certain non-P2P aware
  209. * applications since these network objects won't behave like
  210. * regular ones.
  211. */
  212. if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
  213. wpas_dbus_register_network(wpa_s, ssid);
  214. }
  215. void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
  216. struct wpa_ssid *ssid)
  217. {
  218. #ifdef CONFIG_P2P
  219. wpas_dbus_register_persistent_group(wpa_s, ssid);
  220. #endif /* CONFIG_P2P */
  221. }
  222. void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
  223. struct wpa_ssid *ssid)
  224. {
  225. #ifdef CONFIG_P2P
  226. wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
  227. #endif /* CONFIG_P2P */
  228. }
  229. void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
  230. struct wpa_ssid *ssid)
  231. {
  232. if (wpa_s->p2p_mgmt)
  233. return;
  234. if (wpa_s->next_ssid == ssid)
  235. wpa_s->next_ssid = NULL;
  236. if (wpa_s->wpa)
  237. wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
  238. if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
  239. wpas_dbus_unregister_network(wpa_s, ssid->id);
  240. wpas_p2p_network_removed(wpa_s, ssid);
  241. }
  242. void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
  243. u8 bssid[], unsigned int id)
  244. {
  245. if (wpa_s->p2p_mgmt)
  246. return;
  247. wpas_dbus_register_bss(wpa_s, bssid, id);
  248. wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
  249. id, MAC2STR(bssid));
  250. }
  251. void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
  252. u8 bssid[], unsigned int id)
  253. {
  254. if (wpa_s->p2p_mgmt)
  255. return;
  256. wpas_dbus_unregister_bss(wpa_s, bssid, id);
  257. wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
  258. id, MAC2STR(bssid));
  259. }
  260. void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
  261. unsigned int id)
  262. {
  263. if (wpa_s->p2p_mgmt)
  264. return;
  265. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
  266. }
  267. void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
  268. unsigned int id)
  269. {
  270. if (wpa_s->p2p_mgmt)
  271. return;
  272. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
  273. id);
  274. }
  275. void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
  276. unsigned int id)
  277. {
  278. if (wpa_s->p2p_mgmt)
  279. return;
  280. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
  281. id);
  282. }
  283. void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
  284. unsigned int id)
  285. {
  286. if (wpa_s->p2p_mgmt)
  287. return;
  288. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
  289. }
  290. void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
  291. unsigned int id)
  292. {
  293. if (wpa_s->p2p_mgmt)
  294. return;
  295. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
  296. }
  297. void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
  298. unsigned int id)
  299. {
  300. if (wpa_s->p2p_mgmt)
  301. return;
  302. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
  303. }
  304. void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
  305. unsigned int id)
  306. {
  307. if (wpa_s->p2p_mgmt)
  308. return;
  309. #ifdef CONFIG_WPS
  310. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
  311. #endif /* CONFIG_WPS */
  312. }
  313. void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
  314. unsigned int id)
  315. {
  316. if (wpa_s->p2p_mgmt)
  317. return;
  318. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
  319. }
  320. void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
  321. unsigned int id)
  322. {
  323. if (wpa_s->p2p_mgmt)
  324. return;
  325. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
  326. }
  327. void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
  328. {
  329. if (wpa_s->p2p_mgmt)
  330. return;
  331. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
  332. }
  333. void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
  334. {
  335. if (wpa_s->p2p_mgmt)
  336. return;
  337. wpas_dbus_signal_blob_added(wpa_s, name);
  338. }
  339. void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
  340. {
  341. if (wpa_s->p2p_mgmt)
  342. return;
  343. wpas_dbus_signal_blob_removed(wpa_s, name);
  344. }
  345. void wpas_notify_debug_level_changed(struct wpa_global *global)
  346. {
  347. wpas_dbus_signal_debug_level_changed(global);
  348. }
  349. void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
  350. {
  351. wpas_dbus_signal_debug_timestamp_changed(global);
  352. }
  353. void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
  354. {
  355. wpas_dbus_signal_debug_show_keys_changed(global);
  356. }
  357. void wpas_notify_suspend(struct wpa_global *global)
  358. {
  359. struct wpa_supplicant *wpa_s;
  360. os_get_time(&global->suspend_time);
  361. wpa_printf(MSG_DEBUG, "System suspend notification");
  362. for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
  363. wpa_drv_suspend(wpa_s);
  364. }
  365. void wpas_notify_resume(struct wpa_global *global)
  366. {
  367. struct os_time now;
  368. int slept;
  369. struct wpa_supplicant *wpa_s;
  370. if (global->suspend_time.sec == 0)
  371. slept = -1;
  372. else {
  373. os_get_time(&now);
  374. slept = now.sec - global->suspend_time.sec;
  375. }
  376. wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
  377. slept);
  378. for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
  379. wpa_drv_resume(wpa_s);
  380. if (wpa_s->wpa_state == WPA_DISCONNECTED)
  381. wpa_supplicant_req_scan(wpa_s, 0, 100000);
  382. }
  383. }
  384. #ifdef CONFIG_P2P
  385. void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
  386. const u8 *dev_addr, int new_device)
  387. {
  388. if (new_device) {
  389. /* Create the new peer object */
  390. wpas_dbus_register_peer(wpa_s, dev_addr);
  391. }
  392. /* Notify a new peer has been detected*/
  393. wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
  394. }
  395. void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
  396. const u8 *dev_addr)
  397. {
  398. wpas_dbus_unregister_peer(wpa_s, dev_addr);
  399. /* Create signal on interface object*/
  400. wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
  401. }
  402. void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
  403. const struct wpa_ssid *ssid,
  404. const char *role)
  405. {
  406. wpas_dbus_signal_p2p_group_removed(wpa_s, role);
  407. wpas_dbus_unregister_p2p_group(wpa_s, ssid);
  408. }
  409. void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
  410. const u8 *src, u16 dev_passwd_id)
  411. {
  412. wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id);
  413. }
  414. void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
  415. struct p2p_go_neg_results *res)
  416. {
  417. wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
  418. }
  419. void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
  420. int status, const u8 *bssid)
  421. {
  422. wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
  423. }
  424. void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
  425. int freq, const u8 *sa, u8 dialog_token,
  426. u16 update_indic, const u8 *tlvs,
  427. size_t tlvs_len)
  428. {
  429. wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
  430. update_indic, tlvs, tlvs_len);
  431. }
  432. void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
  433. const u8 *sa, u16 update_indic,
  434. const u8 *tlvs, size_t tlvs_len)
  435. {
  436. wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
  437. tlvs, tlvs_len);
  438. }
  439. /**
  440. * wpas_notify_p2p_provision_discovery - Notification of provision discovery
  441. * @dev_addr: Who sent the request or responded to our request.
  442. * @request: Will be 1 if request, 0 for response.
  443. * @status: Valid only in case of response (0 in case of success)
  444. * @config_methods: WPS config methods
  445. * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
  446. *
  447. * This can be used to notify:
  448. * - Requests or responses
  449. * - Various config methods
  450. * - Failure condition in case of response
  451. */
  452. void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
  453. const u8 *dev_addr, int request,
  454. enum p2p_prov_disc_status status,
  455. u16 config_methods,
  456. unsigned int generated_pin)
  457. {
  458. wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
  459. status, config_methods,
  460. generated_pin);
  461. }
  462. void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
  463. struct wpa_ssid *ssid, int network_id,
  464. int client)
  465. {
  466. /* Notify a group has been started */
  467. wpas_dbus_register_p2p_group(wpa_s, ssid);
  468. wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
  469. }
  470. void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
  471. struct wps_event_fail *fail)
  472. {
  473. wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
  474. }
  475. #endif /* CONFIG_P2P */
  476. static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
  477. const u8 *sta,
  478. const u8 *p2p_dev_addr)
  479. {
  480. #ifdef CONFIG_P2P
  481. wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
  482. /*
  483. * Create 'peer-joined' signal on group object -- will also
  484. * check P2P itself.
  485. */
  486. wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
  487. #endif /* CONFIG_P2P */
  488. /* Notify listeners a new station has been authorized */
  489. wpas_dbus_signal_sta_authorized(wpa_s, sta);
  490. }
  491. static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
  492. const u8 *sta,
  493. const u8 *p2p_dev_addr)
  494. {
  495. #ifdef CONFIG_P2P
  496. /*
  497. * Create 'peer-disconnected' signal on group object if this
  498. * is a P2P group.
  499. */
  500. wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
  501. #endif /* CONFIG_P2P */
  502. /* Notify listeners a station has been deauthorized */
  503. wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
  504. }
  505. void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
  506. const u8 *mac_addr, int authorized,
  507. const u8 *p2p_dev_addr)
  508. {
  509. if (authorized)
  510. wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
  511. else
  512. wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
  513. }
  514. void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
  515. const char *subject, const char *cert_hash,
  516. const struct wpabuf *cert)
  517. {
  518. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
  519. "depth=%d subject='%s'%s%s",
  520. depth, subject,
  521. cert_hash ? " hash=" : "",
  522. cert_hash ? cert_hash : "");
  523. if (cert) {
  524. char *cert_hex;
  525. size_t len = wpabuf_len(cert) * 2 + 1;
  526. cert_hex = os_malloc(len);
  527. if (cert_hex) {
  528. wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
  529. wpabuf_len(cert));
  530. wpa_msg_ctrl(wpa_s, MSG_INFO,
  531. WPA_EVENT_EAP_PEER_CERT
  532. "depth=%d subject='%s' cert=%s",
  533. depth, subject, cert_hex);
  534. os_free(cert_hex);
  535. }
  536. }
  537. /* notify the old DBus API */
  538. wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
  539. cert_hash, cert);
  540. /* notify the new DBus API */
  541. wpas_dbus_signal_certification(wpa_s, depth, subject, cert_hash, cert);
  542. }
  543. void wpas_notify_preq(struct wpa_supplicant *wpa_s,
  544. const u8 *addr, const u8 *dst, const u8 *bssid,
  545. const u8 *ie, size_t ie_len, u32 ssi_signal)
  546. {
  547. #ifdef CONFIG_AP
  548. wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
  549. #endif /* CONFIG_AP */
  550. }
  551. void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
  552. const char *parameter)
  553. {
  554. wpas_dbus_signal_eap_status(wpa_s, status, parameter);
  555. wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
  556. "status='%s' parameter='%s'",
  557. status, parameter);
  558. }
  559. void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
  560. struct wpa_ssid *ssid)
  561. {
  562. if (wpa_s->current_ssid != ssid)
  563. return;
  564. wpa_dbg(wpa_s, MSG_DEBUG,
  565. "Network bssid config changed for the current network - within-ESS roaming %s",
  566. ssid->bssid_set ? "disabled" : "enabled");
  567. wpa_drv_roaming(wpa_s, !ssid->bssid_set,
  568. ssid->bssid_set ? ssid->bssid : NULL);
  569. }