dbus: Add a global property to set or unset WFD IEs

This permits to set or unset the WiFi Display subelements from DBus, by
providing the full WFD specific IE frame.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2014-09-15 08:04:31 +03:00 committed by Jouni Malinen
parent 4bd7e1614f
commit 6a60488745
3 changed files with 92 additions and 0 deletions

View file

@ -2097,6 +2097,12 @@ static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
wpas_dbus_getter_global_capabilities, wpas_dbus_getter_global_capabilities,
NULL NULL
}, },
#ifdef CONFIG_WIFI_DISPLAY
{ "WFDIEs", WPAS_DBUS_NEW_INTERFACE, "ay",
wpas_dbus_getter_global_wfd_ies,
wpas_dbus_setter_global_wfd_ies
},
#endif /* CONFIG_WIFI_DISPLAY */
{ NULL, NULL, NULL, NULL, NULL } { NULL, NULL, NULL, NULL, NULL }
}; };

View file

@ -26,6 +26,7 @@
#include "ap/wps_hostapd.h" #include "ap/wps_hostapd.h"
#include "../p2p_supplicant.h" #include "../p2p_supplicant.h"
#include "../wifi_display.h"
/** /**
* Parses out the mac address from the peer object path. * Parses out the mac address from the peer object path.
@ -2589,3 +2590,77 @@ DBusMessage * wpas_dbus_handler_p2p_serv_disc_external(
return NULL; return NULL;
} }
#ifdef CONFIG_WIFI_DISPLAY
dbus_bool_t wpas_dbus_getter_global_wfd_ies(DBusMessageIter *iter,
DBusError *error, void *user_data)
{
struct wpa_global *global = user_data;
struct wpabuf *ie;
dbus_bool_t ret;
ie = wifi_display_get_wfd_ie(global);
if (ie == NULL)
return wpas_dbus_simple_array_property_getter(iter,
DBUS_TYPE_BYTE,
NULL, 0, error);
ret = wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
wpabuf_head(ie),
wpabuf_len(ie), error);
wpabuf_free(ie);
return ret;
}
dbus_bool_t wpas_dbus_setter_global_wfd_ies(DBusMessageIter *iter,
DBusError *error, void *user_data)
{
struct wpa_global *global = user_data;
DBusMessageIter variant, array;
struct wpabuf *ie = NULL;
const u8 *data;
int len;
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT)
goto err;
dbus_message_iter_recurse(iter, &variant);
if (dbus_message_iter_get_arg_type(&variant) != DBUS_TYPE_ARRAY)
goto err;
dbus_message_iter_recurse(&variant, &array);
dbus_message_iter_get_fixed_array(&array, &data, &len);
if (len == 0) {
wifi_display_enable(global, 0);
wifi_display_deinit(global);
return TRUE;
}
ie = wpabuf_alloc(len);
if (ie == NULL)
goto err;
wpabuf_put_data(ie, data, len);
if (wifi_display_subelem_set_from_ies(global, ie) != 0)
goto err;
if (global->wifi_display == 0)
wifi_display_enable(global, 1);
wpabuf_free(ie);
return TRUE;
err:
wpabuf_free(ie);
dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
"invalid message format");
return FALSE;
}
#endif /* CONFIG_WIFI_DISPLAY */

View file

@ -210,5 +210,16 @@ DBusMessage * wpas_dbus_handler_remove_persistent_group(
DBusMessage * wpas_dbus_handler_remove_all_persistent_groups( DBusMessage * wpas_dbus_handler_remove_all_persistent_groups(
DBusMessage *message, struct wpa_supplicant *wpa_s); DBusMessage *message, struct wpa_supplicant *wpa_s);
#ifdef CONFIG_WIFI_DISPLAY
dbus_bool_t wpas_dbus_getter_global_wfd_ies(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_global_wfd_ies(DBusMessageIter *iter,
DBusError *error,
void *user_data);
#endif /* CONFIG_WIFI_DISPLAY */
#endif /* DBUS_NEW_HANDLERS_P2P_H */ #endif /* DBUS_NEW_HANDLERS_P2P_H */