dbus_new_helpers.h 4.5 KB

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