dbus_new_helpers.h revision 75ecf5267604f166b85a7ee2cf0d9cb682966680
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 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 25typedef DBusMessage * (* WPADBusPropertyAccessor)(DBusMessage *message, 26 const 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 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 */ 70 struct wpa_dbus_argument args[3]; 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 */ 82 struct wpa_dbus_argument args[3]; 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; 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 107#define WPAS_DBUS_AUTH_MODE_MAX 64 108 109#define WPA_DBUS_INTROSPECTION_INTERFACE "org.freedesktop.DBus.Introspectable" 110#define WPA_DBUS_INTROSPECTION_METHOD "Introspect" 111#define WPA_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties" 112#define WPA_DBUS_PROPERTIES_GET "Get" 113#define WPA_DBUS_PROPERTIES_SET "Set" 114#define WPA_DBUS_PROPERTIES_GETALL "GetAll" 115 116void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc); 117 118int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface, char *dbus_path, 119 char *dbus_service, 120 struct wpa_dbus_object_desc *obj_desc); 121 122int wpa_dbus_register_object_per_iface( 123 struct wpas_dbus_priv *ctrl_iface, 124 const char *path, const char *ifname, 125 struct wpa_dbus_object_desc *obj_desc); 126 127int wpa_dbus_unregister_object_per_iface( 128 struct wpas_dbus_priv *ctrl_iface, 129 const char *path); 130 131void wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface, 132 const char *path, const char *interface, 133 DBusMessageIter *dict_iter); 134 135 136void wpa_dbus_flush_all_changed_properties(DBusConnection *con); 137 138void wpa_dbus_flush_object_changed_properties(DBusConnection *con, 139 const char *path); 140 141void wpa_dbus_mark_property_changed(struct wpas_dbus_priv *iface, 142 const char *path, const char *interface, 143 const char *property); 144 145DBusMessage * wpa_dbus_introspect(DBusMessage *message, 146 struct wpa_dbus_object_desc *obj_dsc); 147 148char *wpas_dbus_new_decompose_object_path(const char *path, 149 int p2p_persistent_group, 150 char **network, 151 char **bssid); 152 153#endif /* WPA_DBUS_CTRL_H */ 154