P2P: Allow requested device type to be specified with p2p_find

This allows filtering of P2P peers that reply to the device discovery
Probe Request frames.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-01-08 20:01:19 +02:00
parent d4c7a2b9e6
commit 2b384109f2
2 changed files with 17 additions and 3 deletions

View file

@ -72,7 +72,8 @@ over the main control interface.
Device Discovery
p2p_find [timeout in seconds] [type=<social|progressive>] \
[dev_id=<addr>] [delay=<search delay in ms>]
[dev_id=<addr>] [dev_type=<device type>] \
[delay=<search delay in ms>]
The default behavior is to run a single full scan in the beginning and
then scan only social channels. type=social will scan only social
@ -87,6 +88,10 @@ search for. The optional delay parameter can be used to request an extra
delay to be used between search iterations (e.g., to free up radio
resources for concurrent operations).
The optional dev_type option can be used to specify a single device type
(primary or secondary) to search for, e.g.,
"p2p_find dev_type=1-0050F204-1".
p2p_listen [timeout in seconds]
Start Listen-only state (become discoverable without searching for

View file

@ -3652,6 +3652,7 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
unsigned int timeout = atoi(cmd);
enum p2p_discovery_type type = P2P_FIND_START_WITH_FULL;
u8 dev_id[ETH_ALEN], *_dev_id = NULL;
u8 dev_type[WPS_DEV_TYPE_LEN], *_dev_type = NULL;
char *pos;
unsigned int search_delay;
@ -3668,6 +3669,14 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
_dev_id = dev_id;
}
pos = os_strstr(cmd, "dev_type=");
if (pos) {
pos += 9;
if (wps_dev_type_str2bin(pos, dev_type) < 0)
return -1;
_dev_type = dev_type;
}
pos = os_strstr(cmd, "delay=");
if (pos) {
pos += 6;
@ -3675,8 +3684,8 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
} else
search_delay = wpas_p2p_search_delay(wpa_s);
return wpas_p2p_find(wpa_s, timeout, type, 0, NULL, _dev_id,
search_delay);
return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL, _dev_type,
_dev_id, search_delay);
}