ctrl_iface_dbus_new_helpers.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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, 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 WPA_DBUS_CTRL_H
  16. #define WPA_DBUS_CTRL_H
  17. #include <dbus/dbus.h>
  18. struct ctrl_iface_dbus_new_priv {
  19. DBusConnection *con;
  20. int should_dispatch;
  21. void *application_data;
  22. u32 next_objid;
  23. };
  24. typedef DBusMessage * (* WPADBusMethodHandler)(DBusMessage *message,
  25. void *user_data);
  26. typedef void (* WPADBusArgumentFreeFunction)(void *handler_arg);
  27. typedef DBusMessage * (* WPADBusPropertyAccessor)(DBusMessage *message,
  28. void *user_data);
  29. struct wpa_dbus_object_desc {
  30. DBusConnection *connection;
  31. struct wpa_dbus_method_desc *methods;
  32. struct wpa_dbus_signal_desc *signals;
  33. struct wpa_dbus_property_desc *properties;
  34. };
  35. enum dbus_prop_access { R, W, RW };
  36. enum dbus_arg_direction { ARG_IN, ARG_OUT };
  37. struct wpa_dbus_argument {
  38. char *name;
  39. char *type;
  40. enum dbus_arg_direction dir;
  41. };
  42. #define END_ARGS { NULL, NULL, ARG_IN }
  43. #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
  44. #ifndef SIGPOLL
  45. #ifdef SIGIO
  46. /*
  47. * If we do not have SIGPOLL, try to use SIGIO instead. This is needed for
  48. * FreeBSD.
  49. */
  50. #define SIGPOLL SIGIO
  51. #endif
  52. #endif
  53. #define WPAS_DBUS_OBJECT_PATH_MAX 150
  54. #define WPAS_DBUS_INTERFACE_MAX 150
  55. #define WPAS_DBUS_METHOD_SIGNAL_PROP_MAX 50
  56. #define WPA_DBUS_INTROSPECTION_INTERFACE "org.freedesktop.DBus.Introspectable"
  57. #define WPA_DBUS_INTROSPECTION_METHOD "Introspect"
  58. #define WPA_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
  59. #define WPA_DBUS_PROPERTIES_GET "Get"
  60. #define WPA_DBUS_PROPERTIES_SET "Set"
  61. #define WPA_DBUS_PROPERTIES_GETALL "GetAll"
  62. void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc);
  63. struct ctrl_iface_dbus_new_priv *
  64. wpa_dbus_ctrl_iface_init(void *application_data, char *dbus_path,
  65. char *dbus_service,
  66. struct wpa_dbus_object_desc *obj_desc);
  67. void wpa_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_new_priv *iface);
  68. int wpa_dbus_register_object_per_iface(
  69. struct ctrl_iface_dbus_new_priv *ctrl_iface,
  70. const char *path, const char *ifname,
  71. struct wpa_dbus_object_desc *obj_desc);
  72. int wpa_dbus_unregister_object_per_iface(
  73. struct ctrl_iface_dbus_new_priv *ctrl_iface,
  74. const char *path);
  75. int wpa_dbus_method_register(struct wpa_dbus_object_desc *obj_dsc,
  76. const char *dbus_interface,
  77. const char *dbus_method,
  78. WPADBusMethodHandler method_handler,
  79. void *handler_argument,
  80. WPADBusArgumentFreeFunction argument_free_func,
  81. const struct wpa_dbus_argument args[]);
  82. int wpa_dbus_signal_register(struct wpa_dbus_object_desc *obj_dsc,
  83. const char *dbus_interface,
  84. const char *dbus_signal,
  85. const struct wpa_dbus_argument args[]);
  86. int wpa_dbus_property_register(
  87. struct wpa_dbus_object_desc *obj_dsc,
  88. const char *dbus_interface, const char *dbus_property,
  89. const char *type,
  90. WPADBusPropertyAccessor getter,
  91. WPADBusPropertyAccessor setter,
  92. void *user_data,
  93. WPADBusArgumentFreeFunction user_data_free_func,
  94. enum dbus_prop_access _access);
  95. void wpa_dbus_signal_property_changed(struct ctrl_iface_dbus_new_priv *iface,
  96. WPADBusPropertyAccessor property_getter,
  97. void *getter_arg,
  98. const char *path,
  99. const char *interface_name,
  100. const char *property_name);
  101. /* Methods internal to the dbus control interface */
  102. u32 wpa_dbus_next_objid(struct ctrl_iface_dbus_new_priv *iface);
  103. #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
  104. static inline void wpa_dbus_signal_property_changed(
  105. struct ctrl_iface_dbus_new_priv *iface,
  106. WPADBusPropertyAccessor property_getter, void *getter_arg,
  107. const char *path, const char *interface_name,
  108. const char *property_name)
  109. {
  110. }
  111. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  112. #endif /* WPA_DBUS_CTRL_H */