notify.c 18 KB

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