notify.c 19 KB

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