wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
dbus_dict_helpers.h
Go to the documentation of this file.
1 
5 #ifndef DBUS_DICT_HELPERS_H
6 #define DBUS_DICT_HELPERS_H
7 
8 #include "wpabuf.h"
9 
10 /*
11  * Adding a dict to a DBusMessage
12  */
13 
14 dbus_bool_t wpa_dbus_dict_open_write(DBusMessageIter *iter,
15  DBusMessageIter *iter_dict);
16 
17 dbus_bool_t wpa_dbus_dict_close_write(DBusMessageIter *iter,
18  DBusMessageIter *iter_dict);
19 
20 const char * wpa_dbus_type_as_string(const int type);
21 
22 dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict,
23  const char *key, const char *value);
24 
25 dbus_bool_t wpa_dbus_dict_append_byte(DBusMessageIter *iter_dict,
26  const char *key, const char value);
27 
28 dbus_bool_t wpa_dbus_dict_append_bool(DBusMessageIter *iter_dict,
29  const char *key,
30  const dbus_bool_t value);
31 
32 dbus_bool_t wpa_dbus_dict_append_int16(DBusMessageIter *iter_dict,
33  const char *key,
34  const dbus_int16_t value);
35 
36 dbus_bool_t wpa_dbus_dict_append_uint16(DBusMessageIter *iter_dict,
37  const char *key,
38  const dbus_uint16_t value);
39 
40 dbus_bool_t wpa_dbus_dict_append_int32(DBusMessageIter *iter_dict,
41  const char *key,
42  const dbus_int32_t value);
43 
44 dbus_bool_t wpa_dbus_dict_append_uint32(DBusMessageIter *iter_dict,
45  const char *key,
46  const dbus_uint32_t value);
47 
48 dbus_bool_t wpa_dbus_dict_append_int64(DBusMessageIter *iter_dict,
49  const char *key,
50  const dbus_int64_t value);
51 
52 dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict,
53  const char *key,
54  const dbus_uint64_t value);
55 
56 dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict,
57  const char *key,
58  const double value);
59 
60 dbus_bool_t wpa_dbus_dict_append_object_path(DBusMessageIter *iter_dict,
61  const char *key,
62  const char *value);
63 
64 dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict,
65  const char *key,
66  const char *value,
67  const dbus_uint32_t value_len);
68 
69 /* Manual construction and addition of array elements */
70 dbus_bool_t wpa_dbus_dict_begin_array(DBusMessageIter *iter_dict,
71  const char *key, const char *type,
72  DBusMessageIter *iter_dict_entry,
73  DBusMessageIter *iter_dict_val,
74  DBusMessageIter *iter_array);
75 
76 dbus_bool_t wpa_dbus_dict_begin_string_array(DBusMessageIter *iter_dict,
77  const char *key,
78  DBusMessageIter *iter_dict_entry,
79  DBusMessageIter *iter_dict_val,
80  DBusMessageIter *iter_array);
81 
82 dbus_bool_t wpa_dbus_dict_string_array_add_element(DBusMessageIter *iter_array,
83  const char *elem);
84 
85 dbus_bool_t wpa_dbus_dict_bin_array_add_element(DBusMessageIter *iter_array,
86  const u8 *value,
87  size_t value_len);
88 
89 dbus_bool_t wpa_dbus_dict_end_array(DBusMessageIter *iter_dict,
90  DBusMessageIter *iter_dict_entry,
91  DBusMessageIter *iter_dict_val,
92  DBusMessageIter *iter_array);
93 
94 static inline dbus_bool_t
95 wpa_dbus_dict_end_string_array(DBusMessageIter *iter_dict,
96  DBusMessageIter *iter_dict_entry,
97  DBusMessageIter *iter_dict_val,
98  DBusMessageIter *iter_array)
99 {
100  return wpa_dbus_dict_end_array(iter_dict, iter_dict_entry,
101  iter_dict_val, iter_array);
102 }
103 
104 /* Convenience function to add a whole string list */
105 dbus_bool_t wpa_dbus_dict_append_string_array(DBusMessageIter *iter_dict,
106  const char *key,
107  const char **items,
108  const dbus_uint32_t num_items);
109 
110 dbus_bool_t wpa_dbus_dict_append_wpabuf_array(DBusMessageIter *iter_dict,
111  const char *key,
112  const struct wpabuf **items,
113  const dbus_uint32_t num_items);
114 
115 /*
116  * Reading a dict from a DBusMessage
117  */
118 
119 /*
120  * Used only in struct wpa_dbus_dict_entry::array_type internally to identify
121  * special binary array case.
122  */
123 #define WPAS_DBUS_TYPE_BINARRAY ((int) '@')
124 
126  int type;
130  const char *key;
133  union {
134  char *str_value;
135  char byte_value;
136  dbus_bool_t bool_value;
137  dbus_int16_t int16_value;
138  dbus_uint16_t uint16_value;
139  dbus_int32_t int32_value;
140  dbus_uint32_t uint32_value;
141  dbus_int64_t int64_value;
142  dbus_uint64_t uint64_value;
143  double double_value;
144  char *bytearray_value;
145  char **strarray_value;
146  struct wpabuf **binarray_value;
147  };
148  dbus_uint32_t array_len;
150 };
151 
152 dbus_bool_t wpa_dbus_dict_open_read(DBusMessageIter *iter,
153  DBusMessageIter *iter_dict,
154  DBusError *error);
155 
156 dbus_bool_t wpa_dbus_dict_get_entry(DBusMessageIter *iter_dict,
157  struct wpa_dbus_dict_entry *entry);
158 
159 dbus_bool_t wpa_dbus_dict_has_dict_entry(DBusMessageIter *iter_dict);
160 
162 
163 #endif /* DBUS_DICT_HELPERS_H */
Definition: dbus_dict_helpers.h:125
const char * key
Definition: dbus_dict_helpers.h:130
dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict, const char *key, const char *value, const dbus_uint32_t value_len)
Add a byte array entry to the dict.
Definition: dbus_dict_helpers.c:403
dbus_bool_t wpa_dbus_dict_open_write(DBusMessageIter *iter, DBusMessageIter *iter_dict)
Start a dict in a dbus message. Should be paired with a call to wpa_dbus_dict_close_write().
Definition: dbus_dict_helpers.c:22
dbus_bool_t wpa_dbus_dict_open_read(DBusMessageIter *iter, DBusMessageIter *iter_dict, DBusError *error)
Start reading from a dbus dict.
Definition: dbus_dict_helpers.c:651
dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict, const char *key, const double value)
Add a double-precision floating point entry to the dict.
Definition: dbus_dict_helpers.c:363
dbus_bool_t wpa_dbus_dict_begin_array(DBusMessageIter *iter_dict, const char *key, const char *type, DBusMessageIter *iter_dict_entry, DBusMessageIter *iter_dict_val, DBusMessageIter *iter_array)
Begin an array entry in the dict.
Definition: dbus_dict_helpers.c:431
dbus_bool_t wpa_dbus_dict_append_byte(DBusMessageIter *iter_dict, const char *key, const char value)
Add a byte entry to the dict.
Definition: dbus_dict_helpers.c:213
dbus_bool_t wpa_dbus_dict_append_int64(DBusMessageIter *iter_dict, const char *key, const dbus_int64_t value)
Add a 64-bit integer entry to the dict.
Definition: dbus_dict_helpers.c:325
void wpa_dbus_dict_entry_clear(struct wpa_dbus_dict_entry *entry)
Free any memory used by the entry object.
Definition: dbus_dict_helpers.c:1098
dbus_bool_t wpa_dbus_dict_has_dict_entry(DBusMessageIter *iter_dict)
Return whether or not there are additional dictionary entries.
Definition: dbus_dict_helpers.c:1084
dbus_bool_t wpa_dbus_dict_bin_array_add_element(DBusMessageIter *iter_array, const u8 *value, size_t value_len)
Add a single byte array element to a string array dict entry.
Definition: dbus_dict_helpers.c:506
Definition: wpabuf.h:16
dbus_bool_t wpa_dbus_dict_get_entry(DBusMessageIter *iter_dict, struct wpa_dbus_dict_entry *entry)
Read the current key/value entry from the dict. Entries are dynamically allocated when needed and mus...
Definition: dbus_dict_helpers.c:1020
dbus_bool_t wpa_dbus_dict_string_array_add_element(DBusMessageIter *iter_array, const char *elem)
Add a single string element to a string array dict entry.
Definition: dbus_dict_helpers.c:483
dbus_bool_t wpa_dbus_dict_append_uint16(DBusMessageIter *iter_dict, const char *key, const dbus_uint16_t value)
Add a 16-bit unsigned integer entry to the dict.
Definition: dbus_dict_helpers.c:268
Dynamic data buffer.
dbus_bool_t wpa_dbus_dict_append_string_array(DBusMessageIter *iter_dict, const char *key, const char **items, const dbus_uint32_t num_items)
Convenience function to add an entire string array to the dict.
Definition: dbus_dict_helpers.c:572
dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict, const char *key, const char *value)
Add a string entry to the dict.
Definition: dbus_dict_helpers.c:193
dbus_bool_t wpa_dbus_dict_append_uint32(DBusMessageIter *iter_dict, const char *key, const dbus_uint32_t value)
Add a 32-bit unsigned integer entry to the dict.
Definition: dbus_dict_helpers.c:306
dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict, const char *key, const dbus_uint64_t value)
Add a 64-bit unsigned integer entry to the dict.
Definition: dbus_dict_helpers.c:344
int array_type
the dbus type of the dict entry's value
Definition: dbus_dict_helpers.h:127
dbus_bool_t wpa_dbus_dict_append_wpabuf_array(DBusMessageIter *iter_dict, const char *key, const struct wpabuf **items, const dbus_uint32_t num_items)
Convenience function to add an wpabuf binary array to the dict.
Definition: dbus_dict_helpers.c:608
dbus_bool_t wpa_dbus_dict_append_int16(DBusMessageIter *iter_dict, const char *key, const dbus_int16_t value)
Add a 16-bit signed integer entry to the dict.
Definition: dbus_dict_helpers.c:249
dbus_bool_t wpa_dbus_dict_append_bool(DBusMessageIter *iter_dict, const char *key, const dbus_bool_t value)
Add a boolean entry to the dict.
Definition: dbus_dict_helpers.c:231
dbus_bool_t wpa_dbus_dict_close_write(DBusMessageIter *iter, DBusMessageIter *iter_dict)
End a dict element in a dbus message. Should be paired with a call to wpa_dbus_dict_open_write().
Definition: dbus_dict_helpers.c:53
dbus_bool_t wpa_dbus_dict_append_object_path(DBusMessageIter *iter_dict, const char *key, const char *value)
Add a DBus object path entry to the dict.
Definition: dbus_dict_helpers.c:381
dbus_bool_t wpa_dbus_dict_append_int32(DBusMessageIter *iter_dict, const char *key, const dbus_int32_t value)
Add a 32-bit signed integer to the dict.
Definition: dbus_dict_helpers.c:287
dbus_bool_t wpa_dbus_dict_end_array(DBusMessageIter *iter_dict, DBusMessageIter *iter_dict_entry, DBusMessageIter *iter_dict_val, DBusMessageIter *iter_array)
End an array dict entry.
Definition: dbus_dict_helpers.c:547