]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
D-Bus: Add DeviceType in WPS property
authorAvichal Agarwal <avichal.a@samsung.com>
Wed, 21 Dec 2016 12:24:25 +0000 (17:54 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 23 Dec 2016 19:28:43 +0000 (21:28 +0200)
Signed-off-by: Avichal Agarwal <avichal.a@samsung.com>
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new_handlers.h
wpa_supplicant/dbus/dbus_new_handlers_wps.c

index 6ec7d027cb87b9d2fb24f14ba15cf7cbbdd4bc43..a60118254e4b33911defca8b710544b99ce7c5dd 100644 (file)
@@ -3264,6 +3264,12 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
          wpas_dbus_setter_wps_device_serial_number,
          NULL
        },
+       {
+         "DeviceType", WPAS_DBUS_NEW_IFACE_WPS, "ay",
+         wpas_dbus_getter_wps_device_device_type,
+         wpas_dbus_setter_wps_device_device_type,
+         NULL
+       },
 #endif /* CONFIG_WPS */
 #ifdef CONFIG_P2P
        { "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
index 2f8962242cfa85e357a353d4bc6c75b3876114cb..7450fc73d2b907721870b90405805b20177c8285 100644 (file)
@@ -196,6 +196,8 @@ DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_model_number);
 DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_model_number);
 DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_serial_number);
 DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_serial_number);
+DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_device_type);
+DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_device_type);
 
 DBusMessage * wpas_dbus_handler_tdls_discover(DBusMessage *message,
                                              struct wpa_supplicant *wpa_s);
index 4282f08abdb863bf27992291bfc0fdbba81218c1..0464fb2b9935843b08ae95aee3a1dbc5ccc54926 100644 (file)
@@ -747,3 +747,70 @@ dbus_bool_t wpas_dbus_setter_wps_device_serial_number(
 
        return TRUE;
 }
+
+
+/**
+ * wpas_dbus_getter_wps_device_device_type - Get 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
+ *
+ * Getter for "DeviceType" property.
+ */
+dbus_bool_t wpas_dbus_getter_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;
+
+       if (!wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
+                                                   (char *)
+                                                   wpa_s->conf->device_type,
+                                                   WPS_DEV_TYPE_LEN, error)) {
+               dbus_set_error(error, DBUS_ERROR_FAILED,
+                              "%s: error constructing reply", __func__);
+               return FALSE;
+       }
+
+       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;
+}