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>
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
10 #ifndef WPA_DBUS_CTRL_H
11 #define WPA_DBUS_CTRL_H
13 #include <dbus/dbus.h>
15 typedef DBusMessage * (* WPADBusMethodHandler)(DBusMessage *message,
17 typedef void (* WPADBusArgumentFreeFunction)(void *handler_arg);
19 typedef dbus_bool_t (* WPADBusPropertyAccessor)(DBusMessageIter *iter,
23 struct wpa_dbus_object_desc {
24 DBusConnection *connection;
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;
32 /* property changed flags */
33 u8 *prop_changed_flags;
35 /* argument for method handlers and properties
36 * getter and setter functions */
38 /* function used to free above argument */
39 WPADBusArgumentFreeFunction user_data_free_func;
42 enum dbus_arg_direction { ARG_IN, ARG_OUT };
44 struct wpa_dbus_argument {
47 enum dbus_arg_direction dir;
50 #define END_ARGS { NULL, NULL, ARG_IN }
53 * struct wpa_dbus_method_desc - DBus method description
55 struct wpa_dbus_method_desc {
57 const char *dbus_method;
58 /* method interface */
59 const char *dbus_interface;
60 /* method handling function */
61 WPADBusMethodHandler method_handler;
62 /* array of arguments */
63 struct wpa_dbus_argument args[4];
67 * struct wpa_dbus_signal_desc - DBus signal description
69 struct wpa_dbus_signal_desc {
71 const char *dbus_signal;
72 /* signal interface */
73 const char *dbus_interface;
74 /* array of arguments */
75 struct wpa_dbus_argument args[4];
79 * struct wpa_dbus_property_desc - DBus property description
81 struct wpa_dbus_property_desc {
83 const char *dbus_property;
84 /* property interface */
85 const char *dbus_interface;
86 /* property type signature in DBus type notation */
88 /* property getter function */
89 WPADBusPropertyAccessor getter;
90 /* property setter function */
91 WPADBusPropertyAccessor setter;
95 #define WPAS_DBUS_OBJECT_PATH_MAX 150
96 #define WPAS_DBUS_INTERFACE_MAX 150
97 #define WPAS_DBUS_METHOD_SIGNAL_PROP_MAX 50
98 #define WPAS_DBUS_AUTH_MODE_MAX 64
100 #define WPA_DBUS_INTROSPECTION_INTERFACE "org.freedesktop.DBus.Introspectable"
101 #define WPA_DBUS_INTROSPECTION_METHOD "Introspect"
102 #define WPA_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
103 #define WPA_DBUS_PROPERTIES_GET "Get"
104 #define WPA_DBUS_PROPERTIES_SET "Set"
105 #define WPA_DBUS_PROPERTIES_GETALL "GetAll"
107 void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc);
109 int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface, char *dbus_path,
111 struct wpa_dbus_object_desc *obj_desc);
113 int wpa_dbus_register_object_per_iface(
114 struct wpas_dbus_priv *ctrl_iface,
115 const char *path, const char *ifname,
116 struct wpa_dbus_object_desc *obj_desc);
118 int wpa_dbus_unregister_object_per_iface(
119 struct wpas_dbus_priv *ctrl_iface,
122 dbus_bool_t wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface,
124 const char *interface,
125 DBusMessageIter *iter);
128 void wpa_dbus_flush_all_changed_properties(DBusConnection *con);
130 void wpa_dbus_flush_object_changed_properties(DBusConnection *con,
133 void wpa_dbus_mark_property_changed(struct wpas_dbus_priv *iface,
134 const char *path, const char *interface,
135 const char *property);
137 DBusMessage * wpa_dbus_introspect(DBusMessage *message,
138 struct wpa_dbus_object_desc *obj_dsc);
140 char *wpas_dbus_new_decompose_object_path(const char *path,
141 int p2p_persistent_group,
145 DBusMessage *wpas_dbus_reply_new_from_error(DBusMessage *message,
147 const char *fallback_name,
148 const char *fallback_string);
150 #endif /* WPA_DBUS_CTRL_H */