dbus_new.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. /*
  2. * WPA Supplicant / dbus-based control interface
  3. * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
  4. * Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Alternatively, this software may be distributed under the terms of BSD
  11. * license.
  12. *
  13. * See README and COPYING for more details.
  14. */
  15. #ifndef CTRL_IFACE_DBUS_NEW_H
  16. #define CTRL_IFACE_DBUS_NEW_H
  17. #include "p2p/p2p.h"
  18. struct wpa_global;
  19. struct wpa_supplicant;
  20. struct wpa_ssid;
  21. struct wps_event_m2d;
  22. struct wps_event_fail;
  23. struct wps_credential;
  24. enum wpa_states;
  25. enum wpa_ctrl_req_type;
  26. enum wpas_dbus_prop {
  27. WPAS_DBUS_PROP_AP_SCAN,
  28. WPAS_DBUS_PROP_SCANNING,
  29. WPAS_DBUS_PROP_STATE,
  30. WPAS_DBUS_PROP_CURRENT_BSS,
  31. WPAS_DBUS_PROP_CURRENT_NETWORK,
  32. WPAS_DBUS_PROP_CURRENT_AUTH_MODE,
  33. WPAS_DBUS_PROP_BSSS,
  34. };
  35. enum wpas_dbus_bss_prop {
  36. WPAS_DBUS_BSS_PROP_SIGNAL,
  37. WPAS_DBUS_BSS_PROP_FREQ,
  38. WPAS_DBUS_BSS_PROP_MODE,
  39. WPAS_DBUS_BSS_PROP_PRIVACY,
  40. WPAS_DBUS_BSS_PROP_RATES,
  41. WPAS_DBUS_BSS_PROP_WPA,
  42. WPAS_DBUS_BSS_PROP_RSN,
  43. WPAS_DBUS_BSS_PROP_IES,
  44. };
  45. #define WPAS_DBUS_OBJECT_PATH_MAX 150
  46. #define WPAS_DBUS_NEW_SERVICE "fi.w1.wpa_supplicant1"
  47. #define WPAS_DBUS_NEW_PATH "/fi/w1/wpa_supplicant1"
  48. #define WPAS_DBUS_NEW_INTERFACE "fi.w1.wpa_supplicant1"
  49. #define WPAS_DBUS_NEW_PATH_INTERFACES WPAS_DBUS_NEW_PATH "/Interfaces"
  50. #define WPAS_DBUS_NEW_IFACE_INTERFACE WPAS_DBUS_NEW_INTERFACE ".Interface"
  51. #define WPAS_DBUS_NEW_IFACE_WPS WPAS_DBUS_NEW_IFACE_INTERFACE ".WPS"
  52. #define WPAS_DBUS_NEW_NETWORKS_PART "Networks"
  53. #define WPAS_DBUS_NEW_IFACE_NETWORK WPAS_DBUS_NEW_INTERFACE ".Network"
  54. #define WPAS_DBUS_NEW_BSSIDS_PART "BSSs"
  55. #define WPAS_DBUS_NEW_IFACE_BSS WPAS_DBUS_NEW_INTERFACE ".BSS"
  56. #define WPAS_DBUS_NEW_IFACE_P2PDEVICE \
  57. WPAS_DBUS_NEW_IFACE_INTERFACE ".P2PDevice"
  58. /*
  59. * Groups correspond to P2P groups where this device is a GO (owner)
  60. */
  61. #define WPAS_DBUS_NEW_P2P_GROUPS_PART "Groups"
  62. #define WPAS_DBUS_NEW_IFACE_P2P_GROUP WPAS_DBUS_NEW_INTERFACE ".Group"
  63. /*
  64. * Different dbus object for persistent groups so they do not get confused
  65. * with regular (configured) network objects.
  66. */
  67. #define WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "PersistentGroups"
  68. #define WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP \
  69. WPAS_DBUS_NEW_INTERFACE ".PersistentGroup"
  70. #define WPAS_DBUS_NEW_P2P_PEERS_PART "Peers"
  71. #define WPAS_DBUS_NEW_IFACE_P2P_PEER WPAS_DBUS_NEW_INTERFACE ".Peer"
  72. #define WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "Members"
  73. #define WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER \
  74. WPAS_DBUS_NEW_INTERFACE ".GroupMember"
  75. /* Errors */
  76. #define WPAS_DBUS_ERROR_UNKNOWN_ERROR \
  77. WPAS_DBUS_NEW_INTERFACE ".UnknownError"
  78. #define WPAS_DBUS_ERROR_INVALID_ARGS \
  79. WPAS_DBUS_NEW_INTERFACE ".InvalidArgs"
  80. #define WPAS_DBUS_ERROR_IFACE_EXISTS \
  81. WPAS_DBUS_NEW_INTERFACE ".InterfaceExists"
  82. #define WPAS_DBUS_ERROR_IFACE_UNKNOWN \
  83. WPAS_DBUS_NEW_INTERFACE ".InterfaceUnknown"
  84. #define WPAS_DBUS_ERROR_NOT_CONNECTED \
  85. WPAS_DBUS_NEW_INTERFACE ".NotConnected"
  86. #define WPAS_DBUS_ERROR_NETWORK_UNKNOWN \
  87. WPAS_DBUS_NEW_INTERFACE ".NetworkUnknown"
  88. #define WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNAVAILABLE \
  89. WPAS_DBUS_NEW_INTERFACE ".ConnectChannelUnavailable"
  90. #define WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNSUPPORTED \
  91. WPAS_DBUS_NEW_INTERFACE ".ConnectChannelUnsupported"
  92. #define WPAS_DBUS_ERROR_CONNECT_UNSPECIFIED_ERROR \
  93. WPAS_DBUS_NEW_INTERFACE ".ConnectUnspecifiedError"
  94. #define WPAS_DBUS_ERROR_BLOB_EXISTS \
  95. WPAS_DBUS_NEW_INTERFACE ".BlobExists"
  96. #define WPAS_DBUS_ERROR_BLOB_UNKNOWN \
  97. WPAS_DBUS_NEW_INTERFACE ".BlobUnknown"
  98. #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
  99. int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv);
  100. void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface);
  101. int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s);
  102. int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s);
  103. void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
  104. enum wpas_dbus_prop property);
  105. void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
  106. enum wpas_dbus_bss_prop property,
  107. unsigned int id);
  108. void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
  109. struct wpa_ssid *ssid);
  110. void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id);
  111. void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
  112. struct wpa_ssid *ssid,
  113. enum wpa_ctrl_req_type rtype,
  114. const char *default_text);
  115. void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success);
  116. void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
  117. const struct wps_credential *cred);
  118. void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
  119. struct wps_event_m2d *m2d);
  120. void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
  121. struct wps_event_fail *fail);
  122. void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s);
  123. int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
  124. struct wpa_ssid *ssid);
  125. int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid);
  126. int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
  127. u8 bssid[ETH_ALEN], unsigned int id);
  128. int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
  129. u8 bssid[ETH_ALEN], unsigned int id);
  130. void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
  131. const char *name);
  132. void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
  133. const char *name);
  134. void wpas_dbus_signal_debug_level_changed(struct wpa_global *global);
  135. void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global);
  136. void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global);
  137. int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr);
  138. void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
  139. const u8 *dev_addr);
  140. int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
  141. const u8 *dev_addr);
  142. void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
  143. const u8 *dev_addr);
  144. void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
  145. const char *role);
  146. void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
  147. const u8 *dev_addr, int request,
  148. enum p2p_prov_disc_status status,
  149. u16 config_methods,
  150. unsigned int generated_pin);
  151. void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
  152. const u8 *src, u16 dev_passwd_id);
  153. void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
  154. const struct wpa_ssid *ssid,
  155. int client, int network_id);
  156. void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
  157. struct wpa_ssid *ssid);
  158. void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, int status);
  159. void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
  160. const struct wpa_ssid *ssid);
  161. int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
  162. struct wpa_ssid *ssid);
  163. int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
  164. int nid);
  165. void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
  166. int status, const u8 *bssid);
  167. void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
  168. const u8 *p2p_if_addr);
  169. void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
  170. const u8 *p2p_if_addr);
  171. void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
  172. const u8 *member);
  173. void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
  174. int freq, const u8 *sa, u8 dialog_token,
  175. u16 update_indic, const u8 *tlvs,
  176. size_t tlvs_len);
  177. void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
  178. const u8 *sa, u16 update_indic,
  179. const u8 *tlvs, size_t tlvs_len);
  180. void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
  181. const u8 *member);
  182. void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
  183. struct wps_event_fail *fail);
  184. void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
  185. int depth, const char *subject,
  186. const char *cert_hash,
  187. const struct wpabuf *cert);
  188. #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
  189. static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
  190. {
  191. return 0;
  192. }
  193. static inline int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
  194. {
  195. return 0;
  196. }
  197. #define wpas_dbus_signal_state_changed(w, n, o) do { } while (0)
  198. static inline void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
  199. enum wpas_dbus_prop property)
  200. {
  201. }
  202. static inline void wpas_dbus_bss_signal_prop_changed(
  203. struct wpa_supplicant *wpa_s, enum wpas_dbus_bss_prop property,
  204. unsigned int id)
  205. {
  206. }
  207. static inline void wpas_dbus_signal_network_enabled_changed(
  208. struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
  209. {
  210. }
  211. static inline void wpas_dbus_signal_network_selected(
  212. struct wpa_supplicant *wpa_s, int id)
  213. {
  214. }
  215. static inline void wpas_dbus_signal_network_request(
  216. struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
  217. enum wpa_ctrl_req_type rtype, const char *default_txt)
  218. {
  219. }
  220. static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s,
  221. int success)
  222. {
  223. }
  224. static inline void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
  225. const struct wps_credential *cred)
  226. {
  227. }
  228. static inline void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
  229. struct wps_event_m2d *m2d)
  230. {
  231. }
  232. static inline void wpas_dbus_signal_wps_event_fail(
  233. struct wpa_supplicant *wpa_s, struct wps_event_fail *fail)
  234. {
  235. }
  236. static inline void wpas_dbus_signal_wps_event_success(
  237. struct wpa_supplicant *wpa_s)
  238. {
  239. }
  240. static inline int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
  241. struct wpa_ssid *ssid)
  242. {
  243. return 0;
  244. }
  245. static inline int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s,
  246. int nid)
  247. {
  248. return 0;
  249. }
  250. static inline int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
  251. u8 bssid[ETH_ALEN], unsigned int id)
  252. {
  253. return 0;
  254. }
  255. static inline int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
  256. u8 bssid[ETH_ALEN], unsigned int id)
  257. {
  258. return 0;
  259. }
  260. static inline void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
  261. const char *name)
  262. {
  263. }
  264. static inline void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
  265. const char *name)
  266. {
  267. }
  268. static inline void wpas_dbus_signal_debug_level_changed(
  269. struct wpa_global *global)
  270. {
  271. }
  272. static inline void wpas_dbus_signal_debug_timestamp_changed(
  273. struct wpa_global *global)
  274. {
  275. }
  276. static inline void wpas_dbus_signal_debug_show_keys_changed(
  277. struct wpa_global *global)
  278. {
  279. }
  280. static inline int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s,
  281. const u8 *dev_addr)
  282. {
  283. return 0;
  284. }
  285. static inline int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
  286. const u8 *dev_addr)
  287. {
  288. return 0;
  289. }
  290. static inline void
  291. wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
  292. const char *role)
  293. {
  294. }
  295. static inline void
  296. wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
  297. const u8 *dev_addr, int request,
  298. enum p2p_prov_disc_status status,
  299. u16 config_methods,
  300. unsigned int generated_pin)
  301. {
  302. }
  303. static inline void wpas_dbus_signal_p2p_go_neg_req(
  304. struct wpa_supplicant *wpa_s,
  305. const u8 *src,
  306. u16 dev_passwd_id)
  307. {
  308. }
  309. static inline void
  310. wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
  311. const struct wpa_ssid *ssid,
  312. int client, int network_id)
  313. {
  314. }
  315. static inline void
  316. wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
  317. struct wpa_ssid *ssid)
  318. {
  319. }
  320. static inline int wpas_dbus_register_persistent_group(
  321. struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
  322. {
  323. return 0;
  324. }
  325. static inline int wpas_dbus_unregister_persistent_group(
  326. struct wpa_supplicant *wpa_s, int nid)
  327. {
  328. return 0;
  329. }
  330. static inline void
  331. wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, int status)
  332. {
  333. }
  334. static inline void
  335. wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
  336. const struct wpa_ssid *ssid)
  337. {
  338. }
  339. static inline void wpas_dbus_signal_p2p_invitation_result(
  340. struct wpa_supplicant *wpa_s, int status,
  341. const u8 *bssid)
  342. {
  343. }
  344. static inline void
  345. wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
  346. const u8 *p2p_if_addr)
  347. {
  348. }
  349. static inline void
  350. wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s, int freq,
  351. const u8 *sa, u8 dialog_token, u16 update_indic,
  352. const u8 *tlvs, size_t tlvs_len)
  353. {
  354. }
  355. static inline void
  356. wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
  357. const u8 *sa, u16 update_indic,
  358. const u8 *tlvs, size_t tlvs_len)
  359. {
  360. }
  361. static inline void
  362. wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
  363. const u8 *p2p_if_addr)
  364. {
  365. }
  366. static inline void
  367. wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
  368. const u8 *member)
  369. {
  370. }
  371. static inline void
  372. wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
  373. const u8 *dev_addr)
  374. {
  375. }
  376. static inline void
  377. wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
  378. const u8 *dev_addr)
  379. {
  380. }
  381. static inline void
  382. wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
  383. const u8 *member)
  384. {
  385. }
  386. static inline void
  387. wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
  388. struct wps_event_fail *fail)
  389. {
  390. }
  391. static inline void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
  392. int depth,
  393. const char *subject,
  394. const char *cert_hash,
  395. const struct wpabuf *cert)
  396. {
  397. }
  398. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  399. #endif /* CTRL_IFACE_DBUS_H_NEW */