wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
dbus_dict_helpers.c File Reference

WPA Supplicant / dbus-based control interface. More...

#include "includes.h"
#include <dbus/dbus.h>
#include "common.h"
#include "wpabuf.h"
#include "dbus_dict_helpers.h"

Macros

#define BYTE_ARRAY_CHUNK_SIZE   34
 
#define BYTE_ARRAY_ITEM_SIZE   (sizeof(char))
 
#define STR_ARRAY_CHUNK_SIZE   8
 
#define STR_ARRAY_ITEM_SIZE   (sizeof(char *))
 
#define BIN_ARRAY_CHUNK_SIZE   10
 
#define BIN_ARRAY_ITEM_SIZE   (sizeof(struct wpabuf *))
 

Functions

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(). More...
 
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(). More...
 
const char * wpa_dbus_type_as_string (const int type)
 
dbus_bool_t wpa_dbus_dict_append_string (DBusMessageIter *iter_dict, const char *key, const char *value)
 Add a string entry to the dict. More...
 
dbus_bool_t wpa_dbus_dict_append_byte (DBusMessageIter *iter_dict, const char *key, const char value)
 Add a byte entry to the dict. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
dbus_bool_t wpa_dbus_dict_begin_string_array (DBusMessageIter *iter_dict, const char *key, DBusMessageIter *iter_dict_entry, DBusMessageIter *iter_dict_val, DBusMessageIter *iter_array)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
dbus_bool_t wpa_dbus_dict_open_read (DBusMessageIter *iter, DBusMessageIter *iter_dict, DBusError *error)
 Start reading from a dbus dict. More...
 
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 must be freed after use with the wpa_dbus_dict_entry_clear() function. More...
 
dbus_bool_t wpa_dbus_dict_has_dict_entry (DBusMessageIter *iter_dict)
 Return whether or not there are additional dictionary entries. More...
 
void wpa_dbus_dict_entry_clear (struct wpa_dbus_dict_entry *entry)
 Free any memory used by the entry object. More...
 

Detailed Description

WPA Supplicant / dbus-based control interface.

Function Documentation

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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The boolean value
returnTRUE on success, FALSE on failure
dbus_bool_t wpa_dbus_dict_append_byte ( DBusMessageIter *  iter_dict,
const char *  key,
const char  value 
)

Add a byte entry to the dict.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The byte value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The byte array
paramvalue_len The length of the byte array, in bytes
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The double-precision floating point value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The 16-bit signed integer value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The 32-bit signed integer value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The 64-bit integer value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The DBus object path value
returnTRUE on success, FALSE on failure
dbus_bool_t wpa_dbus_dict_append_string ( DBusMessageIter *  iter_dict,
const char *  key,
const char *  value 
)

Add a string entry to the dict.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The string value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramitems The array of strings
paramnum_items The number of strings in the array
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The 16-bit unsigned integer value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The 32-bit unsigned integer value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramvalue The 64-bit unsigned integer value
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramitems The array of wpabuf structures
paramnum_items The number of strings in the array
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramkey The key of the dict item
paramtype The type of the contained data
paramiter_dict_entry A private DBusMessageIter provided by the caller to be passed to wpa_dbus_dict_end_string_array()
paramiter_dict_val A private DBusMessageIter provided by the caller to be passed to wpa_dbus_dict_end_string_array()
paramiter_array On return, the DBusMessageIter to be passed to wpa_dbus_dict_string_array_add_element()
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_array A valid DBusMessageIter returned from wpa_dbus_dict_begin_array()'s iter_array parameter – note that wpa_dbus_dict_begin_array() must have been called with "ay" as the type
paramvalue The data to be added to the dict entry's array
paramvalue_len The length of the data
returnTRUE on success, FALSE on failure
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().

Parameters
paramiter valid dbus message iterator, same as passed to wpa_dbus_dict_open_write()
paramiter_dict a dbus dict iterator returned from wpa_dbus_dict_open_write()
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_write()
paramiter_dict_entry A private DBusMessageIter returned from wpa_dbus_dict_begin_string_array() or wpa_dbus_dict_begin_array()
paramiter_dict_val A private DBusMessageIter returned from wpa_dbus_dict_begin_string_array() or wpa_dbus_dict_begin_array()
paramiter_array A DBusMessageIter returned from wpa_dbus_dict_begin_string_array() or wpa_dbus_dict_begin_array()
returnTRUE on success, FALSE on failure
void wpa_dbus_dict_entry_clear ( struct wpa_dbus_dict_entry entry)

Free any memory used by the entry object.

Parameters
paramentry The entry object
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 must be freed after use with the wpa_dbus_dict_entry_clear() function.

The returned entry object will be filled with the type and value of the next entry in the dict, or the type will be DBUS_TYPE_INVALID if an error occurred.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_read()
paramentry A valid dict entry object into which the dict key and value will be placed
returnTRUE on success, FALSE on failure
dbus_bool_t wpa_dbus_dict_has_dict_entry ( DBusMessageIter *  iter_dict)

Return whether or not there are additional dictionary entries.

Parameters
paramiter_dict A valid DBusMessageIter returned from wpa_dbus_dict_open_read()
returnTRUE if more dict entries exists, FALSE if no more dict entries exist
dbus_bool_t wpa_dbus_dict_open_read ( DBusMessageIter *  iter,
DBusMessageIter *  iter_dict,
DBusError *  error 
)

Start reading from a dbus dict.

Parameters
paramiter A valid DBusMessageIter pointing to the start of the dict
paramiter_dict (out) A DBusMessageIter to be passed to wpa_dbus_dict_read_next_entry()
erroron failure a descriptive error
returnTRUE on success, FALSE on failure
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().

Parameters
paramiter A valid dbus message iterator
paramiter_dict (out) A dict iterator to pass to further dict functions
returnTRUE on success, FALSE on failure
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.

Parameters
paramiter_array A valid DBusMessageIter returned from wpa_dbus_dict_begin_string_array()'s iter_array parameter
paramelem The string element to be added to the dict entry's string array
returnTRUE on success, FALSE on failure