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:
Jouni Malinen 2014-12-31 13:57:48 +02:00
parent bba40b65b0
commit e3c4f0b5d5
8 changed files with 520 additions and 1027 deletions

View file

@ -345,26 +345,14 @@ struct wpas_dbus_priv * wpas_dbus_init(struct wpa_global *global)
return NULL; return NULL;
priv->global = global; priv->global = global;
if (wpas_dbus_init_common(priv) < 0) { if (wpas_dbus_init_common(priv) < 0 ||
wpas_dbus_deinit(priv);
return NULL;
}
#ifdef CONFIG_CTRL_IFACE_DBUS_NEW #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
if (wpas_dbus_ctrl_iface_init(priv) < 0) { wpas_dbus_ctrl_iface_init(priv) < 0 ||
wpas_dbus_deinit(priv);
return NULL;
}
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
#ifdef CONFIG_CTRL_IFACE_DBUS #ifdef CONFIG_CTRL_IFACE_DBUS
if (wpa_supplicant_dbus_ctrl_iface_init(priv) < 0) { wpa_supplicant_dbus_ctrl_iface_init(priv) < 0 ||
wpas_dbus_deinit(priv);
return NULL;
}
#endif /* CONFIG_CTRL_IFACE_DBUS */ #endif /* CONFIG_CTRL_IFACE_DBUS */
wpas_dbus_init_common_finish(priv) < 0) {
if (wpas_dbus_init_common_finish(priv) < 0) {
wpas_dbus_deinit(priv); wpas_dbus_deinit(priv);
return NULL; return NULL;
} }

View file

@ -106,11 +106,8 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_start(
iter_dict_entry)) iter_dict_entry))
return FALSE; return FALSE;
if (!dbus_message_iter_append_basic(iter_dict_entry, DBUS_TYPE_STRING, return dbus_message_iter_append_basic(iter_dict_entry, DBUS_TYPE_STRING,
&key)) &key);
return FALSE;
return TRUE;
} }
@ -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)) if (!dbus_message_iter_close_container(iter_dict_entry, iter_dict_val))
return FALSE; 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; return FALSE;
if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry, if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry,
key, value_type)) key, value_type) ||
return FALSE; !dbus_message_iter_open_container(&iter_dict_entry,
if (!dbus_message_iter_open_container(&iter_dict_entry,
DBUS_TYPE_VARIANT, 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; return FALSE;
if (!dbus_message_iter_append_basic(&iter_dict_val, value_type, value)) return _wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
return FALSE; &iter_dict_val);
if (!_wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
&iter_dict_val))
return FALSE;
return TRUE;
} }
@ -170,17 +158,13 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_byte_array(
dbus_uint32_t i; dbus_uint32_t i;
if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry, if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry,
key, DBUS_TYPE_ARRAY)) key, DBUS_TYPE_ARRAY) ||
return FALSE; !dbus_message_iter_open_container(&iter_dict_entry,
if (!dbus_message_iter_open_container(&iter_dict_entry,
DBUS_TYPE_VARIANT, DBUS_TYPE_VARIANT,
DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_ARRAY_AS_STRING
DBUS_TYPE_BYTE_AS_STRING, DBUS_TYPE_BYTE_AS_STRING,
&iter_dict_val)) &iter_dict_val) ||
return FALSE; !dbus_message_iter_open_container(&iter_dict_val, DBUS_TYPE_ARRAY,
if (!dbus_message_iter_open_container(&iter_dict_val, DBUS_TYPE_ARRAY,
DBUS_TYPE_BYTE_AS_STRING, DBUS_TYPE_BYTE_AS_STRING,
&iter_array)) &iter_array))
return FALSE; 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)) if (!dbus_message_iter_close_container(&iter_dict_val, &iter_array))
return FALSE; return FALSE;
if (!_wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry, return _wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
&iter_dict_val)) &iter_dict_val);
return FALSE;
return TRUE;
} }
@ -428,9 +409,7 @@ dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict,
const char *value, const char *value,
const dbus_uint32_t value_len) const dbus_uint32_t value_len)
{ {
if (!key) if (!key || (!value && value_len != 0))
return FALSE;
if (!value && (value_len != 0))
return FALSE; return FALSE;
return _wpa_dbus_add_dict_entry_byte_array(iter_dict, key, value, return _wpa_dbus_add_dict_entry_byte_array(iter_dict, key, value,
value_len); 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)) if (os_snprintf_error(sizeof(array_type), err))
return FALSE; return FALSE;
if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array) if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array ||
return FALSE; !_wpa_dbus_add_dict_entry_start(iter_dict, iter_dict_entry,
key, DBUS_TYPE_ARRAY) ||
if (!_wpa_dbus_add_dict_entry_start(iter_dict, iter_dict_entry, !dbus_message_iter_open_container(iter_dict_entry,
key, DBUS_TYPE_ARRAY))
return FALSE;
if (!dbus_message_iter_open_container(iter_dict_entry,
DBUS_TYPE_VARIANT, DBUS_TYPE_VARIANT,
array_type, array_type,
iter_dict_val)) iter_dict_val))
return FALSE; return FALSE;
if (!dbus_message_iter_open_container(iter_dict_val, DBUS_TYPE_ARRAY, return dbus_message_iter_open_container(iter_dict_val, DBUS_TYPE_ARRAY,
type, iter_array)) type, iter_array);
return FALSE;
return TRUE;
} }
@ -542,10 +514,8 @@ dbus_bool_t wpa_dbus_dict_bin_array_add_element(DBusMessageIter *iter_array,
DBusMessageIter iter_bytes; DBusMessageIter iter_bytes;
size_t i; size_t i;
if (!iter_array || !value) if (!iter_array || !value ||
return FALSE; !dbus_message_iter_open_container(iter_array, DBUS_TYPE_ARRAY,
if (!dbus_message_iter_open_container(iter_array, DBUS_TYPE_ARRAY,
DBUS_TYPE_BYTE_AS_STRING, DBUS_TYPE_BYTE_AS_STRING,
&iter_bytes)) &iter_bytes))
return FALSE; return FALSE;
@ -557,10 +527,7 @@ dbus_bool_t wpa_dbus_dict_bin_array_add_element(DBusMessageIter *iter_array,
return FALSE; return FALSE;
} }
if (!dbus_message_iter_close_container(iter_array, &iter_bytes)) return dbus_message_iter_close_container(iter_array, &iter_bytes);
return FALSE;
return TRUE;
} }
@ -586,17 +553,12 @@ dbus_bool_t wpa_dbus_dict_end_array(DBusMessageIter *iter_dict,
DBusMessageIter *iter_dict_val, DBusMessageIter *iter_dict_val,
DBusMessageIter *iter_array) 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; return FALSE;
if (!dbus_message_iter_close_container(iter_dict_val, iter_array)) return _wpa_dbus_add_dict_entry_end(iter_dict, iter_dict_entry,
return FALSE; iter_dict_val);
if (!_wpa_dbus_add_dict_entry_end(iter_dict, iter_dict_entry,
iter_dict_val))
return FALSE;
return TRUE;
} }
@ -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; DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
dbus_uint32_t i; dbus_uint32_t i;
if (!key) if (!key || (!items && num_items != 0) ||
return FALSE; !wpa_dbus_dict_begin_string_array(iter_dict, key,
if (!items && (num_items != 0))
return FALSE;
if (!wpa_dbus_dict_begin_string_array(iter_dict, key,
&iter_dict_entry, &iter_dict_val, &iter_dict_entry, &iter_dict_val,
&iter_array)) &iter_array))
return FALSE; return FALSE;
@ -635,11 +593,8 @@ dbus_bool_t wpa_dbus_dict_append_string_array(DBusMessageIter *iter_dict,
return FALSE; return FALSE;
} }
if (!wpa_dbus_dict_end_string_array(iter_dict, &iter_dict_entry, return wpa_dbus_dict_end_string_array(iter_dict, &iter_dict_entry,
&iter_dict_val, &iter_array)) &iter_dict_val, &iter_array);
return FALSE;
return TRUE;
} }
@ -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; DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
dbus_uint32_t i; dbus_uint32_t i;
if (!key) if (!key ||
return FALSE; (!items && num_items != 0) ||
if (!items && (num_items != 0)) !wpa_dbus_dict_begin_array(iter_dict, key,
return FALSE;
if (!wpa_dbus_dict_begin_array(iter_dict, key,
DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_ARRAY_AS_STRING
DBUS_TYPE_BYTE_AS_STRING, DBUS_TYPE_BYTE_AS_STRING,
&iter_dict_entry, &iter_dict_val, &iter_dict_entry, &iter_dict_val,
@ -681,11 +633,8 @@ dbus_bool_t wpa_dbus_dict_append_wpabuf_array(DBusMessageIter *iter_dict,
return FALSE; return FALSE;
} }
if (!wpa_dbus_dict_end_array(iter_dict, &iter_dict_entry, return wpa_dbus_dict_end_array(iter_dict, &iter_dict_entry,
&iter_dict_val, &iter_array)) &iter_dict_val, &iter_array);
return FALSE;
return TRUE;
} }
@ -1080,10 +1029,8 @@ dbus_bool_t wpa_dbus_dict_get_entry(DBusMessageIter *iter_dict,
int type; int type;
const char *key; const char *key;
if (!iter_dict || !entry) if (!iter_dict || !entry ||
goto error; dbus_message_iter_get_arg_type(iter_dict) != DBUS_TYPE_DICT_ENTRY) {
if (dbus_message_iter_get_arg_type(iter_dict) != DBUS_TYPE_DICT_ENTRY) {
wpa_printf(MSG_DEBUG, "%s: not a dict entry", __func__); wpa_printf(MSG_DEBUG, "%s: not a dict entry", __func__);
goto error; goto error;
} }

View file

@ -148,22 +148,14 @@ static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s,
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&wpa_s->dbus_new_path)) &wpa_s->dbus_new_path) ||
goto err; (properties &&
!wpa_dbus_get_object_properties(
if (properties) {
if (!wpa_dbus_get_object_properties(
iface, wpa_s->dbus_new_path, iface, wpa_s->dbus_new_path,
WPAS_DBUS_NEW_IFACE_INTERFACE, &iter)) WPAS_DBUS_NEW_IFACE_INTERFACE, &iter)))
goto err;
}
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg);
return;
err:
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg); 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 * @wpa_s: %wpa_supplicant network interface data
* @bss_obj_path: BSS object path * @bss_obj_path: BSS object path
* @sig_name: signal name - BSSAdded or BSSRemoved * @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); dbus_message_iter_init_append(msg, &iter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&bss_obj_path)) &bss_obj_path) ||
goto err; (properties &&
!wpa_dbus_get_object_properties(iface, bss_obj_path,
if (properties) {
if (!wpa_dbus_get_object_properties(iface, bss_obj_path,
WPAS_DBUS_NEW_IFACE_BSS, WPAS_DBUS_NEW_IFACE_BSS,
&iter)) &iter)))
goto err;
}
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg);
return;
err:
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg); 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); dbus_message_iter_init_append(msg, &iter);
path = net_obj_path; path = net_obj_path;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&path)) &path) ||
goto err; (properties &&
!wpa_dbus_get_object_properties(
if (properties) {
if (!wpa_dbus_get_object_properties(
iface, net_obj_path, WPAS_DBUS_NEW_IFACE_NETWORK, iface, net_obj_path, WPAS_DBUS_NEW_IFACE_NETWORK,
&iter)) &iter)))
goto err;
}
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg);
return;
err:
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg); 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); dbus_message_iter_init_append(msg, &iter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&net_ptr)) &net_ptr) ||
goto err; !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field) ||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field)) !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &txt))
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:
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg); 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) if (cred->encr_type & WPS_ENCR_AES)
encr_type[et_num++] = "aes"; encr_type[et_num++] = "aes";
if (wpa_s->current_ssid) { if ((wpa_s->current_ssid &&
if (!wpa_dbus_dict_append_byte_array( !wpa_dbus_dict_append_byte_array(
&dict_iter, "BSSID", &dict_iter, "BSSID",
(const char *) wpa_s->current_ssid->bssid, (const char *) wpa_s->current_ssid->bssid, ETH_ALEN)) ||
ETH_ALEN)) !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
goto nomem;
}
if (!wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
(const char *) cred->ssid, (const char *) cred->ssid,
cred->ssid_len) || cred->ssid_len) ||
!wpa_dbus_dict_append_string_array(&dict_iter, "AuthType", !wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
@ -804,29 +768,20 @@ void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
return; return;
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
goto nomem; !wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
!wpa_dbus_dict_append_string(&dict_iter, "subject", subject) ||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) || (cert_hash &&
!wpa_dbus_dict_append_string(&dict_iter, "subject", subject)) !wpa_dbus_dict_append_string(&dict_iter, "cert_hash",
goto nomem; cert_hash)) ||
(cert &&
if (cert_hash &&
!wpa_dbus_dict_append_string(&dict_iter, "cert_hash", cert_hash))
goto nomem;
if (cert &&
!wpa_dbus_dict_append_byte_array(&dict_iter, "cert", !wpa_dbus_dict_append_byte_array(&dict_iter, "cert",
wpabuf_head(cert), wpabuf_head(cert),
wpabuf_len(cert))) wpabuf_len(cert))) ||
goto nomem; !wpa_dbus_dict_close_write(&iter, &dict_iter))
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
if (!wpa_dbus_dict_close_write(&iter, &dict_iter)) else
goto nomem;
dbus_connection_send(iface->con, msg, NULL); dbus_connection_send(iface->con, msg, NULL);
nomem:
dbus_message_unref(msg); 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); 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, !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
&parameter)) &parameter))
goto nomem; wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL); dbus_connection_send(iface->con, msg, NULL);
nomem:
dbus_message_unref(msg); 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, void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
const char *role) const char *role)
{ {
int error = 1;
DBusMessage *msg; DBusMessage *msg;
DBusMessageIter iter, dict_iter; DBusMessageIter iter, dict_iter;
struct wpas_dbus_priv *iface = wpa_s->global->dbus; 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; return;
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
goto nomem; !wpa_dbus_dict_append_object_path(&dict_iter,
if (!wpa_dbus_dict_append_object_path(&dict_iter,
"interface_object", "interface_object",
wpa_s->dbus_new_path)) wpa_s->dbus_new_path) ||
goto nomem; !wpa_dbus_dict_append_string(&dict_iter, "role", role) ||
!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
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_groupobj_path) || wpa_s->dbus_groupobj_path) ||
!wpa_dbus_dict_close_write(&iter, &dict_iter)) !wpa_dbus_dict_close_write(&iter, &dict_iter))
goto nomem; wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
error = 0;
dbus_connection_send(iface->con, msg, NULL); dbus_connection_send(iface->con, msg, NULL);
nomem:
if (error > 0)
wpa_printf(MSG_ERROR,
"dbus: Failed to construct GroupFinished");
dbus_message_unref(msg); dbus_message_unref(msg);
} }
@ -1280,34 +1218,26 @@ void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
return; return;
dbus_message_iter_init_append(msg, &iter); 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 * In case the device supports creating a separate interface the
* DBus client will need to know the object path for the interface * DBus client will need to know the object path for the interface
* object this group was created on, so include it here. * 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", "interface_object",
wpa_s->dbus_new_path)) wpa_s->dbus_new_path) ||
goto nomem; !wpa_dbus_dict_append_string(&dict_iter, "role",
client ? "client" : "GO") ||
if (!wpa_dbus_dict_append_string(&dict_iter, "role", !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
client ? "client" : "GO"))
goto nomem;
if (!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
wpa_s->dbus_groupobj_path) || wpa_s->dbus_groupobj_path) ||
!wpa_dbus_dict_close_write(&iter, &dict_iter)) !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
goto nomem; wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
} else {
dbus_connection_send(iface->con, msg, NULL); dbus_connection_send(iface->con, msg, NULL);
if (client) if (client)
peer_groups_changed(wpa_s); peer_groups_changed(wpa_s);
}
nomem:
dbus_message_unref(msg); dbus_message_unref(msg);
} }
@ -1353,9 +1283,8 @@ void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
return; return;
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
goto err; !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
path) || path) ||
!wpa_dbus_dict_append_int32(&dict_iter, "status", res->status)) !wpa_dbus_dict_append_int32(&dict_iter, "status", res->status))
goto err; goto err;
@ -1364,12 +1293,10 @@ void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
int i = 0; int i = 0;
int freq_list_num = 0; int freq_list_num = 0;
if (res->role_go && if ((res->role_go &&
!wpa_dbus_dict_append_string(&dict_iter, "passphrase", !wpa_dbus_dict_append_string(&dict_iter, "passphrase",
res->passphrase)) res->passphrase)) ||
goto err; !wpa_dbus_dict_append_string(&dict_iter, "role_go",
if (!wpa_dbus_dict_append_string(&dict_iter, "role_go",
res->role_go ? "GO" : res->role_go ? "GO" :
"client") || "client") ||
!wpa_dbus_dict_append_int32(&dict_iter, "frequency", !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, DBUS_TYPE_INT32_AS_STRING,
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_dict_array)) &iter_dict_array) ||
goto err; !dbus_message_iter_append_fixed_array(&iter_dict_array,
if (!dbus_message_iter_append_fixed_array(&iter_dict_array,
DBUS_TYPE_INT32, DBUS_TYPE_INT32,
&f_array, &f_array,
freq_list_num)) freq_list_num) ||
goto err; !wpa_dbus_dict_end_array(&dict_iter,
if (!wpa_dbus_dict_end_array(&dict_iter,
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_dict_array)) &iter_dict_array) ||
goto err; !wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
if (!wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
res->persistent_group) || res->persistent_group) ||
!wpa_dbus_dict_append_uint32(&dict_iter, !wpa_dbus_dict_append_uint32(&dict_iter,
"peer_config_timeout", "peer_config_timeout",
@ -1469,23 +1390,16 @@ void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
return; return;
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
goto nomem; !wpa_dbus_dict_append_int32(&dict_iter, "status", status) ||
(bssid &&
if (!wpa_dbus_dict_append_int32(&dict_iter, "status", status)) !wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
goto nomem;
if (bssid) {
if (!wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
(const char *) bssid, (const char *) bssid,
ETH_ALEN)) ETH_ALEN)) ||
goto nomem; !wpa_dbus_dict_close_write(&iter, &dict_iter))
} wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
if (!wpa_dbus_dict_close_write(&iter, &dict_iter)) else
goto nomem;
dbus_connection_send(iface->con, msg, NULL); dbus_connection_send(iface->con, msg, NULL);
nomem:
dbus_message_unref(msg); 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); dbus_message_iter_init_append(msg, &iter);
path = peer_obj_path; path = peer_obj_path;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&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:
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); 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); 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); dbus_message_iter_init_append(msg, &iter);
path = peer_obj_path; path = peer_obj_path;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&path)) &path)) {
goto err; wpa_printf(MSG_ERROR,
"dbus: Failed to construct PeerDisconnected signal");
} else {
dbus_connection_send(iface->con, msg, NULL); dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg);
wpas_dbus_signal_peer_groups_changed(parent, peer_addr); 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); 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) if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent; 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, msg = dbus_message_new_signal(wpa_s->dbus_new_path,
WPAS_DBUS_NEW_IFACE_P2PDEVICE, WPAS_DBUS_NEW_IFACE_P2PDEVICE,
"ServiceDiscoveryRequest"); "ServiceDiscoveryRequest");
if (msg == NULL) if (msg == NULL)
return; 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, os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa)); 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; path = peer_obj_path;
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
goto error; !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
path) || path) ||
!wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) || !wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
!wpa_dbus_dict_append_int32(&dict_iter, "dialog_token", !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, (const char *) tlvs,
tlvs_len) || tlvs_len) ||
!wpa_dbus_dict_close_write(&iter, &dict_iter)) !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"); wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg); 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) if (wpa_s->p2p_mgmt)
wpa_s = wpa_s->parent; 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, msg = dbus_message_new_signal(wpa_s->dbus_new_path,
WPAS_DBUS_NEW_IFACE_P2PDEVICE, WPAS_DBUS_NEW_IFACE_P2PDEVICE,
"ServiceDiscoveryResponse"); "ServiceDiscoveryResponse");
if (msg == NULL) if (msg == NULL)
return; 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, os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa)); 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; path = peer_obj_path;
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
goto error; !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
path) || path) ||
!wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator", !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
update_indic) || update_indic) ||
@ -1744,17 +1637,13 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
(const char *) tlvs, (const char *) tlvs,
tlvs_len) || tlvs_len) ||
!wpa_dbus_dict_close_write(&iter, &dict_iter)) !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_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg); 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 * wpas_dbus_signal_persistent_group - Send a persistent group related
* event signal * 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); dbus_message_iter_init_append(msg, &iter);
path = pgrp_obj_path; path = pgrp_obj_path;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&path)) &path) ||
goto err; (properties &&
!wpa_dbus_get_object_properties(
if (properties) {
if (!wpa_dbus_get_object_properties(
iface, pgrp_obj_path, iface, pgrp_obj_path,
WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter)) WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter)))
goto err; wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
} else
dbus_connection_send(iface->con, msg, NULL); dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg); 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; path = peer_obj_path;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&path)) &path))
goto err; wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL); dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg); dbus_message_unref(msg);
return;
err:
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
dbus_message_unref(msg);
} }

View file

@ -308,23 +308,17 @@ dbus_bool_t wpas_dbus_simple_property_getter(DBusMessageIter *iter,
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
wpa_dbus_type_as_string(type), wpa_dbus_type_as_string(type),
&variant_iter)) &variant_iter) ||
goto error; !dbus_message_iter_append_basic(&variant_iter, type, val) ||
!dbus_message_iter_close_container(iter, &variant_iter)) {
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:
dbus_set_error(error, DBUS_ERROR_FAILED, dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: error constructing reply", __func__); "%s: error constructing reply", __func__);
return FALSE; return FALSE;
} }
return TRUE;
}
/** /**
* wpas_dbus_simple_property_setter - Set basic type property * 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]; type_str[1] = sub_type_str[0];
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
type_str, &variant_iter)) { type_str, &variant_iter) ||
dbus_set_error(error, DBUS_ERROR_FAILED, !dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
"%s: failed to construct message 1", __func__);
return FALSE;
}
if (!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
sub_type_str, &array_iter)) { sub_type_str, &array_iter)) {
dbus_set_error(error, DBUS_ERROR_FAILED, dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: failed to construct message 2", __func__); "%s: failed to construct message", __func__);
return FALSE; 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, dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: failed to construct message 3", __func__); "%s: failed to construct message 3", __func__);
return FALSE; 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; 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]; inner_type_str[1] = sub_type_str[0];
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
type_str, &variant_iter)) { type_str, &variant_iter) ||
dbus_set_error(error, DBUS_ERROR_FAILED, !dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
"%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)) { inner_type_str, &array_iter)) {
dbus_set_error(error, DBUS_ERROR_FAILED, dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: failed to construct message 2", __func__); "%s: failed to construct message", __func__);
return FALSE; 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, dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: failed to close message 2", __func__); "%s: failed to close message", __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 FALSE;
} }
@ -1429,45 +1404,30 @@ DBusMessage * wpas_dbus_handler_signal_poll(DBusMessage *message,
dbus_message_iter_init_append(reply, &iter); 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,
"a{sv}", &variant_iter)) "a{sv}", &variant_iter) ||
goto nomem; !wpa_dbus_dict_open_write(&variant_iter, &iter_dict) ||
if (!wpa_dbus_dict_open_write(&variant_iter, &iter_dict)) !wpa_dbus_dict_append_int32(&iter_dict, "rssi",
goto nomem; si.current_signal) ||
!wpa_dbus_dict_append_int32(&iter_dict, "linkspeed",
if (!wpa_dbus_dict_append_int32(&iter_dict, "rssi", si.current_signal)) si.current_txrate / 1000) ||
goto nomem; !wpa_dbus_dict_append_int32(&iter_dict, "noise",
if (!wpa_dbus_dict_append_int32(&iter_dict, "linkspeed", si.current_noise) ||
si.current_txrate / 1000)) !wpa_dbus_dict_append_uint32(&iter_dict, "frequency",
goto nomem; si.frequency) ||
if (!wpa_dbus_dict_append_int32(&iter_dict, "noise", si.current_noise)) (si.chanwidth != CHAN_WIDTH_UNKNOWN &&
goto nomem; !wpa_dbus_dict_append_string(
if (!wpa_dbus_dict_append_uint32(&iter_dict, "frequency", si.frequency)) &iter_dict, "width",
goto nomem; channel_width_to_string(si.chanwidth))) ||
(si.center_frq1 > 0 && si.center_frq2 > 0 &&
if (si.chanwidth != CHAN_WIDTH_UNKNOWN) { (!wpa_dbus_dict_append_int32(&iter_dict, "center-frq1",
if (!wpa_dbus_dict_append_string(&iter_dict, "width", si.center_frq1) ||
channel_width_to_string(si.chanwidth))) !wpa_dbus_dict_append_int32(&iter_dict, "center-frq2",
goto nomem; si.center_frq2))) ||
} (si.avg_signal &&
!wpa_dbus_dict_append_int32(&iter_dict, "avg-rssi",
if (si.center_frq1 > 0 && si.center_frq2 > 0) { si.avg_signal)) ||
if (!wpa_dbus_dict_append_int32(&iter_dict, "center-frq1", !wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
si.center_frq1)) !dbus_message_iter_close_container(&iter, &variant_iter))
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))
goto nomem; goto nomem;
return reply; return reply;
@ -2375,10 +2335,8 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
const char *scans[] = { "active", "passive", "ssid" }; const char *scans[] = { "active", "passive", "ssid" };
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
"a{sv}", &variant_iter)) "a{sv}", &variant_iter) ||
goto nomem; !wpa_dbus_dict_open_write(&variant_iter, &iter_dict))
if (!wpa_dbus_dict_open_write(&variant_iter, &iter_dict))
goto nomem; goto nomem;
res = wpa_drv_get_capa(wpa_s, &capa); 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", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Pairwise",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto nomem; ((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP_256) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP_256) { &iter_array, "ccmp-256")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.enc & WPA_DRIVER_CAPA_ENC_GCMP_256) &&
&iter_array, "ccmp-256")) !wpa_dbus_dict_string_array_add_element(
goto nomem; &iter_array, "gcmp-256")) ||
} ((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP_256) { &iter_array, "ccmp")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) &&
&iter_array, "gcmp-256")) !wpa_dbus_dict_string_array_add_element(
goto nomem; &iter_array, "gcmp")) ||
} ((capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) { &iter_array, "tkip")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) &&
&iter_array, "ccmp")) !wpa_dbus_dict_string_array_add_element(
goto nomem; &iter_array, "none")) ||
} !wpa_dbus_dict_end_string_array(&iter_dict,
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_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &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", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Group",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto nomem; ((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP_256) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP_256) { &iter_array, "ccmp-256")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.enc & WPA_DRIVER_CAPA_ENC_GCMP_256) &&
&iter_array, "ccmp-256")) !wpa_dbus_dict_string_array_add_element(
goto nomem; &iter_array, "gcmp-256")) ||
} ((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP_256) { &iter_array, "ccmp")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) &&
&iter_array, "gcmp-256")) !wpa_dbus_dict_string_array_add_element(
goto nomem; &iter_array, "gcmp")) ||
} ((capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) { &iter_array, "tkip")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.enc & WPA_DRIVER_CAPA_ENC_WEP104) &&
&iter_array, "ccmp")) !wpa_dbus_dict_string_array_add_element(
goto nomem; &iter_array, "wep104")) ||
} ((capa.enc & WPA_DRIVER_CAPA_ENC_WEP40) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_GCMP) { &iter_array, "wep40")) ||
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_end_string_array(&iter_dict,
&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_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &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", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "KeyMgmt",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto nomem; !wpa_dbus_dict_string_array_add_element(&iter_array,
"none") ||
if (!wpa_dbus_dict_string_array_add_element(&iter_array, !wpa_dbus_dict_string_array_add_element(&iter_array,
"none"))
goto nomem;
if (!wpa_dbus_dict_string_array_add_element(&iter_array,
"ieee8021x")) "ieee8021x"))
goto nomem; goto nomem;
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA | if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
WPA_DRIVER_CAPA_KEY_MGMT_WPA2)) { WPA_DRIVER_CAPA_KEY_MGMT_WPA2)) {
if (!wpa_dbus_dict_string_array_add_element( if (!wpa_dbus_dict_string_array_add_element(
&iter_array, "wpa-eap")) &iter_array, "wpa-eap") ||
goto nomem; ((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_FT) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_FT) &iter_array, "wpa-ft-eap")))
if (!wpa_dbus_dict_string_array_add_element(
&iter_array, "wpa-ft-eap"))
goto nomem; goto nomem;
/* TODO: Ensure that driver actually supports sha256 encryption. */ /* 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 | if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) { WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
if (!wpa_dbus_dict_string_array_add_element( if (!wpa_dbus_dict_string_array_add_element(
&iter_array, "wpa-psk")) &iter_array, "wpa-psk") ||
goto nomem; ((capa.key_mgmt &
WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK) &&
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK) !wpa_dbus_dict_string_array_add_element(
if (!wpa_dbus_dict_string_array_add_element( &iter_array, "wpa-ft-psk")))
&iter_array, "wpa-ft-psk"))
goto nomem; goto nomem;
/* TODO: Ensure that driver actually supports sha256 encryption. */ /* TODO: Ensure that driver actually supports sha256 encryption. */
@ -2571,11 +2479,10 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
#endif /* CONFIG_IEEE80211W */ #endif /* CONFIG_IEEE80211W */
} }
if (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) { if ((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) &&
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_string_array_add_element(&iter_array,
&iter_array, "wpa-none")) "wpa-none"))
goto nomem; goto nomem;
}
#ifdef CONFIG_WPS #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", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Protocol",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto nomem; ((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) &&
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA2 | !wpa_dbus_dict_string_array_add_element(
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) { &iter_array, "rsn")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
&iter_array, "rsn")) WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK)) &&
goto nomem; !wpa_dbus_dict_string_array_add_element(
} &iter_array, "wpa")) ||
!wpa_dbus_dict_end_string_array(&iter_dict,
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_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array))
@ -2640,25 +2539,16 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
&iter_array)) &iter_array))
goto nomem; goto nomem;
if (capa.auth & (WPA_DRIVER_AUTH_OPEN)) { if (((capa.auth & WPA_DRIVER_AUTH_OPEN) &&
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_string_array_add_element(
&iter_array, "open")) &iter_array, "open")) ||
goto nomem; ((capa.auth & WPA_DRIVER_AUTH_SHARED) &&
} !wpa_dbus_dict_string_array_add_element(
&iter_array, "shared")) ||
if (capa.auth & (WPA_DRIVER_AUTH_SHARED)) { ((capa.auth & WPA_DRIVER_AUTH_LEAP) &&
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_string_array_add_element(
&iter_array, "shared")) &iter_array, "leap")) ||
goto nomem; !wpa_dbus_dict_end_string_array(&iter_dict,
}
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,
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &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", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Modes",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto nomem; !wpa_dbus_dict_string_array_add_element(
&iter_array, "infrastructure") ||
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_string_array_add_element(
&iter_array, "infrastructure")) &iter_array, "ad-hoc") ||
goto nomem; (res >= 0 && (capa.flags & WPA_DRIVER_FLAGS_AP) &&
!wpa_dbus_dict_string_array_add_element(
if (!wpa_dbus_dict_string_array_add_element( &iter_array, "ap")) ||
&iter_array, "ad-hoc")) (res >= 0 && (capa.flags & WPA_DRIVER_FLAGS_P2P_CAPABLE) &&
goto nomem; !wpa_dbus_dict_string_array_add_element(
&iter_array, "p2p")) ||
if (res >= 0) { !wpa_dbus_dict_end_string_array(&iter_dict,
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_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array))
@ -2714,9 +2590,8 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
goto nomem; goto nomem;
} }
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict)) if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
goto nomem; !dbus_message_iter_close_container(iter, &variant_iter))
if (!dbus_message_iter_close_container(iter, &variant_iter))
goto nomem; goto nomem;
return TRUE; return TRUE;
@ -3845,9 +3720,8 @@ static dbus_bool_t wpas_dbus_get_bss_security_prop(DBusMessageIter *iter,
goto nomem; goto nomem;
} }
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict)) if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
goto nomem; !dbus_message_iter_close_container(iter, &variant_iter))
if (!dbus_message_iter_close_container(iter, &variant_iter))
goto nomem; goto nomem;
return TRUE; 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)); os_memset(&wpa_data, 0, sizeof(wpa_data));
ie = wpa_bss_get_vendor_ie(res, WPA_IE_VENDOR_TYPE); ie = wpa_bss_get_vendor_ie(res, WPA_IE_VENDOR_TYPE);
if (ie) { if (ie && wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
dbus_set_error_const(error, DBUS_ERROR_FAILED, dbus_set_error_const(error, DBUS_ERROR_FAILED,
"failed to parse WPA IE"); "failed to parse WPA IE");
return FALSE; return FALSE;
} }
}
return wpas_dbus_get_bss_security_prop(iter, &wpa_data, error); 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)); os_memset(&wpa_data, 0, sizeof(wpa_data));
ie = wpa_bss_get_ie(res, WLAN_EID_RSN); ie = wpa_bss_get_ie(res, WLAN_EID_RSN);
if (ie) { if (ie && wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
if (wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
dbus_set_error_const(error, DBUS_ERROR_FAILED, dbus_set_error_const(error, DBUS_ERROR_FAILED,
"failed to parse RSN IE"); "failed to parse RSN IE");
return FALSE; return FALSE;
} }
}
return wpas_dbus_get_bss_security_prop(iter, &wpa_data, error); 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; return FALSE;
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
"a{sv}", &variant_iter)) "a{sv}", &variant_iter) ||
goto nomem; !wpa_dbus_dict_open_write(&variant_iter, &iter_dict))
if (!wpa_dbus_dict_open_write(&variant_iter, &iter_dict))
goto nomem; goto nomem;
#ifdef CONFIG_WPS #ifdef CONFIG_WPS
@ -3971,12 +3839,9 @@ dbus_bool_t wpas_dbus_getter_bss_wps(DBusMessageIter *iter, DBusError *error,
} }
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */
if (!wpa_dbus_dict_append_string(&iter_dict, "Type", type)) if (!wpa_dbus_dict_append_string(&iter_dict, "Type", type) ||
goto nomem; !wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
!dbus_message_iter_close_container(iter, &variant_iter))
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict))
goto nomem;
if (!dbus_message_iter_close_container(iter, &variant_iter))
goto nomem; goto nomem;
return TRUE; return TRUE;
@ -4279,28 +4144,22 @@ void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s,
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_init_append(msg, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
goto fail; (addr && !wpa_dbus_dict_append_byte_array(&dict_iter, "addr",
if (addr && !wpa_dbus_dict_append_byte_array(&dict_iter, "addr",
(const char *) addr, (const char *) addr,
ETH_ALEN)) ETH_ALEN)) ||
goto fail; (dst && !wpa_dbus_dict_append_byte_array(&dict_iter, "dst",
if (dst && !wpa_dbus_dict_append_byte_array(&dict_iter, "dst",
(const char *) dst, (const char *) dst,
ETH_ALEN)) ETH_ALEN)) ||
goto fail; (bssid && !wpa_dbus_dict_append_byte_array(&dict_iter, "bssid",
if (bssid && !wpa_dbus_dict_append_byte_array(&dict_iter, "bssid",
(const char *) bssid, (const char *) bssid,
ETH_ALEN)) ETH_ALEN)) ||
goto fail; (ie && ie_len && !wpa_dbus_dict_append_byte_array(&dict_iter, "ies",
if (ie && ie_len && !wpa_dbus_dict_append_byte_array(&dict_iter, "ies",
(const char *) ie, (const char *) ie,
ie_len)) ie_len)) ||
goto fail; (ssi_signal && !wpa_dbus_dict_append_int32(&dict_iter, "signal",
if (ssi_signal && !wpa_dbus_dict_append_int32(&dict_iter, "signal", ssi_signal)) ||
ssi_signal)) !wpa_dbus_dict_close_write(&iter, &dict_iter))
goto fail;
if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
goto fail; goto fail;
dbus_connection_send(priv->con, msg, NULL); dbus_connection_send(priv->con, msg, NULL);

View file

@ -809,75 +809,37 @@ dbus_bool_t wpas_dbus_getter_p2p_device_config(DBusMessageIter *iter,
wpa_s->conf->wps_vendor_ext[i]; wpa_s->conf->wps_vendor_ext[i];
} }
if (num_vendor_extensions && if ((num_vendor_extensions &&
!wpa_dbus_dict_append_wpabuf_array(&dict_iter, !wpa_dbus_dict_append_wpabuf_array(&dict_iter,
"VendorExtension", "VendorExtension",
vendor_ext, vendor_ext,
num_vendor_extensions)) num_vendor_extensions)) ||
goto err_no_mem; !wpa_dbus_dict_append_uint32(&dict_iter, "GOIntent",
wpa_s->conf->p2p_go_intent) ||
/* GO Intent */ !wpa_dbus_dict_append_bool(&dict_iter, "PersistentReconnect",
if (!wpa_dbus_dict_append_uint32(&dict_iter, "GOIntent", wpa_s->conf->persistent_reconnect) ||
wpa_s->conf->p2p_go_intent)) !wpa_dbus_dict_append_uint32(&dict_iter, "ListenRegClass",
goto err_no_mem; wpa_s->conf->p2p_listen_reg_class) ||
!wpa_dbus_dict_append_uint32(&dict_iter, "ListenChannel",
/* Persistent Reconnect */ wpa_s->conf->p2p_listen_channel) ||
if (!wpa_dbus_dict_append_bool(&dict_iter, "PersistentReconnect", !wpa_dbus_dict_append_uint32(&dict_iter, "OperRegClass",
wpa_s->conf->persistent_reconnect)) wpa_s->conf->p2p_oper_reg_class) ||
goto err_no_mem; !wpa_dbus_dict_append_uint32(&dict_iter, "OperChannel",
wpa_s->conf->p2p_oper_channel) ||
/* Listen Reg Class */ (wpa_s->conf->p2p_ssid_postfix &&
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 &&
!wpa_dbus_dict_append_string(&dict_iter, "SsidPostfix", !wpa_dbus_dict_append_string(&dict_iter, "SsidPostfix",
wpa_s->conf->p2p_ssid_postfix)) wpa_s->conf->p2p_ssid_postfix)) ||
goto err_no_mem; !wpa_dbus_dict_append_bool(&dict_iter, "IntraBss",
wpa_s->conf->p2p_intra_bss) ||
/* Intra Bss */ !wpa_dbus_dict_append_uint32(&dict_iter, "GroupIdle",
if (!wpa_dbus_dict_append_bool(&dict_iter, "IntraBss", wpa_s->conf->p2p_group_idle) ||
wpa_s->conf->p2p_intra_bss)) !wpa_dbus_dict_append_uint32(&dict_iter, "disassoc_low_ack",
goto err_no_mem; wpa_s->conf->disassoc_low_ack) ||
!wpa_dbus_dict_append_bool(&dict_iter, "NoGroupIface",
/* Group Idle */ wpa_s->conf->p2p_no_group_iface) ||
if (!wpa_dbus_dict_append_uint32(&dict_iter, "GroupIdle", !wpa_dbus_dict_append_uint32(&dict_iter, "p2p_search_delay",
wpa_s->conf->p2p_group_idle)) wpa_s->conf->p2p_search_delay) ||
goto err_no_mem; !wpa_dbus_dict_close_write(&variant_iter, &dict_iter) ||
/* 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) ||
!dbus_message_iter_close_container(iter, &variant_iter)) !dbus_message_iter_close_container(iter, &variant_iter))
goto err_no_mem; 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, info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
peer_args->p2p_device_addr, 0); peer_args->p2p_device_addr, 0);
if (info == NULL) { if (info == NULL) {
dbus_set_error(error, DBUS_ERROR_FAILED, dbus_set_error(error, DBUS_ERROR_FAILED, "failed to find peer");
"failed to find peer");
return FALSE; 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_ARRAY_AS_STRING DBUS_TYPE_ARRAY_AS_STRING
DBUS_TYPE_BYTE_AS_STRING, DBUS_TYPE_BYTE_AS_STRING,
&variant_iter)) { &variant_iter) ||
dbus_set_error(error, DBUS_ERROR_FAILED, !dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
"%s: failed to construct message 1", __func__);
return FALSE;
}
if (!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_ARRAY_AS_STRING
DBUS_TYPE_BYTE_AS_STRING, DBUS_TYPE_BYTE_AS_STRING,
&array_iter)) { &array_iter)) {
dbus_set_error(error, DBUS_ERROR_FAILED, dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: failed to construct message 2", __func__); "%s: failed to construct message 1", __func__);
return FALSE; return FALSE;
} }
@ -1448,29 +1404,14 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_secondary_device_types(
if (!dbus_message_iter_open_container( if (!dbus_message_iter_open_container(
&array_iter, DBUS_TYPE_ARRAY, &array_iter, DBUS_TYPE_ARRAY,
DBUS_TYPE_BYTE_AS_STRING, DBUS_TYPE_BYTE_AS_STRING,
&inner_array_iter)) { &inner_array_iter) ||
dbus_set_error(error, DBUS_ERROR_FAILED, !dbus_message_iter_append_fixed_array(
"%s: failed to construct "
"message 3 (%d)",
__func__, i);
return FALSE;
}
if (!dbus_message_iter_append_fixed_array(
&inner_array_iter, DBUS_TYPE_BYTE, &inner_array_iter, DBUS_TYPE_BYTE,
&sec_dev_type_list, WPS_DEV_TYPE_LEN)) { &sec_dev_type_list, WPS_DEV_TYPE_LEN) ||
dbus_set_error(error, DBUS_ERROR_FAILED, !dbus_message_iter_close_container(
"%s: failed to construct "
"message 4 (%d)",
__func__, i);
return FALSE;
}
if (!dbus_message_iter_close_container(
&array_iter, &inner_array_iter)) { &array_iter, &inner_array_iter)) {
dbus_set_error(error, DBUS_ERROR_FAILED, dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: failed to construct " "%s: failed to construct message 2 (%d)",
"message 5 (%d)",
__func__, i); __func__, i);
return FALSE; 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, dbus_set_error(error, DBUS_ERROR_FAILED,
"%s: failed to construct message 6", __func__); "%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 7", __func__);
return FALSE; return FALSE;
} }

View file

@ -311,22 +311,10 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
} }
dbus_message_iter_init_append(reply, &iter); dbus_message_iter_init_append(reply, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) { if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
dbus_message_unref(reply); (os_strlen(npin) > 0 &&
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, !wpa_dbus_dict_append_string(&dict_iter, "Pin", npin)) ||
NULL); !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
}
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)) {
dbus_message_unref(reply); dbus_message_unref(reply);
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL); NULL);

View file

@ -630,10 +630,8 @@ static dbus_bool_t put_changed_properties(
if (!dbus_message_iter_open_container(dict_iter, if (!dbus_message_iter_open_container(dict_iter,
DBUS_TYPE_DICT_ENTRY, DBUS_TYPE_DICT_ENTRY,
NULL, &entry_iter)) NULL, &entry_iter) ||
return FALSE; !dbus_message_iter_append_basic(&entry_iter,
if (!dbus_message_iter_append_basic(&entry_iter,
DBUS_TYPE_STRING, DBUS_TYPE_STRING,
&dsc->dbus_property)) &dsc->dbus_property))
return FALSE; return FALSE;
@ -677,26 +675,16 @@ static void do_send_prop_changed_signal(
dbus_message_iter_init_append(msg, &signal_iter); dbus_message_iter_init_append(msg, &signal_iter);
if (!dbus_message_iter_append_basic(&signal_iter, DBUS_TYPE_STRING, if (!dbus_message_iter_append_basic(&signal_iter, DBUS_TYPE_STRING,
&interface)) &interface) ||
goto err;
/* Changed properties dict */ /* Changed properties dict */
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY, !dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
"{sv}", &dict_iter)) "{sv}", &dict_iter) ||
goto err; !put_changed_properties(obj_dsc, interface, &dict_iter, 0) ||
!dbus_message_iter_close_container(&signal_iter, &dict_iter) ||
if (!put_changed_properties(obj_dsc, interface, &dict_iter, 0))
goto err;
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter))
goto err;
/* Invalidated properties array (empty) */ /* Invalidated properties array (empty) */
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY, !dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
"s", &dict_iter)) "s", &dict_iter) ||
goto err; !dbus_message_iter_close_container(&signal_iter, &dict_iter))
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter))
goto err; goto err;
dbus_connection_send(con, msg, NULL); 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); dbus_message_iter_init_append(msg, &signal_iter);
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY, if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
"{sv}", &dict_iter)) "{sv}", &dict_iter) ||
goto err; !put_changed_properties(obj_dsc, interface, &dict_iter, 1) ||
!dbus_message_iter_close_container(&signal_iter, &dict_iter))
if (!put_changed_properties(obj_dsc, interface, &dict_iter, 1))
goto err;
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter))
goto err; goto err;
dbus_connection_send(con, msg, NULL); dbus_connection_send(con, msg, NULL);

View file

@ -409,84 +409,56 @@ DBusMessage * wpas_dbus_bssid_properties(DBusMessage *message,
{ {
DBusMessage *reply; DBusMessage *reply;
DBusMessageIter iter, iter_dict; DBusMessageIter iter, iter_dict;
const u8 *ie; const u8 *wpa_ie, *rsn_ie, *wps_ie;
/* Dump the properties into a dbus message */ /* Dump the properties into a dbus message */
reply = dbus_message_new_method_return(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); dbus_message_iter_init_append(reply, &iter);
if (!wpa_dbus_dict_open_write(&iter, &iter_dict)) if (!wpa_dbus_dict_open_write(&iter, &iter_dict) ||
goto error; !wpa_dbus_dict_append_byte_array(&iter_dict, "bssid",
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "bssid",
(const char *) bss->bssid, (const char *) bss->bssid,
ETH_ALEN)) ETH_ALEN) ||
goto error; !wpa_dbus_dict_append_byte_array(&iter_dict, "ssid",
(const char *) bss->ssid,
ie = wpa_bss_get_ie(bss, WLAN_EID_SSID); bss->ssid_len) ||
if (ie) { (wpa_ie &&
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "ssid", !wpa_dbus_dict_append_byte_array(&iter_dict, "wpaie",
(const char *) (ie + 2), (const char *) wpa_ie,
ie[1])) wpa_ie[1] + 2)) ||
goto error; (rsn_ie &&
} !wpa_dbus_dict_append_byte_array(&iter_dict, "rsnie",
(const char *) rsn_ie,
ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE); rsn_ie[1] + 2)) ||
if (ie) { (wps_ie &&
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "wpaie", !wpa_dbus_dict_append_byte_array(&iter_dict, "wpsie",
(const char *) ie, (const char *) wps_ie,
ie[1] + 2)) wps_ie[1] + 2)) ||
goto error; (bss->freq &&
} !wpa_dbus_dict_append_int32(&iter_dict, "frequency", bss->freq)) ||
!wpa_dbus_dict_append_uint16(&iter_dict, "capabilities",
ie = wpa_bss_get_ie(bss, WLAN_EID_RSN); bss->caps) ||
if (ie) { (!(bss->flags & WPA_BSS_QUAL_INVALID) &&
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "rsnie", !wpa_dbus_dict_append_int32(&iter_dict, "quality", bss->qual)) ||
(const char *) ie, (!(bss->flags & WPA_BSS_NOISE_INVALID) &&
ie[1] + 2)) !wpa_dbus_dict_append_int32(&iter_dict, "noise", bss->noise)) ||
goto error; (!(bss->flags & WPA_BSS_LEVEL_INVALID) &&
} !wpa_dbus_dict_append_int32(&iter_dict, "level", bss->level)) ||
!wpa_dbus_dict_append_int32(&iter_dict, "maxrate",
ie = wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE); wpa_bss_get_max_rate(bss) * 500000) ||
if (ie) { !wpa_dbus_dict_close_write(&iter, &iter_dict)) {
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:
if (reply) if (reply)
dbus_message_unref(reply); dbus_message_unref(reply);
return dbus_message_new_error(message, WPAS_ERROR_INTERNAL_ERROR, reply = dbus_message_new_error(
"an internal error occurred returning " message, WPAS_ERROR_INTERNAL_ERROR,
"BSSID properties."); "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", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "pairwise",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto error; ((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) { &iter_array, "CCMP")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) &&
&iter_array, "CCMP")) !wpa_dbus_dict_string_array_add_element(
goto error; &iter_array, "TKIP")) ||
} ((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) { &iter_array, "NONE")) ||
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_end_string_array(&iter_dict,
&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_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array))
@ -601,31 +562,19 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
&iter_array)) &iter_array))
goto error; goto error;
if (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) { if (((capa.enc & WPA_DRIVER_CAPA_ENC_CCMP) &&
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_string_array_add_element(
&iter_array, "CCMP")) &iter_array, "CCMP")) ||
goto error; ((capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) &&
} !wpa_dbus_dict_string_array_add_element(
&iter_array, "TKIP")) ||
if (capa.enc & WPA_DRIVER_CAPA_ENC_TKIP) { ((capa.enc & WPA_DRIVER_CAPA_ENC_WEP104) &&
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_string_array_add_element(
&iter_array, "TKIP")) &iter_array, "WEP104")) ||
goto error; ((capa.enc & WPA_DRIVER_CAPA_ENC_WEP40) &&
} !wpa_dbus_dict_string_array_add_element(
&iter_array, "WEP40")) ||
if (capa.enc & WPA_DRIVER_CAPA_ENC_WEP104) { !wpa_dbus_dict_end_string_array(&iter_dict,
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,
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array))
@ -648,38 +597,23 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "key_mgmt", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "key_mgmt",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto error; !wpa_dbus_dict_string_array_add_element(&iter_array,
"NONE") ||
if (!wpa_dbus_dict_string_array_add_element(&iter_array, !wpa_dbus_dict_string_array_add_element(&iter_array,
"NONE")) "IEEE8021X") ||
goto error; ((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_dbus_dict_string_array_add_element(
"IEEE8021X")) &iter_array, "WPA-EAP")) ||
goto error; ((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) &&
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA | !wpa_dbus_dict_string_array_add_element(
WPA_DRIVER_CAPA_KEY_MGMT_WPA2)) { &iter_array, "WPA-PSK")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) &&
&iter_array, "WPA-EAP")) !wpa_dbus_dict_string_array_add_element(
goto error; &iter_array, "WPA-NONE")) ||
} !wpa_dbus_dict_end_string_array(&iter_dict,
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_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array))
@ -699,24 +633,16 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "proto", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "proto",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto error; ((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) &&
if (capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA2 | !wpa_dbus_dict_string_array_add_element(
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) { &iter_array, "RSN")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
&iter_array, "RSN")) WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK)) &&
goto error; !wpa_dbus_dict_string_array_add_element(
} &iter_array, "WPA")) ||
!wpa_dbus_dict_end_string_array(&iter_dict,
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_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array))
@ -736,28 +662,17 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "auth_alg", if (!wpa_dbus_dict_begin_string_array(&iter_dict, "auth_alg",
&iter_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array) ||
goto error; ((capa.auth & WPA_DRIVER_AUTH_OPEN) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.auth & (WPA_DRIVER_AUTH_OPEN)) { &iter_array, "OPEN")) ||
if (!wpa_dbus_dict_string_array_add_element( ((capa.auth & WPA_DRIVER_AUTH_SHARED) &&
&iter_array, "OPEN")) !wpa_dbus_dict_string_array_add_element(
goto error; &iter_array, "SHARED")) ||
} ((capa.auth & WPA_DRIVER_AUTH_LEAP) &&
!wpa_dbus_dict_string_array_add_element(
if (capa.auth & (WPA_DRIVER_AUTH_SHARED)) { &iter_array, "LEAP")) ||
if (!wpa_dbus_dict_string_array_add_element( !wpa_dbus_dict_end_string_array(&iter_dict,
&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_dict_entry, &iter_dict_entry,
&iter_dict_val, &iter_dict_val,
&iter_array)) &iter_array))