]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Allow requested device type to be specified with p2p_find
authorJouni Malinen <j@w1.fi>
Wed, 8 Jan 2014 18:01:19 +0000 (20:01 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 8 Jan 2014 18:01:19 +0000 (20:01 +0200)
This allows filtering of P2P peers that reply to the device discovery
Probe Request frames.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/README-P2P
wpa_supplicant/ctrl_iface.c

index 08d39e246656e5284d57ed799a4e3470e068c2ca..7354bbf039d8cba3c7e9695ae228fcf8d85f2c39 100644 (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
index b4dcb39c5fb7cdf18447fe155817a32a680d6654..3f53691aad93f73ecc6ea4cf2b962408a482d1d0 100644 (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);
 }