dbus_new_helpers.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. 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. #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. int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface, char *dbus_path,
  64. char *dbus_service,
  65. struct wpa_dbus_object_desc *obj_desc);
  66. int wpa_dbus_register_object_per_iface(
  67. struct wpas_dbus_priv *ctrl_iface,
  68. const char *path, const char *ifname,
  69. struct wpa_dbus_object_desc *obj_desc);
  70. int wpa_dbus_unregister_object_per_iface(
  71. struct wpas_dbus_priv *ctrl_iface,
  72. const char *path);
  73. int wpa_dbus_method_register(struct wpa_dbus_object_desc *obj_dsc,
  74. const char *dbus_interface,
  75. const char *dbus_method,
  76. WPADBusMethodHandler method_handler,
  77. const struct wpa_dbus_argument args[]);
  78. int wpa_dbus_signal_register(struct wpa_dbus_object_desc *obj_dsc,
  79. const char *dbus_interface,
  80. const char *dbus_signal,
  81. const struct wpa_dbus_argument args[]);
  82. int wpa_dbus_property_register(
  83. struct wpa_dbus_object_desc *obj_dsc,
  84. const char *dbus_interface, const char *dbus_property,
  85. const char *type,
  86. WPADBusPropertyAccessor getter,
  87. WPADBusPropertyAccessor setter,
  88. enum dbus_prop_access _access);
  89. void wpa_dbus_signal_property_changed(struct wpas_dbus_priv *iface,
  90. WPADBusPropertyAccessor property_getter,
  91. void *getter_arg,
  92. const char *path,
  93. const char *interface_name,
  94. const char *property_name);
  95. #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
  96. static inline void wpa_dbus_signal_property_changed(
  97. struct wpas_dbus_priv *iface,
  98. WPADBusPropertyAccessor property_getter, void *getter_arg,
  99. const char *path, const char *interface_name,
  100. const char *property_name)
  101. {
  102. }
  103. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  104. #endif /* WPA_DBUS_CTRL_H */