P2PS: Add option to specify seek strings into P2P_FIND

P2PS seek strings can now be specified in the P2P_FIND control interface
command with one or more optional "seek=<str>" parameters.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Brian Gix 2014-09-05 17:27:20 +03:00 committed by Jouni Malinen
parent 5f18501f46
commit 5177509657
7 changed files with 130 additions and 8 deletions

View file

@ -4483,6 +4483,8 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
u8 dev_type[WPS_DEV_TYPE_LEN], *_dev_type = NULL;
char *pos;
unsigned int search_delay;
const char *seek[P2P_MAX_QUERY_HASH + 1];
u8 seek_count = 0;
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
wpa_dbg(wpa_s, MSG_INFO,
@ -4517,8 +4519,33 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
} else
search_delay = wpas_p2p_search_delay(wpa_s);
/* Must be searched for last, because it adds nul termination */
pos = os_strstr(cmd, " seek=");
while (pos && seek_count < P2P_MAX_QUERY_HASH + 1) {
char *term;
term = os_strchr(pos + 1, ' ');
seek[seek_count++] = pos + 6;
pos = os_strstr(pos + 6, " seek=");
if (term)
*term = '\0';
}
if (!seek_count)
return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL,
_dev_type, _dev_id,
search_delay, 0, NULL);
if (seek_count > P2P_MAX_QUERY_HASH) {
seek[0] = NULL;
return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL,
_dev_type, _dev_id,
search_delay, 1, seek);
}
return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL, _dev_type,
_dev_id, search_delay);
_dev_id, search_delay, seek_count, seek);
}
@ -7654,7 +7681,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_MESH */
#ifdef CONFIG_P2P
} else if (os_strncmp(buf, "P2P_FIND ", 9) == 0) {
if (p2p_ctrl_find(wpa_s, buf + 9))
if (p2p_ctrl_find(wpa_s, buf + 8))
reply_len = -1;
} else if (os_strcmp(buf, "P2P_FIND") == 0) {
if (p2p_ctrl_find(wpa_s, ""))

View file

@ -131,7 +131,7 @@ DBusMessage * wpas_dbus_handler_p2p_find(DBusMessage *message,
wpa_s = wpa_s->p2p_dev;
wpas_p2p_find(wpa_s, timeout, type, num_req_dev_types, req_dev_types,
NULL, 0);
NULL, 0, 0, NULL);
os_free(req_dev_types);
return reply;

View file

@ -5912,7 +5912,8 @@ static void wpas_p2p_clear_pending_action_tx(struct wpa_supplicant *wpa_s)
int wpas_p2p_find(struct wpa_supplicant *wpa_s, unsigned int timeout,
enum p2p_discovery_type type,
unsigned int num_req_dev_types, const u8 *req_dev_types,
const u8 *dev_id, unsigned int search_delay)
const u8 *dev_id, unsigned int search_delay,
u8 seek_cnt, const char **seek_string)
{
wpas_p2p_clear_pending_action_tx(wpa_s);
wpa_s->p2p_long_listen = 0;
@ -5925,7 +5926,7 @@ int wpas_p2p_find(struct wpa_supplicant *wpa_s, unsigned int timeout,
return p2p_find(wpa_s->global->p2p, timeout, type,
num_req_dev_types, req_dev_types, dev_id,
search_delay);
search_delay, seek_cnt, seek_string);
}

View file

@ -55,7 +55,8 @@ enum p2p_discovery_type;
int wpas_p2p_find(struct wpa_supplicant *wpa_s, unsigned int timeout,
enum p2p_discovery_type type,
unsigned int num_req_dev_types, const u8 *req_dev_types,
const u8 *dev_id, unsigned int search_delay);
const u8 *dev_id, unsigned int search_delay,
u8 seek_cnt, const char **seek_string);
void wpas_p2p_stop_find(struct wpa_supplicant *wpa_s);
int wpas_p2p_listen(struct wpa_supplicant *wpa_s, unsigned int timeout);
int wpas_p2p_listen_start(struct wpa_supplicant *wpa_s, unsigned int timeout);