ctrl_iface_dbus.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #ifdef CONFIG_CTRL_IFACE_DBUS
  17. #ifndef SIGPOLL
  18. #ifdef SIGIO
  19. /*
  20. * If we do not have SIGPOLL, try to use SIGIO instead. This is needed for
  21. * FreeBSD.
  22. */
  23. #define SIGPOLL SIGIO
  24. #endif
  25. #endif
  26. #include <dbus/dbus.h>
  27. #define WPAS_DBUS_OBJECT_PATH_MAX 150
  28. #define WPAS_DBUS_SERVICE "fi.epitest.hostap.WPASupplicant"
  29. #define WPAS_DBUS_PATH "/fi/epitest/hostap/WPASupplicant"
  30. #define WPAS_DBUS_INTERFACE "fi.epitest.hostap.WPASupplicant"
  31. #define WPAS_DBUS_PATH_INTERFACES WPAS_DBUS_PATH "/Interfaces"
  32. #define WPAS_DBUS_IFACE_INTERFACE WPAS_DBUS_INTERFACE ".Interface"
  33. #define WPAS_DBUS_NETWORKS_PART "Networks"
  34. #define WPAS_DBUS_IFACE_NETWORK WPAS_DBUS_INTERFACE ".Network"
  35. #define WPAS_DBUS_BSSIDS_PART "BSSIDs"
  36. #define WPAS_DBUS_IFACE_BSSID WPAS_DBUS_INTERFACE ".BSSID"
  37. /* Errors */
  38. #define WPAS_ERROR_INVALID_NETWORK \
  39. WPAS_DBUS_IFACE_INTERFACE ".InvalidNetwork"
  40. #define WPAS_ERROR_INVALID_BSSID \
  41. WPAS_DBUS_IFACE_INTERFACE ".InvalidBSSID"
  42. #define WPAS_ERROR_INVALID_OPTS \
  43. WPAS_DBUS_INTERFACE ".InvalidOptions"
  44. #define WPAS_ERROR_INVALID_IFACE \
  45. WPAS_DBUS_INTERFACE ".InvalidInterface"
  46. #define WPAS_ERROR_ADD_ERROR \
  47. WPAS_DBUS_INTERFACE ".AddError"
  48. #define WPAS_ERROR_EXISTS_ERROR \
  49. WPAS_DBUS_INTERFACE ".ExistsError"
  50. #define WPAS_ERROR_REMOVE_ERROR \
  51. WPAS_DBUS_INTERFACE ".RemoveError"
  52. #define WPAS_ERROR_SCAN_ERROR \
  53. WPAS_DBUS_IFACE_INTERFACE ".ScanError"
  54. #define WPAS_ERROR_ADD_NETWORK_ERROR \
  55. WPAS_DBUS_IFACE_INTERFACE ".AddNetworkError"
  56. #define WPAS_ERROR_INTERNAL_ERROR \
  57. WPAS_DBUS_IFACE_INTERFACE ".InternalError"
  58. #define WPAS_ERROR_REMOVE_NETWORK_ERROR \
  59. WPAS_DBUS_IFACE_INTERFACE ".RemoveNetworkError"
  60. #define WPAS_DBUS_BSSID_FORMAT "%02x%02x%02x%02x%02x%02x"
  61. struct wpa_global;
  62. struct wpa_supplicant;
  63. struct ctrl_iface_dbus_priv *
  64. wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global);
  65. void wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface);
  66. void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s);
  67. void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
  68. wpa_states new_state,
  69. wpa_states old_state);
  70. char * wpas_dbus_decompose_object_path(const char *path, char **network,
  71. char **bssid);
  72. int wpas_dbus_register_iface(struct wpa_supplicant *wpa_s);
  73. int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s);
  74. /* Methods internal to the dbus control interface */
  75. u32 wpa_supplicant_dbus_next_objid(struct ctrl_iface_dbus_priv *iface);
  76. int wpa_supplicant_set_dbus_path(struct wpa_supplicant *wpa_s,
  77. const char *path);
  78. const char *wpa_supplicant_get_dbus_path(struct wpa_supplicant *wpa_s);
  79. struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path(
  80. struct wpa_global *global, const char *path);
  81. DBusMessage * wpas_dbus_new_invalid_iface_error(DBusMessage *message);
  82. DBusMessage * wpas_dbus_new_invalid_network_error(DBusMessage *message);
  83. #else /* CONFIG_CTRL_IFACE_DBUS */
  84. static inline struct ctrl_iface_dbus_priv *
  85. wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global)
  86. {
  87. return (struct ctrl_iface_dbus_priv *) 1;
  88. }
  89. static inline void
  90. wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface)
  91. {
  92. }
  93. static inline void
  94. wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s)
  95. {
  96. }
  97. static inline void
  98. wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
  99. wpa_states new_state,
  100. wpa_states old_state)
  101. {
  102. }
  103. static inline int
  104. wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
  105. {
  106. return 0;
  107. }
  108. static inline int
  109. wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s)
  110. {
  111. return 0;
  112. }
  113. #endif /* CONFIG_CTRL_IFACE_DBUS */
  114. #endif /* CTRL_IFACE_DBUS_H */