notify.c 20 KB

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