From patchwork Wed Feb 22 20:59:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinette Chatre X-Patchwork-Id: 142530 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 369B7B6EEC for ; Thu, 23 Feb 2012 07:59:13 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C1D029C1E6; Wed, 22 Feb 2012 15:59:09 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 57inJqRRUejn; Wed, 22 Feb 2012 15:59:09 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 11F949C1BC; Wed, 22 Feb 2012 15:58:45 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id F229117C011 for ; Wed, 22 Feb 2012 15:58:43 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BOsRWyjeqbHO for ; Wed, 22 Feb 2012 15:58:39 -0500 (EST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C16779C167 for ; Wed, 22 Feb 2012 15:58:38 -0500 (EST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 22 Feb 2012 12:58:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,352,1309762800"; d="scan'208";a="110928038" Received: from splap.jf.intel.com ([10.7.198.55]) by orsmga001.jf.intel.com with ESMTP; 22 Feb 2012 12:58:38 -0800 From: Reinette Chatre To: j@w1.fi Subject: [PATCH 2/3] dbus: revert changes to some peer properties Date: Wed, 22 Feb 2012 12:59:06 -0800 Message-Id: <1329944347-6465-3-git-send-email-reinette.chatre@intel.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1329944347-6465-1-git-send-email-reinette.chatre@intel.com> References: <20120215200512.GA17410@w1.fi> <1329944347-6465-1-git-send-email-reinette.chatre@intel.com> Cc: hostap@lists.shmoo.com X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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 intended-for: hostap-1 --- wpa_supplicant/dbus/dbus_new.c | 4 +- wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 96 ++++++++++++++++++++------- 2 files changed, 75 insertions(+), 25 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..62489f4 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,78 @@ 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 +1430,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 +1451,12 @@ 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"); - return FALSE; - } + if (!wpas_dbus_simple_array_array_property_getter(iter, + DBUS_TYPE_BYTE, + vendor_extension, + num, + error)) + return FALSE; return TRUE; }