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