dbus_new_helpers.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 DBusMessage * (* WPADBusPropertyAccessor)(DBusMessage *message,
  22. const void *user_data);
  23. struct wpa_dbus_object_desc {
  24. DBusConnection *connection;
  25. /* list of methods, properties and signals registered with object */
  26. const struct wpa_dbus_method_desc *methods;
  27. const struct wpa_dbus_signal_desc *signals;
  28. const struct wpa_dbus_property_desc *properties;
  29. /* argument for method handlers and properties
  30. * getter and setter functions */
  31. void *user_data;
  32. /* function used to free above argument */
  33. WPADBusArgumentFreeFunction user_data_free_func;
  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. /**
  44. * struct wpa_dbus_method_desc - DBus method description
  45. */
  46. struct wpa_dbus_method_desc {
  47. /* method name */
  48. const char *dbus_method;
  49. /* method interface */
  50. const char *dbus_interface;
  51. /* method handling function */
  52. WPADBusMethodHandler method_handler;
  53. /* array of arguments */
  54. struct wpa_dbus_argument args[3];
  55. };
  56. /**
  57. * struct wpa_dbus_signal_desc - DBus signal description
  58. */
  59. struct wpa_dbus_signal_desc {
  60. /* signal name */
  61. const char *dbus_signal;
  62. /* signal interface */
  63. const char *dbus_interface;
  64. /* array of arguments */
  65. struct wpa_dbus_argument args[3];
  66. };
  67. /**
  68. * struct wpa_dbus_property_desc - DBus property description
  69. */
  70. struct wpa_dbus_property_desc {
  71. /* property name */
  72. const char *dbus_property;
  73. /* property interface */
  74. const char *dbus_interface;
  75. /* property type signature in DBus type notation */
  76. const char *type;
  77. /* property getter function */
  78. WPADBusPropertyAccessor getter;
  79. /* property setter function */
  80. WPADBusPropertyAccessor setter;
  81. /* property access permissions */
  82. enum dbus_prop_access access;
  83. };
  84. #define WPAS_DBUS_OBJECT_PATH_MAX 150
  85. #define WPAS_DBUS_INTERFACE_MAX 150
  86. #define WPAS_DBUS_METHOD_SIGNAL_PROP_MAX 50
  87. #define WPA_DBUS_INTROSPECTION_INTERFACE "org.freedesktop.DBus.Introspectable"
  88. #define WPA_DBUS_INTROSPECTION_METHOD "Introspect"
  89. #define WPA_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
  90. #define WPA_DBUS_PROPERTIES_GET "Get"
  91. #define WPA_DBUS_PROPERTIES_SET "Set"
  92. #define WPA_DBUS_PROPERTIES_GETALL "GetAll"
  93. void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc);
  94. int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface, char *dbus_path,
  95. char *dbus_service,
  96. struct wpa_dbus_object_desc *obj_desc);
  97. int wpa_dbus_register_object_per_iface(
  98. struct wpas_dbus_priv *ctrl_iface,
  99. const char *path, const char *ifname,
  100. struct wpa_dbus_object_desc *obj_desc);
  101. int wpa_dbus_unregister_object_per_iface(
  102. struct wpas_dbus_priv *ctrl_iface,
  103. const char *path);
  104. void wpa_dbus_signal_property_changed(struct wpas_dbus_priv *iface,
  105. WPADBusPropertyAccessor property_getter,
  106. void *getter_arg,
  107. const char *path,
  108. const char *interface_name,
  109. const char *property_name);
  110. void wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface,
  111. const char *path, const char *interface,
  112. DBusMessageIter *dict_iter);
  113. DBusMessage * wpa_dbus_introspect(DBusMessage *message,
  114. struct wpa_dbus_object_desc *obj_dsc);
  115. #endif /* WPA_DBUS_CTRL_H */