notify.c 19 KB

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