dbus_new.h 14 KB

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