dbus_new.h 13 KB

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