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>
This commit is contained in:
parent
e706d2d30d
commit
b125c48fce
3 changed files with 56 additions and 3 deletions
|
@ -33,6 +33,7 @@
|
|||
#include "offchannel.h"
|
||||
#include "wps_supplicant.h"
|
||||
#include "p2p_supplicant.h"
|
||||
#include "wifi_display.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1442,18 +1443,28 @@ void wpas_dev_found(void *ctx, const u8 *addr,
|
|||
#ifndef CONFIG_NO_STDOUT_DEBUG
|
||||
struct wpa_supplicant *wpa_s = ctx;
|
||||
char devtype[WPS_DEV_TYPE_BUFSIZE];
|
||||
char *wfd_dev_info_hex = NULL;
|
||||
|
||||
#ifdef CONFIG_WIFI_DISPLAY
|
||||
wfd_dev_info_hex = wifi_display_subelem_hex(info->wfd_subelems,
|
||||
WFD_SUBELEM_DEVICE_INFO);
|
||||
#endif /* CONFIG_WIFI_DISPLAY */
|
||||
|
||||
wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_DEVICE_FOUND MACSTR
|
||||
" p2p_dev_addr=" MACSTR
|
||||
" pri_dev_type=%s name='%s' config_methods=0x%x "
|
||||
"dev_capab=0x%x group_capab=0x%x",
|
||||
"dev_capab=0x%x group_capab=0x%x%s%s",
|
||||
MAC2STR(addr), MAC2STR(info->p2p_device_addr),
|
||||
wps_dev_type_bin2str(info->pri_dev_type, devtype,
|
||||
sizeof(devtype)),
|
||||
info->device_name, info->config_methods,
|
||||
info->dev_capab, info->group_capab);
|
||||
info->dev_capab, info->group_capab,
|
||||
wfd_dev_info_hex ? " wfd_dev_info=0x" : "",
|
||||
wfd_dev_info_hex ? wfd_dev_info_hex : "");
|
||||
#endif /* CONFIG_NO_STDOUT_DEBUG */
|
||||
|
||||
os_free(wfd_dev_info_hex);
|
||||
|
||||
wpas_notify_p2p_device_found(ctx, info->p2p_device_addr, new_device);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -16,5 +16,6 @@ void wifi_display_enable(struct wpa_global *global, int enabled);
|
|||
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);
|
||||
char * wifi_display_subelem_hex(const struct wpabuf *wfd_subelems, u8 id);
|
||||
|
||||
#endif /* WIFI_DISPLAY_H */
|
||||
|
|
Loading…
Reference in a new issue