P2P: Allow Device ID to be specified for p2p_find command

dev_id=<P2P Device Addr> can now be specified as an argument to
p2p_find to request P2P find for a specific P2P device.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2012-01-08 09:25:29 -08:00
parent 68921e24b2
commit 6d92fa6e92
9 changed files with 55 additions and 23 deletions

View file

@ -2451,13 +2451,23 @@ 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;
char *pos;
if (os_strstr(cmd, "type=social"))
type = P2P_FIND_ONLY_SOCIAL;
else if (os_strstr(cmd, "type=progressive"))
type = P2P_FIND_PROGRESSIVE;
return wpas_p2p_find(wpa_s, timeout, type, 0, NULL);
pos = os_strstr(cmd, "dev_id=");
if (pos) {
pos += 7;
if (hwaddr_aton(pos, dev_id))
return -1;
_dev_id = dev_id;
}
return wpas_p2p_find(wpa_s, timeout, type, 0, NULL, _dev_id);
}

View file

@ -131,7 +131,8 @@ DBusMessage * wpas_dbus_handler_p2p_find(DBusMessage *message,
wpa_dbus_dict_entry_clear(&entry);
}
wpas_p2p_find(wpa_s, timeout, type, num_req_dev_types, req_dev_types);
wpas_p2p_find(wpa_s, timeout, type, num_req_dev_types, req_dev_types,
NULL);
os_free(req_dev_types);
return reply;

View file

@ -94,7 +94,7 @@ static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s,
static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq,
unsigned int num_req_dev_types,
const u8 *req_dev_types)
const u8 *req_dev_types, const u8 *dev_id)
{
struct wpa_supplicant *wpa_s = ctx;
struct wpa_driver_scan_params params;
@ -130,7 +130,7 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq,
wpabuf_put_buf(ies, wps_ie);
wpabuf_free(wps_ie);
p2p_scan_ie(wpa_s->global->p2p, ies);
p2p_scan_ie(wpa_s->global->p2p, ies, dev_id);
params.p2p_probe = 1;
params.extra_ies = wpabuf_head(ies);
@ -2667,7 +2667,7 @@ static void wpas_p2p_join_scan(void *eloop_ctx, void *timeout_ctx)
wpabuf_put_buf(ies, wps_ie);
wpabuf_free(wps_ie);
p2p_scan_ie(wpa_s->global->p2p, ies);
p2p_scan_ie(wpa_s->global->p2p, ies, NULL);
params.p2p_probe = 1;
params.extra_ies = wpabuf_head(ies);
@ -3459,7 +3459,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)
unsigned int num_req_dev_types, const u8 *req_dev_types,
const u8 *dev_id)
{
wpas_p2p_clear_pending_action_tx(wpa_s);
wpa_s->p2p_long_listen = 0;
@ -3471,7 +3472,7 @@ int wpas_p2p_find(struct wpa_supplicant *wpa_s, unsigned int timeout,
return -1;
return p2p_find(wpa_s->global->p2p, timeout, type,
num_req_dev_types, req_dev_types);
num_req_dev_types, req_dev_types, dev_id);
}
@ -3599,7 +3600,7 @@ void wpas_p2p_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ies)
if (wpa_s->global->p2p == NULL)
return;
p2p_scan_ie(wpa_s->global->p2p, ies);
p2p_scan_ie(wpa_s->global->p2p, ies, NULL);
}

View file

@ -52,7 +52,8 @@ int wpas_p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
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);
unsigned int num_req_dev_types, const u8 *req_dev_types,
const u8 *dev_id);
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_assoc_req_ie(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,

View file

@ -1930,7 +1930,10 @@ static int wpa_cli_cmd_p2p_find(struct wpa_ctrl *ctrl, int argc, char *argv[])
if (argc == 0)
return wpa_ctrl_command(ctrl, "P2P_FIND");
if (argc > 1)
if (argc > 2)
res = os_snprintf(cmd, sizeof(cmd), "P2P_FIND %s %s %s",
argv[0], argv[1], argv[2]);
else if (argc > 1)
res = os_snprintf(cmd, sizeof(cmd), "P2P_FIND %s %s",
argv[0], argv[1]);
else