P2P: Add optional "join" argument for p2p_prov_disc command

This can be used to request Provision Discovery Request to be sent
for the purpose of joining a running group, e.g., to request the GO
to display a PIN that we can then use with p2p_connect join command.

Signed-hostap: Jithu Jance <jithu@broadcom.com>
This commit is contained in:
Jithu Jance 2011-12-06 21:28:02 +02:00 committed by Jouni Malinen
parent 61ff2c8080
commit 8c5f730983
8 changed files with 33 additions and 22 deletions

View file

@ -2194,7 +2194,7 @@ struct wpa_driver_ops {
* struct wpa_driver_capa.
*/
int (*p2p_prov_disc_req)(void *priv, const u8 *peer_addr,
u16 config_methods);
u16 config_methods, int join);
/**
* p2p_sd_request - Schedule a service discovery query

View file

@ -101,7 +101,7 @@ Flush P2P peer table and state.
Group Formation
p2p_prov_disc <peer device address> <display|keypad|pbc>
p2p_prov_disc <peer device address> <display|keypad|pbc> [join]
Send P2P provision discovery request to the specified peer. The
parameters for this command are the P2P device address of the peer and
@ -110,6 +110,10 @@ the desired configuration method. For example, "p2p_prov_disc
us and "p2p_prov_disc 02:01:02:03:04:05 keypad" would request the peer
to enter a PIN that we display.
The optional "join" parameter can be used to indicate that this command
is requesting an already running GO to prepare for a new client. This is
mainly used with "display" to request it to display a PIN.
p2p_connect <peer device address> <pbc|pin|PIN#> [display|keypad]
[persistent] [join|auth] [go_intent=<0..15>] [freq=<in MHz>]

View file

@ -2551,7 +2551,7 @@ static int p2p_ctrl_prov_disc(struct wpa_supplicant *wpa_s, char *cmd)
u8 addr[ETH_ALEN];
char *pos;
/* <addr> <config method> */
/* <addr> <config method> [join] */
if (hwaddr_aton(cmd, addr))
return -1;
@ -2561,7 +2561,8 @@ static int p2p_ctrl_prov_disc(struct wpa_supplicant *wpa_s, char *cmd)
return -1;
pos++;
return wpas_p2p_prov_disc(wpa_s, addr, pos);
return wpas_p2p_prov_disc(wpa_s, addr, pos,
os_strstr(pos, "join") != NULL);
}

View file

@ -692,7 +692,7 @@ DBusMessage * wpas_dbus_handler_p2p_prov_disc_req(DBusMessage *message,
os_strcmp(config_method, "pushbutton"))
return wpas_dbus_error_invalid_args(message, NULL);
if (wpas_p2p_prov_disc(wpa_s, peer_addr, config_method) < 0)
if (wpas_p2p_prov_disc(wpa_s, peer_addr, config_method, 0) < 0)
return wpas_dbus_error_unknown_error(message,
"Failed to send provision discovery request");

View file

@ -569,12 +569,12 @@ static inline int wpa_drv_p2p_set_params(struct wpa_supplicant *wpa_s,
static inline int wpa_drv_p2p_prov_disc_req(struct wpa_supplicant *wpa_s,
const u8 *peer_addr,
u16 config_methods)
u16 config_methods, int join)
{
if (!wpa_s->driver->p2p_prov_disc_req)
return -1;
return wpa_s->driver->p2p_prov_disc_req(wpa_s->drv_priv, peer_addr,
config_methods);
config_methods, join);
}
static inline u64 wpa_drv_p2p_sd_request(struct wpa_supplicant *wpa_s,

View file

@ -3281,30 +3281,32 @@ void wpas_p2p_wps_failed(struct wpa_supplicant *wpa_s,
int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
const char *config_method)
const char *config_method, int join)
{
u16 config_methods;
if (os_strcmp(config_method, "display") == 0)
if (os_strncmp(config_method, "display", 7) == 0)
config_methods = WPS_CONFIG_DISPLAY;
else if (os_strcmp(config_method, "keypad") == 0)
else if (os_strncmp(config_method, "keypad", 6) == 0)
config_methods = WPS_CONFIG_KEYPAD;
else if (os_strcmp(config_method, "pbc") == 0 ||
os_strcmp(config_method, "pushbutton") == 0)
else if (os_strncmp(config_method, "pbc", 3) == 0 ||
os_strncmp(config_method, "pushbutton", 10) == 0)
config_methods = WPS_CONFIG_PUSHBUTTON;
else
else {
wpa_printf(MSG_DEBUG, "P2P: Unknown config method");
return -1;
}
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
return wpa_drv_p2p_prov_disc_req(wpa_s, peer_addr,
config_methods);
config_methods, join);
}
if (wpa_s->global->p2p == NULL || wpa_s->global->p2p_disabled)
return -1;
return p2p_prov_disc_req(wpa_s->global->p2p, peer_addr,
config_methods, 0);
config_methods, join);
}

View file

@ -43,7 +43,7 @@ struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
int registrar);
int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
const char *config_method);
const char *config_method, int join);
void wpas_send_action_tx_status(struct wpa_supplicant *wpa_s, const u8 *dst,
const u8 *data, size_t data_len,
enum p2p_send_action_result result);

View file

@ -2077,15 +2077,19 @@ static int wpa_cli_cmd_p2p_prov_disc(struct wpa_ctrl *ctrl, int argc,
char cmd[128];
int res;
if (argc != 2) {
printf("Invalid P2P_PROV_DISC command: needs two arguments "
"(address and config method\n"
"(display, keypad, or pbc)\n");
if (argc != 2 && argc != 3) {
printf("Invalid P2P_PROV_DISC command: needs at least "
"two arguments, address and config method\n"
"(display, keypad, or pbc) and an optional join\n");
return -1;
}
res = os_snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s %s",
argv[0], argv[1]);
if (argc == 3)
res = os_snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s %s %s",
argv[0], argv[1], argv[2]);
else
res = os_snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s %s",
argv[0], argv[1]);
if (res < 0 || (size_t) res >= sizeof(cmd))
return -1;
cmd[sizeof(cmd) - 1] = '\0';