3 * WPA supplicant library with GLib integration
5 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <dbus/dbus.h>
24 #define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"
25 #define SUPPLICANT_INTERFACE "fi.w1.wpa_supplicant1"
26 #define SUPPLICANT_PATH "/fi/w1/wpa_supplicant1"
28 typedef void (*supplicant_dbus_array_function) (DBusMessageIter *iter,
31 typedef void (*supplicant_dbus_property_function) (const char *key,
32 DBusMessageIter *iter, void *user_data);
34 typedef void (*supplicant_dbus_setup_function) (DBusMessageIter *iter,
37 typedef void (*supplicant_dbus_result_function) (const char *error,
38 DBusMessageIter *iter, void *user_data);
40 void supplicant_dbus_property_append_array(DBusMessageIter *iter,
41 const char *key, int type,
42 supplicant_dbus_array_function function,
45 void supplicant_dbus_setup(DBusConnection *conn);
47 void supplicant_dbus_array_foreach(DBusMessageIter *iter,
48 supplicant_dbus_array_function function,
51 void supplicant_dbus_property_foreach(DBusMessageIter *iter,
52 supplicant_dbus_property_function function,
55 int supplicant_dbus_property_get_all(const char *path, const char *interface,
56 supplicant_dbus_property_function function,
57 void *user_data, gpointer caller);
59 int supplicant_dbus_property_get(const char *path, const char *interface,
61 supplicant_dbus_property_function function,
62 void *user_data, gpointer caller);
64 int supplicant_dbus_property_set(const char *path, const char *interface,
65 const char *key, const char *signature,
66 supplicant_dbus_setup_function setup,
67 supplicant_dbus_result_function function,
68 void *user_data, gpointer caller);
70 void supplicant_dbus_property_call_cancel_all(gpointer caller);
72 int supplicant_dbus_method_call(const char *path,
73 const char *interface, const char *method,
74 supplicant_dbus_setup_function setup,
75 supplicant_dbus_result_function function,
79 void supplicant_dbus_method_call_cancel_all(gpointer caller);
81 void supplicant_dbus_property_append_basic(DBusMessageIter *iter,
82 const char *key, int type, void *val);
84 void supplicant_dbus_property_append_fixed_array(DBusMessageIter *iter,
85 const char *key, int type, void *val, int len);
87 static inline void supplicant_dbus_dict_open(DBusMessageIter *iter,
88 DBusMessageIter *dict)
90 dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
91 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
92 DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
93 DBUS_DICT_ENTRY_END_CHAR_AS_STRING, dict);
96 static inline void supplicant_dbus_dict_close(DBusMessageIter *iter,
97 DBusMessageIter *dict)
99 dbus_message_iter_close_container(iter, dict);
102 static inline void supplicant_dbus_dict_append_basic(DBusMessageIter *dict,
103 const char *key, int type, void *val)
105 DBusMessageIter entry;
107 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
109 supplicant_dbus_property_append_basic(&entry, key, type, val);
110 dbus_message_iter_close_container(dict, &entry);
114 supplicant_dbus_dict_append_fixed_array(DBusMessageIter *dict,
115 const char *key, int type, void *val, int len)
117 DBusMessageIter entry;
119 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
121 supplicant_dbus_property_append_fixed_array(&entry, key, type, val, len);
122 dbus_message_iter_close_container(dict, &entry);
126 supplicant_dbus_dict_append_array(DBusMessageIter *dict,
127 const char *key, int type,
128 supplicant_dbus_array_function function,
131 DBusMessageIter entry;
133 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
135 supplicant_dbus_property_append_array(&entry, key, type,
136 function, user_data);
137 dbus_message_iter_close_container(dict, &entry);