D-Bus: Simplify message building error paths
There is no need to have multiple separate return statements for error cases in a sequence of operations. In addition, there is not much point in "converting" boolean return values with "if (!res) return FALSE; return TRUE;" style constructions. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
bba40b65b0
commit
e3c4f0b5d5
8 changed files with 520 additions and 1027 deletions
|
@ -345,26 +345,14 @@ struct wpas_dbus_priv * wpas_dbus_init(struct wpa_global *global)
|
|||
return NULL;
|
||||
priv->global = global;
|
||||
|
||||
if (wpas_dbus_init_common(priv) < 0) {
|
||||
wpas_dbus_deinit(priv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (wpas_dbus_init_common(priv) < 0 ||
|
||||
#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
|
||||
if (wpas_dbus_ctrl_iface_init(priv) < 0) {
|
||||
wpas_dbus_deinit(priv);
|
||||
return NULL;
|
||||
}
|
||||
wpas_dbus_ctrl_iface_init(priv) < 0 ||
|
||||
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
|
||||
|
||||
#ifdef CONFIG_CTRL_IFACE_DBUS
|
||||
if (wpa_supplicant_dbus_ctrl_iface_init(priv) < 0) {
|
||||
wpas_dbus_deinit(priv);
|
||||
return NULL;
|
||||
}
|
||||
wpa_supplicant_dbus_ctrl_iface_init(priv) < 0 ||
|
||||
#endif /* CONFIG_CTRL_IFACE_DBUS */
|
||||
|
||||
if (wpas_dbus_init_common_finish(priv) < 0) {
|
||||
wpas_dbus_init_common_finish(priv) < 0) {
|
||||
wpas_dbus_deinit(priv);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -106,11 +106,8 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_start(
|
|||
iter_dict_entry))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_append_basic(iter_dict_entry, DBUS_TYPE_STRING,
|
||||
&key))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return dbus_message_iter_append_basic(iter_dict_entry, DBUS_TYPE_STRING,
|
||||
&key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,10 +117,8 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_end(
|
|||
{
|
||||
if (!dbus_message_iter_close_container(iter_dict_entry, iter_dict_val))
|
||||
return FALSE;
|
||||
if (!dbus_message_iter_close_container(iter_dict, iter_dict_entry))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return dbus_message_iter_close_container(iter_dict, iter_dict_entry);
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,22 +138,15 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_basic(DBusMessageIter *iter_dict,
|
|||
return FALSE;
|
||||
|
||||
if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry,
|
||||
key, value_type))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container(&iter_dict_entry,
|
||||
key, value_type) ||
|
||||
!dbus_message_iter_open_container(&iter_dict_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
type_as_string, &iter_dict_val))
|
||||
type_as_string, &iter_dict_val) ||
|
||||
!dbus_message_iter_append_basic(&iter_dict_val, value_type, value))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_append_basic(&iter_dict_val, value_type, value))
|
||||
return FALSE;
|
||||
|
||||
if (!_wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return _wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val);
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,17 +158,13 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_byte_array(
|
|||
dbus_uint32_t i;
|
||||
|
||||
if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry,
|
||||
key, DBUS_TYPE_ARRAY))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container(&iter_dict_entry,
|
||||
key, DBUS_TYPE_ARRAY) ||
|
||||
!dbus_message_iter_open_container(&iter_dict_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
DBUS_TYPE_ARRAY_AS_STRING
|
||||
DBUS_TYPE_BYTE_AS_STRING,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container(&iter_dict_val, DBUS_TYPE_ARRAY,
|
||||
&iter_dict_val) ||
|
||||
!dbus_message_iter_open_container(&iter_dict_val, DBUS_TYPE_ARRAY,
|
||||
DBUS_TYPE_BYTE_AS_STRING,
|
||||
&iter_array))
|
||||
return FALSE;
|
||||
|
@ -195,11 +179,8 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_byte_array(
|
|||
if (!dbus_message_iter_close_container(&iter_dict_val, &iter_array))
|
||||
return FALSE;
|
||||
|
||||
if (!_wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return _wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val);
|
||||
}
|
||||
|
||||
|
||||
|
@ -428,9 +409,7 @@ dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict,
|
|||
const char *value,
|
||||
const dbus_uint32_t value_len)
|
||||
{
|
||||
if (!key)
|
||||
return FALSE;
|
||||
if (!value && (value_len != 0))
|
||||
if (!key || (!value && value_len != 0))
|
||||
return FALSE;
|
||||
return _wpa_dbus_add_dict_entry_byte_array(iter_dict, key, value,
|
||||
value_len);
|
||||
|
@ -468,24 +447,17 @@ dbus_bool_t wpa_dbus_dict_begin_array(DBusMessageIter *iter_dict,
|
|||
if (os_snprintf_error(sizeof(array_type), err))
|
||||
return FALSE;
|
||||
|
||||
if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array)
|
||||
return FALSE;
|
||||
|
||||
if (!_wpa_dbus_add_dict_entry_start(iter_dict, iter_dict_entry,
|
||||
key, DBUS_TYPE_ARRAY))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container(iter_dict_entry,
|
||||
if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array ||
|
||||
!_wpa_dbus_add_dict_entry_start(iter_dict, iter_dict_entry,
|
||||
key, DBUS_TYPE_ARRAY) ||
|
||||
!dbus_message_iter_open_container(iter_dict_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
array_type,
|
||||
iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container(iter_dict_val, DBUS_TYPE_ARRAY,
|
||||
type, iter_array))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return dbus_message_iter_open_container(iter_dict_val, DBUS_TYPE_ARRAY,
|
||||
type, iter_array);
|
||||
}
|
||||
|
||||
|
||||
|
@ -542,10 +514,8 @@ dbus_bool_t wpa_dbus_dict_bin_array_add_element(DBusMessageIter *iter_array,
|
|||
DBusMessageIter iter_bytes;
|
||||
size_t i;
|
||||
|
||||
if (!iter_array || !value)
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container(iter_array, DBUS_TYPE_ARRAY,
|
||||
if (!iter_array || !value ||
|
||||
!dbus_message_iter_open_container(iter_array, DBUS_TYPE_ARRAY,
|
||||
DBUS_TYPE_BYTE_AS_STRING,
|
||||
&iter_bytes))
|
||||
return FALSE;
|
||||
|
@ -557,10 +527,7 @@ dbus_bool_t wpa_dbus_dict_bin_array_add_element(DBusMessageIter *iter_array,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_close_container(iter_array, &iter_bytes))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return dbus_message_iter_close_container(iter_array, &iter_bytes);
|
||||
}
|
||||
|
||||
|
||||
|
@ -586,17 +553,12 @@ dbus_bool_t wpa_dbus_dict_end_array(DBusMessageIter *iter_dict,
|
|||
DBusMessageIter *iter_dict_val,
|
||||
DBusMessageIter *iter_array)
|
||||
{
|
||||
if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array)
|
||||
if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array ||
|
||||
!dbus_message_iter_close_container(iter_dict_val, iter_array))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_close_container(iter_dict_val, iter_array))
|
||||
return FALSE;
|
||||
|
||||
if (!_wpa_dbus_add_dict_entry_end(iter_dict, iter_dict_entry,
|
||||
iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return _wpa_dbus_add_dict_entry_end(iter_dict, iter_dict_entry,
|
||||
iter_dict_val);
|
||||
}
|
||||
|
||||
|
||||
|
@ -619,12 +581,8 @@ dbus_bool_t wpa_dbus_dict_append_string_array(DBusMessageIter *iter_dict,
|
|||
DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
|
||||
dbus_uint32_t i;
|
||||
|
||||
if (!key)
|
||||
return FALSE;
|
||||
if (!items && (num_items != 0))
|
||||
return FALSE;
|
||||
|
||||
if (!wpa_dbus_dict_begin_string_array(iter_dict, key,
|
||||
if (!key || (!items && num_items != 0) ||
|
||||
!wpa_dbus_dict_begin_string_array(iter_dict, key,
|
||||
&iter_dict_entry, &iter_dict_val,
|
||||
&iter_array))
|
||||
return FALSE;
|
||||
|
@ -635,11 +593,8 @@ dbus_bool_t wpa_dbus_dict_append_string_array(DBusMessageIter *iter_dict,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val, &iter_array))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return wpa_dbus_dict_end_string_array(iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val, &iter_array);
|
||||
}
|
||||
|
||||
|
||||
|
@ -662,12 +617,9 @@ dbus_bool_t wpa_dbus_dict_append_wpabuf_array(DBusMessageIter *iter_dict,
|
|||
DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
|
||||
dbus_uint32_t i;
|
||||
|
||||
if (!key)
|
||||
return FALSE;
|
||||
if (!items && (num_items != 0))
|
||||
return FALSE;
|
||||
|
||||
if (!wpa_dbus_dict_begin_array(iter_dict, key,
|
||||
if (!key ||
|
||||
(!items && num_items != 0) ||
|
||||
!wpa_dbus_dict_begin_array(iter_dict, key,
|
||||
DBUS_TYPE_ARRAY_AS_STRING
|
||||
DBUS_TYPE_BYTE_AS_STRING,
|
||||
&iter_dict_entry, &iter_dict_val,
|
||||
|
@ -681,11 +633,8 @@ dbus_bool_t wpa_dbus_dict_append_wpabuf_array(DBusMessageIter *iter_dict,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_array(iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val, &iter_array))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return wpa_dbus_dict_end_array(iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val, &iter_array);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1080,10 +1029,8 @@ dbus_bool_t wpa_dbus_dict_get_entry(DBusMessageIter *iter_dict,
|
|||
int type;
|
||||
const char *key;
|
||||
|
||||
if (!iter_dict || !entry)
|
||||
goto error;
|
||||
|
||||
if (dbus_message_iter_get_arg_type(iter_dict) != DBUS_TYPE_DICT_ENTRY) {
|
||||
if (!iter_dict || !entry ||
|
||||
dbus_message_iter_get_arg_type(iter_dict) != DBUS_TYPE_DICT_ENTRY) {
|
||||
wpa_printf(MSG_DEBUG, "%s: not a dict entry", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -148,22 +148,14 @@ static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s,
|
|||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
||||
&wpa_s->dbus_new_path))
|
||||
goto err;
|
||||
|
||||
if (properties) {
|
||||
if (!wpa_dbus_get_object_properties(
|
||||
&wpa_s->dbus_new_path) ||
|
||||
(properties &&
|
||||
!wpa_dbus_get_object_properties(
|
||||
iface, wpa_s->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_INTERFACE, &iter))
|
||||
goto err;
|
||||
}
|
||||
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
|
||||
err:
|
||||
WPAS_DBUS_NEW_IFACE_INTERFACE, &iter)))
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -229,7 +221,7 @@ void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success)
|
|||
|
||||
|
||||
/**
|
||||
* wpas_dbus_signal_blob - Send a BSS related event signal
|
||||
* wpas_dbus_signal_bss - Send a BSS related event signal
|
||||
* @wpa_s: %wpa_supplicant network interface data
|
||||
* @bss_obj_path: BSS object path
|
||||
* @sig_name: signal name - BSSAdded or BSSRemoved
|
||||
|
@ -259,22 +251,14 @@ static void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s,
|
|||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
||||
&bss_obj_path))
|
||||
goto err;
|
||||
|
||||
if (properties) {
|
||||
if (!wpa_dbus_get_object_properties(iface, bss_obj_path,
|
||||
&bss_obj_path) ||
|
||||
(properties &&
|
||||
!wpa_dbus_get_object_properties(iface, bss_obj_path,
|
||||
WPAS_DBUS_NEW_IFACE_BSS,
|
||||
&iter))
|
||||
goto err;
|
||||
}
|
||||
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
|
||||
err:
|
||||
&iter)))
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -407,23 +391,14 @@ static void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s,
|
|||
dbus_message_iter_init_append(msg, &iter);
|
||||
path = net_obj_path;
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
||||
&path))
|
||||
goto err;
|
||||
|
||||
if (properties) {
|
||||
if (!wpa_dbus_get_object_properties(
|
||||
&path) ||
|
||||
(properties &&
|
||||
!wpa_dbus_get_object_properties(
|
||||
iface, net_obj_path, WPAS_DBUS_NEW_IFACE_NETWORK,
|
||||
&iter))
|
||||
goto err;
|
||||
}
|
||||
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
|
||||
err:
|
||||
&iter)))
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -513,19 +488,12 @@ void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
|
|||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
||||
&net_ptr))
|
||||
goto err;
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field))
|
||||
goto err;
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &txt))
|
||||
goto err;
|
||||
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
|
||||
err:
|
||||
&net_ptr) ||
|
||||
!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field) ||
|
||||
!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &txt))
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -749,15 +717,11 @@ void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
|
|||
if (cred->encr_type & WPS_ENCR_AES)
|
||||
encr_type[et_num++] = "aes";
|
||||
|
||||
if (wpa_s->current_ssid) {
|
||||
if (!wpa_dbus_dict_append_byte_array(
|
||||
if ((wpa_s->current_ssid &&
|
||||
!wpa_dbus_dict_append_byte_array(
|
||||
&dict_iter, "BSSID",
|
||||
(const char *) wpa_s->current_ssid->bssid,
|
||||
ETH_ALEN))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
|
||||
(const char *) wpa_s->current_ssid->bssid, ETH_ALEN)) ||
|
||||
!wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
|
||||
(const char *) cred->ssid,
|
||||
cred->ssid_len) ||
|
||||
!wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
|
||||
|
@ -804,29 +768,20 @@ void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "subject", subject))
|
||||
goto nomem;
|
||||
|
||||
if (cert_hash &&
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "cert_hash", cert_hash))
|
||||
goto nomem;
|
||||
|
||||
if (cert &&
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "subject", subject) ||
|
||||
(cert_hash &&
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "cert_hash",
|
||||
cert_hash)) ||
|
||||
(cert &&
|
||||
!wpa_dbus_dict_append_byte_array(&dict_iter, "cert",
|
||||
wpabuf_head(cert),
|
||||
wpabuf_len(cert)))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
goto nomem;
|
||||
|
||||
wpabuf_len(cert))) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
|
||||
nomem:
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -852,15 +807,12 @@ void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
|
|||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status)
|
||||
||
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status) ||
|
||||
!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
|
||||
¶meter))
|
||||
goto nomem;
|
||||
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
|
||||
nomem:
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -946,7 +898,6 @@ void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
|
|||
void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
|
||||
const char *role)
|
||||
{
|
||||
int error = 1;
|
||||
DBusMessage *msg;
|
||||
DBusMessageIter iter, dict_iter;
|
||||
struct wpas_dbus_priv *iface = wpa_s->global->dbus;
|
||||
|
@ -970,30 +921,17 @@ void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_append_object_path(&dict_iter,
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
!wpa_dbus_dict_append_object_path(&dict_iter,
|
||||
"interface_object",
|
||||
wpa_s->dbus_new_path))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_append_string(&dict_iter, "role", role))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
|
||||
wpa_s->dbus_new_path) ||
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "role", role) ||
|
||||
!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
|
||||
wpa_s->dbus_groupobj_path) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
goto nomem;
|
||||
|
||||
error = 0;
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
|
||||
nomem:
|
||||
if (error > 0)
|
||||
wpa_printf(MSG_ERROR,
|
||||
"dbus: Failed to construct GroupFinished");
|
||||
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -1280,34 +1218,26 @@ void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
|
||||
goto nomem;
|
||||
|
||||
/*
|
||||
* In case the device supports creating a separate interface the
|
||||
* DBus client will need to know the object path for the interface
|
||||
* object this group was created on, so include it here.
|
||||
*/
|
||||
if (!wpa_dbus_dict_append_object_path(&dict_iter,
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
!wpa_dbus_dict_append_object_path(&dict_iter,
|
||||
"interface_object",
|
||||
wpa_s->dbus_new_path))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_append_string(&dict_iter, "role",
|
||||
client ? "client" : "GO"))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
|
||||
wpa_s->dbus_new_path) ||
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "role",
|
||||
client ? "client" : "GO") ||
|
||||
!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
|
||||
wpa_s->dbus_groupobj_path) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
goto nomem;
|
||||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter)) {
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
} else {
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
|
||||
if (client)
|
||||
peer_groups_changed(wpa_s);
|
||||
|
||||
nomem:
|
||||
}
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -1353,9 +1283,8 @@ void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
|
||||
goto err;
|
||||
if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
|
||||
path) ||
|
||||
!wpa_dbus_dict_append_int32(&dict_iter, "status", res->status))
|
||||
goto err;
|
||||
|
@ -1364,12 +1293,10 @@ void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
|
|||
int i = 0;
|
||||
int freq_list_num = 0;
|
||||
|
||||
if (res->role_go &&
|
||||
if ((res->role_go &&
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "passphrase",
|
||||
res->passphrase))
|
||||
goto err;
|
||||
|
||||
if (!wpa_dbus_dict_append_string(&dict_iter, "role_go",
|
||||
res->passphrase)) ||
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "role_go",
|
||||
res->role_go ? "GO" :
|
||||
"client") ||
|
||||
!wpa_dbus_dict_append_int32(&dict_iter, "frequency",
|
||||
|
@ -1404,22 +1331,16 @@ void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
|
|||
DBUS_TYPE_INT32_AS_STRING,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_dict_array))
|
||||
goto err;
|
||||
|
||||
if (!dbus_message_iter_append_fixed_array(&iter_dict_array,
|
||||
&iter_dict_array) ||
|
||||
!dbus_message_iter_append_fixed_array(&iter_dict_array,
|
||||
DBUS_TYPE_INT32,
|
||||
&f_array,
|
||||
freq_list_num))
|
||||
goto err;
|
||||
|
||||
if (!wpa_dbus_dict_end_array(&dict_iter,
|
||||
freq_list_num) ||
|
||||
!wpa_dbus_dict_end_array(&dict_iter,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_dict_array))
|
||||
goto err;
|
||||
|
||||
if (!wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
|
||||
&iter_dict_array) ||
|
||||
!wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
|
||||
res->persistent_group) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter,
|
||||
"peer_config_timeout",
|
||||
|
@ -1469,23 +1390,16 @@ void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_append_int32(&dict_iter, "status", status))
|
||||
goto nomem;
|
||||
if (bssid) {
|
||||
if (!wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
!wpa_dbus_dict_append_int32(&dict_iter, "status", status) ||
|
||||
(bssid &&
|
||||
!wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
|
||||
(const char *) bssid,
|
||||
ETH_ALEN))
|
||||
goto nomem;
|
||||
}
|
||||
if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
goto nomem;
|
||||
|
||||
ETH_ALEN)) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
|
||||
nomem:
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -1535,18 +1449,12 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
|
|||
dbus_message_iter_init_append(msg, &iter);
|
||||
path = peer_obj_path;
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
||||
&path))
|
||||
goto err;
|
||||
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
|
||||
wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
&path)) {
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
} else {
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
|
||||
}
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -1596,19 +1504,13 @@ void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
|
|||
dbus_message_iter_init_append(msg, &iter);
|
||||
path = peer_obj_path;
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
||||
&path))
|
||||
goto err;
|
||||
|
||||
&path)) {
|
||||
wpa_printf(MSG_ERROR,
|
||||
"dbus: Failed to construct PeerDisconnected signal");
|
||||
} else {
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
|
||||
wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct PeerDisconnected "
|
||||
"signal");
|
||||
}
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -1644,16 +1546,16 @@ void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
|
|||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
/* Check if this is a known peer */
|
||||
if (!p2p_peer_known(wpa_s->global->p2p, sa))
|
||||
return;
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
|
||||
"ServiceDiscoveryRequest");
|
||||
if (msg == NULL)
|
||||
return;
|
||||
|
||||
/* Check if this is a known peer */
|
||||
if (!p2p_peer_known(wpa_s->global->p2p, sa))
|
||||
goto error;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
|
||||
COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
|
||||
|
@ -1661,11 +1563,8 @@ void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
|
|||
path = peer_obj_path;
|
||||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
|
||||
goto error;
|
||||
|
||||
|
||||
if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
|
||||
path) ||
|
||||
!wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
|
||||
!wpa_dbus_dict_append_int32(&dict_iter, "dialog_token",
|
||||
|
@ -1676,13 +1575,9 @@ void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
|
|||
(const char *) tlvs,
|
||||
tlvs_len) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
goto error;
|
||||
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
error:
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
@ -1716,16 +1611,16 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
|
|||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
/* Check if this is a known peer */
|
||||
if (!p2p_peer_known(wpa_s->global->p2p, sa))
|
||||
return;
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
|
||||
"ServiceDiscoveryResponse");
|
||||
if (msg == NULL)
|
||||
return;
|
||||
|
||||
/* Check if this is a known peer */
|
||||
if (!p2p_peer_known(wpa_s->global->p2p, sa))
|
||||
goto error;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
|
||||
COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
|
||||
|
@ -1733,10 +1628,8 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
|
|||
path = peer_obj_path;
|
||||
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
|
||||
goto error;
|
||||
|
||||
if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
|
||||
path) ||
|
||||
!wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
|
||||
update_indic) ||
|
||||
|
@ -1744,17 +1637,13 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
|
|||
(const char *) tlvs,
|
||||
tlvs_len) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
goto error;
|
||||
|
||||
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
error:
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpas_dbus_signal_persistent_group - Send a persistent group related
|
||||
* event signal
|
||||
|
@ -1796,24 +1685,16 @@ static void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
|
|||
dbus_message_iter_init_append(msg, &iter);
|
||||
path = pgrp_obj_path;
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
||||
&path))
|
||||
goto err;
|
||||
|
||||
if (properties) {
|
||||
if (!wpa_dbus_get_object_properties(
|
||||
&path) ||
|
||||
(properties &&
|
||||
!wpa_dbus_get_object_properties(
|
||||
iface, pgrp_obj_path,
|
||||
WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter))
|
||||
goto err;
|
||||
}
|
||||
|
||||
WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter)))
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
|
||||
err:
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3479,16 +3360,11 @@ static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
|
|||
path = peer_obj_path;
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
||||
&path))
|
||||
goto err;
|
||||
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
else
|
||||
dbus_connection_send(iface->con, msg, NULL);
|
||||
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
|
||||
err:
|
||||
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -308,23 +308,17 @@ dbus_bool_t wpas_dbus_simple_property_getter(DBusMessageIter *iter,
|
|||
|
||||
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
|
||||
wpa_dbus_type_as_string(type),
|
||||
&variant_iter))
|
||||
goto error;
|
||||
|
||||
if (!dbus_message_iter_append_basic(&variant_iter, type, val))
|
||||
goto error;
|
||||
|
||||
if (!dbus_message_iter_close_container(iter, &variant_iter))
|
||||
goto error;
|
||||
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
&variant_iter) ||
|
||||
!dbus_message_iter_append_basic(&variant_iter, type, val) ||
|
||||
!dbus_message_iter_close_container(iter, &variant_iter)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: error constructing reply", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpas_dbus_simple_property_setter - Set basic type property
|
||||
|
@ -393,16 +387,11 @@ dbus_bool_t wpas_dbus_simple_array_property_getter(DBusMessageIter *iter,
|
|||
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,
|
||||
type_str, &variant_iter) ||
|
||||
!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
|
||||
sub_type_str, &array_iter)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: failed to construct message 2", __func__);
|
||||
"%s: failed to construct message", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -446,18 +435,13 @@ dbus_bool_t wpas_dbus_simple_array_property_getter(DBusMessageIter *iter,
|
|||
}
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {
|
||||
if (!dbus_message_iter_close_container(&variant_iter, &array_iter) ||
|
||||
!dbus_message_iter_close_container(iter, &variant_iter)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: failed to construct message 3", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -497,15 +481,11 @@ dbus_bool_t wpas_dbus_simple_array_array_property_getter(DBusMessageIter *iter,
|
|||
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,
|
||||
type_str, &variant_iter) ||
|
||||
!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__);
|
||||
"%s: failed to construct message", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -516,15 +496,10 @@ dbus_bool_t wpas_dbus_simple_array_array_property_getter(DBusMessageIter *iter,
|
|||
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {
|
||||
if (!dbus_message_iter_close_container(&variant_iter, &array_iter) ||
|
||||
!dbus_message_iter_close_container(iter, &variant_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__);
|
||||
"%s: failed to close message", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1429,45 +1404,30 @@ DBusMessage * wpas_dbus_handler_signal_poll(DBusMessage *message,
|
|||
dbus_message_iter_init_append(reply, &iter);
|
||||
|
||||
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;
|
||||
|
||||
if (!wpa_dbus_dict_append_int32(&iter_dict, "rssi", si.current_signal))
|
||||
goto nomem;
|
||||
if (!wpa_dbus_dict_append_int32(&iter_dict, "linkspeed",
|
||||
si.current_txrate / 1000))
|
||||
goto nomem;
|
||||
if (!wpa_dbus_dict_append_int32(&iter_dict, "noise", si.current_noise))
|
||||
goto nomem;
|
||||
if (!wpa_dbus_dict_append_uint32(&iter_dict, "frequency", si.frequency))
|
||||
goto nomem;
|
||||
|
||||
if (si.chanwidth != CHAN_WIDTH_UNKNOWN) {
|
||||
if (!wpa_dbus_dict_append_string(&iter_dict, "width",
|
||||
channel_width_to_string(si.chanwidth)))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (si.center_frq1 > 0 && si.center_frq2 > 0) {
|
||||
if (!wpa_dbus_dict_append_int32(&iter_dict, "center-frq1",
|
||||
si.center_frq1))
|
||||
goto nomem;
|
||||
if (!wpa_dbus_dict_append_int32(&iter_dict, "center-frq2",
|
||||
si.center_frq2))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (si.avg_signal) {
|
||||
if (!wpa_dbus_dict_append_int32(&iter_dict, "avg-rssi",
|
||||
si.avg_signal))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict))
|
||||
goto nomem;
|
||||
if (!dbus_message_iter_close_container(&iter, &variant_iter))
|
||||
"a{sv}", &variant_iter) ||
|
||||
!wpa_dbus_dict_open_write(&variant_iter, &iter_dict) ||
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "rssi",
|
||||
si.current_signal) ||
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "linkspeed",
|
||||
si.current_txrate / 1000) ||
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "noise",
|
||||
si.current_noise) ||
|
||||
!wpa_dbus_dict_append_uint32(&iter_dict, "frequency",
|
||||
si.frequency) ||
|
||||
(si.chanwidth != CHAN_WIDTH_UNKNOWN &&
|
||||
!wpa_dbus_dict_append_string(
|
||||
&iter_dict, "width",
|
||||
channel_width_to_string(si.chanwidth))) ||
|
||||
(si.center_frq1 > 0 && si.center_frq2 > 0 &&
|
||||
(!wpa_dbus_dict_append_int32(&iter_dict, "center-frq1",
|
||||
si.center_frq1) ||
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "center-frq2",
|
||||
si.center_frq2))) ||
|
||||
(si.avg_signal &&
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "avg-rssi",
|
||||
si.avg_signal)) ||
|
||||
!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
|
||||
!dbus_message_iter_close_container(&iter, &variant_iter))
|
||||
goto nomem;
|
||||
|
||||
return reply;
|
||||
|
@ -2375,10 +2335,8 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
const char *scans[] = { "active", "passive", "ssid" };
|
||||
|
||||
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))
|
||||
"a{sv}", &variant_iter) ||
|
||||
!wpa_dbus_dict_open_write(&variant_iter, &iter_dict))
|
||||
goto nomem;
|
||||
|
||||
res = wpa_drv_get_capa(wpa_s, &capa);
|
||||
|
@ -2394,46 +2352,26 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Pairwise",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto nomem;
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP_256) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ccmp-256"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP_256) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "gcmp-256"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ccmp"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "gcmp"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "tkip"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "none"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_array) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP_256) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ccmp-256")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_GCMP_256) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "gcmp-256")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ccmp")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "gcmp")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "tkip")) ||
|
||||
((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "none")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -2453,52 +2391,29 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Group",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto nomem;
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP_256) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ccmp-256"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP_256) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "gcmp-256"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ccmp"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "gcmp"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "tkip"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_WEP104) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wep104"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_WEP40) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wep40"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_array) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP_256) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ccmp-256")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_GCMP_256) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "gcmp-256")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ccmp")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "gcmp")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "tkip")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_WEP104) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wep104")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_WEP40) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wep40")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -2522,26 +2437,20 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "KeyMgmt",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
"none"))
|
||||
goto nomem;
|
||||
|
||||
if (!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
&iter_array) ||
|
||||
!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
"none") ||
|
||||
!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
"ieee8021x"))
|
||||
goto nomem;
|
||||
|
||||
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa-eap"))
|
||||
goto nomem;
|
||||
|
||||
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_FT)
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa-ft-eap"))
|
||||
&iter_array, "wpa-eap") ||
|
||||
((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_FT) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa-ft-eap")))
|
||||
goto nomem;
|
||||
|
||||
/* TODO: Ensure that driver actually supports sha256 encryption. */
|
||||
|
@ -2555,12 +2464,11 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa-psk"))
|
||||
goto nomem;
|
||||
|
||||
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK)
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa-ft-psk"))
|
||||
&iter_array, "wpa-psk") ||
|
||||
((capa.key_mgmt &
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa-ft-psk")))
|
||||
goto nomem;
|
||||
|
||||
/* TODO: Ensure that driver actually supports sha256 encryption. */
|
||||
|
@ -2571,11 +2479,10 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
#endif /* CONFIG_IEEE80211W */
|
||||
}
|
||||
|
||||
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa-none"))
|
||||
if ((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) &&
|
||||
!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
"wpa-none"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS
|
||||
|
@ -2602,24 +2509,16 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Protocol",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto nomem;
|
||||
|
||||
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "rsn"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_array) ||
|
||||
((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "rsn")) ||
|
||||
((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK)) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "wpa")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -2640,25 +2539,16 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
&iter_array))
|
||||
goto nomem;
|
||||
|
||||
if (capa.auth & (WPA_DRIVER_AUTH_OPEN)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "open"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.auth & (WPA_DRIVER_AUTH_SHARED)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "shared"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (capa.auth & (WPA_DRIVER_AUTH_LEAP)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "leap"))
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
if (((capa.auth & WPA_DRIVER_AUTH_OPEN) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "open")) ||
|
||||
((capa.auth & WPA_DRIVER_AUTH_SHARED) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "shared")) ||
|
||||
((capa.auth & WPA_DRIVER_AUTH_LEAP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "leap")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -2674,32 +2564,18 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Modes",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto nomem;
|
||||
|
||||
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_array) ||
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "infrastructure") ||
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ad-hoc") ||
|
||||
(res >= 0 && (capa.flags & WPA_DRIVER_FLAGS_AP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "ap")) ||
|
||||
(res >= 0 && (capa.flags & WPA_DRIVER_FLAGS_P2P_CAPABLE) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "p2p")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -2714,9 +2590,8 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
|
|||
goto nomem;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict))
|
||||
goto nomem;
|
||||
if (!dbus_message_iter_close_container(iter, &variant_iter))
|
||||
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
|
||||
!dbus_message_iter_close_container(iter, &variant_iter))
|
||||
goto nomem;
|
||||
|
||||
return TRUE;
|
||||
|
@ -3845,9 +3720,8 @@ static dbus_bool_t wpas_dbus_get_bss_security_prop(DBusMessageIter *iter,
|
|||
goto nomem;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict))
|
||||
goto nomem;
|
||||
if (!dbus_message_iter_close_container(iter, &variant_iter))
|
||||
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
|
||||
!dbus_message_iter_close_container(iter, &variant_iter))
|
||||
goto nomem;
|
||||
|
||||
return TRUE;
|
||||
|
@ -3881,13 +3755,11 @@ dbus_bool_t wpas_dbus_getter_bss_wpa(DBusMessageIter *iter, DBusError *error,
|
|||
|
||||
os_memset(&wpa_data, 0, sizeof(wpa_data));
|
||||
ie = wpa_bss_get_vendor_ie(res, WPA_IE_VENDOR_TYPE);
|
||||
if (ie) {
|
||||
if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
|
||||
if (ie && 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;
|
||||
}
|
||||
}
|
||||
|
||||
return wpas_dbus_get_bss_security_prop(iter, &wpa_data, error);
|
||||
}
|
||||
|
@ -3916,13 +3788,11 @@ dbus_bool_t wpas_dbus_getter_bss_rsn(DBusMessageIter *iter, DBusError *error,
|
|||
|
||||
os_memset(&wpa_data, 0, sizeof(wpa_data));
|
||||
ie = wpa_bss_get_ie(res, WLAN_EID_RSN);
|
||||
if (ie) {
|
||||
if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
|
||||
if (ie && 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;
|
||||
}
|
||||
}
|
||||
|
||||
return wpas_dbus_get_bss_security_prop(iter, &wpa_data, error);
|
||||
}
|
||||
|
@ -3953,10 +3823,8 @@ dbus_bool_t wpas_dbus_getter_bss_wps(DBusMessageIter *iter, DBusError *error,
|
|||
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))
|
||||
"a{sv}", &variant_iter) ||
|
||||
!wpa_dbus_dict_open_write(&variant_iter, &iter_dict))
|
||||
goto nomem;
|
||||
|
||||
#ifdef CONFIG_WPS
|
||||
|
@ -3971,12 +3839,9 @@ dbus_bool_t wpas_dbus_getter_bss_wps(DBusMessageIter *iter, DBusError *error,
|
|||
}
|
||||
#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))
|
||||
if (!wpa_dbus_dict_append_string(&iter_dict, "Type", type) ||
|
||||
!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
|
||||
!dbus_message_iter_close_container(iter, &variant_iter))
|
||||
goto nomem;
|
||||
|
||||
return TRUE;
|
||||
|
@ -4279,28 +4144,22 @@ void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s,
|
|||
|
||||
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",
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
(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",
|
||||
ETH_ALEN)) ||
|
||||
(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",
|
||||
ETH_ALEN)) ||
|
||||
(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",
|
||||
ETH_ALEN)) ||
|
||||
(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))
|
||||
ie_len)) ||
|
||||
(ssi_signal && !wpa_dbus_dict_append_int32(&dict_iter, "signal",
|
||||
ssi_signal)) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
||||
goto fail;
|
||||
|
||||
dbus_connection_send(priv->con, msg, NULL);
|
||||
|
|
|
@ -809,75 +809,37 @@ dbus_bool_t wpas_dbus_getter_p2p_device_config(DBusMessageIter *iter,
|
|||
wpa_s->conf->wps_vendor_ext[i];
|
||||
}
|
||||
|
||||
if (num_vendor_extensions &&
|
||||
if ((num_vendor_extensions &&
|
||||
!wpa_dbus_dict_append_wpabuf_array(&dict_iter,
|
||||
"VendorExtension",
|
||||
vendor_ext,
|
||||
num_vendor_extensions))
|
||||
goto err_no_mem;
|
||||
|
||||
/* GO Intent */
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "GOIntent",
|
||||
wpa_s->conf->p2p_go_intent))
|
||||
goto err_no_mem;
|
||||
|
||||
/* Persistent Reconnect */
|
||||
if (!wpa_dbus_dict_append_bool(&dict_iter, "PersistentReconnect",
|
||||
wpa_s->conf->persistent_reconnect))
|
||||
goto err_no_mem;
|
||||
|
||||
/* Listen Reg Class */
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "ListenRegClass",
|
||||
wpa_s->conf->p2p_listen_reg_class))
|
||||
goto err_no_mem;
|
||||
|
||||
/* Listen Channel */
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "ListenChannel",
|
||||
wpa_s->conf->p2p_listen_channel))
|
||||
goto err_no_mem;
|
||||
|
||||
/* Oper Reg Class */
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "OperRegClass",
|
||||
wpa_s->conf->p2p_oper_reg_class))
|
||||
goto err_no_mem;
|
||||
|
||||
/* Oper Channel */
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "OperChannel",
|
||||
wpa_s->conf->p2p_oper_channel))
|
||||
goto err_no_mem;
|
||||
|
||||
/* SSID Postfix */
|
||||
if (wpa_s->conf->p2p_ssid_postfix &&
|
||||
num_vendor_extensions)) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "GOIntent",
|
||||
wpa_s->conf->p2p_go_intent) ||
|
||||
!wpa_dbus_dict_append_bool(&dict_iter, "PersistentReconnect",
|
||||
wpa_s->conf->persistent_reconnect) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "ListenRegClass",
|
||||
wpa_s->conf->p2p_listen_reg_class) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "ListenChannel",
|
||||
wpa_s->conf->p2p_listen_channel) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "OperRegClass",
|
||||
wpa_s->conf->p2p_oper_reg_class) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "OperChannel",
|
||||
wpa_s->conf->p2p_oper_channel) ||
|
||||
(wpa_s->conf->p2p_ssid_postfix &&
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "SsidPostfix",
|
||||
wpa_s->conf->p2p_ssid_postfix))
|
||||
goto err_no_mem;
|
||||
|
||||
/* Intra Bss */
|
||||
if (!wpa_dbus_dict_append_bool(&dict_iter, "IntraBss",
|
||||
wpa_s->conf->p2p_intra_bss))
|
||||
goto err_no_mem;
|
||||
|
||||
/* Group Idle */
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "GroupIdle",
|
||||
wpa_s->conf->p2p_group_idle))
|
||||
goto err_no_mem;
|
||||
|
||||
/* Dissasociation low ack */
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "disassoc_low_ack",
|
||||
wpa_s->conf->disassoc_low_ack))
|
||||
goto err_no_mem;
|
||||
|
||||
/* No Group Iface */
|
||||
if (!wpa_dbus_dict_append_bool(&dict_iter, "NoGroupIface",
|
||||
wpa_s->conf->p2p_no_group_iface))
|
||||
goto err_no_mem;
|
||||
|
||||
/* P2P Search Delay */
|
||||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "p2p_search_delay",
|
||||
wpa_s->conf->p2p_search_delay))
|
||||
goto err_no_mem;
|
||||
|
||||
if (!wpa_dbus_dict_close_write(&variant_iter, &dict_iter) ||
|
||||
wpa_s->conf->p2p_ssid_postfix)) ||
|
||||
!wpa_dbus_dict_append_bool(&dict_iter, "IntraBss",
|
||||
wpa_s->conf->p2p_intra_bss) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "GroupIdle",
|
||||
wpa_s->conf->p2p_group_idle) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "disassoc_low_ack",
|
||||
wpa_s->conf->disassoc_low_ack) ||
|
||||
!wpa_dbus_dict_append_bool(&dict_iter, "NoGroupIface",
|
||||
wpa_s->conf->p2p_no_group_iface) ||
|
||||
!wpa_dbus_dict_append_uint32(&dict_iter, "p2p_search_delay",
|
||||
wpa_s->conf->p2p_search_delay) ||
|
||||
!wpa_dbus_dict_close_write(&variant_iter, &dict_iter) ||
|
||||
!dbus_message_iter_close_container(iter, &variant_iter))
|
||||
goto err_no_mem;
|
||||
|
||||
|
@ -1413,8 +1375,7 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_secondary_device_types(
|
|||
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
||||
peer_args->p2p_device_addr, 0);
|
||||
if (info == NULL) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"failed to find peer");
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED, "failed to find peer");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1422,18 +1383,13 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_secondary_device_types(
|
|||
DBUS_TYPE_ARRAY_AS_STRING
|
||||
DBUS_TYPE_ARRAY_AS_STRING
|
||||
DBUS_TYPE_BYTE_AS_STRING,
|
||||
&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,
|
||||
&variant_iter) ||
|
||||
!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
|
||||
DBUS_TYPE_ARRAY_AS_STRING
|
||||
DBUS_TYPE_BYTE_AS_STRING,
|
||||
&array_iter)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: failed to construct message 2", __func__);
|
||||
"%s: failed to construct message 1", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1448,29 +1404,14 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_secondary_device_types(
|
|||
if (!dbus_message_iter_open_container(
|
||||
&array_iter, DBUS_TYPE_ARRAY,
|
||||
DBUS_TYPE_BYTE_AS_STRING,
|
||||
&inner_array_iter)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: failed to construct "
|
||||
"message 3 (%d)",
|
||||
__func__, i);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_append_fixed_array(
|
||||
&inner_array_iter) ||
|
||||
!dbus_message_iter_append_fixed_array(
|
||||
&inner_array_iter, DBUS_TYPE_BYTE,
|
||||
&sec_dev_type_list, WPS_DEV_TYPE_LEN)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: failed to construct "
|
||||
"message 4 (%d)",
|
||||
__func__, i);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_close_container(
|
||||
&sec_dev_type_list, WPS_DEV_TYPE_LEN) ||
|
||||
!dbus_message_iter_close_container(
|
||||
&array_iter, &inner_array_iter)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: failed to construct "
|
||||
"message 5 (%d)",
|
||||
"%s: failed to construct message 2 (%d)",
|
||||
__func__, i);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1479,15 +1420,10 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_secondary_device_types(
|
|||
}
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {
|
||||
if (!dbus_message_iter_close_container(&variant_iter, &array_iter) ||
|
||||
!dbus_message_iter_close_container(iter, &variant_iter)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: failed to construct message 6", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_close_container(iter, &variant_iter)) {
|
||||
dbus_set_error(error, DBUS_ERROR_FAILED,
|
||||
"%s: failed to construct message 7", __func__);
|
||||
"%s: failed to construct message 3", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -311,22 +311,10 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
|
|||
}
|
||||
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) {
|
||||
dbus_message_unref(reply);
|
||||
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (os_strlen(npin) > 0) {
|
||||
if (!wpa_dbus_dict_append_string(&dict_iter, "Pin", npin)) {
|
||||
dbus_message_unref(reply);
|
||||
return dbus_message_new_error(message,
|
||||
DBUS_ERROR_NO_MEMORY,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_close_write(&iter, &dict_iter)) {
|
||||
if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
||||
(os_strlen(npin) > 0 &&
|
||||
!wpa_dbus_dict_append_string(&dict_iter, "Pin", npin)) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &dict_iter)) {
|
||||
dbus_message_unref(reply);
|
||||
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
||||
NULL);
|
||||
|
|
|
@ -630,10 +630,8 @@ static dbus_bool_t put_changed_properties(
|
|||
|
||||
if (!dbus_message_iter_open_container(dict_iter,
|
||||
DBUS_TYPE_DICT_ENTRY,
|
||||
NULL, &entry_iter))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_append_basic(&entry_iter,
|
||||
NULL, &entry_iter) ||
|
||||
!dbus_message_iter_append_basic(&entry_iter,
|
||||
DBUS_TYPE_STRING,
|
||||
&dsc->dbus_property))
|
||||
return FALSE;
|
||||
|
@ -677,26 +675,16 @@ static void do_send_prop_changed_signal(
|
|||
dbus_message_iter_init_append(msg, &signal_iter);
|
||||
|
||||
if (!dbus_message_iter_append_basic(&signal_iter, DBUS_TYPE_STRING,
|
||||
&interface))
|
||||
goto err;
|
||||
|
||||
&interface) ||
|
||||
/* Changed properties dict */
|
||||
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||
"{sv}", &dict_iter))
|
||||
goto err;
|
||||
|
||||
if (!put_changed_properties(obj_dsc, interface, &dict_iter, 0))
|
||||
goto err;
|
||||
|
||||
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||
goto err;
|
||||
|
||||
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||
"{sv}", &dict_iter) ||
|
||||
!put_changed_properties(obj_dsc, interface, &dict_iter, 0) ||
|
||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter) ||
|
||||
/* Invalidated properties array (empty) */
|
||||
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||
"s", &dict_iter))
|
||||
goto err;
|
||||
|
||||
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||
"s", &dict_iter) ||
|
||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||
goto err;
|
||||
|
||||
dbus_connection_send(con, msg, NULL);
|
||||
|
@ -726,13 +714,9 @@ static void do_send_deprecated_prop_changed_signal(
|
|||
dbus_message_iter_init_append(msg, &signal_iter);
|
||||
|
||||
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||
"{sv}", &dict_iter))
|
||||
goto err;
|
||||
|
||||
if (!put_changed_properties(obj_dsc, interface, &dict_iter, 1))
|
||||
goto err;
|
||||
|
||||
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||
"{sv}", &dict_iter) ||
|
||||
!put_changed_properties(obj_dsc, interface, &dict_iter, 1) ||
|
||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||
goto err;
|
||||
|
||||
dbus_connection_send(con, msg, NULL);
|
||||
|
|
|
@ -409,84 +409,56 @@ DBusMessage * wpas_dbus_bssid_properties(DBusMessage *message,
|
|||
{
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter, iter_dict;
|
||||
const u8 *ie;
|
||||
const u8 *wpa_ie, *rsn_ie, *wps_ie;
|
||||
|
||||
/* Dump the properties into a dbus message */
|
||||
reply = dbus_message_new_method_return(message);
|
||||
|
||||
wpa_ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
|
||||
rsn_ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
|
||||
wps_ie = wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE);
|
||||
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
if (!wpa_dbus_dict_open_write(&iter, &iter_dict))
|
||||
goto error;
|
||||
|
||||
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "bssid",
|
||||
if (!wpa_dbus_dict_open_write(&iter, &iter_dict) ||
|
||||
!wpa_dbus_dict_append_byte_array(&iter_dict, "bssid",
|
||||
(const char *) bss->bssid,
|
||||
ETH_ALEN))
|
||||
goto error;
|
||||
|
||||
ie = wpa_bss_get_ie(bss, WLAN_EID_SSID);
|
||||
if (ie) {
|
||||
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "ssid",
|
||||
(const char *) (ie + 2),
|
||||
ie[1]))
|
||||
goto error;
|
||||
}
|
||||
|
||||
ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
|
||||
if (ie) {
|
||||
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "wpaie",
|
||||
(const char *) ie,
|
||||
ie[1] + 2))
|
||||
goto error;
|
||||
}
|
||||
|
||||
ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
|
||||
if (ie) {
|
||||
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "rsnie",
|
||||
(const char *) ie,
|
||||
ie[1] + 2))
|
||||
goto error;
|
||||
}
|
||||
|
||||
ie = wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE);
|
||||
if (ie) {
|
||||
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "wpsie",
|
||||
(const char *) ie,
|
||||
ie[1] + 2))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (bss->freq) {
|
||||
if (!wpa_dbus_dict_append_int32(&iter_dict, "frequency",
|
||||
bss->freq))
|
||||
goto error;
|
||||
}
|
||||
if (!wpa_dbus_dict_append_uint16(&iter_dict, "capabilities",
|
||||
bss->caps))
|
||||
goto error;
|
||||
if (!(bss->flags & WPA_BSS_QUAL_INVALID) &&
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "quality", bss->qual))
|
||||
goto error;
|
||||
if (!(bss->flags & WPA_BSS_NOISE_INVALID) &&
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "noise", bss->noise))
|
||||
goto error;
|
||||
if (!(bss->flags & WPA_BSS_LEVEL_INVALID) &&
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "level", bss->level))
|
||||
goto error;
|
||||
if (!wpa_dbus_dict_append_int32(&iter_dict, "maxrate",
|
||||
wpa_bss_get_max_rate(bss) * 500000))
|
||||
goto error;
|
||||
|
||||
if (!wpa_dbus_dict_close_write(&iter, &iter_dict))
|
||||
goto error;
|
||||
|
||||
return reply;
|
||||
|
||||
error:
|
||||
ETH_ALEN) ||
|
||||
!wpa_dbus_dict_append_byte_array(&iter_dict, "ssid",
|
||||
(const char *) bss->ssid,
|
||||
bss->ssid_len) ||
|
||||
(wpa_ie &&
|
||||
!wpa_dbus_dict_append_byte_array(&iter_dict, "wpaie",
|
||||
(const char *) wpa_ie,
|
||||
wpa_ie[1] + 2)) ||
|
||||
(rsn_ie &&
|
||||
!wpa_dbus_dict_append_byte_array(&iter_dict, "rsnie",
|
||||
(const char *) rsn_ie,
|
||||
rsn_ie[1] + 2)) ||
|
||||
(wps_ie &&
|
||||
!wpa_dbus_dict_append_byte_array(&iter_dict, "wpsie",
|
||||
(const char *) wps_ie,
|
||||
wps_ie[1] + 2)) ||
|
||||
(bss->freq &&
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "frequency", bss->freq)) ||
|
||||
!wpa_dbus_dict_append_uint16(&iter_dict, "capabilities",
|
||||
bss->caps) ||
|
||||
(!(bss->flags & WPA_BSS_QUAL_INVALID) &&
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "quality", bss->qual)) ||
|
||||
(!(bss->flags & WPA_BSS_NOISE_INVALID) &&
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "noise", bss->noise)) ||
|
||||
(!(bss->flags & WPA_BSS_LEVEL_INVALID) &&
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "level", bss->level)) ||
|
||||
!wpa_dbus_dict_append_int32(&iter_dict, "maxrate",
|
||||
wpa_bss_get_max_rate(bss) * 500000) ||
|
||||
!wpa_dbus_dict_close_write(&iter, &iter_dict)) {
|
||||
if (reply)
|
||||
dbus_message_unref(reply);
|
||||
return dbus_message_new_error(message, WPAS_ERROR_INTERNAL_ERROR,
|
||||
"an internal error occurred returning "
|
||||
"BSSID properties.");
|
||||
reply = dbus_message_new_error(
|
||||
message, WPAS_ERROR_INTERNAL_ERROR,
|
||||
"an internal error occurred returning BSSID properties.");
|
||||
}
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
||||
|
@ -555,28 +527,17 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "pairwise",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto error;
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "CCMP"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "TKIP"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "NONE"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_array) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "CCMP")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "TKIP")) ||
|
||||
((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "NONE")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -601,31 +562,19 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
|
|||
&iter_array))
|
||||
goto error;
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "CCMP"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "TKIP"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_WEP104) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WEP104"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.enc & WPA_DRIVER_CAPA_ENC_WEP40) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WEP40"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
if (((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "CCMP")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "TKIP")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_WEP104) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WEP104")) ||
|
||||
((capa.enc & WPA_DRIVER_CAPA_ENC_WEP40) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WEP40")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -648,38 +597,23 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "key_mgmt",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto error;
|
||||
|
||||
if (!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
"NONE"))
|
||||
goto error;
|
||||
|
||||
if (!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
"IEEE8021X"))
|
||||
goto error;
|
||||
|
||||
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WPA-EAP"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WPA-PSK"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WPA-NONE"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_array) ||
|
||||
!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
"NONE") ||
|
||||
!wpa_dbus_dict_string_array_add_element(&iter_array,
|
||||
"IEEE8021X") ||
|
||||
((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2)) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WPA-EAP")) ||
|
||||
((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WPA-PSK")) ||
|
||||
((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WPA-NONE")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -699,24 +633,16 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "proto",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto error;
|
||||
|
||||
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "RSN"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WPA"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_array) ||
|
||||
((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "RSN")) ||
|
||||
((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK)) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "WPA")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
@ -736,28 +662,17 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
|
|||
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "auth_alg",
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
goto error;
|
||||
|
||||
if (capa.auth & (WPA_DRIVER_AUTH_OPEN)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "OPEN"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.auth & (WPA_DRIVER_AUTH_SHARED)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "SHARED"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (capa.auth & (WPA_DRIVER_AUTH_LEAP)) {
|
||||
if (!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "LEAP"))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_array) ||
|
||||
((capa.auth & WPA_DRIVER_AUTH_OPEN) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "OPEN")) ||
|
||||
((capa.auth & WPA_DRIVER_AUTH_SHARED) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "SHARED")) ||
|
||||
((capa.auth & WPA_DRIVER_AUTH_LEAP) &&
|
||||
!wpa_dbus_dict_string_array_add_element(
|
||||
&iter_array, "LEAP")) ||
|
||||
!wpa_dbus_dict_end_string_array(&iter_dict,
|
||||
&iter_dict_entry,
|
||||
&iter_dict_val,
|
||||
&iter_array))
|
||||
|
|
Loading…
Reference in a new issue