D-Bus: Add device serial number in WPS property

Signed-off-by: Avichal Agarwal <avichal.a@samsung.com>
Signed-off-by: Mayank Haarit <mayank.h@samsung.com>
This commit is contained in:
Avichal Agarwal 2016-12-21 17:54:24 +05:30 committed by Jouni Malinen
parent 3ee6a3ab35
commit 266097fdad
3 changed files with 66 additions and 0 deletions

View file

@ -3258,6 +3258,12 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
wpas_dbus_setter_wps_device_model_number, wpas_dbus_setter_wps_device_model_number,
NULL NULL
}, },
{
"SerialNumber", WPAS_DBUS_NEW_IFACE_WPS, "s",
wpas_dbus_getter_wps_device_serial_number,
wpas_dbus_setter_wps_device_serial_number,
NULL
},
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */
#ifdef CONFIG_P2P #ifdef CONFIG_P2P
{ "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}", { "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",

View file

@ -194,6 +194,8 @@ DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_model_name);
DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_model_name); DECLARE_ACCESSOR(wpas_dbus_setter_wps_device_model_name);
DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_model_number); DECLARE_ACCESSOR(wpas_dbus_getter_wps_device_model_number);
DECLARE_ACCESSOR(wpas_dbus_setter_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);
DBusMessage * wpas_dbus_handler_tdls_discover(DBusMessage *message, DBusMessage * wpas_dbus_handler_tdls_discover(DBusMessage *message,
struct wpa_supplicant *wpa_s); struct wpa_supplicant *wpa_s);

View file

@ -689,3 +689,61 @@ dbus_bool_t wpas_dbus_setter_wps_device_model_number(
return TRUE; return TRUE;
} }
/**
* wpas_dbus_getter_wps_device_serial_number - 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.
*/
dbus_bool_t wpas_dbus_getter_wps_device_serial_number(
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)
model_number = "";
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
&model_number, error);
}
/**
* wpas_dbus_setter_wps_device_serial_number - 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.
*/
dbus_bool_t wpas_dbus_setter_wps_device_serial_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, *serial_number;
if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
&methods))
return FALSE;
if (os_strlen(methods) > WPS_SERIAL_NUMBER_MAX_LEN)
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;
}