ctrl_iface_dbus.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. #ifdef CONFIG_WPS
  62. #define WPAS_ERROR_WPS_PBC_ERROR \
  63. WPAS_DBUS_IFACE_INTERFACE ".WpsPbcError"
  64. #define WPAS_ERROR_WPS_PIN_ERROR \
  65. WPAS_DBUS_IFACE_INTERFACE ".WpsPinError"
  66. #define WPAS_ERROR_WPS_REG_ERROR \
  67. WPAS_DBUS_IFACE_INTERFACE ".WpsRegError"
  68. #endif /* CONFIG_WPS */
  69. #define WPAS_DBUS_BSSID_FORMAT "%02x%02x%02x%02x%02x%02x"
  70. struct wpa_global;
  71. struct wpa_supplicant;
  72. struct ctrl_iface_dbus_priv *
  73. wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global);
  74. void wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface);
  75. void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s);
  76. void wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s);
  77. void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
  78. wpa_states new_state,
  79. wpa_states old_state);
  80. void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
  81. const struct wps_credential *cred);
  82. char * wpas_dbus_decompose_object_path(const char *path, char **network,
  83. char **bssid);
  84. int wpas_dbus_register_iface(struct wpa_supplicant *wpa_s);
  85. int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s);
  86. /* Methods internal to the dbus control interface */
  87. u32 wpa_supplicant_dbus_next_objid(struct ctrl_iface_dbus_priv *iface);
  88. int wpa_supplicant_set_dbus_path(struct wpa_supplicant *wpa_s,
  89. const char *path);
  90. const char *wpa_supplicant_get_dbus_path(struct wpa_supplicant *wpa_s);
  91. struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path(
  92. struct wpa_global *global, const char *path);
  93. DBusMessage * wpas_dbus_new_invalid_iface_error(DBusMessage *message);
  94. DBusMessage * wpas_dbus_new_invalid_network_error(DBusMessage *message);
  95. #else /* CONFIG_CTRL_IFACE_DBUS */
  96. static inline struct ctrl_iface_dbus_priv *
  97. wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global)
  98. {
  99. return (struct ctrl_iface_dbus_priv *) 1;
  100. }
  101. static inline void
  102. wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface)
  103. {
  104. }
  105. static inline void
  106. wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s)
  107. {
  108. }
  109. static inline void
  110. wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s)
  111. {
  112. }
  113. static inline void
  114. wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
  115. wpa_states new_state,
  116. wpa_states old_state)
  117. {
  118. }
  119. static inline void
  120. wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
  121. const struct wps_credential *cred)
  122. {
  123. }
  124. static inline int
  125. wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
  126. {
  127. return 0;
  128. }
  129. static inline int
  130. wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s)
  131. {
  132. return 0;
  133. }
  134. #endif /* CONFIG_CTRL_IFACE_DBUS */
  135. #endif /* CTRL_IFACE_DBUS_H */