dbus.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * WPA Supplicant / dbus-based control interface
  3. * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef CTRL_IFACE_DBUS_H
  15. #define CTRL_IFACE_DBUS_H
  16. struct wps_credential;
  17. #ifdef CONFIG_CTRL_IFACE_DBUS
  18. #ifndef SIGPOLL
  19. #ifdef SIGIO
  20. /*
  21. * If we do not have SIGPOLL, try to use SIGIO instead. This is needed for
  22. * FreeBSD.
  23. */
  24. #define SIGPOLL SIGIO
  25. #endif
  26. #endif
  27. #include <dbus/dbus.h>
  28. #define WPAS_DBUS_OBJECT_PATH_MAX 150
  29. #define WPAS_DBUS_SERVICE "fi.epitest.hostap.WPASupplicant"
  30. #define WPAS_DBUS_PATH "/fi/epitest/hostap/WPASupplicant"
  31. #define WPAS_DBUS_INTERFACE "fi.epitest.hostap.WPASupplicant"
  32. #define WPAS_DBUS_PATH_INTERFACES WPAS_DBUS_PATH "/Interfaces"
  33. #define WPAS_DBUS_IFACE_INTERFACE WPAS_DBUS_INTERFACE ".Interface"
  34. #define WPAS_DBUS_NETWORKS_PART "Networks"
  35. #define WPAS_DBUS_IFACE_NETWORK WPAS_DBUS_INTERFACE ".Network"
  36. #define WPAS_DBUS_BSSIDS_PART "BSSIDs"
  37. #define WPAS_DBUS_IFACE_BSSID WPAS_DBUS_INTERFACE ".BSSID"
  38. /* Errors */
  39. #define WPAS_ERROR_INVALID_NETWORK \
  40. WPAS_DBUS_IFACE_INTERFACE ".InvalidNetwork"
  41. #define WPAS_ERROR_INVALID_BSSID \
  42. WPAS_DBUS_IFACE_INTERFACE ".InvalidBSSID"
  43. #define WPAS_ERROR_INVALID_OPTS \
  44. WPAS_DBUS_INTERFACE ".InvalidOptions"
  45. #define WPAS_ERROR_INVALID_IFACE \
  46. WPAS_DBUS_INTERFACE ".InvalidInterface"
  47. #define WPAS_ERROR_ADD_ERROR \
  48. WPAS_DBUS_INTERFACE ".AddError"
  49. #define WPAS_ERROR_EXISTS_ERROR \
  50. WPAS_DBUS_INTERFACE ".ExistsError"
  51. #define WPAS_ERROR_REMOVE_ERROR \
  52. WPAS_DBUS_INTERFACE ".RemoveError"
  53. #define WPAS_ERROR_SCAN_ERROR \
  54. WPAS_DBUS_IFACE_INTERFACE ".ScanError"
  55. #define WPAS_ERROR_ADD_NETWORK_ERROR \
  56. WPAS_DBUS_IFACE_INTERFACE ".AddNetworkError"
  57. #define WPAS_ERROR_INTERNAL_ERROR \
  58. WPAS_DBUS_IFACE_INTERFACE ".InternalError"
  59. #define WPAS_ERROR_REMOVE_NETWORK_ERROR \
  60. WPAS_DBUS_IFACE_INTERFACE ".RemoveNetworkError"
  61. #define WPAS_ERROR_WPS_PBC_ERROR \
  62. WPAS_DBUS_IFACE_INTERFACE ".WpsPbcError"
  63. #define WPAS_ERROR_WPS_PIN_ERROR \
  64. WPAS_DBUS_IFACE_INTERFACE ".WpsPinError"
  65. #define WPAS_ERROR_WPS_REG_ERROR \
  66. WPAS_DBUS_IFACE_INTERFACE ".WpsRegError"
  67. #define WPAS_DBUS_BSSID_FORMAT "%02x%02x%02x%02x%02x%02x"
  68. struct wpa_global;
  69. struct wpa_supplicant;
  70. struct ctrl_iface_dbus_priv *
  71. wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global);
  72. void wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface);
  73. void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s);
  74. void wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s);
  75. void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
  76. wpa_states new_state,
  77. wpa_states old_state);
  78. void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
  79. const struct wps_credential *cred);
  80. char * wpas_dbus_decompose_object_path(const char *path, char **network,
  81. char **bssid);
  82. int wpas_dbus_register_iface(struct wpa_supplicant *wpa_s);
  83. int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s);
  84. /* Methods internal to the dbus control interface */
  85. u32 wpa_supplicant_dbus_next_objid(struct ctrl_iface_dbus_priv *iface);
  86. int wpa_supplicant_set_dbus_path(struct wpa_supplicant *wpa_s,
  87. const char *path);
  88. const char *wpa_supplicant_get_dbus_path(struct wpa_supplicant *wpa_s);
  89. struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path(
  90. struct wpa_global *global, const char *path);
  91. DBusMessage * wpas_dbus_new_invalid_iface_error(DBusMessage *message);
  92. DBusMessage * wpas_dbus_new_invalid_network_error(DBusMessage *message);
  93. #else /* CONFIG_CTRL_IFACE_DBUS */
  94. static inline struct ctrl_iface_dbus_priv *
  95. wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global)
  96. {
  97. return (struct ctrl_iface_dbus_priv *) 1;
  98. }
  99. static inline void
  100. wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface)
  101. {
  102. }
  103. static inline void
  104. wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s)
  105. {
  106. }
  107. static inline void
  108. wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s)
  109. {
  110. }
  111. static inline void
  112. wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
  113. wpa_states new_state,
  114. wpa_states old_state)
  115. {
  116. }
  117. static inline void
  118. wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
  119. const struct wps_credential *cred)
  120. {
  121. }
  122. static inline int
  123. wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
  124. {
  125. return 0;
  126. }
  127. static inline int
  128. wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s)
  129. {
  130. return 0;
  131. }
  132. #endif /* CONFIG_CTRL_IFACE_DBUS */
  133. #endif /* CTRL_IFACE_DBUS_H */