[PATCH 3/3] dbus: Add a global property to set or unset WFD IEs
Dan Williams
dcbw
Wed Aug 27 10:54:32 PDT 2014
On Tue, 2014-08-26 at 10:02 +0300, Tomasz Bursztyka wrote:
> This permits to set or unset the WiFi Display subelements from DBus, by
> providing the full WFD specific IE frame.
We've talked before about loosening the root restriction for the D-Bus
interface, so that user-level apps can get information from the
supplicant for stuff like WiFi positioning.
But if we just changed the dbus permissions, that would open up stuff
like this property, which is writable. I'm not saying this is a problem
now, but it will be if/when people do the work for those other
use-cases.
Dan
> ---
> wpa_supplicant/dbus/dbus_new.c | 6 +++
> wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 74 +++++++++++++++++++++++++++++
> wpa_supplicant/dbus/dbus_new_handlers_p2p.h | 11 +++++
> 3 files changed, 91 insertions(+)
>
> diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
> index e9f6589..c55ae7c 100644
> --- a/wpa_supplicant/dbus/dbus_new.c
> +++ b/wpa_supplicant/dbus/dbus_new.c
> @@ -2094,6 +2094,12 @@ static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
> wpas_dbus_getter_global_capabilities,
> 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 }
> };
>
> diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
> index c9ecc7b..5e90b37 100644
> --- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
> +++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
> @@ -26,6 +26,7 @@
> #include "ap/wps_hostapd.h"
>
> #include "../p2p_supplicant.h"
> +#include "../wifi_display.h"
>
> /**
> * Parses out the mac address from the peer object path.
> @@ -2589,3 +2590,76 @@ DBusMessage * wpas_dbus_handler_p2p_serv_disc_external(
> 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, (char *) ie->buf,
> + ie->used, 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:
> + if (ie != NULL)
> + wpabuf_free(ie);
> +
> + dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
> + "invalid message format");
> + return FALSE;
> +}
> +#endif /* CONFIG_WIFI_DISPLAY */
> diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
> index 67dbfc9..6e67c89 100644
> --- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
> +++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
> @@ -210,5 +210,16 @@ DBusMessage * wpas_dbus_handler_remove_persistent_group(
> DBusMessage * wpas_dbus_handler_remove_all_persistent_groups(
> 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 */
More information about the Hostap
mailing list