notify.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  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->next_ssid == ssid)
  233. wpa_s->next_ssid = NULL;
  234. if (wpa_s->wpa)
  235. wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
  236. if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
  237. !wpa_s->p2p_mgmt)
  238. wpas_dbus_unregister_network(wpa_s, ssid->id);
  239. if (network_is_persistent_group(ssid))
  240. wpas_notify_persistent_group_removed(wpa_s, ssid);
  241. wpas_p2p_network_removed(wpa_s, ssid);
  242. }
  243. void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
  244. u8 bssid[], unsigned int id)
  245. {
  246. if (wpa_s->p2p_mgmt)
  247. return;
  248. wpas_dbus_register_bss(wpa_s, bssid, id);
  249. wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
  250. id, MAC2STR(bssid));
  251. }
  252. void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
  253. u8 bssid[], unsigned int id)
  254. {
  255. if (wpa_s->p2p_mgmt)
  256. return;
  257. wpas_dbus_unregister_bss(wpa_s, bssid, id);
  258. wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
  259. id, MAC2STR(bssid));
  260. }
  261. void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
  262. unsigned int id)
  263. {
  264. if (wpa_s->p2p_mgmt)
  265. return;
  266. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
  267. }
  268. void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
  269. unsigned int id)
  270. {
  271. if (wpa_s->p2p_mgmt)
  272. return;
  273. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
  274. id);
  275. }
  276. void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
  277. unsigned int id)
  278. {
  279. if (wpa_s->p2p_mgmt)
  280. return;
  281. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
  282. id);
  283. }
  284. void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
  285. unsigned int id)
  286. {
  287. if (wpa_s->p2p_mgmt)
  288. return;
  289. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
  290. }
  291. void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
  292. unsigned int id)
  293. {
  294. if (wpa_s->p2p_mgmt)
  295. return;
  296. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
  297. }
  298. void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
  299. unsigned int id)
  300. {
  301. if (wpa_s->p2p_mgmt)
  302. return;
  303. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
  304. }
  305. void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
  306. unsigned int id)
  307. {
  308. if (wpa_s->p2p_mgmt)
  309. return;
  310. #ifdef CONFIG_WPS
  311. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
  312. #endif /* CONFIG_WPS */
  313. }
  314. void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
  315. unsigned int id)
  316. {
  317. if (wpa_s->p2p_mgmt)
  318. return;
  319. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
  320. }
  321. void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
  322. unsigned int id)
  323. {
  324. if (wpa_s->p2p_mgmt)
  325. return;
  326. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
  327. }
  328. void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
  329. {
  330. if (wpa_s->p2p_mgmt)
  331. return;
  332. wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
  333. }
  334. void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
  335. {
  336. if (wpa_s->p2p_mgmt)
  337. return;
  338. wpas_dbus_signal_blob_added(wpa_s, name);
  339. }
  340. void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
  341. {
  342. if (wpa_s->p2p_mgmt)
  343. return;
  344. wpas_dbus_signal_blob_removed(wpa_s, name);
  345. }
  346. void wpas_notify_debug_level_changed(struct wpa_global *global)
  347. {
  348. wpas_dbus_signal_debug_level_changed(global);
  349. }
  350. void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
  351. {
  352. wpas_dbus_signal_debug_timestamp_changed(global);
  353. }
  354. void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
  355. {
  356. wpas_dbus_signal_debug_show_keys_changed(global);
  357. }
  358. void wpas_notify_suspend(struct wpa_global *global)
  359. {
  360. struct wpa_supplicant *wpa_s;
  361. os_get_time(&global->suspend_time);
  362. wpa_printf(MSG_DEBUG, "System suspend notification");
  363. for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
  364. wpa_drv_suspend(wpa_s);
  365. }
  366. void wpas_notify_resume(struct wpa_global *global)
  367. {
  368. struct os_time now;
  369. int slept;
  370. struct wpa_supplicant *wpa_s;
  371. if (global->suspend_time.sec == 0)
  372. slept = -1;
  373. else {
  374. os_get_time(&now);
  375. slept = now.sec - global->suspend_time.sec;
  376. }
  377. wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
  378. slept);
  379. for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
  380. wpa_drv_resume(wpa_s);
  381. if (wpa_s->wpa_state == WPA_DISCONNECTED)
  382. wpa_supplicant_req_scan(wpa_s, 0, 100000);
  383. }
  384. }
  385. #ifdef CONFIG_P2P
  386. void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
  387. {
  388. /* Notify P2P find has stopped */
  389. wpas_dbus_signal_p2p_find_stopped(wpa_s);
  390. }
  391. void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
  392. const u8 *dev_addr, int new_device)
  393. {
  394. if (new_device) {
  395. /* Create the new peer object */
  396. wpas_dbus_register_peer(wpa_s, dev_addr);
  397. }
  398. /* Notify a new peer has been detected*/
  399. wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
  400. }
  401. void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
  402. const u8 *dev_addr)
  403. {
  404. wpas_dbus_unregister_peer(wpa_s, dev_addr);
  405. /* Create signal on interface object*/
  406. wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
  407. }
  408. void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
  409. const struct wpa_ssid *ssid,
  410. const char *role)
  411. {
  412. wpas_dbus_signal_p2p_group_removed(wpa_s, role);
  413. wpas_dbus_unregister_p2p_group(wpa_s, ssid);
  414. }
  415. void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
  416. const u8 *src, u16 dev_passwd_id, u8 go_intent)
  417. {
  418. wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
  419. }
  420. void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
  421. struct p2p_go_neg_results *res)
  422. {
  423. wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
  424. }
  425. void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
  426. int status, const u8 *bssid)
  427. {
  428. wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
  429. }
  430. void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
  431. int freq, const u8 *sa, u8 dialog_token,
  432. u16 update_indic, const u8 *tlvs,
  433. size_t tlvs_len)
  434. {
  435. wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
  436. update_indic, tlvs, tlvs_len);
  437. }
  438. void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
  439. const u8 *sa, u16 update_indic,
  440. const u8 *tlvs, size_t tlvs_len)
  441. {
  442. wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
  443. tlvs, tlvs_len);
  444. }
  445. /**
  446. * wpas_notify_p2p_provision_discovery - Notification of provision discovery
  447. * @dev_addr: Who sent the request or responded to our request.
  448. * @request: Will be 1 if request, 0 for response.
  449. * @status: Valid only in case of response (0 in case of success)
  450. * @config_methods: WPS config methods
  451. * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
  452. *
  453. * This can be used to notify:
  454. * - Requests or responses
  455. * - Various config methods
  456. * - Failure condition in case of response
  457. */
  458. void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
  459. const u8 *dev_addr, int request,
  460. enum p2p_prov_disc_status status,
  461. u16 config_methods,
  462. unsigned int generated_pin)
  463. {
  464. wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
  465. status, config_methods,
  466. generated_pin);
  467. }
  468. void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
  469. struct wpa_ssid *ssid, int network_id,
  470. int client)
  471. {
  472. /* Notify a group has been started */
  473. wpas_dbus_register_p2p_group(wpa_s, ssid);
  474. wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
  475. }
  476. void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
  477. struct wps_event_fail *fail)
  478. {
  479. wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
  480. }
  481. #endif /* CONFIG_P2P */
  482. static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
  483. const u8 *sta,
  484. const u8 *p2p_dev_addr)
  485. {
  486. #ifdef CONFIG_P2P
  487. wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
  488. /*
  489. * Create 'peer-joined' signal on group object -- will also
  490. * check P2P itself.
  491. */
  492. if (p2p_dev_addr)
  493. wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
  494. #endif /* CONFIG_P2P */
  495. /* Notify listeners a new station has been authorized */
  496. wpas_dbus_signal_sta_authorized(wpa_s, sta);
  497. }
  498. static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
  499. const u8 *sta,
  500. const u8 *p2p_dev_addr)
  501. {
  502. #ifdef CONFIG_P2P
  503. /*
  504. * Create 'peer-disconnected' signal on group object if this
  505. * is a P2P group.
  506. */
  507. if (p2p_dev_addr)
  508. wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
  509. #endif /* CONFIG_P2P */
  510. /* Notify listeners a station has been deauthorized */
  511. wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
  512. }
  513. void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
  514. const u8 *mac_addr, int authorized,
  515. const u8 *p2p_dev_addr)
  516. {
  517. if (authorized)
  518. wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
  519. else
  520. wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
  521. }
  522. void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
  523. const char *subject, const char *altsubject[],
  524. int num_altsubject, const char *cert_hash,
  525. const struct wpabuf *cert)
  526. {
  527. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
  528. "depth=%d subject='%s'%s%s",
  529. depth, subject, cert_hash ? " hash=" : "",
  530. cert_hash ? cert_hash : "");
  531. if (cert) {
  532. char *cert_hex;
  533. size_t len = wpabuf_len(cert) * 2 + 1;
  534. cert_hex = os_malloc(len);
  535. if (cert_hex) {
  536. wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
  537. wpabuf_len(cert));
  538. wpa_msg_ctrl(wpa_s, MSG_INFO,
  539. WPA_EVENT_EAP_PEER_CERT
  540. "depth=%d subject='%s' cert=%s",
  541. depth, subject, cert_hex);
  542. os_free(cert_hex);
  543. }
  544. }
  545. if (altsubject) {
  546. int i;
  547. for (i = 0; i < num_altsubject; i++)
  548. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
  549. "depth=%d %s", depth, altsubject[i]);
  550. }
  551. /* notify the old DBus API */
  552. wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
  553. cert_hash, cert);
  554. /* notify the new DBus API */
  555. wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
  556. num_altsubject, cert_hash, cert);
  557. }
  558. void wpas_notify_preq(struct wpa_supplicant *wpa_s,
  559. const u8 *addr, const u8 *dst, const u8 *bssid,
  560. const u8 *ie, size_t ie_len, u32 ssi_signal)
  561. {
  562. #ifdef CONFIG_AP
  563. wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
  564. #endif /* CONFIG_AP */
  565. }
  566. void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
  567. const char *parameter)
  568. {
  569. wpas_dbus_signal_eap_status(wpa_s, status, parameter);
  570. wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
  571. "status='%s' parameter='%s'",
  572. status, parameter);
  573. }
  574. void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
  575. struct wpa_ssid *ssid)
  576. {
  577. if (wpa_s->current_ssid != ssid)
  578. return;
  579. wpa_dbg(wpa_s, MSG_DEBUG,
  580. "Network bssid config changed for the current network - within-ESS roaming %s",
  581. ssid->bssid_set ? "disabled" : "enabled");
  582. wpa_drv_roaming(wpa_s, !ssid->bssid_set,
  583. ssid->bssid_set ? ssid->bssid : NULL);
  584. }
  585. void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
  586. struct wpa_ssid *ssid)
  587. {
  588. #ifdef CONFIG_P2P
  589. if (ssid->disabled == 2) {
  590. /* Changed from normal network profile to persistent group */
  591. ssid->disabled = 0;
  592. wpas_dbus_unregister_network(wpa_s, ssid->id);
  593. ssid->disabled = 2;
  594. wpas_dbus_register_persistent_group(wpa_s, ssid);
  595. } else {
  596. /* Changed from persistent group to normal network profile */
  597. wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
  598. wpas_dbus_register_network(wpa_s, ssid);
  599. }
  600. #endif /* CONFIG_P2P */
  601. }