aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/wifi_display.c
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2013-11-25 22:56:38 (GMT)
committerJouni Malinen <j@w1.fi>2013-12-08 01:57:55 (GMT)
commitb125c48fce823f28d22ebd68297c5b94366c6aa1 (patch)
tree81c69c690db201ea2d3d5b333cd717a1b81e4233 /wpa_supplicant/wifi_display.c
parente706d2d30d37fd8626969a1df2adc73059f4ab35 (diff)
downloadhostap-b125c48fce823f28d22ebd68297c5b94366c6aa1.zip
hostap-b125c48fce823f28d22ebd68297c5b94366c6aa1.tar.gz
hostap-b125c48fce823f28d22ebd68297c5b94366c6aa1.tar.bz2
P2P: Add wfd_dev_info= field for device found event
This field allows adds enough information into the P2P-DEVICE-FOUND events to figure out if the peer supports Wi-Fi Display. Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'wpa_supplicant/wifi_display.c')
-rw-r--r--wpa_supplicant/wifi_display.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/wpa_supplicant/wifi_display.c b/wpa_supplicant/wifi_display.c
index 92ca536..578199e 100644
--- a/wpa_supplicant/wifi_display.c
+++ b/wpa_supplicant/wifi_display.c
@@ -16,6 +16,9 @@
#include "wifi_display.h"
+#define WIFI_DISPLAY_SUBELEM_HEADER_LEN 3
+
+
int wifi_display_init(struct wpa_global *global)
{
global->wifi_display = 1;
@@ -249,3 +252,41 @@ int wifi_display_subelem_get(struct wpa_global *global, char *cmd,
1,
wpabuf_len(global->wfd_subelem[subelem]) - 1);
}
+
+
+char * wifi_display_subelem_hex(const struct wpabuf *wfd_subelems, u8 id)
+{
+ char *subelem = NULL;
+ const u8 *buf;
+ size_t buflen;
+ size_t i = 0;
+ u16 elen;
+
+ if (!wfd_subelems)
+ return NULL;
+
+ buf = wpabuf_head_u8(wfd_subelems);
+ if (!buf)
+ return NULL;
+
+ buflen = wpabuf_len(wfd_subelems);
+
+ while (i + WIFI_DISPLAY_SUBELEM_HEADER_LEN < buflen) {
+ elen = WPA_GET_BE16(buf + i + 1);
+
+ if (buf[i] == id) {
+ subelem = os_zalloc(2 * elen + 1);
+ if (!subelem)
+ return NULL;
+ wpa_snprintf_hex(subelem, 2 * elen + 1,
+ buf + i +
+ WIFI_DISPLAY_SUBELEM_HEADER_LEN,
+ elen);
+ break;
+ }
+
+ i += elen + WIFI_DISPLAY_SUBELEM_HEADER_LEN;
+ }
+
+ return subelem;
+}