dbus_new_helpers.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 software may be distributed under the terms of the BSD license.
  7. * See README for more details.
  8. */
  9. #ifndef WPA_DBUS_CTRL_H
  10. #define WPA_DBUS_CTRL_H
  11. #include <dbus/dbus.h>
  12. typedef DBusMessage * (* WPADBusMethodHandler)(DBusMessage *message,
  13. void *user_data);
  14. typedef void (* WPADBusArgumentFreeFunction)(void *handler_arg);
  15. typedef dbus_bool_t (* WPADBusPropertyAccessor)(DBusMessageIter *iter,
  16. DBusError *error,
  17. void *user_data);
  18. struct wpa_dbus_object_desc {
  19. DBusConnection *connection;
  20. char *path;
  21. /* list of methods, properties and signals registered with object */
  22. const struct wpa_dbus_method_desc *methods;
  23. const struct wpa_dbus_signal_desc *signals;
  24. const struct wpa_dbus_property_desc *properties;
  25. /* property changed flags */
  26. u8 *prop_changed_flags;
  27. /* argument for method handlers and properties
  28. * getter and setter functions */
  29. void *user_data;
  30. /* function used to free above argument */
  31. WPADBusArgumentFreeFunction user_data_free_func;
  32. };
  33. enum dbus_arg_direction { ARG_IN, ARG_OUT };
  34. struct wpa_dbus_argument {
  35. char *name;
  36. char *type;
  37. enum dbus_arg_direction dir;
  38. };
  39. #define END_ARGS { NULL, NULL, ARG_IN }
  40. /**
  41. * struct wpa_dbus_method_desc - DBus method description
  42. */
  43. struct wpa_dbus_method_desc {
  44. /* method name */
  45. const char *dbus_method;
  46. /* method interface */
  47. const char *dbus_interface;
  48. /* method handling function */
  49. WPADBusMethodHandler method_handler;
  50. /* array of arguments */
  51. struct wpa_dbus_argument args[4];
  52. };
  53. /**
  54. * struct wpa_dbus_signal_desc - DBus signal description
  55. */
  56. struct wpa_dbus_signal_desc {
  57. /* signal name */
  58. const char *dbus_signal;
  59. /* signal interface */
  60. const char *dbus_interface;
  61. /* array of arguments */
  62. struct wpa_dbus_argument args[4];
  63. };
  64. /**
  65. * struct wpa_dbus_property_desc - DBus property description
  66. */
  67. struct wpa_dbus_property_desc {
  68. /* property name */
  69. const char *dbus_property;
  70. /* property interface */
  71. const char *dbus_interface;
  72. /* property type signature in DBus type notation */
  73. const char *type;
  74. /* property getter function */
  75. WPADBusPropertyAccessor getter;
  76. /* property setter function */
  77. WPADBusPropertyAccessor setter;
  78. };
  79. #define WPAS_DBUS_OBJECT_PATH_MAX 150
  80. #define WPAS_DBUS_INTERFACE_MAX 150
  81. #define WPAS_DBUS_METHOD_SIGNAL_PROP_MAX 50
  82. #define WPAS_DBUS_AUTH_MODE_MAX 64
  83. #define WPA_DBUS_INTROSPECTION_INTERFACE "org.freedesktop.DBus.Introspectable"
  84. #define WPA_DBUS_INTROSPECTION_METHOD "Introspect"
  85. #define WPA_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
  86. #define WPA_DBUS_PROPERTIES_GET "Get"
  87. #define WPA_DBUS_PROPERTIES_SET "Set"
  88. #define WPA_DBUS_PROPERTIES_GETALL "GetAll"
  89. void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc);
  90. int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface, char *dbus_path,
  91. char *dbus_service,
  92. struct wpa_dbus_object_desc *obj_desc);
  93. int wpa_dbus_register_object_per_iface(
  94. struct wpas_dbus_priv *ctrl_iface,
  95. const char *path, const char *ifname,
  96. struct wpa_dbus_object_desc *obj_desc);
  97. int wpa_dbus_unregister_object_per_iface(
  98. struct wpas_dbus_priv *ctrl_iface,
  99. const char *path);
  100. dbus_bool_t wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface,
  101. const char *path,
  102. const char *interface,
  103. DBusMessageIter *iter);
  104. void wpa_dbus_flush_all_changed_properties(DBusConnection *con);
  105. void wpa_dbus_flush_object_changed_properties(DBusConnection *con,
  106. const char *path);
  107. void wpa_dbus_mark_property_changed(struct wpas_dbus_priv *iface,
  108. const char *path, const char *interface,
  109. const char *property);
  110. DBusMessage * wpa_dbus_introspect(DBusMessage *message,
  111. struct wpa_dbus_object_desc *obj_dsc);
  112. char *wpas_dbus_new_decompose_object_path(const char *path,
  113. int p2p_persistent_group,
  114. char **network,
  115. char **bssid);
  116. DBusMessage *wpas_dbus_reply_new_from_error(DBusMessage *message,
  117. DBusError *error,
  118. const char *fallback_name,
  119. const char *fallback_string);
  120. #endif /* WPA_DBUS_CTRL_H */