diff options
author | Reinette Chatre <reinette.chatre@intel.com> | 2012-02-25 10:50:13 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2012-02-25 10:50:13 +0200 |
commit | ca298427004f0f68de042fa6d3061a706f52f18c (patch) | |
tree | 9a745e4634fb9e9b3f8aad1c1a963eff8f86c6be | |
parent | 96c4f3a70754a142318264de963b0ec41271987c (diff) | |
download | external_wpa_supplicant_8_ti-ca298427004f0f68de042fa6d3061a706f52f18c.zip external_wpa_supplicant_8_ti-ca298427004f0f68de042fa6d3061a706f52f18c.tar.gz external_wpa_supplicant_8_ti-ca298427004f0f68de042fa6d3061a706f52f18c.tar.bz2 |
dbus: revert changes to some peer properties
Commit 3f6e50ac282bbcb4be137023316543bd232ba350 made it possible to access
P2P peer properties using the org.freedesktop.DBus.Properties interface.
While maintaining the original intent of that patch we make two changes
to it here:
First, 3f6e50ac282bbcb4be137023316543bd232ba350 changed the type used to
represent the WPS vendor extension data from bytes to a string. In
addition to the type change the way in which the vendor extension data
was provided to the function creating the string was incorrect and would
not present the correct vendor extension data even in string format.
Revert the type change made in 3f6e50ac282bbcb4be137023316543bd232ba350
and present the WPS vendor extension data as an array of an array of
bytes as it was before.
Second, 3f6e50ac282bbcb4be137023316543bd232ba350 changes the secondary
device types representation from an array of an array of bytes to an
array of bytes. Revert that change to make secondary device types
accessible via an array of an array of bytes again.
Signed-hostap: Reinette Chatre <reinette.chatre@intel.com>
intended-for: hostap-1
-rw-r--r-- | wpa_supplicant/dbus/dbus_new.c | 4 | ||||
-rw-r--r-- | wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 94 |
2 files changed, 74 insertions, 24 deletions
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index ce7cffb..a240649 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -2921,11 +2921,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = { wpas_dbus_getter_p2p_peer_group_capability, NULL }, - { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay", + { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay", wpas_dbus_getter_p2p_peer_secondary_device_types, NULL }, - { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER, "as", + { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay", wpas_dbus_getter_p2p_peer_vendor_extension, NULL }, diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c index 79373b4..8036b63 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c +++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c @@ -1341,6 +1341,7 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_secondary_device_types( { struct peer_handler_args *peer_args = user_data; const struct p2p_peer_info *info; + DBusMessageIter variant_iter, array_iter; info = p2p_get_peer_found(peer_args->wpa_s->global->p2p, peer_args->p2p_device_addr, 0); @@ -1350,29 +1351,80 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_secondary_device_types( return FALSE; } + if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, + 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, + 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__); + return FALSE; + } + if (info->wps_sec_dev_type_list_len) { const u8 *sec_dev_type_list = info->wps_sec_dev_type_list; - int num_sec_dev_types = info->wps_sec_dev_type_list_len; + int num_sec_device_types = + info->wps_sec_dev_type_list_len / WPS_DEV_TYPE_LEN; + int i; + DBusMessageIter inner_array_iter; + + for (i = 0; i < num_sec_device_types; i++) { + 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 (!wpas_dbus_simple_array_property_getter(iter, - DBUS_TYPE_BYTE, - sec_dev_type_list, - num_sec_dev_types, - error)) - goto err_no_mem; - else - return TRUE; + if (!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( + &array_iter, &inner_array_iter)) { + dbus_set_error(error, DBUS_ERROR_FAILED, + "%s: failed to construct " + "message 5 (%d)", + __func__, i); + return FALSE; + } + + sec_dev_type_list += WPS_DEV_TYPE_LEN; + } } - if (!wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE, NULL, - 0, error)) - goto err_no_mem; + if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) { + dbus_set_error(error, DBUS_ERROR_FAILED, + "%s: failed to construct message 6", __func__); + return FALSE; + } - return TRUE; + 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; + } -err_no_mem: - dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory"); - return FALSE; + return TRUE; } @@ -1380,7 +1432,7 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_vendor_extension(DBusMessageIter *iter, DBusError *error, void *user_data) { - const struct wpabuf *vendor_extension[P2P_MAX_WPS_VENDOR_EXT]; + struct wpabuf *vendor_extension[P2P_MAX_WPS_VENDOR_EXT]; int i, num; struct peer_handler_args *peer_args = user_data; const struct p2p_peer_info *info; @@ -1401,12 +1453,10 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_vendor_extension(DBusMessageIter *iter, num++; } - if (!wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_STRING, - vendor_extension, num, - error)) { - dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory"); + if (!wpas_dbus_simple_array_array_property_getter(iter, DBUS_TYPE_BYTE, + vendor_extension, + num, error)) return FALSE; - } return TRUE; } |