dbus_new_helpers.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. struct wpa_dbus_method_desc *methods;
  27. struct wpa_dbus_signal_desc *signals;
  28. 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. #ifndef SIGPOLL
  44. #ifdef SIGIO
  45. /*
  46. * If we do not have SIGPOLL, try to use SIGIO instead. This is needed for
  47. * FreeBSD.
  48. */
  49. #define SIGPOLL SIGIO
  50. #endif
  51. #endif
  52. #define WPAS_DBUS_OBJECT_PATH_MAX 150
  53. #define WPAS_DBUS_INTERFACE_MAX 150
  54. #define WPAS_DBUS_METHOD_SIGNAL_PROP_MAX 50
  55. #define WPA_DBUS_INTROSPECTION_INTERFACE "org.freedesktop.DBus.Introspectable"
  56. #define WPA_DBUS_INTROSPECTION_METHOD "Introspect"
  57. #define WPA_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
  58. #define WPA_DBUS_PROPERTIES_GET "Get"
  59. #define WPA_DBUS_PROPERTIES_SET "Set"
  60. #define WPA_DBUS_PROPERTIES_GETALL "GetAll"
  61. void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc);
  62. int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface, char *dbus_path,
  63. char *dbus_service,
  64. struct wpa_dbus_object_desc *obj_desc);
  65. int wpa_dbus_register_object_per_iface(
  66. struct wpas_dbus_priv *ctrl_iface,
  67. const char *path, const char *ifname,
  68. struct wpa_dbus_object_desc *obj_desc);
  69. int wpa_dbus_unregister_object_per_iface(
  70. struct wpas_dbus_priv *ctrl_iface,
  71. const char *path);
  72. int wpa_dbus_method_register(struct wpa_dbus_object_desc *obj_dsc,
  73. const char *dbus_interface,
  74. const char *dbus_method,
  75. WPADBusMethodHandler method_handler,
  76. const struct wpa_dbus_argument args[]);
  77. int wpa_dbus_signal_register(struct wpa_dbus_object_desc *obj_dsc,
  78. const char *dbus_interface,
  79. const char *dbus_signal,
  80. const struct wpa_dbus_argument args[]);
  81. int wpa_dbus_property_register(
  82. struct wpa_dbus_object_desc *obj_dsc,
  83. const char *dbus_interface, const char *dbus_property,
  84. const char *type,
  85. WPADBusPropertyAccessor getter,
  86. WPADBusPropertyAccessor setter,
  87. enum dbus_prop_access _access);
  88. void wpa_dbus_signal_property_changed(struct wpas_dbus_priv *iface,
  89. WPADBusPropertyAccessor property_getter,
  90. void *getter_arg,
  91. const char *path,
  92. const char *interface_name,
  93. const char *property_name);
  94. void wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface,
  95. const char *path, const char *interface,
  96. DBusMessageIter *dict_iter);
  97. #endif /* WPA_DBUS_CTRL_H */