/**
 * wpas_dbus_setter_wps_device_model_number - Set current device model number
 * @iter: Pointer to incoming dbus message iter
 * @error: Location to store error on failure
 * @user_data: Function specific data
 * Returns: TRUE on success, FALSE on failure
 *
 * Setter for "ModelNumber" property.
 */
dbus_bool_t wpas_dbus_setter_wps_device_model_number(
	const struct wpa_dbus_property_desc *property_desc,
	DBusMessageIter *iter, DBusError *error, void *user_data)
{
	struct wpa_supplicant *wpa_s = user_data;
	char *methods, *model_number;

	if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
					      &methods))
		return FALSE;

	if (os_strlen(methods) > WPS_MODEL_NUMBER_MAX_LEN)
		return FALSE;

	model_number = os_strdup(methods);
	if (!model_number)
		return FALSE;

	os_free(wpa_s->conf->model_number);
	wpa_s->conf->model_number = model_number;
	wpa_s->conf->changed_parameters |= CFG_CHANGED_WPS_STRING;
	wpa_supplicant_update_config(wpa_s);

	return TRUE;
}
/**
 * wpas_dbus_setter_wps_device_device_type - Set current device type
 * @iter: Pointer to incoming dbus message iter
 * @error: Location to store error on failure
 * @user_data: Function specific data
 * Returns: TRUE on success, FALSE on failure
 *
 * Setter for "DeviceType" property.
 */
dbus_bool_t wpas_dbus_setter_wps_device_device_type(
	const struct wpa_dbus_property_desc *property_desc,
	DBusMessageIter *iter, DBusError *error, void *user_data)
{
	struct wpa_supplicant *wpa_s = user_data;
	u8 *dev_type;
	int dev_len;
	DBusMessageIter variant, array_iter;

	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT)
		return FALSE;

	dbus_message_iter_recurse(iter, &variant);
	if (dbus_message_iter_get_arg_type(&variant) != DBUS_TYPE_ARRAY)
		return FALSE;

	dbus_message_iter_recurse(&variant, &array_iter);
	dbus_message_iter_get_fixed_array(&array_iter, &dev_type, &dev_len);

	if (dev_len != WPS_DEV_TYPE_LEN)
		return FALSE;

	os_memcpy(wpa_s->conf->device_type, dev_type, WPS_DEV_TYPE_LEN);
	wpa_s->conf->changed_parameters |= CFG_CHANGED_DEVICE_TYPE;
	wpa_supplicant_update_config(wpa_s);

	return TRUE;
}
/**
 * wpas_dbus_setter_wps_device_name - Set current WPS device name
 * @iter: Pointer to incoming dbus message iter
 * @error: Location to store error on failure
 * @user_data: Function specific data
 * Returns: TRUE on success, FALSE on failure
 *
 * Setter for "DeviceName" property.
 */
dbus_bool_t wpas_dbus_setter_wps_device_name(
	const struct wpa_dbus_property_desc *property_desc,
	DBusMessageIter *iter, DBusError *error, void *user_data)
{
	struct wpa_supplicant *wpa_s = user_data;
	char *methods, *devname;

	if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
					      &methods))
		return FALSE;

	if (os_strlen(methods) > WPS_DEV_NAME_MAX_LEN)
		return FALSE;

	devname = os_strdup(methods);
	if (!devname)
		return FALSE;

	os_free(wpa_s->conf->device_name);
	wpa_s->conf->device_name = devname;
	wpa_s->conf->changed_parameters |= CFG_CHANGED_DEVICE_NAME;
	wpa_supplicant_update_config(wpa_s);

	return TRUE;
}
/**
 * wpas_dbus_setter_config_methods - Set WPS configuration methods
 * @iter: Pointer to incoming dbus message iter
 * @error: Location to store error on failure
 * @user_data: Function specific data
 * Returns: TRUE on success, FALSE on failure
 *
 * Setter for "ConfigMethods" property. Sets the methods string, apply such
 * change and returns true on success. Returns false otherwise.
 */
dbus_bool_t wpas_dbus_setter_config_methods(DBusMessageIter *iter,
					    DBusError *error,
					    void *user_data)
{
	struct wpa_supplicant *wpa_s = user_data;
	char *methods, *new_methods;

	if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
					      &methods))
		return FALSE;

	new_methods = os_strdup(methods);
	if (!new_methods)
		return FALSE;

	os_free(wpa_s->conf->config_methods);
	wpa_s->conf->config_methods = new_methods;

	wpa_s->conf->changed_parameters |= CFG_CHANGED_CONFIG_METHODS;
	wpa_supplicant_update_config(wpa_s);

	return TRUE;
}