DBus/P2P: Return Primary and Secondary device types as bytes

These properties are already correctly treated as bytes for the local
device, we need to do same for peers.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
This commit is contained in:
Jayant Sane 2011-08-06 21:34:11 +03:00 committed by Jouni Malinen
parent 2e92310217
commit e261d5a9a6

View file

@ -1126,7 +1126,6 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_properties(DBusMessageIter *iter,
struct peer_handler_args *peer_args = user_data; struct peer_handler_args *peer_args = user_data;
DBusMessageIter variant_iter, dict_iter; DBusMessageIter variant_iter, dict_iter;
const struct p2p_peer_info *info = NULL; const struct p2p_peer_info *info = NULL;
char devtype[WPS_DEV_TYPE_BUFSIZE];
const struct wpabuf *vendor_extension[P2P_MAX_WPS_VENDOR_EXT]; const struct wpabuf *vendor_extension[P2P_MAX_WPS_VENDOR_EXT];
int i, num; int i, num;
@ -1144,12 +1143,12 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_properties(DBusMessageIter *iter,
goto err_no_mem; goto err_no_mem;
/* Fill out the dictionary */ /* Fill out the dictionary */
wps_dev_type_bin2str(info->pri_dev_type, devtype, sizeof(devtype));
if (!wpa_dbus_dict_append_string(&dict_iter, "DeviceName", if (!wpa_dbus_dict_append_string(&dict_iter, "DeviceName",
info->device_name)) info->device_name))
goto err_no_mem; goto err_no_mem;
if (!wpa_dbus_dict_append_string(&dict_iter, "PrimaryDeviceType", if (!wpa_dbus_dict_append_byte_array(&dict_iter, "PrimaryDeviceType",
devtype)) (char *)info->pri_dev_type,
WPS_DEV_TYPE_LEN))
goto err_no_mem; goto err_no_mem;
if (!wpa_dbus_dict_append_uint16(&dict_iter, "config_method", if (!wpa_dbus_dict_append_uint16(&dict_iter, "config_method",
info->config_methods)) info->config_methods))
@ -1165,53 +1164,34 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_properties(DBusMessageIter *iter,
goto err_no_mem; goto err_no_mem;
if (info->wps_sec_dev_type_list_len) { if (info->wps_sec_dev_type_list_len) {
char *sec_dev_types[MAX_SEC_DEVICE_TYPES]; const u8 *sec_dev_type_list = info->wps_sec_dev_type_list;
u8 *sec_dev_type_list = NULL; int num_sec_dev_types =
char secdevtype[WPS_DEV_TYPE_BUFSIZE]; info->wps_sec_dev_type_list_len / WPS_DEV_TYPE_LEN;
int num_sec_dev_types = 0; DBusMessageIter iter_secdev_dict_entry, iter_secdev_dict_val,
iter_secdev_dict_array;
sec_dev_type_list = os_zalloc(info->wps_sec_dev_type_list_len);
if (sec_dev_type_list == NULL)
goto err_no_mem;
os_memcpy(sec_dev_type_list, info->wps_sec_dev_type_list,
info->wps_sec_dev_type_list_len);
for (i = 0; i < MAX_SEC_DEVICE_TYPES &&
i < (int) (info->wps_sec_dev_type_list_len /
WPS_DEV_TYPE_LEN);
i++) {
sec_dev_types[i] = os_zalloc(sizeof(secdevtype));
if (!sec_dev_types[i] ||
wps_dev_type_bin2str(
&sec_dev_type_list[i * WPS_DEV_TYPE_LEN],
sec_dev_types[i],
sizeof(secdevtype)) == NULL) {
while (--i >= 0)
os_free(sec_dev_types[i]);
os_free(sec_dev_type_list);
goto err_no_mem;
}
num_sec_dev_types++;
}
os_free(sec_dev_type_list);
if (num_sec_dev_types) { if (num_sec_dev_types) {
if (!wpa_dbus_dict_append_string_array(&dict_iter, if (!wpa_dbus_dict_begin_array(&dict_iter,
"SecondaryDeviceTypes", "SecondaryDeviceTypes",
(const char **)sec_dev_types, DBUS_TYPE_ARRAY_AS_STRING
num_sec_dev_types)) { DBUS_TYPE_BYTE_AS_STRING,
for (i = 0; i < num_sec_dev_types; i++) &iter_secdev_dict_entry,
os_free(sec_dev_types[i]); &iter_secdev_dict_val,
&iter_secdev_dict_array))
goto err_no_mem; goto err_no_mem;
for (i = 0; i < num_sec_dev_types; i++) {
wpa_dbus_dict_bin_array_add_element(
&iter_secdev_dict_array,
sec_dev_type_list,
WPS_DEV_TYPE_LEN);
sec_dev_type_list += WPS_DEV_TYPE_LEN;
} }
for (i = 0; i < num_sec_dev_types; i++) if (!wpa_dbus_dict_end_array(&dict_iter,
os_free(sec_dev_types[i]); &iter_secdev_dict_entry,
&iter_secdev_dict_val,
&iter_secdev_dict_array))
goto err_no_mem;
} }
} }