From d4177443d4ee1a7c3d325881ab2acca325dca673 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Mon, 15 Sep 2014 08:04:29 +0300 Subject: [PATCH] wifi_display: Add a utility function to get the sub-elements as IEs This will be useful for DBus API to expose current WFD configuration. Signed-off-by: Tomasz Bursztyka --- wpa_supplicant/wifi_display.c | 28 ++++++++++++++++++++++++++++ wpa_supplicant/wifi_display.h | 1 + 2 files changed, 29 insertions(+) diff --git a/wpa_supplicant/wifi_display.c b/wpa_supplicant/wifi_display.c index b6f923638..80c4e13ac 100644 --- a/wpa_supplicant/wifi_display.c +++ b/wpa_supplicant/wifi_display.c @@ -36,6 +36,34 @@ void wifi_display_deinit(struct wpa_global *global) } +struct wpabuf * wifi_display_get_wfd_ie(struct wpa_global *global) +{ + struct wpabuf *ie; + size_t len; + int i; + + if (global->p2p == NULL) + return NULL; + + len = 0; + for (i = 0; i < MAX_WFD_SUBELEMS; i++) { + if (global->wfd_subelem[i]) + len += wpabuf_len(global->wfd_subelem[i]); + } + + ie = wpabuf_alloc(len); + if (ie == NULL) + return NULL; + + for (i = 0; i < MAX_WFD_SUBELEMS; i++) { + if (global->wfd_subelem[i]) + wpabuf_put_buf(ie, global->wfd_subelem[i]); + } + + return ie; +} + + static int wifi_display_update_wfd_ie(struct wpa_global *global) { struct wpabuf *ie, *buf; diff --git a/wpa_supplicant/wifi_display.h b/wpa_supplicant/wifi_display.h index 755481755..67d8bc1af 100644 --- a/wpa_supplicant/wifi_display.h +++ b/wpa_supplicant/wifi_display.h @@ -13,6 +13,7 @@ int wifi_display_init(struct wpa_global *global); void wifi_display_deinit(struct wpa_global *global); void wifi_display_enable(struct wpa_global *global, int enabled); +struct wpabuf *wifi_display_get_wfd_ie(struct wpa_global *global); int wifi_display_subelem_set(struct wpa_global *global, char *cmd); int wifi_display_subelem_get(struct wpa_global *global, char *cmd, char *buf, size_t buflen);