7,14c7,8
< * This program is free software; you can redistribute it and/or modify
< * it under the terms of the GNU General Public License version 2 as
< * published by the Free Software Foundation.
< *
< * Alternatively, this software may be distributed under the terms of BSD
< * license.
< *
< * See README and COPYING for more details.
---
> * This software may be distributed under the terms of the BSD license.
> * See README for more details.
28d21
< #include "../wpas_glue.h"
30a24
> #include "../autoscan.h"
34a29
> #include "dbus_common_i.h"
41c36
< "msgdump", "debug", "info", "warning", "error", NULL
---
> "excessive", "msgdump", "debug", "info", "warning", "error", NULL
46,109d40
< * wpas_dbus_new_decompose_object_path - Decompose an interface object path into parts
< * @path: The dbus object path
< * @network: (out) the configured network this object path refers to, if any
< * @bssid: (out) the scanned bssid this object path refers to, if any
< * Returns: The object path of the network interface this path refers to
< *
< * For a given object path, decomposes the object path into object id, network,
< * and BSSID parts, if those parts exist.
< */
< static char * wpas_dbus_new_decompose_object_path(const char *path,
< char **network,
< char **bssid)
< {
< const unsigned int dev_path_prefix_len =
< strlen(WPAS_DBUS_NEW_PATH_INTERFACES "/");
< char *obj_path_only;
< char *next_sep;
<
< /* Be a bit paranoid about path */
< if (!path || os_strncmp(path, WPAS_DBUS_NEW_PATH_INTERFACES "/",
< dev_path_prefix_len))
< return NULL;
<
< /* Ensure there's something at the end of the path */
< if ((path + dev_path_prefix_len)[0] == '\0')
< return NULL;
<
< obj_path_only = os_strdup(path);
< if (obj_path_only == NULL)
< return NULL;
<
< next_sep = os_strchr(obj_path_only + dev_path_prefix_len, '/');
< if (next_sep != NULL) {
< const char *net_part = os_strstr(
< next_sep, WPAS_DBUS_NEW_NETWORKS_PART "/");
< const char *bssid_part = os_strstr(
< next_sep, WPAS_DBUS_NEW_BSSIDS_PART "/");
<
< if (network && net_part) {
< /* Deal with a request for a configured network */
< const char *net_name = net_part +
< os_strlen(WPAS_DBUS_NEW_NETWORKS_PART "/");
< *network = NULL;
< if (os_strlen(net_name))
< *network = os_strdup(net_name);
< } else if (bssid && bssid_part) {
< /* Deal with a request for a scanned BSSID */
< const char *bssid_name = bssid_part +
< os_strlen(WPAS_DBUS_NEW_BSSIDS_PART "/");
< if (strlen(bssid_name))
< *bssid = os_strdup(bssid_name);
< else
< *bssid = NULL;
< }
<
< /* Cut off interface object path before "/" */
< *next_sep = '\0';
< }
<
< return obj_path_only;
< }
<
<
< /**
119a51,64
> /*
> * This function can be called as a result of a failure
> * within internal getter calls, which will call this function
> * with a NULL message parameter. However, dbus_message_new_error
> * looks very unkindly (i.e, abort()) on a NULL message, so
> * in this case, we should not call it.
> */
> if (message == NULL) {
> wpa_printf(MSG_INFO, "dbus: wpas_dbus_error_unknown_error "
> "called with NULL message (arg=%s)",
> arg ? arg : "N/A");
> return NULL;
> }
>
181c126
< "bssid", NULL
---
> "bssid", "scan_freq", "freq_list", NULL
216d160
< * @message: Pointer to incoming dbus message
221c165,166
< * Returns: NULL when succeed or DBus error on failure
---
> * @error: On failure, an error describing the failure
> * Returns: TRUE if the request succeeds, FALSE if it failed
225,228c170,173
< static DBusMessage * set_network_properties(DBusMessage *message,
< struct wpa_supplicant *wpa_s,
< struct wpa_ssid *ssid,
< DBusMessageIter *iter)
---
> dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
> struct wpa_ssid *ssid,
> DBusMessageIter *iter,
> DBusError *error)
230d174
<
232d175
< DBusMessage *reply = NULL;
233a177
> char *value = NULL;
235,236c179,180
< if (!wpa_dbus_dict_open_read(iter, &iter_dict))
< return wpas_dbus_error_invalid_args(message, NULL);
---
> if (!wpa_dbus_dict_open_read(iter, &iter_dict, error))
> return FALSE;
239d182
< char *value = NULL;
242,245c185,189
< if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) {
< reply = wpas_dbus_error_invalid_args(message, NULL);
< break;
< }
---
>
> if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
> goto error;
>
> value = NULL;
307c251
< (strcmp(entry.key, "ssid") == 0 && ssid->passphrase))
---
> (os_strcmp(entry.key, "ssid") == 0 && ssid->passphrase))
314,320d257
< continue;
<
< error:
< os_free(value);
< reply = wpas_dbus_error_invalid_args(message, entry.key);
< wpa_dbus_dict_entry_clear(&entry);
< break;
323c260,267
< return reply;
---
> return TRUE;
>
> error:
> os_free(value);
> wpa_dbus_dict_entry_clear(&entry);
> dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
> "invalid message format");
> return FALSE;
329c273
< * @message: Pointer to incoming dbus message
---
> * @iter: Message iter to use when appending arguments
332,333c276,277
< * Returns: The DBus message containing response for Properties.Get call
< * or DBus error message if error occurred.
---
> * @error: On failure an error describing the failure
> * Returns: TRUE if the request was successful, FALSE if it failed
337,338c281,284
< DBusMessage * wpas_dbus_simple_property_getter(DBusMessage *message,
< const int type, const void *val)
---
> dbus_bool_t wpas_dbus_simple_property_getter(DBusMessageIter *iter,
> const int type,
> const void *val,
> DBusError *error)
340,341c286
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter;
---
> DBusMessageIter variant_iter;
344,346c289,291
< wpa_printf(MSG_ERROR, "dbus: wpas_dbus_simple_property_getter:"
< " given type is not basic");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: given type is not basic", __func__);
> return FALSE;
349,352c294,297
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
> wpa_dbus_type_as_string(type),
> &variant_iter))
> goto error;
354,376c299,300
< if (reply != NULL) {
< dbus_message_iter_init_append(reply, &iter);
< if (!dbus_message_iter_open_container(
< &iter, DBUS_TYPE_VARIANT,
< wpa_dbus_type_as_string(type), &variant_iter) ||
< !dbus_message_iter_append_basic(&variant_iter, type,
< val) ||
< !dbus_message_iter_close_container(&iter, &variant_iter)) {
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_property_getter: out of "
< "memory to put property value into "
< "message");
< dbus_message_unref(reply);
< reply = dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
< }
< } else {
< wpa_printf(MSG_ERROR, "dbus: wpas_dbus_simple_property_getter:"
< " out of memory to return property value");
< reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
< }
---
> if (!dbus_message_iter_append_basic(&variant_iter, type, val))
> goto error;
378c302,310
< return reply;
---
> if (!dbus_message_iter_close_container(iter, &variant_iter))
> goto error;
>
> return TRUE;
>
> error:
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: error constructing reply", __func__);
> return FALSE;
387c319
< * Returns: NULL or DBus error message if error occurred.
---
> * Returns: TRUE if the request was successful, FALSE if it failed
391,392c323,325
< DBusMessage * wpas_dbus_simple_property_setter(DBusMessage *message,
< const int type, void *val)
---
> dbus_bool_t wpas_dbus_simple_property_setter(DBusMessageIter *iter,
> DBusError *error,
> const int type, void *val)
394c327
< DBusMessageIter iter, variant_iter;
---
> DBusMessageIter variant_iter;
397,399c330,332
< wpa_printf(MSG_ERROR, "dbus: wpas_dbus_simple_property_setter:"
< " given type is not basic");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: given type is not basic", __func__);
> return FALSE;
402,413c335,336
< if (!dbus_message_iter_init(message, &iter)) {
< wpa_printf(MSG_ERROR, "dbus: wpas_dbus_simple_property_setter:"
< " out of memory to return scanning state");
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
< }
<
< /* omit first and second argument and get value from third */
< dbus_message_iter_next(&iter);
< dbus_message_iter_next(&iter);
< dbus_message_iter_recurse(&iter, &variant_iter);
<
---
> /* Look at the new value */
> dbus_message_iter_recurse(iter, &variant_iter);
415,418c338,340
< wpa_printf(MSG_DEBUG, "dbus: wpas_dbus_simple_property_setter:"
< " wrong property type");
< return wpas_dbus_error_invalid_args(message,
< "wrong property type");
---
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "wrong property type");
> return FALSE;
422c344
< return NULL;
---
> return TRUE;
428c350
< * @message: Pointer to incoming dbus message
---
> * @iter: Pointer to incoming dbus message iterator
432,433c354,355
< * Returns: The DBus message containing response for Properties.Get call
< * or DBus error message if error occurred.
---
> * @error: a pointer to an error to fill on failure
> * Returns: TRUE if the request succeeded, FALSE if it failed
438,441c360,364
< DBusMessage * wpas_dbus_simple_array_property_getter(DBusMessage *message,
< const int type,
< const void *array,
< size_t array_len)
---
> dbus_bool_t wpas_dbus_simple_array_property_getter(DBusMessageIter *iter,
> const int type,
> const void *array,
> size_t array_len,
> DBusError *error)
443,444c366
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter, array_iter;
---
> DBusMessageIter variant_iter, array_iter;
450,453c372,374
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: given "
< "type is not basic");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: given type is not basic", __func__);
> return FALSE;
459,468c380,384
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (reply == NULL) {
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: out of "
< "memory to create return message");
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
> type_str, &variant_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 1", __func__);
> return FALSE;
471,475c387
< dbus_message_iter_init_append(reply, &iter);
<
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
< type_str, &variant_iter) ||
< !dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
---
> if (!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
477,482c389,391
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: out of "
< "memory to open container");
< dbus_message_unref(reply);
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 2", __func__);
> return FALSE;
510,514c419,421
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: "
< "fatal: unknown element type");
< element_size = 1;
< break;
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: unknown element type %d", __func__, type);
> return FALSE;
522,529c429,432
< if (!dbus_message_iter_close_container(&variant_iter, &array_iter) ||
< !dbus_message_iter_close_container(&iter, &variant_iter)) {
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: out of "
< "memory to close container");
< dbus_message_unref(reply);
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 3", __func__);
> return FALSE;
532c435,441
< return reply;
---
> if (!dbus_message_iter_close_container(iter, &variant_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 4", __func__);
> return FALSE;
> }
>
> return TRUE;
536a446,515
> * wpas_dbus_simple_array_array_property_getter - Get array array type property
> * @iter: Pointer to incoming dbus message iterator
> * @type: DBus type of property array elements (must be basic type)
> * @array: pointer to array of elements to put into response message
> * @array_len: length of above array
> * @error: a pointer to an error to fill on failure
> * Returns: TRUE if the request succeeded, FALSE if it failed
> *
> * Generic getter for array type properties. Array elements type is
> * required to be basic.
> */
> dbus_bool_t wpas_dbus_simple_array_array_property_getter(DBusMessageIter *iter,
> const int type,
> struct wpabuf **array,
> size_t array_len,
> DBusError *error)
> {
> DBusMessageIter variant_iter, array_iter;
> char type_str[] = "aa?";
> char inner_type_str[] = "a?";
> const char *sub_type_str;
> size_t i;
>
> if (!dbus_type_is_basic(type)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: given type is not basic", __func__);
> return FALSE;
> }
>
> sub_type_str = wpa_dbus_type_as_string(type);
> type_str[2] = sub_type_str[0];
> inner_type_str[1] = sub_type_str[0];
>
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
> type_str, &variant_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 1", __func__);
> return FALSE;
> }
> if (!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
> inner_type_str, &array_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 2", __func__);
> return FALSE;
> }
>
> for (i = 0; i < array_len; i++) {
> wpa_dbus_dict_bin_array_add_element(&array_iter,
> wpabuf_head(array[i]),
> wpabuf_len(array[i]));
>
> }
>
> if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to close message 2", __func__);
> return FALSE;
> }
>
> if (!dbus_message_iter_close_container(iter, &variant_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to close message 1", __func__);
> return FALSE;
> }
>
> return TRUE;
> }
>
>
> /**
555a535
> char *confname = NULL;
560c540
< if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
---
> if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
565c545
< if (!strcmp(entry.key, "Driver") &&
---
> if (!os_strcmp(entry.key, "Driver") &&
571c551
< } else if (!strcmp(entry.key, "Ifname") &&
---
> } else if (!os_strcmp(entry.key, "Ifname") &&
577c557
< } else if (!strcmp(entry.key, "BridgeIfname") &&
---
> } else if (!os_strcmp(entry.key, "ConfigFile") &&
578a559,564
> confname = os_strdup(entry.str_value);
> wpa_dbus_dict_entry_clear(&entry);
> if (confname == NULL)
> goto error;
> } else if (!os_strcmp(entry.key, "BridgeIfname") &&
> (entry.type == DBUS_TYPE_STRING)) {
606a593
> iface.confname = confname;
623a611
> os_free(confname);
657c645
< else if (wpa_supplicant_remove_iface(global, wpa_s)) {
---
> else if (wpa_supplicant_remove_iface(global, wpa_s, 0)) {
709,711c697,700
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: DBus message with value of debug level
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
715,716c704,706
< DBusMessage * wpas_dbus_getter_debug_level(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_getter_debug_level(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
719a710
>
722,723c713,714
< if (idx > 4)
< idx = 4;
---
> if (idx > 5)
> idx = 5;
725,726c716,717
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &str);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &str, error);
732,734c723,726
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: DBus message with value of debug timestamp
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
738,739c730,732
< DBusMessage * wpas_dbus_getter_debug_timestamp(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_getter_debug_timestamp(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
741,742c734,735
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &wpa_debug_timestamp);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &wpa_debug_timestamp, error);
749,751c742,745
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: DBus message with value of debug show_keys
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
755,756c749,751
< DBusMessage * wpas_dbus_getter_debug_show_keys(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_getter_debug_show_keys(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
758,759c753,754
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &wpa_debug_show_keys);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &wpa_debug_show_keys, error);
765,767c760,763
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: %NULL or DBus error message
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
771,772c767,768
< DBusMessage * wpas_dbus_setter_debug_level(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_setter_debug_level(DBusMessageIter *iter,
> DBusError *error, void *user_data)
774c770
< DBusMessage *reply;
---
> struct wpa_global *global = user_data;
778,781c774,776
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_STRING,
< &str);
< if (reply)
< return reply;
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
> &str))
> return FALSE;
792,794c787,789
< dbus_message_unref(reply);
< return wpas_dbus_error_invalid_args(
< message, "Wrong debug level value");
---
> dbus_set_error_const(error, DBUS_ERROR_FAILED, "wrong debug "
> "level value");
> return FALSE;
797c792
< return NULL;
---
> return TRUE;
803,805c798,801
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: %NULL or DBus error message
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
809,810c805,807
< DBusMessage * wpas_dbus_setter_debug_timestamp(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_setter_debug_timestamp(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
812c809
< DBusMessage *reply;
---
> struct wpa_global *global = user_data;
815,818c812,814
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
< &val);
< if (reply)
< return reply;
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
> &val))
> return FALSE;
822,823c818
<
< return NULL;
---
> return TRUE;
829,831c824,827
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: %NULL or DBus error message
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
835,836c831,833
< DBusMessage * wpas_dbus_setter_debug_show_keys(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_setter_debug_show_keys(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
838c835
< DBusMessage *reply;
---
> struct wpa_global *global = user_data;
841,844c838,840
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
< &val);
< if (reply)
< return reply;
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
> &val))
> return FALSE;
849,850c845
<
< return NULL;
---
> return TRUE;
856,859c851,854
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: The object paths array containing registered interfaces
< * objects paths or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
865,866c860,862
< DBusMessage * wpas_dbus_getter_interfaces(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_getter_interfaces(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
868c864
< DBusMessage *reply = NULL;
---
> struct wpa_global *global = user_data;
871a868
> dbus_bool_t success;
876c873
< paths = os_zalloc(num * sizeof(char*));
---
> paths = os_calloc(num, sizeof(char *));
878,879c875,876
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
883c880
< paths[i] = wpa_s->dbus_new_path;
---
> paths[i++] = wpa_s->dbus_new_path;
885,887c882,884
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< paths, num);
---
> success = wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_OBJECT_PATH,
> paths, num, error);
890c887
< return reply;
---
> return success;
896,899c893,896
< * @message: Pointer to incoming dbus message
< * @nothing: not used argument. may be NULL or anything else
< * Returns: The object paths array containing supported EAP methods
< * represented by strings or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
904c901,902
< DBusMessage * wpas_dbus_getter_eap_methods(DBusMessage *message, void *nothing)
---
> dbus_bool_t wpas_dbus_getter_eap_methods(DBusMessageIter *iter,
> DBusError *error, void *user_data)
906d903
< DBusMessage *reply = NULL;
908a906
> dbus_bool_t success;
912,913c910,911
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
916,918c914,917
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_STRING,
< eap_methods, num_items);
---
> success = wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_STRING,
> eap_methods,
> num_items, error);
923c922
< return reply;
---
> return success;
926a926,963
> /**
> * wpas_dbus_getter_global_capabilities - Request supported global capabilities
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "Capabilities" property. Handles requests by dbus clients to
> * return a list of strings with supported capabilities like AP, RSN IBSS,
> * and P2P that are determined at compile time.
> */
> dbus_bool_t wpas_dbus_getter_global_capabilities(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> const char *capabilities[5] = { NULL, NULL, NULL, NULL, NULL };
> size_t num_items = 0;
>
> #ifdef CONFIG_AP
> capabilities[num_items++] = "ap";
> #endif /* CONFIG_AP */
> #ifdef CONFIG_IBSS_RSN
> capabilities[num_items++] = "ibss-rsn";
> #endif /* CONFIG_IBSS_RSN */
> #ifdef CONFIG_P2P
> capabilities[num_items++] = "p2p";
> #endif /* CONFIG_P2P */
> #ifdef CONFIG_INTERWORKING
> capabilities[num_items++] = "interworking";
> #endif /* CONFIG_INTERWORKING */
>
> return wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_STRING,
> capabilities,
> num_items, error);
> }
>
>
990,993d1026
< if (len == 0) {
< dbus_message_iter_next(&array_iter);
< continue;
< }
995,1001c1028,1034
< ssid = os_malloc(len);
< if (ssid == NULL) {
< wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: "
< "out of memory. Cannot allocate memory for "
< "SSID");
< *reply = dbus_message_new_error(
< message, DBUS_ERROR_NO_MEMORY, NULL);
---
> if (len > MAX_SSID_LEN) {
> wpa_printf(MSG_DEBUG,
> "wpas_dbus_handler_scan[dbus]: "
> "SSID too long (len=%d max_len=%d)",
> len, MAX_SSID_LEN);
> *reply = wpas_dbus_error_invalid_args(
> message, "Invalid SSID: too long");
1004c1037,1054
< os_memcpy(ssid, val, len);
---
>
> if (len != 0) {
> ssid = os_malloc(len);
> if (ssid == NULL) {
> wpa_printf(MSG_DEBUG,
> "wpas_dbus_handler_scan[dbus]: "
> "out of memory. Cannot allocate "
> "memory for SSID");
> *reply = dbus_message_new_error(
> message, DBUS_ERROR_NO_MEMORY, NULL);
> return -1;
> }
> os_memcpy(ssid, val, len);
> } else {
> /* Allow zero-length SSIDs */
> ssid = NULL;
> }
>
1149,1150c1199,1201
< nfreqs = os_realloc(freqs, sizeof(int) *
< (freqs_num + FREQS_ALLOC_CHUNK));
---
> nfreqs = os_realloc_array(
> freqs, freqs_num + FREQS_ALLOC_CHUNK,
> sizeof(int));
1170,1171c1221
< nfreqs = os_realloc(freqs,
< sizeof(int) * (freqs_num + 1));
---
> nfreqs = os_realloc_array(freqs, freqs_num + 1, sizeof(int));
1263,1264d1312
< /* wildcard ssid */
< params.num_ssids++;
1267c1315
< wpa_s->scan_req = 2;
---
> wpa_s->scan_req = MANUAL_SCAN_REQ;
1270a1319,1325
> if (!params.num_ssids) {
> /* Add wildcard ssid */
> params.num_ssids++;
> }
> #ifdef CONFIG_AUTOSCAN
> autoscan_deinit(wpa_s);
> #endif /* CONFIG_AUTOSCAN */
1328a1384
> DBusError error;
1346,1347c1402,1403
< reply = set_network_properties(message, wpa_s, ssid, &iter);
< if (reply) {
---
> dbus_error_init(&error);
> if (!set_network_properties(wpa_s, ssid, &iter, &error)) {
1350a1407,1410
> reply = wpas_dbus_reply_new_from_error(message, &error,
> DBUS_ERROR_INVALID_ARGS,
> "Failed to add network");
> dbus_error_free(&error);
1384a1445,1466
> * wpas_dbus_handler_reassociate - Reassociate to current AP
> * @message: Pointer to incoming dbus message
> * @wpa_s: wpa_supplicant structure for a network interface
> * Returns: NotConnected DBus error message if not connected
> * or NULL otherwise.
> *
> * Handler function for "Reassociate" method call of network interface.
> */
> DBusMessage * wpas_dbus_handler_reassociate(DBusMessage *message,
> struct wpa_supplicant *wpa_s)
> {
> if (wpa_s->current_ssid != NULL) {
> wpas_request_connection(wpa_s);
> return NULL;
> }
>
> return dbus_message_new_error(message, WPAS_DBUS_ERROR_NOT_CONNECTED,
> "This interface is not connected");
> }
>
>
> /**
1406,1407c1488,1490
< iface = wpas_dbus_new_decompose_object_path(op, &net_id, NULL);
< if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
---
> iface = wpas_dbus_new_decompose_object_path(op, 0, &net_id, NULL);
> if (iface == NULL || net_id == NULL ||
> os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
1411a1495
> errno = 0;
1413c1497
< if (errno == EINVAL) {
---
> if (errno != 0) {
1446a1531,1550
> static void remove_network(void *arg, struct wpa_ssid *ssid)
> {
> struct wpa_supplicant *wpa_s = arg;
>
> wpas_notify_network_removed(wpa_s, ssid);
>
> if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) {
> wpa_printf(MSG_ERROR,
> "wpas_dbus_handler_remove_all_networks[dbus]: "
> "error occurred when removing network %d",
> ssid->id);
> return;
> }
>
> if (ssid == wpa_s->current_ssid)
> wpa_supplicant_deauthenticate(wpa_s,
> WLAN_REASON_DEAUTH_LEAVING);
> }
>
>
1447a1552,1568
> * wpas_dbus_handler_remove_all_networks - Remove all configured networks
> * @message: Pointer to incoming dbus message
> * @wpa_s: wpa_supplicant structure for a network interface
> * Returns: NULL on success or dbus error on failure
> *
> * Handler function for "RemoveAllNetworks" method call of a network interface.
> */
> DBusMessage * wpas_dbus_handler_remove_all_networks(
> DBusMessage *message, struct wpa_supplicant *wpa_s)
> {
> /* NB: could check for failure and return an error */
> wpa_config_foreach_network(wpa_s->conf, remove_network, wpa_s);
> return NULL;
> }
>
>
> /**
1469,1470c1590,1592
< iface = wpas_dbus_new_decompose_object_path(op, &net_id, NULL);
< if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
---
> iface = wpas_dbus_new_decompose_object_path(op, 0, &net_id, NULL);
> if (iface == NULL || net_id == NULL ||
> os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
1474a1597
> errno = 0;
1476c1599
< if (errno == EINVAL) {
---
> if (errno != 0) {
1497a1621,1686
> * wpas_dbus_handler_network_reply - Reply to a NetworkRequest signal
> * @message: Pointer to incoming dbus message
> * @wpa_s: wpa_supplicant structure for a network interface
> * Returns: NULL on success or dbus error on failure
> *
> * Handler function for "NetworkReply" method call of network interface.
> */
> DBusMessage * wpas_dbus_handler_network_reply(DBusMessage *message,
> struct wpa_supplicant *wpa_s)
> {
> #ifdef IEEE8021X_EAPOL
> DBusMessage *reply = NULL;
> const char *op, *field, *value;
> char *iface = NULL, *net_id = NULL;
> int id;
> struct wpa_ssid *ssid;
>
> if (!dbus_message_get_args(message, NULL,
> DBUS_TYPE_OBJECT_PATH, &op,
> DBUS_TYPE_STRING, &field,
> DBUS_TYPE_STRING, &value,
> DBUS_TYPE_INVALID))
> return wpas_dbus_error_invalid_args(message, NULL);
>
> /* Extract the network ID and ensure the network */
> /* is actually a child of this interface */
> iface = wpas_dbus_new_decompose_object_path(op, 0, &net_id, NULL);
> if (iface == NULL || net_id == NULL ||
> os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
> reply = wpas_dbus_error_invalid_args(message, op);
> goto out;
> }
>
> errno = 0;
> id = strtoul(net_id, NULL, 10);
> if (errno != 0) {
> reply = wpas_dbus_error_invalid_args(message, net_id);
> goto out;
> }
>
> ssid = wpa_config_get_network(wpa_s->conf, id);
> if (ssid == NULL) {
> reply = wpas_dbus_error_network_unknown(message);
> goto out;
> }
>
> if (wpa_supplicant_ctrl_iface_ctrl_rsp_handle(wpa_s, ssid,
> field, value) < 0)
> reply = wpas_dbus_error_invalid_args(message, field);
> else {
> /* Tell EAP to retry immediately */
> eapol_sm_notify_ctrl_response(wpa_s->eapol);
> }
>
> out:
> os_free(iface);
> os_free(net_id);
> return reply;
> #else /* IEEE8021X_EAPOL */
> wpa_printf(MSG_DEBUG, "CTRL_IFACE: 802.1X not included");
> return wpas_dbus_error_unknown_error(message, "802.1X not included");
> #endif /* IEEE8021X_EAPOL */
> }
>
>
> /**
1660a1850,1861
> /*
> * wpas_dbus_handler_flush_bss - Flush the BSS cache
> * @message: Pointer to incoming dbus message
> * @wpa_s: wpa_supplicant structure for a network interface
> * Returns: NULL
> *
> * Handler function for "FlushBSS" method call of network interface.
> */
> DBusMessage * wpas_dbus_handler_flush_bss(DBusMessage *message,
> struct wpa_supplicant *wpa_s)
> {
> dbus_uint32_t age;
1661a1863,1875
> dbus_message_get_args(message, NULL, DBUS_TYPE_UINT32, &age,
> DBUS_TYPE_INVALID);
>
> if (age == 0)
> wpa_bss_flush(wpa_s);
> else
> wpa_bss_flush_by_age(wpa_s, age);
>
> return NULL;
> }
>
>
> #ifdef CONFIG_AUTOSCAN
1663c1877
< * wpas_dbus_getter_capabilities - Return interface capabilities
---
> * wpas_dbus_handler_autoscan - Set autoscan parameters for the interface
1666c1880
< * Returns: A dbus message containing a dict of strings
---
> * Returns: NULL
1668c1882
< * Getter for "Capabilities" property of an interface.
---
> * Handler function for "AutoScan" method call of network interface.
1670,1671c1884,1885
< DBusMessage * wpas_dbus_getter_capabilities(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> DBusMessage * wpas_dbus_handler_autoscan(DBusMessage *message,
> struct wpa_supplicant *wpa_s)
1673a1888,1935
> enum wpa_states state = wpa_s->wpa_state;
> char *arg;
>
> dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg,
> DBUS_TYPE_INVALID);
>
> if (arg != NULL && os_strlen(arg) > 0) {
> char *tmp;
> tmp = os_strdup(arg);
> if (tmp == NULL) {
> reply = dbus_message_new_error(message,
> DBUS_ERROR_NO_MEMORY,
> NULL);
> } else {
> os_free(wpa_s->conf->autoscan);
> wpa_s->conf->autoscan = tmp;
> if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
> autoscan_init(wpa_s, 1);
> else if (state == WPA_SCANNING)
> wpa_supplicant_reinit_autoscan(wpa_s);
> }
> } else if (arg != NULL && os_strlen(arg) == 0) {
> os_free(wpa_s->conf->autoscan);
> wpa_s->conf->autoscan = NULL;
> autoscan_deinit(wpa_s);
> } else
> reply = dbus_message_new_error(message,
> DBUS_ERROR_INVALID_ARGS,
> NULL);
>
> return reply;
> }
> #endif /* CONFIG_AUTOSCAN */
>
>
> /**
> * wpas_dbus_getter_capabilities - Return interface capabilities
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "Capabilities" property of an interface.
> */
> dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
> DBusError *error, void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
1676,1677c1938
< DBusMessageIter iter, iter_dict;
< DBusMessageIter iter_dict_entry, iter_dict_val, iter_array,
---
> DBusMessageIter iter_dict, iter_dict_entry, iter_dict_val, iter_array,
1680,1681d1940
< const char *modes[] = { "infrastructure", "ad-hoc", "ap" };
< int n = sizeof(modes) / sizeof(char *);
1683,1691c1942
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (!reply)
< goto nomem;
<
< dbus_message_iter_init_append(reply, &iter);
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
1719a1971,1976
> if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) {
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "gcmp"))
> goto nomem;
> }
>
1760a2018,2023
> if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) {
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "gcmp"))
> goto nomem;
> }
>
1952,1954c2215,2218
< if (res < 0 || !(capa.flags & WPA_DRIVER_FLAGS_AP))
< n--; /* exclude ap mode if it is not supported by the driver */
< if (!wpa_dbus_dict_append_string_array(&iter_dict, "Modes", modes, n))
---
> if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Modes",
> &iter_dict_entry,
> &iter_dict_val,
> &iter_array))
1956a2221,2257
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "infrastructure"))
> goto nomem;
>
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "ad-hoc"))
> goto nomem;
>
> if (res >= 0) {
> if (capa.flags & (WPA_DRIVER_FLAGS_AP)) {
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "ap"))
> goto nomem;
> }
>
> if (capa.flags & (WPA_DRIVER_FLAGS_P2P_CAPABLE)) {
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "p2p"))
> goto nomem;
> }
> }
>
> if (!wpa_dbus_dict_end_string_array(&iter_dict,
> &iter_dict_entry,
> &iter_dict_val,
> &iter_array))
> goto nomem;
> /***** Modes end */
>
> if (res >= 0) {
> dbus_int32_t max_scan_ssid = capa.max_scan_ssids;
>
> if (!wpa_dbus_dict_append_int32(&iter_dict, "MaxScanSSID",
> max_scan_ssid))
> goto nomem;
> }
>
1959c2260
< if (!dbus_message_iter_close_container(&iter, &variant_iter))
---
> if (!dbus_message_iter_close_container(iter, &variant_iter))
1962c2263
< return reply;
---
> return TRUE;
1965,1968c2266,2267
< if (reply)
< dbus_message_unref(reply);
<
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
1974,1977c2273,2276
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a STRING representing the current
< * interface state
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
1981,1982c2280,2281
< DBusMessage * wpas_dbus_getter_state(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_state(DBusMessageIter *iter, DBusError *error,
> void *user_data)
1984c2283
< DBusMessage *reply = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
1986a2286
> dbus_bool_t success = FALSE;
1994,1995c2294,2295
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2002,2003c2302,2303
< reply = wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &state_ls);
---
> success = wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &state_ls, error);
2007c2307
< return reply;
---
> return success;
2013,2015c2313,2316
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing whether the interface is scanning
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2019,2020c2320,2321
< DBusMessage * wpas_dbus_getter_scanning(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_scanning(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2021a2323
> struct wpa_supplicant *wpa_s = user_data;
2023,2024c2325,2327
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &scanning);
---
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &scanning, error);
2030,2032c2333,2336
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A message containong value of ap_scan variable
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2036,2037c2340,2341
< DBusMessage * wpas_dbus_getter_ap_scan(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_ap_scan(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2038a2343
> struct wpa_supplicant *wpa_s = user_data;
2040,2041c2345,2347
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_UINT32,
< &ap_scan);
---
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32,
> &ap_scan, error);
2047,2049c2353,2356
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: NULL
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2053,2054c2360,2361
< DBusMessage * wpas_dbus_setter_ap_scan(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_setter_ap_scan(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2056c2363
< DBusMessage *reply = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
2059,2062c2366,2368
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_UINT32,
< &ap_scan);
< if (reply)
< return reply;
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_UINT32,
> &ap_scan))
> return FALSE;
2065,2066c2371,2373
< return wpas_dbus_error_invalid_args(
< message, "ap_scan must equal 0, 1 or 2");
---
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "ap_scan must be 0, 1, or 2");
> return FALSE;
2068c2375
< return NULL;
---
> return TRUE;
2072a2380,2661
> * wpas_dbus_getter_fast_reauth - Control fast
> * reauthentication (TLS session resumption)
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "FastReauth" property.
> */
> dbus_bool_t wpas_dbus_getter_fast_reauth(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_bool_t fast_reauth = wpa_s->conf->fast_reauth ? TRUE : FALSE;
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &fast_reauth, error);
> }
>
>
> /**
> * wpas_dbus_setter_fast_reauth - Control fast
> * reauthentication (TLS session resumption)
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "FastReauth" property.
> */
> dbus_bool_t wpas_dbus_setter_fast_reauth(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_bool_t fast_reauth;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
> &fast_reauth))
> return FALSE;
>
> wpa_s->conf->fast_reauth = fast_reauth;
> return TRUE;
> }
>
>
> /**
> * wpas_dbus_getter_disconnect_reason - Get most recent reason for disconnect
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "DisconnectReason" property. The reason is negative if it is
> * locally generated.
> */
> dbus_bool_t wpas_dbus_getter_disconnect_reason(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_int32_t reason = wpa_s->disconnect_reason;
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
> &reason, error);
> }
>
>
> /**
> * wpas_dbus_getter_bss_expire_age - Get BSS entry expiration age
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "BSSExpireAge" property.
> */
> dbus_bool_t wpas_dbus_getter_bss_expire_age(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_uint32_t expire_age = wpa_s->conf->bss_expiration_age;
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32,
> &expire_age, error);
> }
>
>
> /**
> * wpas_dbus_setter_bss_expire_age - Control BSS entry expiration age
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "BSSExpireAge" property.
> */
> dbus_bool_t wpas_dbus_setter_bss_expire_age(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_uint32_t expire_age;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_UINT32,
> &expire_age))
> return FALSE;
>
> if (wpa_supplicant_set_bss_expiration_age(wpa_s, expire_age)) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "BSSExpireAge must be >= 10");
> return FALSE;
> }
> return TRUE;
> }
>
>
> /**
> * wpas_dbus_getter_bss_expire_count - Get BSS entry expiration scan count
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "BSSExpireCount" property.
> */
> dbus_bool_t wpas_dbus_getter_bss_expire_count(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_uint32_t expire_count = wpa_s->conf->bss_expiration_scan_count;
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32,
> &expire_count, error);
> }
>
>
> /**
> * wpas_dbus_setter_bss_expire_count - Control BSS entry expiration scan count
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "BSSExpireCount" property.
> */
> dbus_bool_t wpas_dbus_setter_bss_expire_count(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_uint32_t expire_count;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_UINT32,
> &expire_count))
> return FALSE;
>
> if (wpa_supplicant_set_bss_expiration_count(wpa_s, expire_count)) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "BSSExpireCount must be > 0");
> return FALSE;
> }
> return TRUE;
> }
>
>
> /**
> * wpas_dbus_getter_country - Control country code
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "Country" property.
> */
> dbus_bool_t wpas_dbus_getter_country(DBusMessageIter *iter, DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> char country[3];
> char *str = country;
>
> country[0] = wpa_s->conf->country[0];
> country[1] = wpa_s->conf->country[1];
> country[2] = '\0';
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &str, error);
> }
>
>
> /**
> * wpas_dbus_setter_country - Control country code
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "Country" property.
> */
> dbus_bool_t wpas_dbus_setter_country(DBusMessageIter *iter, DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> const char *country;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
> &country))
> return FALSE;
>
> if (!country[0] || !country[1]) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "invalid country code");
> return FALSE;
> }
>
> if (wpa_s->drv_priv != NULL && wpa_drv_set_country(wpa_s, country)) {
> wpa_printf(MSG_DEBUG, "Failed to set country");
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "failed to set country code");
> return FALSE;
> }
>
> wpa_s->conf->country[0] = country[0];
> wpa_s->conf->country[1] = country[1];
> return TRUE;
> }
>
>
> /**
> * wpas_dbus_getter_scan_interval - Get scan interval
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "ScanInterval" property.
> */
> dbus_bool_t wpas_dbus_getter_scan_interval(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_int32_t scan_interval = wpa_s->scan_interval;
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
> &scan_interval, error);
> }
>
>
> /**
> * wpas_dbus_setter_scan_interval - Control scan interval
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "ScanInterval" property.
> */
> dbus_bool_t wpas_dbus_setter_scan_interval(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_int32_t scan_interval;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_INT32,
> &scan_interval))
> return FALSE;
>
> if (wpa_supplicant_set_scan_interval(wpa_s, scan_interval)) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "scan_interval must be >= 0");
> return FALSE;
> }
> return TRUE;
> }
>
>
> /**
2074,2077c2663,2666
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a name of network interface
< * associated with with wpa_s
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2081,2082c2670,2671
< DBusMessage * wpas_dbus_getter_ifname(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_ifname(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2083a2673
> struct wpa_supplicant *wpa_s = user_data;
2085,2086c2675,2677
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &ifname);
---
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &ifname, error);
2092,2095c2683,2686
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a name of network interface
< * driver associated with with wpa_s
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2099,2100c2690,2691
< DBusMessage * wpas_dbus_getter_driver(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_driver(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2101a2693
> struct wpa_supplicant *wpa_s = user_data;
2107c2699,2701
< return wpas_dbus_error_unknown_error(message, NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED, "%s: no driver set",
> __func__);
> return FALSE;
2111,2112c2705,2706
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &driver);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &driver, error);
2118,2121c2712,2715
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a DBus object path to
< * current BSS
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2125,2126c2719,2721
< DBusMessage * wpas_dbus_getter_current_bss(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_current_bss(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2128c2723
< DBusMessage *reply;
---
> struct wpa_supplicant *wpa_s = user_data;
2138,2142c2733,2734
< reply = wpas_dbus_simple_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< &bss_obj_path);
<
< return reply;
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_OBJECT_PATH,
> &bss_obj_path, error);
2148,2151c2740,2743
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a DBus object path to
< * current network
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2155,2156c2747,2749
< DBusMessage * wpas_dbus_getter_current_network(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_current_network(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2158c2751
< DBusMessage *reply;
---
> struct wpa_supplicant *wpa_s = user_data;
2168,2172c2761,2762
< reply = wpas_dbus_simple_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< &net_obj_path);
<
< return reply;
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_OBJECT_PATH,
> &net_obj_path, error);
2177,2181c2767,2771
< * wpas_dbus_getter_bridge_ifname - Get interface name
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a name of bridge network
< * interface associated with with wpa_s
---
> * wpas_dbus_getter_current_auth_mode - Get current authentication type
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2183c2773
< * Getter for "BridgeIfname" property.
---
> * Getter for "CurrentAuthMode" property.
2185,2186c2775,2777
< DBusMessage * wpas_dbus_getter_bridge_ifname(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_current_auth_mode(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2188c2779,2782
< const char *bridge_ifname = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
> const char *eap_mode;
> const char *auth_mode;
> char eap_mode_buf[WPAS_DBUS_AUTH_MODE_MAX];
2190,2194c2784,2795
< bridge_ifname = wpa_s->bridge_ifname;
< if (bridge_ifname == NULL) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bridge_ifname[dbus]: "
< "wpa_s has no bridge interface name set");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> if (wpa_s->wpa_state != WPA_COMPLETED) {
> auth_mode = "INACTIVE";
> } else if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X ||
> wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
> eap_mode = wpa_supplicant_get_eap_mode(wpa_s);
> os_snprintf(eap_mode_buf, WPAS_DBUS_AUTH_MODE_MAX,
> "EAP-%s", eap_mode);
> auth_mode = eap_mode_buf;
>
> } else {
> auth_mode = wpa_key_mgmt_txt(wpa_s->key_mgmt,
> wpa_s->current_ssid->proto);
2197,2198c2798,2799
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &bridge_ifname);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &auth_mode, error);
2202a2804,2823
> * wpas_dbus_getter_bridge_ifname - Get interface name
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "BridgeIfname" property.
> */
> dbus_bool_t wpas_dbus_getter_bridge_ifname(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> const char *bridge_ifname = wpa_s->bridge_ifname;
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &bridge_ifname, error);
> }
>
>
> /**
2204,2207c2825,2828
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: a dbus message containing an array of all known BSS objects
< * dbus paths
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2211,2212c2832,2833
< DBusMessage * wpas_dbus_getter_bsss(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_bsss(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2214c2835
< DBusMessage *reply = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
2217a2839
> dbus_bool_t success = FALSE;
2219c2841
< paths = os_zalloc(wpa_s->num_bss * sizeof(char *));
---
> paths = os_calloc(wpa_s->num_bss, sizeof(char *));
2221,2222c2843,2844
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2229,2231c2851,2852
< reply = dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
> "no memory");
2240,2242c2861,2864
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< paths, wpa_s->num_bss);
---
> success = wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_OBJECT_PATH,
> paths, wpa_s->num_bss,
> error);
2248c2870
< return reply;
---
> return success;
2254,2257c2876,2879
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: a dbus message containing an array of all configured
< * networks dbus object paths.
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2261,2262c2883,2884
< DBusMessage * wpas_dbus_getter_networks(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_networks(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2264c2886
< DBusMessage *reply = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
2267a2890
> dbus_bool_t success = FALSE;
2270,2272c2893,2897
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_networks[dbus]: "
< "An error occurred getting networks list.");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> wpa_printf(MSG_ERROR, "%s[dbus]: An error occurred getting "
> "networks list.", __func__);
> dbus_set_error(error, DBUS_ERROR_FAILED, "%s: an error "
> "occurred getting the networks list", __func__);
> return FALSE;
2276c2901,2902
< num++;
---
> if (!network_is_persistent_group(ssid))
> num++;
2278c2904
< paths = os_zalloc(num * sizeof(char *));
---
> paths = os_calloc(num, sizeof(char *));
2280,2281c2906,2907
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2285a2912,2913
> if (network_is_persistent_group(ssid))
> continue;
2288,2290c2916
< reply = dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error(error, DBUS_ERROR_NO_MEMORY, "no memory");
2300,2302c2926,2928
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< paths, num);
---
> success = wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_OBJECT_PATH,
> paths, num, error);
2308c2934
< return reply;
---
> return success;
2314,2316c2940,2943
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: a dbus message containing a dictionary of pairs (blob_name, blob)
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2320,2321c2947,2948
< DBusMessage * wpas_dbus_getter_blobs(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_blobs(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2323,2324c2950,2951
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter, dict_iter, entry_iter, array_iter;
---
> struct wpa_supplicant *wpa_s = user_data;
> DBusMessageIter variant_iter, dict_iter, entry_iter, array_iter;
2327,2337c2954
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (!reply)
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
<
< dbus_message_iter_init_append(reply, &iter);
<
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
2341,2343c2958,2959
< dbus_message_unref(reply);
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2366,2369c2982,2984
< dbus_message_unref(reply);
< return dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
> "no memory");
> return FALSE;
2376,2379c2991,2993
< !dbus_message_iter_close_container(&iter, &variant_iter)) {
< dbus_message_unref(reply);
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> !dbus_message_iter_close_container(iter, &variant_iter)) {
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2382c2996
< return reply;
---
> return TRUE;
2385a3000,3016
> static struct wpa_bss * get_bss_helper(struct bss_handler_args *args,
> DBusError *error, const char *func_name)
> {
> struct wpa_bss *res = wpa_bss_get_id(args->wpa_s, args->id);
>
> if (!res) {
> wpa_printf(MSG_ERROR, "%s[dbus]: no bss with id %d found",
> func_name, args->id);
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: BSS %d not found",
> func_name, args->id);
> }
>
> return res;
> }
>
>
2388,2390c3019,3022
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the bssid for the requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2394,2395c3026,3027
< DBusMessage * wpas_dbus_getter_bss_bssid(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_bssid(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2397c3029,3030
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2399,2403c3032,3034
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_bssid[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2405,2406c3036,3038
< return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
< res->bssid, ETH_ALEN);
---
> return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
> res->bssid, ETH_ALEN,
> error);
2412,2414c3044,3047
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the ssid for the requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2418,2419c3051,3052
< DBusMessage * wpas_dbus_getter_bss_ssid(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_ssid(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2421c3054,3055
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2423,2427c3057,3059
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_ssid[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2429,2431c3061,3063
< return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
< res->ssid,
< res->ssid_len);
---
> return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
> res->ssid, res->ssid_len,
> error);
2437,2439c3069,3072
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the privacy flag value of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2443,2444c3076,3077
< DBusMessage * wpas_dbus_getter_bss_privacy(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_privacy(DBusMessageIter *iter,
> DBusError *error, void *user_data)
2446c3079,3080
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2449,2453c3083,3085
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_privacy[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2456,2457c3088,3089
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &privacy);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &privacy, error);
2463,2465c3095,3098
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the mode of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2469,2470c3102,3103
< DBusMessage * wpas_dbus_getter_bss_mode(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_mode(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2472c3105,3106
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2475,2479c3109,3111
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_mode[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2486,2487c3118,3119
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &mode);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &mode, error);
2493,2495c3125,3128
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the signal strength of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2499,2500c3132,3133
< DBusMessage * wpas_dbus_getter_bss_signal(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_signal(DBusMessageIter *iter,
> DBusError *error, void *user_data)
2502c3135,3137
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
> s16 level;
2504,2508c3139,3141
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_signal[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2510,2511c3143,3145
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_INT16,
< &res->level);
---
> level = (s16) res->level;
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT16,
> &level, error);
2517,2519c3151,3154
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the frequency of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2523,2524c3158,3159
< DBusMessage * wpas_dbus_getter_bss_frequency(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_frequency(DBusMessageIter *iter,
> DBusError *error, void *user_data)
2526c3161,3163
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
> u16 freq;
2528,2532c3165,3167
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_frequency[dbus]: "
< "no bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2534,2535c3169,3171
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_UINT16,
< &res->freq);
---
> freq = (u16) res->freq;
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16,
> &freq, error);
2547,2549c3183,3186
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing sorted array of bit rates
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2553,2554c3190,3191
< DBusMessage * wpas_dbus_getter_bss_rates(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_rates(DBusMessageIter *iter,
> DBusError *error, void *user_data)
2556,2557c3193,3194
< DBusMessage *reply;
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2560a3198
> dbus_bool_t success = FALSE;
2562,2566c3200,3202
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_rates[dbus]: "
< "no bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2570c3206
< return NULL;
---
> return FALSE;
2577,2578c3213,3214
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2584,2586c3220,3222
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_UINT32,
< real_rates, rates_num);
---
> success = wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_UINT32,
> real_rates, rates_num,
> error);
2590c3226
< return reply;
---
> return success;
2594,2595c3230,3232
< static DBusMessage * wpas_dbus_get_bss_security_prop(
< DBusMessage *message, struct wpa_ie_data *ie_data)
---
> static dbus_bool_t wpas_dbus_get_bss_security_prop(DBusMessageIter *iter,
> struct wpa_ie_data *ie_data,
> DBusError *error)
2597,2598c3234
< DBusMessage *reply;
< DBusMessageIter iter, iter_dict, variant_iter;
---
> DBusMessageIter iter_dict, variant_iter;
2600c3236
< const char *pairwise[2]; /* max 2 pairwise ciphers is supported */
---
> const char *pairwise[3]; /* max 3 pairwise ciphers is supported */
2604,2612c3240
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (!reply)
< goto nomem;
<
< dbus_message_iter_init_append(reply, &iter);
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
2650a3279,3281
> case WPA_CIPHER_GCMP:
> group = "gcmp";
> break;
2667a3299,3300
> if (ie_data->pairwise_cipher & WPA_CIPHER_GCMP)
> pairwise[n++] = "gcmp";
2693c3326
< if (!dbus_message_iter_close_container(&iter, &variant_iter))
---
> if (!dbus_message_iter_close_container(iter, &variant_iter))
2696c3329
< return reply;
---
> return TRUE;
2699,2702c3332,3333
< if (reply)
< dbus_message_unref(reply);
<
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2708,2710c3339,3342
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the WPA options of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2714,2715c3346,3347
< DBusMessage * wpas_dbus_getter_bss_wpa(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_wpa(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2717c3349,3350
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2721,2725c3354,3356
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_wpa[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2730,2732c3361,3365
< if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0)
< return wpas_dbus_error_unknown_error(message,
< "invalid WPA IE");
---
> if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "failed to parse WPA IE");
> return FALSE;
> }
2735c3368
< return wpas_dbus_get_bss_security_prop(message, &wpa_data);
---
> return wpas_dbus_get_bss_security_prop(iter, &wpa_data, error);
2741,2743c3374,3377
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the RSN options of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2747,2748c3381,3382
< DBusMessage * wpas_dbus_getter_bss_rsn(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_rsn(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2750c3384,3385
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2754,2758c3389,3391
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_rsn[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2763,2765c3396,3400
< if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0)
< return wpas_dbus_error_unknown_error(message,
< "invalid RSN IE");
---
> if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "failed to parse RSN IE");
> return FALSE;
> }
2768c3403
< return wpas_dbus_get_bss_security_prop(message, &wpa_data);
---
> return wpas_dbus_get_bss_security_prop(iter, &wpa_data, error);
2772a3408,3464
> * wpas_dbus_getter_bss_wps - Return the WPS options of a BSS
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "WPS" property.
> */
> dbus_bool_t wpas_dbus_getter_bss_wps(DBusMessageIter *iter, DBusError *error,
> void *user_data)
> {
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
> #ifdef CONFIG_WPS
> struct wpabuf *wps_ie;
> #endif /* CONFIG_WPS */
> DBusMessageIter iter_dict, variant_iter;
> const char *type = "";
>
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
>
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
> "a{sv}", &variant_iter))
> goto nomem;
>
> if (!wpa_dbus_dict_open_write(&variant_iter, &iter_dict))
> goto nomem;
>
> #ifdef CONFIG_WPS
> wps_ie = wpa_bss_get_vendor_ie_multi(res, WPS_IE_VENDOR_TYPE);
> if (wps_ie) {
> if (wps_is_selected_pbc_registrar(wps_ie))
> type = "pbc";
> else if (wps_is_selected_pin_registrar(wps_ie))
> type = "pin";
> }
> #endif /* CONFIG_WPS */
>
> if (!wpa_dbus_dict_append_string(&iter_dict, "Type", type))
> goto nomem;
>
> if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict))
> goto nomem;
> if (!dbus_message_iter_close_container(iter, &variant_iter))
> goto nomem;
>
> return TRUE;
>
> nomem:
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
> }
>
>
> /**
2774,2776c3466,3469
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing IEs byte array
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2780,2781c3473,3474
< DBusMessage * wpas_dbus_getter_bss_ies(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_ies(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2783c3476,3477
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2785,2789c3479,3481
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_ies[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2791,2792c3483,3485
< return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
< res + 1, res->ie_len);
---
> return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
> res + 1, res->ie_len,
> error);
2798,2802c3491,3494
< * @message: Pointer to incoming dbus message
< * @wpas_dbus_setter_enabled: wpa_supplicant structure for a network interface
< * and wpa_ssid structure for a configured network
< * Returns: DBus message with boolean indicating state of configured network
< * or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2806,2807c3498,3499
< DBusMessage * wpas_dbus_getter_enabled(DBusMessage *message,
< struct network_handler_args *net)
---
> dbus_bool_t wpas_dbus_getter_enabled(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2808a3501
> struct network_handler_args *net = user_data;
2810,2811c3503,3505
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &enabled);
---
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &enabled, error);
2817,2820c3511,3514
< * @message: Pointer to incoming dbus message
< * @wpas_dbus_setter_enabled: wpa_supplicant structure for a network interface
< * and wpa_ssid structure for a configured network
< * Returns: NULL indicating success or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2824,2825c3518,3519
< DBusMessage * wpas_dbus_setter_enabled(DBusMessage *message,
< struct network_handler_args *net)
---
> dbus_bool_t wpas_dbus_setter_enabled(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2827,2828c3521
< DBusMessage *reply = NULL;
<
---
> struct network_handler_args *net = user_data;
2831d3523
<
2834,2835c3526,3528
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
< &enable);
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
> &enable))
> return FALSE;
2837,2839d3529
< if (reply)
< return reply;
<
2848c3538
< return NULL;
---
> return TRUE;
2854,2857c3544,3547
< * @message: Pointer to incoming dbus message
< * @net: wpa_supplicant structure for a network interface and
< * wpa_ssid structure for a configured network
< * Returns: DBus message with network properties or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2861,2862c3551,3553
< DBusMessage * wpas_dbus_getter_network_properties(
< DBusMessage *message, struct network_handler_args *net)
---
> dbus_bool_t wpas_dbus_getter_network_properties(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2864,2865c3555,3556
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter, dict_iter;
---
> struct network_handler_args *net = user_data;
> DBusMessageIter variant_iter, dict_iter;
2867,2870c3558,3559
< char **props = wpa_config_get_all(net->ssid, 0);
< if (!props)
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> char **props = wpa_config_get_all(net->ssid, 1);
> dbus_bool_t success = FALSE;
2872,2879c3561,3563
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (!reply) {
< reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
< goto out;
---
> if (!props) {
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2882,2885c3566,3567
< dbus_message_iter_init_append(reply, &iter);
<
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
< "a{sv}", &variant_iter) ||
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, "a{sv}",
> &variant_iter) ||
2887,2889c3569
< dbus_message_unref(reply);
< reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
2897,2900c3577,3578
< dbus_message_unref(reply);
< reply = dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
> "no memory");
2908,2911c3586,3587
< !dbus_message_iter_close_container(&iter, &variant_iter)) {
< dbus_message_unref(reply);
< reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> !dbus_message_iter_close_container(iter, &variant_iter)) {
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
2914a3591,3592
> success = TRUE;
>
2922c3600
< return reply;
---
> return success;
2928,2931c3606,3609
< * @message: Pointer to incoming dbus message
< * @net: wpa_supplicant structure for a network interface and
< * wpa_ssid structure for a configured network
< * Returns: NULL indicating success or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2935,2936c3613,3615
< DBusMessage * wpas_dbus_setter_network_properties(
< DBusMessage *message, struct network_handler_args *net)
---
> dbus_bool_t wpas_dbus_setter_network_properties(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2937a3617
> struct network_handler_args *net = user_data;
2938a3619
> DBusMessageIter variant_iter;
2940,2941c3621,3623
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter;
---
> dbus_message_iter_recurse(iter, &variant_iter);
> return set_network_properties(net->wpa_s, ssid, &variant_iter, error);
> }
2943d3624
< dbus_message_iter_init(message, &iter);
2945,2946c3626
< dbus_message_iter_next(&iter);
< dbus_message_iter_next(&iter);
---
> #ifdef CONFIG_AP
2948c3628,3632
< dbus_message_iter_recurse(&iter, &variant_iter);
---
> DBusMessage * wpas_dbus_handler_subscribe_preq(
> DBusMessage *message, struct wpa_supplicant *wpa_s)
> {
> struct wpas_dbus_priv *priv = wpa_s->global->dbus;
> char *name;
2950,2954c3634,3637
< reply = set_network_properties(message, net->wpa_s, ssid,
< &variant_iter);
< if (reply)
< wpa_printf(MSG_DEBUG, "dbus control interface couldn't set "
< "network properties");
---
> if (wpa_s->preq_notify_peer != NULL) {
> if (os_strcmp(dbus_message_get_sender(message),
> wpa_s->preq_notify_peer) == 0)
> return NULL;
2956c3639,3675
< return reply;
---
> return dbus_message_new_error(message,
> WPAS_DBUS_ERROR_SUBSCRIPTION_IN_USE,
> "Another application is already subscribed");
> }
>
> name = os_strdup(dbus_message_get_sender(message));
> if (!name)
> return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
> "out of memory");
>
> wpa_s->preq_notify_peer = name;
>
> /* Subscribe to clean up if application closes socket */
> wpas_dbus_subscribe_noc(priv);
>
> /*
> * Double-check it's still alive to make sure that we didn't
> * miss the NameOwnerChanged signal, e.g. while strdup'ing.
> */
> if (!dbus_bus_name_has_owner(priv->con, name, NULL)) {
> /*
> * Application no longer exists, clean up.
> * The return value is irrelevant now.
> *
> * Need to check if the NameOwnerChanged handling
> * already cleaned up because we have processed
> * DBus messages while checking if the name still
> * has an owner.
> */
> if (!wpa_s->preq_notify_peer)
> return NULL;
> os_free(wpa_s->preq_notify_peer);
> wpa_s->preq_notify_peer = NULL;
> wpas_dbus_unsubscribe_noc(priv);
> }
>
> return NULL;
2957a3677,3759
>
>
> DBusMessage * wpas_dbus_handler_unsubscribe_preq(
> DBusMessage *message, struct wpa_supplicant *wpa_s)
> {
> struct wpas_dbus_priv *priv = wpa_s->global->dbus;
>
> if (!wpa_s->preq_notify_peer)
> return dbus_message_new_error(message,
> WPAS_DBUS_ERROR_NO_SUBSCRIPTION,
> "Not subscribed");
>
> if (os_strcmp(wpa_s->preq_notify_peer,
> dbus_message_get_sender(message)))
> return dbus_message_new_error(message,
> WPAS_DBUS_ERROR_SUBSCRIPTION_EPERM,
> "Can't unsubscribe others");
>
> os_free(wpa_s->preq_notify_peer);
> wpa_s->preq_notify_peer = NULL;
> wpas_dbus_unsubscribe_noc(priv);
> return NULL;
> }
>
>
> void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s,
> const u8 *addr, const u8 *dst, const u8 *bssid,
> const u8 *ie, size_t ie_len, u32 ssi_signal)
> {
> DBusMessage *msg;
> DBusMessageIter iter, dict_iter;
> struct wpas_dbus_priv *priv = wpa_s->global->dbus;
>
> /* Do nothing if the control interface is not turned on */
> if (priv == NULL)
> return;
>
> if (wpa_s->preq_notify_peer == NULL)
> return;
>
> msg = dbus_message_new_signal(wpa_s->dbus_new_path,
> WPAS_DBUS_NEW_IFACE_INTERFACE,
> "ProbeRequest");
> if (msg == NULL)
> return;
>
> dbus_message_set_destination(msg, wpa_s->preq_notify_peer);
>
> dbus_message_iter_init_append(msg, &iter);
>
> if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
> goto fail;
> if (addr && !wpa_dbus_dict_append_byte_array(&dict_iter, "addr",
> (const char *) addr,
> ETH_ALEN))
> goto fail;
> if (dst && !wpa_dbus_dict_append_byte_array(&dict_iter, "dst",
> (const char *) dst,
> ETH_ALEN))
> goto fail;
> if (bssid && !wpa_dbus_dict_append_byte_array(&dict_iter, "bssid",
> (const char *) bssid,
> ETH_ALEN))
> goto fail;
> if (ie && ie_len && !wpa_dbus_dict_append_byte_array(&dict_iter, "ies",
> (const char *) ie,
> ie_len))
> goto fail;
> if (ssi_signal && !wpa_dbus_dict_append_int32(&dict_iter, "signal",
> ssi_signal))
> goto fail;
> if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
> goto fail;
>
> dbus_connection_send(priv->con, msg, NULL);
> goto out;
> fail:
> wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
> out:
> dbus_message_unref(msg);
> }
>
> #endif /* CONFIG_AP */
< * This program is free software; you can redistribute it and/or modify
< * it under the terms of the GNU General Public License version 2 as
< * published by the Free Software Foundation.
< *
< * Alternatively, this software may be distributed under the terms of BSD
< * license.
< *
< * See README and COPYING for more details.
---
> * This software may be distributed under the terms of the BSD license.
> * See README for more details.
28d21
< #include "../wpas_glue.h"
30a24
> #include "../autoscan.h"
34a29
> #include "dbus_common_i.h"
41c36
< "msgdump", "debug", "info", "warning", "error", NULL
---
> "excessive", "msgdump", "debug", "info", "warning", "error", NULL
46,109d40
< * wpas_dbus_new_decompose_object_path - Decompose an interface object path into parts
< * @path: The dbus object path
< * @network: (out) the configured network this object path refers to, if any
< * @bssid: (out) the scanned bssid this object path refers to, if any
< * Returns: The object path of the network interface this path refers to
< *
< * For a given object path, decomposes the object path into object id, network,
< * and BSSID parts, if those parts exist.
< */
< static char * wpas_dbus_new_decompose_object_path(const char *path,
< char **network,
< char **bssid)
< {
< const unsigned int dev_path_prefix_len =
< strlen(WPAS_DBUS_NEW_PATH_INTERFACES "/");
< char *obj_path_only;
< char *next_sep;
<
< /* Be a bit paranoid about path */
< if (!path || os_strncmp(path, WPAS_DBUS_NEW_PATH_INTERFACES "/",
< dev_path_prefix_len))
< return NULL;
<
< /* Ensure there's something at the end of the path */
< if ((path + dev_path_prefix_len)[0] == '\0')
< return NULL;
<
< obj_path_only = os_strdup(path);
< if (obj_path_only == NULL)
< return NULL;
<
< next_sep = os_strchr(obj_path_only + dev_path_prefix_len, '/');
< if (next_sep != NULL) {
< const char *net_part = os_strstr(
< next_sep, WPAS_DBUS_NEW_NETWORKS_PART "/");
< const char *bssid_part = os_strstr(
< next_sep, WPAS_DBUS_NEW_BSSIDS_PART "/");
<
< if (network && net_part) {
< /* Deal with a request for a configured network */
< const char *net_name = net_part +
< os_strlen(WPAS_DBUS_NEW_NETWORKS_PART "/");
< *network = NULL;
< if (os_strlen(net_name))
< *network = os_strdup(net_name);
< } else if (bssid && bssid_part) {
< /* Deal with a request for a scanned BSSID */
< const char *bssid_name = bssid_part +
< os_strlen(WPAS_DBUS_NEW_BSSIDS_PART "/");
< if (strlen(bssid_name))
< *bssid = os_strdup(bssid_name);
< else
< *bssid = NULL;
< }
<
< /* Cut off interface object path before "/" */
< *next_sep = '\0';
< }
<
< return obj_path_only;
< }
<
<
< /**
119a51,64
> /*
> * This function can be called as a result of a failure
> * within internal getter calls, which will call this function
> * with a NULL message parameter. However, dbus_message_new_error
> * looks very unkindly (i.e, abort()) on a NULL message, so
> * in this case, we should not call it.
> */
> if (message == NULL) {
> wpa_printf(MSG_INFO, "dbus: wpas_dbus_error_unknown_error "
> "called with NULL message (arg=%s)",
> arg ? arg : "N/A");
> return NULL;
> }
>
181c126
< "bssid", NULL
---
> "bssid", "scan_freq", "freq_list", NULL
216d160
< * @message: Pointer to incoming dbus message
221c165,166
< * Returns: NULL when succeed or DBus error on failure
---
> * @error: On failure, an error describing the failure
> * Returns: TRUE if the request succeeds, FALSE if it failed
225,228c170,173
< static DBusMessage * set_network_properties(DBusMessage *message,
< struct wpa_supplicant *wpa_s,
< struct wpa_ssid *ssid,
< DBusMessageIter *iter)
---
> dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
> struct wpa_ssid *ssid,
> DBusMessageIter *iter,
> DBusError *error)
230d174
<
232d175
< DBusMessage *reply = NULL;
233a177
> char *value = NULL;
235,236c179,180
< if (!wpa_dbus_dict_open_read(iter, &iter_dict))
< return wpas_dbus_error_invalid_args(message, NULL);
---
> if (!wpa_dbus_dict_open_read(iter, &iter_dict, error))
> return FALSE;
239d182
< char *value = NULL;
242,245c185,189
< if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) {
< reply = wpas_dbus_error_invalid_args(message, NULL);
< break;
< }
---
>
> if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
> goto error;
>
> value = NULL;
307c251
< (strcmp(entry.key, "ssid") == 0 && ssid->passphrase))
---
> (os_strcmp(entry.key, "ssid") == 0 && ssid->passphrase))
314,320d257
< continue;
<
< error:
< os_free(value);
< reply = wpas_dbus_error_invalid_args(message, entry.key);
< wpa_dbus_dict_entry_clear(&entry);
< break;
323c260,267
< return reply;
---
> return TRUE;
>
> error:
> os_free(value);
> wpa_dbus_dict_entry_clear(&entry);
> dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
> "invalid message format");
> return FALSE;
329c273
< * @message: Pointer to incoming dbus message
---
> * @iter: Message iter to use when appending arguments
332,333c276,277
< * Returns: The DBus message containing response for Properties.Get call
< * or DBus error message if error occurred.
---
> * @error: On failure an error describing the failure
> * Returns: TRUE if the request was successful, FALSE if it failed
337,338c281,284
< DBusMessage * wpas_dbus_simple_property_getter(DBusMessage *message,
< const int type, const void *val)
---
> dbus_bool_t wpas_dbus_simple_property_getter(DBusMessageIter *iter,
> const int type,
> const void *val,
> DBusError *error)
340,341c286
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter;
---
> DBusMessageIter variant_iter;
344,346c289,291
< wpa_printf(MSG_ERROR, "dbus: wpas_dbus_simple_property_getter:"
< " given type is not basic");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: given type is not basic", __func__);
> return FALSE;
349,352c294,297
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
> wpa_dbus_type_as_string(type),
> &variant_iter))
> goto error;
354,376c299,300
< if (reply != NULL) {
< dbus_message_iter_init_append(reply, &iter);
< if (!dbus_message_iter_open_container(
< &iter, DBUS_TYPE_VARIANT,
< wpa_dbus_type_as_string(type), &variant_iter) ||
< !dbus_message_iter_append_basic(&variant_iter, type,
< val) ||
< !dbus_message_iter_close_container(&iter, &variant_iter)) {
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_property_getter: out of "
< "memory to put property value into "
< "message");
< dbus_message_unref(reply);
< reply = dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
< }
< } else {
< wpa_printf(MSG_ERROR, "dbus: wpas_dbus_simple_property_getter:"
< " out of memory to return property value");
< reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
< }
---
> if (!dbus_message_iter_append_basic(&variant_iter, type, val))
> goto error;
378c302,310
< return reply;
---
> if (!dbus_message_iter_close_container(iter, &variant_iter))
> goto error;
>
> return TRUE;
>
> error:
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: error constructing reply", __func__);
> return FALSE;
387c319
< * Returns: NULL or DBus error message if error occurred.
---
> * Returns: TRUE if the request was successful, FALSE if it failed
391,392c323,325
< DBusMessage * wpas_dbus_simple_property_setter(DBusMessage *message,
< const int type, void *val)
---
> dbus_bool_t wpas_dbus_simple_property_setter(DBusMessageIter *iter,
> DBusError *error,
> const int type, void *val)
394c327
< DBusMessageIter iter, variant_iter;
---
> DBusMessageIter variant_iter;
397,399c330,332
< wpa_printf(MSG_ERROR, "dbus: wpas_dbus_simple_property_setter:"
< " given type is not basic");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: given type is not basic", __func__);
> return FALSE;
402,413c335,336
< if (!dbus_message_iter_init(message, &iter)) {
< wpa_printf(MSG_ERROR, "dbus: wpas_dbus_simple_property_setter:"
< " out of memory to return scanning state");
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
< }
<
< /* omit first and second argument and get value from third */
< dbus_message_iter_next(&iter);
< dbus_message_iter_next(&iter);
< dbus_message_iter_recurse(&iter, &variant_iter);
<
---
> /* Look at the new value */
> dbus_message_iter_recurse(iter, &variant_iter);
415,418c338,340
< wpa_printf(MSG_DEBUG, "dbus: wpas_dbus_simple_property_setter:"
< " wrong property type");
< return wpas_dbus_error_invalid_args(message,
< "wrong property type");
---
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "wrong property type");
> return FALSE;
422c344
< return NULL;
---
> return TRUE;
428c350
< * @message: Pointer to incoming dbus message
---
> * @iter: Pointer to incoming dbus message iterator
432,433c354,355
< * Returns: The DBus message containing response for Properties.Get call
< * or DBus error message if error occurred.
---
> * @error: a pointer to an error to fill on failure
> * Returns: TRUE if the request succeeded, FALSE if it failed
438,441c360,364
< DBusMessage * wpas_dbus_simple_array_property_getter(DBusMessage *message,
< const int type,
< const void *array,
< size_t array_len)
---
> dbus_bool_t wpas_dbus_simple_array_property_getter(DBusMessageIter *iter,
> const int type,
> const void *array,
> size_t array_len,
> DBusError *error)
443,444c366
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter, array_iter;
---
> DBusMessageIter variant_iter, array_iter;
450,453c372,374
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: given "
< "type is not basic");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: given type is not basic", __func__);
> return FALSE;
459,468c380,384
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (reply == NULL) {
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: out of "
< "memory to create return message");
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
> type_str, &variant_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 1", __func__);
> return FALSE;
471,475c387
< dbus_message_iter_init_append(reply, &iter);
<
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
< type_str, &variant_iter) ||
< !dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
---
> if (!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
477,482c389,391
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: out of "
< "memory to open container");
< dbus_message_unref(reply);
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 2", __func__);
> return FALSE;
510,514c419,421
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: "
< "fatal: unknown element type");
< element_size = 1;
< break;
---
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: unknown element type %d", __func__, type);
> return FALSE;
522,529c429,432
< if (!dbus_message_iter_close_container(&variant_iter, &array_iter) ||
< !dbus_message_iter_close_container(&iter, &variant_iter)) {
< wpa_printf(MSG_ERROR, "dbus: "
< "wpas_dbus_simple_array_property_getter: out of "
< "memory to close container");
< dbus_message_unref(reply);
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 3", __func__);
> return FALSE;
532c435,441
< return reply;
---
> if (!dbus_message_iter_close_container(iter, &variant_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 4", __func__);
> return FALSE;
> }
>
> return TRUE;
536a446,515
> * wpas_dbus_simple_array_array_property_getter - Get array array type property
> * @iter: Pointer to incoming dbus message iterator
> * @type: DBus type of property array elements (must be basic type)
> * @array: pointer to array of elements to put into response message
> * @array_len: length of above array
> * @error: a pointer to an error to fill on failure
> * Returns: TRUE if the request succeeded, FALSE if it failed
> *
> * Generic getter for array type properties. Array elements type is
> * required to be basic.
> */
> dbus_bool_t wpas_dbus_simple_array_array_property_getter(DBusMessageIter *iter,
> const int type,
> struct wpabuf **array,
> size_t array_len,
> DBusError *error)
> {
> DBusMessageIter variant_iter, array_iter;
> char type_str[] = "aa?";
> char inner_type_str[] = "a?";
> const char *sub_type_str;
> size_t i;
>
> if (!dbus_type_is_basic(type)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: given type is not basic", __func__);
> return FALSE;
> }
>
> sub_type_str = wpa_dbus_type_as_string(type);
> type_str[2] = sub_type_str[0];
> inner_type_str[1] = sub_type_str[0];
>
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
> type_str, &variant_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 1", __func__);
> return FALSE;
> }
> if (!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
> inner_type_str, &array_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to construct message 2", __func__);
> return FALSE;
> }
>
> for (i = 0; i < array_len; i++) {
> wpa_dbus_dict_bin_array_add_element(&array_iter,
> wpabuf_head(array[i]),
> wpabuf_len(array[i]));
>
> }
>
> if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to close message 2", __func__);
> return FALSE;
> }
>
> if (!dbus_message_iter_close_container(iter, &variant_iter)) {
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: failed to close message 1", __func__);
> return FALSE;
> }
>
> return TRUE;
> }
>
>
> /**
555a535
> char *confname = NULL;
560c540
< if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
---
> if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
565c545
< if (!strcmp(entry.key, "Driver") &&
---
> if (!os_strcmp(entry.key, "Driver") &&
571c551
< } else if (!strcmp(entry.key, "Ifname") &&
---
> } else if (!os_strcmp(entry.key, "Ifname") &&
577c557
< } else if (!strcmp(entry.key, "BridgeIfname") &&
---
> } else if (!os_strcmp(entry.key, "ConfigFile") &&
578a559,564
> confname = os_strdup(entry.str_value);
> wpa_dbus_dict_entry_clear(&entry);
> if (confname == NULL)
> goto error;
> } else if (!os_strcmp(entry.key, "BridgeIfname") &&
> (entry.type == DBUS_TYPE_STRING)) {
606a593
> iface.confname = confname;
623a611
> os_free(confname);
657c645
< else if (wpa_supplicant_remove_iface(global, wpa_s)) {
---
> else if (wpa_supplicant_remove_iface(global, wpa_s, 0)) {
709,711c697,700
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: DBus message with value of debug level
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
715,716c704,706
< DBusMessage * wpas_dbus_getter_debug_level(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_getter_debug_level(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
719a710
>
722,723c713,714
< if (idx > 4)
< idx = 4;
---
> if (idx > 5)
> idx = 5;
725,726c716,717
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &str);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &str, error);
732,734c723,726
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: DBus message with value of debug timestamp
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
738,739c730,732
< DBusMessage * wpas_dbus_getter_debug_timestamp(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_getter_debug_timestamp(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
741,742c734,735
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &wpa_debug_timestamp);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &wpa_debug_timestamp, error);
749,751c742,745
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: DBus message with value of debug show_keys
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
755,756c749,751
< DBusMessage * wpas_dbus_getter_debug_show_keys(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_getter_debug_show_keys(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
758,759c753,754
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &wpa_debug_show_keys);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &wpa_debug_show_keys, error);
765,767c760,763
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: %NULL or DBus error message
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
771,772c767,768
< DBusMessage * wpas_dbus_setter_debug_level(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_setter_debug_level(DBusMessageIter *iter,
> DBusError *error, void *user_data)
774c770
< DBusMessage *reply;
---
> struct wpa_global *global = user_data;
778,781c774,776
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_STRING,
< &str);
< if (reply)
< return reply;
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
> &str))
> return FALSE;
792,794c787,789
< dbus_message_unref(reply);
< return wpas_dbus_error_invalid_args(
< message, "Wrong debug level value");
---
> dbus_set_error_const(error, DBUS_ERROR_FAILED, "wrong debug "
> "level value");
> return FALSE;
797c792
< return NULL;
---
> return TRUE;
803,805c798,801
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: %NULL or DBus error message
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
809,810c805,807
< DBusMessage * wpas_dbus_setter_debug_timestamp(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_setter_debug_timestamp(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
812c809
< DBusMessage *reply;
---
> struct wpa_global *global = user_data;
815,818c812,814
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
< &val);
< if (reply)
< return reply;
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
> &val))
> return FALSE;
822,823c818
<
< return NULL;
---
> return TRUE;
829,831c824,827
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: %NULL or DBus error message
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
835,836c831,833
< DBusMessage * wpas_dbus_setter_debug_show_keys(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_setter_debug_show_keys(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
838c835
< DBusMessage *reply;
---
> struct wpa_global *global = user_data;
841,844c838,840
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
< &val);
< if (reply)
< return reply;
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
> &val))
> return FALSE;
849,850c845
<
< return NULL;
---
> return TRUE;
856,859c851,854
< * @message: Pointer to incoming dbus message
< * @global: %wpa_supplicant global data structure
< * Returns: The object paths array containing registered interfaces
< * objects paths or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
865,866c860,862
< DBusMessage * wpas_dbus_getter_interfaces(DBusMessage *message,
< struct wpa_global *global)
---
> dbus_bool_t wpas_dbus_getter_interfaces(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
868c864
< DBusMessage *reply = NULL;
---
> struct wpa_global *global = user_data;
871a868
> dbus_bool_t success;
876c873
< paths = os_zalloc(num * sizeof(char*));
---
> paths = os_calloc(num, sizeof(char *));
878,879c875,876
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
883c880
< paths[i] = wpa_s->dbus_new_path;
---
> paths[i++] = wpa_s->dbus_new_path;
885,887c882,884
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< paths, num);
---
> success = wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_OBJECT_PATH,
> paths, num, error);
890c887
< return reply;
---
> return success;
896,899c893,896
< * @message: Pointer to incoming dbus message
< * @nothing: not used argument. may be NULL or anything else
< * Returns: The object paths array containing supported EAP methods
< * represented by strings or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
904c901,902
< DBusMessage * wpas_dbus_getter_eap_methods(DBusMessage *message, void *nothing)
---
> dbus_bool_t wpas_dbus_getter_eap_methods(DBusMessageIter *iter,
> DBusError *error, void *user_data)
906d903
< DBusMessage *reply = NULL;
908a906
> dbus_bool_t success;
912,913c910,911
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
916,918c914,917
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_STRING,
< eap_methods, num_items);
---
> success = wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_STRING,
> eap_methods,
> num_items, error);
923c922
< return reply;
---
> return success;
926a926,963
> /**
> * wpas_dbus_getter_global_capabilities - Request supported global capabilities
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "Capabilities" property. Handles requests by dbus clients to
> * return a list of strings with supported capabilities like AP, RSN IBSS,
> * and P2P that are determined at compile time.
> */
> dbus_bool_t wpas_dbus_getter_global_capabilities(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> const char *capabilities[5] = { NULL, NULL, NULL, NULL, NULL };
> size_t num_items = 0;
>
> #ifdef CONFIG_AP
> capabilities[num_items++] = "ap";
> #endif /* CONFIG_AP */
> #ifdef CONFIG_IBSS_RSN
> capabilities[num_items++] = "ibss-rsn";
> #endif /* CONFIG_IBSS_RSN */
> #ifdef CONFIG_P2P
> capabilities[num_items++] = "p2p";
> #endif /* CONFIG_P2P */
> #ifdef CONFIG_INTERWORKING
> capabilities[num_items++] = "interworking";
> #endif /* CONFIG_INTERWORKING */
>
> return wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_STRING,
> capabilities,
> num_items, error);
> }
>
>
990,993d1026
< if (len == 0) {
< dbus_message_iter_next(&array_iter);
< continue;
< }
995,1001c1028,1034
< ssid = os_malloc(len);
< if (ssid == NULL) {
< wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: "
< "out of memory. Cannot allocate memory for "
< "SSID");
< *reply = dbus_message_new_error(
< message, DBUS_ERROR_NO_MEMORY, NULL);
---
> if (len > MAX_SSID_LEN) {
> wpa_printf(MSG_DEBUG,
> "wpas_dbus_handler_scan[dbus]: "
> "SSID too long (len=%d max_len=%d)",
> len, MAX_SSID_LEN);
> *reply = wpas_dbus_error_invalid_args(
> message, "Invalid SSID: too long");
1004c1037,1054
< os_memcpy(ssid, val, len);
---
>
> if (len != 0) {
> ssid = os_malloc(len);
> if (ssid == NULL) {
> wpa_printf(MSG_DEBUG,
> "wpas_dbus_handler_scan[dbus]: "
> "out of memory. Cannot allocate "
> "memory for SSID");
> *reply = dbus_message_new_error(
> message, DBUS_ERROR_NO_MEMORY, NULL);
> return -1;
> }
> os_memcpy(ssid, val, len);
> } else {
> /* Allow zero-length SSIDs */
> ssid = NULL;
> }
>
1149,1150c1199,1201
< nfreqs = os_realloc(freqs, sizeof(int) *
< (freqs_num + FREQS_ALLOC_CHUNK));
---
> nfreqs = os_realloc_array(
> freqs, freqs_num + FREQS_ALLOC_CHUNK,
> sizeof(int));
1170,1171c1221
< nfreqs = os_realloc(freqs,
< sizeof(int) * (freqs_num + 1));
---
> nfreqs = os_realloc_array(freqs, freqs_num + 1, sizeof(int));
1263,1264d1312
< /* wildcard ssid */
< params.num_ssids++;
1267c1315
< wpa_s->scan_req = 2;
---
> wpa_s->scan_req = MANUAL_SCAN_REQ;
1270a1319,1325
> if (!params.num_ssids) {
> /* Add wildcard ssid */
> params.num_ssids++;
> }
> #ifdef CONFIG_AUTOSCAN
> autoscan_deinit(wpa_s);
> #endif /* CONFIG_AUTOSCAN */
1328a1384
> DBusError error;
1346,1347c1402,1403
< reply = set_network_properties(message, wpa_s, ssid, &iter);
< if (reply) {
---
> dbus_error_init(&error);
> if (!set_network_properties(wpa_s, ssid, &iter, &error)) {
1350a1407,1410
> reply = wpas_dbus_reply_new_from_error(message, &error,
> DBUS_ERROR_INVALID_ARGS,
> "Failed to add network");
> dbus_error_free(&error);
1384a1445,1466
> * wpas_dbus_handler_reassociate - Reassociate to current AP
> * @message: Pointer to incoming dbus message
> * @wpa_s: wpa_supplicant structure for a network interface
> * Returns: NotConnected DBus error message if not connected
> * or NULL otherwise.
> *
> * Handler function for "Reassociate" method call of network interface.
> */
> DBusMessage * wpas_dbus_handler_reassociate(DBusMessage *message,
> struct wpa_supplicant *wpa_s)
> {
> if (wpa_s->current_ssid != NULL) {
> wpas_request_connection(wpa_s);
> return NULL;
> }
>
> return dbus_message_new_error(message, WPAS_DBUS_ERROR_NOT_CONNECTED,
> "This interface is not connected");
> }
>
>
> /**
1406,1407c1488,1490
< iface = wpas_dbus_new_decompose_object_path(op, &net_id, NULL);
< if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
---
> iface = wpas_dbus_new_decompose_object_path(op, 0, &net_id, NULL);
> if (iface == NULL || net_id == NULL ||
> os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
1411a1495
> errno = 0;
1413c1497
< if (errno == EINVAL) {
---
> if (errno != 0) {
1446a1531,1550
> static void remove_network(void *arg, struct wpa_ssid *ssid)
> {
> struct wpa_supplicant *wpa_s = arg;
>
> wpas_notify_network_removed(wpa_s, ssid);
>
> if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) {
> wpa_printf(MSG_ERROR,
> "wpas_dbus_handler_remove_all_networks[dbus]: "
> "error occurred when removing network %d",
> ssid->id);
> return;
> }
>
> if (ssid == wpa_s->current_ssid)
> wpa_supplicant_deauthenticate(wpa_s,
> WLAN_REASON_DEAUTH_LEAVING);
> }
>
>
1447a1552,1568
> * wpas_dbus_handler_remove_all_networks - Remove all configured networks
> * @message: Pointer to incoming dbus message
> * @wpa_s: wpa_supplicant structure for a network interface
> * Returns: NULL on success or dbus error on failure
> *
> * Handler function for "RemoveAllNetworks" method call of a network interface.
> */
> DBusMessage * wpas_dbus_handler_remove_all_networks(
> DBusMessage *message, struct wpa_supplicant *wpa_s)
> {
> /* NB: could check for failure and return an error */
> wpa_config_foreach_network(wpa_s->conf, remove_network, wpa_s);
> return NULL;
> }
>
>
> /**
1469,1470c1590,1592
< iface = wpas_dbus_new_decompose_object_path(op, &net_id, NULL);
< if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
---
> iface = wpas_dbus_new_decompose_object_path(op, 0, &net_id, NULL);
> if (iface == NULL || net_id == NULL ||
> os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
1474a1597
> errno = 0;
1476c1599
< if (errno == EINVAL) {
---
> if (errno != 0) {
1497a1621,1686
> * wpas_dbus_handler_network_reply - Reply to a NetworkRequest signal
> * @message: Pointer to incoming dbus message
> * @wpa_s: wpa_supplicant structure for a network interface
> * Returns: NULL on success or dbus error on failure
> *
> * Handler function for "NetworkReply" method call of network interface.
> */
> DBusMessage * wpas_dbus_handler_network_reply(DBusMessage *message,
> struct wpa_supplicant *wpa_s)
> {
> #ifdef IEEE8021X_EAPOL
> DBusMessage *reply = NULL;
> const char *op, *field, *value;
> char *iface = NULL, *net_id = NULL;
> int id;
> struct wpa_ssid *ssid;
>
> if (!dbus_message_get_args(message, NULL,
> DBUS_TYPE_OBJECT_PATH, &op,
> DBUS_TYPE_STRING, &field,
> DBUS_TYPE_STRING, &value,
> DBUS_TYPE_INVALID))
> return wpas_dbus_error_invalid_args(message, NULL);
>
> /* Extract the network ID and ensure the network */
> /* is actually a child of this interface */
> iface = wpas_dbus_new_decompose_object_path(op, 0, &net_id, NULL);
> if (iface == NULL || net_id == NULL ||
> os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
> reply = wpas_dbus_error_invalid_args(message, op);
> goto out;
> }
>
> errno = 0;
> id = strtoul(net_id, NULL, 10);
> if (errno != 0) {
> reply = wpas_dbus_error_invalid_args(message, net_id);
> goto out;
> }
>
> ssid = wpa_config_get_network(wpa_s->conf, id);
> if (ssid == NULL) {
> reply = wpas_dbus_error_network_unknown(message);
> goto out;
> }
>
> if (wpa_supplicant_ctrl_iface_ctrl_rsp_handle(wpa_s, ssid,
> field, value) < 0)
> reply = wpas_dbus_error_invalid_args(message, field);
> else {
> /* Tell EAP to retry immediately */
> eapol_sm_notify_ctrl_response(wpa_s->eapol);
> }
>
> out:
> os_free(iface);
> os_free(net_id);
> return reply;
> #else /* IEEE8021X_EAPOL */
> wpa_printf(MSG_DEBUG, "CTRL_IFACE: 802.1X not included");
> return wpas_dbus_error_unknown_error(message, "802.1X not included");
> #endif /* IEEE8021X_EAPOL */
> }
>
>
> /**
1660a1850,1861
> /*
> * wpas_dbus_handler_flush_bss - Flush the BSS cache
> * @message: Pointer to incoming dbus message
> * @wpa_s: wpa_supplicant structure for a network interface
> * Returns: NULL
> *
> * Handler function for "FlushBSS" method call of network interface.
> */
> DBusMessage * wpas_dbus_handler_flush_bss(DBusMessage *message,
> struct wpa_supplicant *wpa_s)
> {
> dbus_uint32_t age;
1661a1863,1875
> dbus_message_get_args(message, NULL, DBUS_TYPE_UINT32, &age,
> DBUS_TYPE_INVALID);
>
> if (age == 0)
> wpa_bss_flush(wpa_s);
> else
> wpa_bss_flush_by_age(wpa_s, age);
>
> return NULL;
> }
>
>
> #ifdef CONFIG_AUTOSCAN
1663c1877
< * wpas_dbus_getter_capabilities - Return interface capabilities
---
> * wpas_dbus_handler_autoscan - Set autoscan parameters for the interface
1666c1880
< * Returns: A dbus message containing a dict of strings
---
> * Returns: NULL
1668c1882
< * Getter for "Capabilities" property of an interface.
---
> * Handler function for "AutoScan" method call of network interface.
1670,1671c1884,1885
< DBusMessage * wpas_dbus_getter_capabilities(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> DBusMessage * wpas_dbus_handler_autoscan(DBusMessage *message,
> struct wpa_supplicant *wpa_s)
1673a1888,1935
> enum wpa_states state = wpa_s->wpa_state;
> char *arg;
>
> dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg,
> DBUS_TYPE_INVALID);
>
> if (arg != NULL && os_strlen(arg) > 0) {
> char *tmp;
> tmp = os_strdup(arg);
> if (tmp == NULL) {
> reply = dbus_message_new_error(message,
> DBUS_ERROR_NO_MEMORY,
> NULL);
> } else {
> os_free(wpa_s->conf->autoscan);
> wpa_s->conf->autoscan = tmp;
> if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
> autoscan_init(wpa_s, 1);
> else if (state == WPA_SCANNING)
> wpa_supplicant_reinit_autoscan(wpa_s);
> }
> } else if (arg != NULL && os_strlen(arg) == 0) {
> os_free(wpa_s->conf->autoscan);
> wpa_s->conf->autoscan = NULL;
> autoscan_deinit(wpa_s);
> } else
> reply = dbus_message_new_error(message,
> DBUS_ERROR_INVALID_ARGS,
> NULL);
>
> return reply;
> }
> #endif /* CONFIG_AUTOSCAN */
>
>
> /**
> * wpas_dbus_getter_capabilities - Return interface capabilities
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "Capabilities" property of an interface.
> */
> dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
> DBusError *error, void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
1676,1677c1938
< DBusMessageIter iter, iter_dict;
< DBusMessageIter iter_dict_entry, iter_dict_val, iter_array,
---
> DBusMessageIter iter_dict, iter_dict_entry, iter_dict_val, iter_array,
1680,1681d1940
< const char *modes[] = { "infrastructure", "ad-hoc", "ap" };
< int n = sizeof(modes) / sizeof(char *);
1683,1691c1942
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (!reply)
< goto nomem;
<
< dbus_message_iter_init_append(reply, &iter);
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
1719a1971,1976
> if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) {
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "gcmp"))
> goto nomem;
> }
>
1760a2018,2023
> if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) {
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "gcmp"))
> goto nomem;
> }
>
1952,1954c2215,2218
< if (res < 0 || !(capa.flags & WPA_DRIVER_FLAGS_AP))
< n--; /* exclude ap mode if it is not supported by the driver */
< if (!wpa_dbus_dict_append_string_array(&iter_dict, "Modes", modes, n))
---
> if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Modes",
> &iter_dict_entry,
> &iter_dict_val,
> &iter_array))
1956a2221,2257
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "infrastructure"))
> goto nomem;
>
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "ad-hoc"))
> goto nomem;
>
> if (res >= 0) {
> if (capa.flags & (WPA_DRIVER_FLAGS_AP)) {
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "ap"))
> goto nomem;
> }
>
> if (capa.flags & (WPA_DRIVER_FLAGS_P2P_CAPABLE)) {
> if (!wpa_dbus_dict_string_array_add_element(
> &iter_array, "p2p"))
> goto nomem;
> }
> }
>
> if (!wpa_dbus_dict_end_string_array(&iter_dict,
> &iter_dict_entry,
> &iter_dict_val,
> &iter_array))
> goto nomem;
> /***** Modes end */
>
> if (res >= 0) {
> dbus_int32_t max_scan_ssid = capa.max_scan_ssids;
>
> if (!wpa_dbus_dict_append_int32(&iter_dict, "MaxScanSSID",
> max_scan_ssid))
> goto nomem;
> }
>
1959c2260
< if (!dbus_message_iter_close_container(&iter, &variant_iter))
---
> if (!dbus_message_iter_close_container(iter, &variant_iter))
1962c2263
< return reply;
---
> return TRUE;
1965,1968c2266,2267
< if (reply)
< dbus_message_unref(reply);
<
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
1974,1977c2273,2276
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a STRING representing the current
< * interface state
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
1981,1982c2280,2281
< DBusMessage * wpas_dbus_getter_state(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_state(DBusMessageIter *iter, DBusError *error,
> void *user_data)
1984c2283
< DBusMessage *reply = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
1986a2286
> dbus_bool_t success = FALSE;
1994,1995c2294,2295
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2002,2003c2302,2303
< reply = wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &state_ls);
---
> success = wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &state_ls, error);
2007c2307
< return reply;
---
> return success;
2013,2015c2313,2316
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing whether the interface is scanning
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2019,2020c2320,2321
< DBusMessage * wpas_dbus_getter_scanning(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_scanning(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2021a2323
> struct wpa_supplicant *wpa_s = user_data;
2023,2024c2325,2327
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &scanning);
---
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &scanning, error);
2030,2032c2333,2336
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A message containong value of ap_scan variable
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2036,2037c2340,2341
< DBusMessage * wpas_dbus_getter_ap_scan(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_ap_scan(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2038a2343
> struct wpa_supplicant *wpa_s = user_data;
2040,2041c2345,2347
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_UINT32,
< &ap_scan);
---
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32,
> &ap_scan, error);
2047,2049c2353,2356
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: NULL
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2053,2054c2360,2361
< DBusMessage * wpas_dbus_setter_ap_scan(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_setter_ap_scan(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2056c2363
< DBusMessage *reply = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
2059,2062c2366,2368
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_UINT32,
< &ap_scan);
< if (reply)
< return reply;
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_UINT32,
> &ap_scan))
> return FALSE;
2065,2066c2371,2373
< return wpas_dbus_error_invalid_args(
< message, "ap_scan must equal 0, 1 or 2");
---
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "ap_scan must be 0, 1, or 2");
> return FALSE;
2068c2375
< return NULL;
---
> return TRUE;
2072a2380,2661
> * wpas_dbus_getter_fast_reauth - Control fast
> * reauthentication (TLS session resumption)
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "FastReauth" property.
> */
> dbus_bool_t wpas_dbus_getter_fast_reauth(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_bool_t fast_reauth = wpa_s->conf->fast_reauth ? TRUE : FALSE;
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &fast_reauth, error);
> }
>
>
> /**
> * wpas_dbus_setter_fast_reauth - Control fast
> * reauthentication (TLS session resumption)
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "FastReauth" property.
> */
> dbus_bool_t wpas_dbus_setter_fast_reauth(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_bool_t fast_reauth;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
> &fast_reauth))
> return FALSE;
>
> wpa_s->conf->fast_reauth = fast_reauth;
> return TRUE;
> }
>
>
> /**
> * wpas_dbus_getter_disconnect_reason - Get most recent reason for disconnect
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "DisconnectReason" property. The reason is negative if it is
> * locally generated.
> */
> dbus_bool_t wpas_dbus_getter_disconnect_reason(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_int32_t reason = wpa_s->disconnect_reason;
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
> &reason, error);
> }
>
>
> /**
> * wpas_dbus_getter_bss_expire_age - Get BSS entry expiration age
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "BSSExpireAge" property.
> */
> dbus_bool_t wpas_dbus_getter_bss_expire_age(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_uint32_t expire_age = wpa_s->conf->bss_expiration_age;
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32,
> &expire_age, error);
> }
>
>
> /**
> * wpas_dbus_setter_bss_expire_age - Control BSS entry expiration age
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "BSSExpireAge" property.
> */
> dbus_bool_t wpas_dbus_setter_bss_expire_age(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_uint32_t expire_age;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_UINT32,
> &expire_age))
> return FALSE;
>
> if (wpa_supplicant_set_bss_expiration_age(wpa_s, expire_age)) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "BSSExpireAge must be >= 10");
> return FALSE;
> }
> return TRUE;
> }
>
>
> /**
> * wpas_dbus_getter_bss_expire_count - Get BSS entry expiration scan count
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "BSSExpireCount" property.
> */
> dbus_bool_t wpas_dbus_getter_bss_expire_count(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_uint32_t expire_count = wpa_s->conf->bss_expiration_scan_count;
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32,
> &expire_count, error);
> }
>
>
> /**
> * wpas_dbus_setter_bss_expire_count - Control BSS entry expiration scan count
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "BSSExpireCount" property.
> */
> dbus_bool_t wpas_dbus_setter_bss_expire_count(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_uint32_t expire_count;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_UINT32,
> &expire_count))
> return FALSE;
>
> if (wpa_supplicant_set_bss_expiration_count(wpa_s, expire_count)) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "BSSExpireCount must be > 0");
> return FALSE;
> }
> return TRUE;
> }
>
>
> /**
> * wpas_dbus_getter_country - Control country code
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "Country" property.
> */
> dbus_bool_t wpas_dbus_getter_country(DBusMessageIter *iter, DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> char country[3];
> char *str = country;
>
> country[0] = wpa_s->conf->country[0];
> country[1] = wpa_s->conf->country[1];
> country[2] = '\0';
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &str, error);
> }
>
>
> /**
> * wpas_dbus_setter_country - Control country code
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "Country" property.
> */
> dbus_bool_t wpas_dbus_setter_country(DBusMessageIter *iter, DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> const char *country;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
> &country))
> return FALSE;
>
> if (!country[0] || !country[1]) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "invalid country code");
> return FALSE;
> }
>
> if (wpa_s->drv_priv != NULL && wpa_drv_set_country(wpa_s, country)) {
> wpa_printf(MSG_DEBUG, "Failed to set country");
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "failed to set country code");
> return FALSE;
> }
>
> wpa_s->conf->country[0] = country[0];
> wpa_s->conf->country[1] = country[1];
> return TRUE;
> }
>
>
> /**
> * wpas_dbus_getter_scan_interval - Get scan interval
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter function for "ScanInterval" property.
> */
> dbus_bool_t wpas_dbus_getter_scan_interval(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_int32_t scan_interval = wpa_s->scan_interval;
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
> &scan_interval, error);
> }
>
>
> /**
> * wpas_dbus_setter_scan_interval - Control scan interval
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Setter function for "ScanInterval" property.
> */
> dbus_bool_t wpas_dbus_setter_scan_interval(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> dbus_int32_t scan_interval;
>
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_INT32,
> &scan_interval))
> return FALSE;
>
> if (wpa_supplicant_set_scan_interval(wpa_s, scan_interval)) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "scan_interval must be >= 0");
> return FALSE;
> }
> return TRUE;
> }
>
>
> /**
2074,2077c2663,2666
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a name of network interface
< * associated with with wpa_s
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2081,2082c2670,2671
< DBusMessage * wpas_dbus_getter_ifname(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_ifname(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2083a2673
> struct wpa_supplicant *wpa_s = user_data;
2085,2086c2675,2677
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &ifname);
---
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &ifname, error);
2092,2095c2683,2686
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a name of network interface
< * driver associated with with wpa_s
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2099,2100c2690,2691
< DBusMessage * wpas_dbus_getter_driver(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_driver(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2101a2693
> struct wpa_supplicant *wpa_s = user_data;
2107c2699,2701
< return wpas_dbus_error_unknown_error(message, NULL);
---
> dbus_set_error(error, DBUS_ERROR_FAILED, "%s: no driver set",
> __func__);
> return FALSE;
2111,2112c2705,2706
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &driver);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &driver, error);
2118,2121c2712,2715
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a DBus object path to
< * current BSS
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2125,2126c2719,2721
< DBusMessage * wpas_dbus_getter_current_bss(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_current_bss(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2128c2723
< DBusMessage *reply;
---
> struct wpa_supplicant *wpa_s = user_data;
2138,2142c2733,2734
< reply = wpas_dbus_simple_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< &bss_obj_path);
<
< return reply;
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_OBJECT_PATH,
> &bss_obj_path, error);
2148,2151c2740,2743
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a DBus object path to
< * current network
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2155,2156c2747,2749
< DBusMessage * wpas_dbus_getter_current_network(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_current_network(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2158c2751
< DBusMessage *reply;
---
> struct wpa_supplicant *wpa_s = user_data;
2168,2172c2761,2762
< reply = wpas_dbus_simple_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< &net_obj_path);
<
< return reply;
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_OBJECT_PATH,
> &net_obj_path, error);
2177,2181c2767,2771
< * wpas_dbus_getter_bridge_ifname - Get interface name
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: A dbus message containing a name of bridge network
< * interface associated with with wpa_s
---
> * wpas_dbus_getter_current_auth_mode - Get current authentication type
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2183c2773
< * Getter for "BridgeIfname" property.
---
> * Getter for "CurrentAuthMode" property.
2185,2186c2775,2777
< DBusMessage * wpas_dbus_getter_bridge_ifname(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_current_auth_mode(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2188c2779,2782
< const char *bridge_ifname = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
> const char *eap_mode;
> const char *auth_mode;
> char eap_mode_buf[WPAS_DBUS_AUTH_MODE_MAX];
2190,2194c2784,2795
< bridge_ifname = wpa_s->bridge_ifname;
< if (bridge_ifname == NULL) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bridge_ifname[dbus]: "
< "wpa_s has no bridge interface name set");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> if (wpa_s->wpa_state != WPA_COMPLETED) {
> auth_mode = "INACTIVE";
> } else if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X ||
> wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
> eap_mode = wpa_supplicant_get_eap_mode(wpa_s);
> os_snprintf(eap_mode_buf, WPAS_DBUS_AUTH_MODE_MAX,
> "EAP-%s", eap_mode);
> auth_mode = eap_mode_buf;
>
> } else {
> auth_mode = wpa_key_mgmt_txt(wpa_s->key_mgmt,
> wpa_s->current_ssid->proto);
2197,2198c2798,2799
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &bridge_ifname);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &auth_mode, error);
2202a2804,2823
> * wpas_dbus_getter_bridge_ifname - Get interface name
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "BridgeIfname" property.
> */
> dbus_bool_t wpas_dbus_getter_bridge_ifname(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
> {
> struct wpa_supplicant *wpa_s = user_data;
> const char *bridge_ifname = wpa_s->bridge_ifname;
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &bridge_ifname, error);
> }
>
>
> /**
2204,2207c2825,2828
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: a dbus message containing an array of all known BSS objects
< * dbus paths
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2211,2212c2832,2833
< DBusMessage * wpas_dbus_getter_bsss(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_bsss(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2214c2835
< DBusMessage *reply = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
2217a2839
> dbus_bool_t success = FALSE;
2219c2841
< paths = os_zalloc(wpa_s->num_bss * sizeof(char *));
---
> paths = os_calloc(wpa_s->num_bss, sizeof(char *));
2221,2222c2843,2844
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2229,2231c2851,2852
< reply = dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
> "no memory");
2240,2242c2861,2864
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< paths, wpa_s->num_bss);
---
> success = wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_OBJECT_PATH,
> paths, wpa_s->num_bss,
> error);
2248c2870
< return reply;
---
> return success;
2254,2257c2876,2879
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: a dbus message containing an array of all configured
< * networks dbus object paths.
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2261,2262c2883,2884
< DBusMessage * wpas_dbus_getter_networks(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_networks(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2264c2886
< DBusMessage *reply = NULL;
---
> struct wpa_supplicant *wpa_s = user_data;
2267a2890
> dbus_bool_t success = FALSE;
2270,2272c2893,2897
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_networks[dbus]: "
< "An error occurred getting networks list.");
< return wpas_dbus_error_unknown_error(message, NULL);
---
> wpa_printf(MSG_ERROR, "%s[dbus]: An error occurred getting "
> "networks list.", __func__);
> dbus_set_error(error, DBUS_ERROR_FAILED, "%s: an error "
> "occurred getting the networks list", __func__);
> return FALSE;
2276c2901,2902
< num++;
---
> if (!network_is_persistent_group(ssid))
> num++;
2278c2904
< paths = os_zalloc(num * sizeof(char *));
---
> paths = os_calloc(num, sizeof(char *));
2280,2281c2906,2907
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2285a2912,2913
> if (network_is_persistent_group(ssid))
> continue;
2288,2290c2916
< reply = dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error(error, DBUS_ERROR_NO_MEMORY, "no memory");
2300,2302c2926,2928
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_OBJECT_PATH,
< paths, num);
---
> success = wpas_dbus_simple_array_property_getter(iter,
> DBUS_TYPE_OBJECT_PATH,
> paths, num, error);
2308c2934
< return reply;
---
> return success;
2314,2316c2940,2943
< * @message: Pointer to incoming dbus message
< * @wpa_s: wpa_supplicant structure for a network interface
< * Returns: a dbus message containing a dictionary of pairs (blob_name, blob)
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2320,2321c2947,2948
< DBusMessage * wpas_dbus_getter_blobs(DBusMessage *message,
< struct wpa_supplicant *wpa_s)
---
> dbus_bool_t wpas_dbus_getter_blobs(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2323,2324c2950,2951
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter, dict_iter, entry_iter, array_iter;
---
> struct wpa_supplicant *wpa_s = user_data;
> DBusMessageIter variant_iter, dict_iter, entry_iter, array_iter;
2327,2337c2954
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (!reply)
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
<
< dbus_message_iter_init_append(reply, &iter);
<
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
2341,2343c2958,2959
< dbus_message_unref(reply);
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2366,2369c2982,2984
< dbus_message_unref(reply);
< return dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
> "no memory");
> return FALSE;
2376,2379c2991,2993
< !dbus_message_iter_close_container(&iter, &variant_iter)) {
< dbus_message_unref(reply);
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> !dbus_message_iter_close_container(iter, &variant_iter)) {
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2382c2996
< return reply;
---
> return TRUE;
2385a3000,3016
> static struct wpa_bss * get_bss_helper(struct bss_handler_args *args,
> DBusError *error, const char *func_name)
> {
> struct wpa_bss *res = wpa_bss_get_id(args->wpa_s, args->id);
>
> if (!res) {
> wpa_printf(MSG_ERROR, "%s[dbus]: no bss with id %d found",
> func_name, args->id);
> dbus_set_error(error, DBUS_ERROR_FAILED,
> "%s: BSS %d not found",
> func_name, args->id);
> }
>
> return res;
> }
>
>
2388,2390c3019,3022
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the bssid for the requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2394,2395c3026,3027
< DBusMessage * wpas_dbus_getter_bss_bssid(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_bssid(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2397c3029,3030
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2399,2403c3032,3034
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_bssid[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2405,2406c3036,3038
< return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
< res->bssid, ETH_ALEN);
---
> return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
> res->bssid, ETH_ALEN,
> error);
2412,2414c3044,3047
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the ssid for the requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2418,2419c3051,3052
< DBusMessage * wpas_dbus_getter_bss_ssid(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_ssid(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2421c3054,3055
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2423,2427c3057,3059
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_ssid[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2429,2431c3061,3063
< return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
< res->ssid,
< res->ssid_len);
---
> return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
> res->ssid, res->ssid_len,
> error);
2437,2439c3069,3072
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the privacy flag value of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2443,2444c3076,3077
< DBusMessage * wpas_dbus_getter_bss_privacy(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_privacy(DBusMessageIter *iter,
> DBusError *error, void *user_data)
2446c3079,3080
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2449,2453c3083,3085
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_privacy[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2456,2457c3088,3089
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &privacy);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &privacy, error);
2463,2465c3095,3098
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the mode of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2469,2470c3102,3103
< DBusMessage * wpas_dbus_getter_bss_mode(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_mode(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2472c3105,3106
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2475,2479c3109,3111
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_mode[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2486,2487c3118,3119
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
< &mode);
---
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
> &mode, error);
2493,2495c3125,3128
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the signal strength of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2499,2500c3132,3133
< DBusMessage * wpas_dbus_getter_bss_signal(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_signal(DBusMessageIter *iter,
> DBusError *error, void *user_data)
2502c3135,3137
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
> s16 level;
2504,2508c3139,3141
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_signal[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2510,2511c3143,3145
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_INT16,
< &res->level);
---
> level = (s16) res->level;
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT16,
> &level, error);
2517,2519c3151,3154
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the frequency of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2523,2524c3158,3159
< DBusMessage * wpas_dbus_getter_bss_frequency(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_frequency(DBusMessageIter *iter,
> DBusError *error, void *user_data)
2526c3161,3163
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
> u16 freq;
2528,2532c3165,3167
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_frequency[dbus]: "
< "no bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2534,2535c3169,3171
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_UINT16,
< &res->freq);
---
> freq = (u16) res->freq;
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16,
> &freq, error);
2547,2549c3183,3186
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing sorted array of bit rates
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2553,2554c3190,3191
< DBusMessage * wpas_dbus_getter_bss_rates(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_rates(DBusMessageIter *iter,
> DBusError *error, void *user_data)
2556,2557c3193,3194
< DBusMessage *reply;
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2560a3198
> dbus_bool_t success = FALSE;
2562,2566c3200,3202
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_rates[dbus]: "
< "no bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2570c3206
< return NULL;
---
> return FALSE;
2577,2578c3213,3214
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2584,2586c3220,3222
< reply = wpas_dbus_simple_array_property_getter(message,
< DBUS_TYPE_UINT32,
< real_rates, rates_num);
---
> success = wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_UINT32,
> real_rates, rates_num,
> error);
2590c3226
< return reply;
---
> return success;
2594,2595c3230,3232
< static DBusMessage * wpas_dbus_get_bss_security_prop(
< DBusMessage *message, struct wpa_ie_data *ie_data)
---
> static dbus_bool_t wpas_dbus_get_bss_security_prop(DBusMessageIter *iter,
> struct wpa_ie_data *ie_data,
> DBusError *error)
2597,2598c3234
< DBusMessage *reply;
< DBusMessageIter iter, iter_dict, variant_iter;
---
> DBusMessageIter iter_dict, variant_iter;
2600c3236
< const char *pairwise[2]; /* max 2 pairwise ciphers is supported */
---
> const char *pairwise[3]; /* max 3 pairwise ciphers is supported */
2604,2612c3240
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (!reply)
< goto nomem;
<
< dbus_message_iter_init_append(reply, &iter);
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
2650a3279,3281
> case WPA_CIPHER_GCMP:
> group = "gcmp";
> break;
2667a3299,3300
> if (ie_data->pairwise_cipher & WPA_CIPHER_GCMP)
> pairwise[n++] = "gcmp";
2693c3326
< if (!dbus_message_iter_close_container(&iter, &variant_iter))
---
> if (!dbus_message_iter_close_container(iter, &variant_iter))
2696c3329
< return reply;
---
> return TRUE;
2699,2702c3332,3333
< if (reply)
< dbus_message_unref(reply);
<
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2708,2710c3339,3342
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the WPA options of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2714,2715c3346,3347
< DBusMessage * wpas_dbus_getter_bss_wpa(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_wpa(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2717c3349,3350
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2721,2725c3354,3356
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_wpa[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2730,2732c3361,3365
< if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0)
< return wpas_dbus_error_unknown_error(message,
< "invalid WPA IE");
---
> if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "failed to parse WPA IE");
> return FALSE;
> }
2735c3368
< return wpas_dbus_get_bss_security_prop(message, &wpa_data);
---
> return wpas_dbus_get_bss_security_prop(iter, &wpa_data, error);
2741,2743c3374,3377
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing the RSN options of requested bss
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2747,2748c3381,3382
< DBusMessage * wpas_dbus_getter_bss_rsn(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_rsn(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2750c3384,3385
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2754,2758c3389,3391
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_rsn[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2763,2765c3396,3400
< if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0)
< return wpas_dbus_error_unknown_error(message,
< "invalid RSN IE");
---
> if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
> dbus_set_error_const(error, DBUS_ERROR_FAILED,
> "failed to parse RSN IE");
> return FALSE;
> }
2768c3403
< return wpas_dbus_get_bss_security_prop(message, &wpa_data);
---
> return wpas_dbus_get_bss_security_prop(iter, &wpa_data, error);
2772a3408,3464
> * wpas_dbus_getter_bss_wps - Return the WPS options of a BSS
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
> *
> * Getter for "WPS" property.
> */
> dbus_bool_t wpas_dbus_getter_bss_wps(DBusMessageIter *iter, DBusError *error,
> void *user_data)
> {
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
> #ifdef CONFIG_WPS
> struct wpabuf *wps_ie;
> #endif /* CONFIG_WPS */
> DBusMessageIter iter_dict, variant_iter;
> const char *type = "";
>
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
>
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
> "a{sv}", &variant_iter))
> goto nomem;
>
> if (!wpa_dbus_dict_open_write(&variant_iter, &iter_dict))
> goto nomem;
>
> #ifdef CONFIG_WPS
> wps_ie = wpa_bss_get_vendor_ie_multi(res, WPS_IE_VENDOR_TYPE);
> if (wps_ie) {
> if (wps_is_selected_pbc_registrar(wps_ie))
> type = "pbc";
> else if (wps_is_selected_pin_registrar(wps_ie))
> type = "pin";
> }
> #endif /* CONFIG_WPS */
>
> if (!wpa_dbus_dict_append_string(&iter_dict, "Type", type))
> goto nomem;
>
> if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict))
> goto nomem;
> if (!dbus_message_iter_close_container(iter, &variant_iter))
> goto nomem;
>
> return TRUE;
>
> nomem:
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
> }
>
>
> /**
2774,2776c3466,3469
< * @message: Pointer to incoming dbus message
< * @bss: a pair of interface describing structure and bss's id
< * Returns: a dbus message containing IEs byte array
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2780,2781c3473,3474
< DBusMessage * wpas_dbus_getter_bss_ies(DBusMessage *message,
< struct bss_handler_args *bss)
---
> dbus_bool_t wpas_dbus_getter_bss_ies(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2783c3476,3477
< struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
---
> struct bss_handler_args *args = user_data;
> struct wpa_bss *res;
2785,2789c3479,3481
< if (!res) {
< wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_ies[dbus]: no "
< "bss with id %d found", bss->id);
< return NULL;
< }
---
> res = get_bss_helper(args, error, __func__);
> if (!res)
> return FALSE;
2791,2792c3483,3485
< return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
< res + 1, res->ie_len);
---
> return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
> res + 1, res->ie_len,
> error);
2798,2802c3491,3494
< * @message: Pointer to incoming dbus message
< * @wpas_dbus_setter_enabled: wpa_supplicant structure for a network interface
< * and wpa_ssid structure for a configured network
< * Returns: DBus message with boolean indicating state of configured network
< * or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2806,2807c3498,3499
< DBusMessage * wpas_dbus_getter_enabled(DBusMessage *message,
< struct network_handler_args *net)
---
> dbus_bool_t wpas_dbus_getter_enabled(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2808a3501
> struct network_handler_args *net = user_data;
2810,2811c3503,3505
< return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
< &enabled);
---
>
> return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
> &enabled, error);
2817,2820c3511,3514
< * @message: Pointer to incoming dbus message
< * @wpas_dbus_setter_enabled: wpa_supplicant structure for a network interface
< * and wpa_ssid structure for a configured network
< * Returns: NULL indicating success or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2824,2825c3518,3519
< DBusMessage * wpas_dbus_setter_enabled(DBusMessage *message,
< struct network_handler_args *net)
---
> dbus_bool_t wpas_dbus_setter_enabled(DBusMessageIter *iter, DBusError *error,
> void *user_data)
2827,2828c3521
< DBusMessage *reply = NULL;
<
---
> struct network_handler_args *net = user_data;
2831d3523
<
2834,2835c3526,3528
< reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
< &enable);
---
> if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_BOOLEAN,
> &enable))
> return FALSE;
2837,2839d3529
< if (reply)
< return reply;
<
2848c3538
< return NULL;
---
> return TRUE;
2854,2857c3544,3547
< * @message: Pointer to incoming dbus message
< * @net: wpa_supplicant structure for a network interface and
< * wpa_ssid structure for a configured network
< * Returns: DBus message with network properties or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2861,2862c3551,3553
< DBusMessage * wpas_dbus_getter_network_properties(
< DBusMessage *message, struct network_handler_args *net)
---
> dbus_bool_t wpas_dbus_getter_network_properties(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2864,2865c3555,3556
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter, dict_iter;
---
> struct network_handler_args *net = user_data;
> DBusMessageIter variant_iter, dict_iter;
2867,2870c3558,3559
< char **props = wpa_config_get_all(net->ssid, 0);
< if (!props)
< return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> char **props = wpa_config_get_all(net->ssid, 1);
> dbus_bool_t success = FALSE;
2872,2879c3561,3563
< if (message == NULL)
< reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
< else
< reply = dbus_message_new_method_return(message);
< if (!reply) {
< reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
< goto out;
---
> if (!props) {
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
> return FALSE;
2882,2885c3566,3567
< dbus_message_iter_init_append(reply, &iter);
<
< if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
< "a{sv}", &variant_iter) ||
---
> if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, "a{sv}",
> &variant_iter) ||
2887,2889c3569
< dbus_message_unref(reply);
< reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
2897,2900c3577,3578
< dbus_message_unref(reply);
< reply = dbus_message_new_error(message,
< DBUS_ERROR_NO_MEMORY,
< NULL);
---
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
> "no memory");
2908,2911c3586,3587
< !dbus_message_iter_close_container(&iter, &variant_iter)) {
< dbus_message_unref(reply);
< reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
< NULL);
---
> !dbus_message_iter_close_container(iter, &variant_iter)) {
> dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
2914a3591,3592
> success = TRUE;
>
2922c3600
< return reply;
---
> return success;
2928,2931c3606,3609
< * @message: Pointer to incoming dbus message
< * @net: wpa_supplicant structure for a network interface and
< * wpa_ssid structure for a configured network
< * Returns: NULL indicating success or DBus error on failure
---
> * @iter: Pointer to incoming dbus message iter
> * @error: Location to store error on failure
> * @user_data: Function specific data
> * Returns: TRUE on success, FALSE on failure
2935,2936c3613,3615
< DBusMessage * wpas_dbus_setter_network_properties(
< DBusMessage *message, struct network_handler_args *net)
---
> dbus_bool_t wpas_dbus_setter_network_properties(DBusMessageIter *iter,
> DBusError *error,
> void *user_data)
2937a3617
> struct network_handler_args *net = user_data;
2938a3619
> DBusMessageIter variant_iter;
2940,2941c3621,3623
< DBusMessage *reply = NULL;
< DBusMessageIter iter, variant_iter;
---
> dbus_message_iter_recurse(iter, &variant_iter);
> return set_network_properties(net->wpa_s, ssid, &variant_iter, error);
> }
2943d3624
< dbus_message_iter_init(message, &iter);
2945,2946c3626
< dbus_message_iter_next(&iter);
< dbus_message_iter_next(&iter);
---
> #ifdef CONFIG_AP
2948c3628,3632
< dbus_message_iter_recurse(&iter, &variant_iter);
---
> DBusMessage * wpas_dbus_handler_subscribe_preq(
> DBusMessage *message, struct wpa_supplicant *wpa_s)
> {
> struct wpas_dbus_priv *priv = wpa_s->global->dbus;
> char *name;
2950,2954c3634,3637
< reply = set_network_properties(message, net->wpa_s, ssid,
< &variant_iter);
< if (reply)
< wpa_printf(MSG_DEBUG, "dbus control interface couldn't set "
< "network properties");
---
> if (wpa_s->preq_notify_peer != NULL) {
> if (os_strcmp(dbus_message_get_sender(message),
> wpa_s->preq_notify_peer) == 0)
> return NULL;
2956c3639,3675
< return reply;
---
> return dbus_message_new_error(message,
> WPAS_DBUS_ERROR_SUBSCRIPTION_IN_USE,
> "Another application is already subscribed");
> }
>
> name = os_strdup(dbus_message_get_sender(message));
> if (!name)
> return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
> "out of memory");
>
> wpa_s->preq_notify_peer = name;
>
> /* Subscribe to clean up if application closes socket */
> wpas_dbus_subscribe_noc(priv);
>
> /*
> * Double-check it's still alive to make sure that we didn't
> * miss the NameOwnerChanged signal, e.g. while strdup'ing.
> */
> if (!dbus_bus_name_has_owner(priv->con, name, NULL)) {
> /*
> * Application no longer exists, clean up.
> * The return value is irrelevant now.
> *
> * Need to check if the NameOwnerChanged handling
> * already cleaned up because we have processed
> * DBus messages while checking if the name still
> * has an owner.
> */
> if (!wpa_s->preq_notify_peer)
> return NULL;
> os_free(wpa_s->preq_notify_peer);
> wpa_s->preq_notify_peer = NULL;
> wpas_dbus_unsubscribe_noc(priv);
> }
>
> return NULL;
2957a3677,3759
>
>
> DBusMessage * wpas_dbus_handler_unsubscribe_preq(
> DBusMessage *message, struct wpa_supplicant *wpa_s)
> {
> struct wpas_dbus_priv *priv = wpa_s->global->dbus;
>
> if (!wpa_s->preq_notify_peer)
> return dbus_message_new_error(message,
> WPAS_DBUS_ERROR_NO_SUBSCRIPTION,
> "Not subscribed");
>
> if (os_strcmp(wpa_s->preq_notify_peer,
> dbus_message_get_sender(message)))
> return dbus_message_new_error(message,
> WPAS_DBUS_ERROR_SUBSCRIPTION_EPERM,
> "Can't unsubscribe others");
>
> os_free(wpa_s->preq_notify_peer);
> wpa_s->preq_notify_peer = NULL;
> wpas_dbus_unsubscribe_noc(priv);
> return NULL;
> }
>
>
> void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s,
> const u8 *addr, const u8 *dst, const u8 *bssid,
> const u8 *ie, size_t ie_len, u32 ssi_signal)
> {
> DBusMessage *msg;
> DBusMessageIter iter, dict_iter;
> struct wpas_dbus_priv *priv = wpa_s->global->dbus;
>
> /* Do nothing if the control interface is not turned on */
> if (priv == NULL)
> return;
>
> if (wpa_s->preq_notify_peer == NULL)
> return;
>
> msg = dbus_message_new_signal(wpa_s->dbus_new_path,
> WPAS_DBUS_NEW_IFACE_INTERFACE,
> "ProbeRequest");
> if (msg == NULL)
> return;
>
> dbus_message_set_destination(msg, wpa_s->preq_notify_peer);
>
> dbus_message_iter_init_append(msg, &iter);
>
> if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
> goto fail;
> if (addr && !wpa_dbus_dict_append_byte_array(&dict_iter, "addr",
> (const char *) addr,
> ETH_ALEN))
> goto fail;
> if (dst && !wpa_dbus_dict_append_byte_array(&dict_iter, "dst",
> (const char *) dst,
> ETH_ALEN))
> goto fail;
> if (bssid && !wpa_dbus_dict_append_byte_array(&dict_iter, "bssid",
> (const char *) bssid,
> ETH_ALEN))
> goto fail;
> if (ie && ie_len && !wpa_dbus_dict_append_byte_array(&dict_iter, "ies",
> (const char *) ie,
> ie_len))
> goto fail;
> if (ssi_signal && !wpa_dbus_dict_append_int32(&dict_iter, "signal",
> ssi_signal))
> goto fail;
> if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
> goto fail;
>
> dbus_connection_send(priv->con, msg, NULL);
> goto out;
> fail:
> wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
> out:
> dbus_message_unref(msg);
> }
>
> #endif /* CONFIG_AP */