[PATCH 5/6] adding device serial number in wps property on dbus

Avichal Agarwal avichal.a at samsung.com
Wed Dec 21 04:24:24 PST 2016


Signed-off-by: Avichal Agarwal <avichal.a at samsung.com>
Signed-off-by: Mayank Haarit <mayank.h at samsung.com>

---
 wpa_supplicant/dbus/dbus_new.c              |  6 +++
 wpa_supplicant/dbus/dbus_new_handlers.h     |  3 +-
 wpa_supplicant/dbus/dbus_new_handlers_wps.c | 59 +++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index b5c4e49..429945b 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -3258,6 +3258,12 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
 	  wpas_dbus_setter_wps_device_ModelNumber,
 	  NULL
 	},
+	{
+	  "SerialNumber" ,WPAS_DBUS_NEW_IFACE_WPS, "s" ,
+	  wpas_dbus_getter_wps_device_SerialNumber,
+	  wpas_dbus_setter_wps_device_SerialNumber,
+	  NULL
+	},
 #endif /* CONFIG_WPS */
 #ifdef CONFIG_P2P
 	{ "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index 2367b13..d898b81 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -194,7 +194,8 @@ DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_model_name);
 DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_model_name);
 DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_ModelNumber);
 DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_ModelNumber);
-
+DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_SerialNumber);
+DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_SerialNumber);
 
 DBusMessage * wpas_dbus_handler_tdls_discover(DBusMessage *message,
 					      struct wpa_supplicant *wpa_s);
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_wps.c b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
index 48a027a..2f99fdf 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_wps.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
@@ -636,6 +636,65 @@ dbus_bool_t wpas_dbus_getter_wps_device_ModelNumber(
 }
 
 /**
+ * wpas_dbus_getter_wps_device_SerialNumber - Get current device serial 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
+ *
+ * Getter for "SerialNumber" property. Returned boolean will be true if
+ * providing the relevant string worked, or false otherwise.
+ */
+dbus_bool_t wpas_dbus_getter_wps_device_SerialNumber(
+	const struct wpa_dbus_property_desc *property_desc,
+	DBusMessageIter *iter, DBusError *error, void *user_data)
+{
+	struct wpa_supplicant *wpa_s = user_data;
+	char *model_number = wpa_s->conf->serial_number;
+
+	if (model_number == NULL)
+		model_number = "";
+	return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
+						&model_number, error);
+}
+
+/**
+ * wpas_dbus_setter_wps_device_SerialNumber - Set current device serial 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 "SerialNumber" property. Returned boolean will be true if
+ * providing the relevant string worked, or false otherwise.
+ */
+dbus_bool_t wpas_dbus_setter_wps_device_SerialNumber(
+	const struct wpa_dbus_property_desc *property_desc,
+	DBusMessageIter *iter, DBusError *error, void *user_data)
+{
+	struct wpa_supplicant *wpa_s = user_data;
+	char *methods;
+	char *serial_number;
+
+	if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
+					      &methods))
+		return FALSE;
+
+	if(os_strlen(methods) > 32 )
+		return FALSE;
+
+	serial_number = os_strdup(methods);
+	if (!serial_number)
+		return FALSE;
+	os_free(wpa_s->conf->serial_number);
+	wpa_s->conf->serial_number = serial_number;
+	wpa_s->conf->changed_parameters |= CFG_CHANGED_WPS_STRING;
+	wpa_supplicant_update_config(wpa_s);
+
+	return TRUE;
+}
+
+/**
  * wpas_dbus_getter_config_methods - Get current WPS configuration methods
  * @iter: Pointer to incoming dbus message iter
  * @error: Location to store error on failure
-- 
2.7.4




More information about the Hostap mailing list