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:
parent
61ff2c8080
commit
8c5f730983
8 changed files with 33 additions and 22 deletions
|
@ -2194,7 +2194,7 @@ struct wpa_driver_ops {
|
||||||
* struct wpa_driver_capa.
|
* struct wpa_driver_capa.
|
||||||
*/
|
*/
|
||||||
int (*p2p_prov_disc_req)(void *priv, const u8 *peer_addr,
|
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
|
* p2p_sd_request - Schedule a service discovery query
|
||||||
|
|
|
@ -101,7 +101,7 @@ Flush P2P peer table and state.
|
||||||
|
|
||||||
Group Formation
|
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
|
Send P2P provision discovery request to the specified peer. The
|
||||||
parameters for this command are the P2P device address of the peer and
|
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
|
us and "p2p_prov_disc 02:01:02:03:04:05 keypad" would request the peer
|
||||||
to enter a PIN that we display.
|
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]
|
p2p_connect <peer device address> <pbc|pin|PIN#> [display|keypad]
|
||||||
[persistent] [join|auth] [go_intent=<0..15>] [freq=<in MHz>]
|
[persistent] [join|auth] [go_intent=<0..15>] [freq=<in MHz>]
|
||||||
|
|
||||||
|
|
|
@ -2551,7 +2551,7 @@ static int p2p_ctrl_prov_disc(struct wpa_supplicant *wpa_s, char *cmd)
|
||||||
u8 addr[ETH_ALEN];
|
u8 addr[ETH_ALEN];
|
||||||
char *pos;
|
char *pos;
|
||||||
|
|
||||||
/* <addr> <config method> */
|
/* <addr> <config method> [join] */
|
||||||
|
|
||||||
if (hwaddr_aton(cmd, addr))
|
if (hwaddr_aton(cmd, addr))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2561,7 +2561,8 @@ static int p2p_ctrl_prov_disc(struct wpa_supplicant *wpa_s, char *cmd)
|
||||||
return -1;
|
return -1;
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
return wpas_p2p_prov_disc(wpa_s, addr, pos);
|
return wpas_p2p_prov_disc(wpa_s, addr, pos,
|
||||||
|
os_strstr(pos, "join") != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -692,7 +692,7 @@ DBusMessage * wpas_dbus_handler_p2p_prov_disc_req(DBusMessage *message,
|
||||||
os_strcmp(config_method, "pushbutton"))
|
os_strcmp(config_method, "pushbutton"))
|
||||||
return wpas_dbus_error_invalid_args(message, NULL);
|
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,
|
return wpas_dbus_error_unknown_error(message,
|
||||||
"Failed to send provision discovery request");
|
"Failed to send provision discovery request");
|
||||||
|
|
||||||
|
|
|
@ -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,
|
static inline int wpa_drv_p2p_prov_disc_req(struct wpa_supplicant *wpa_s,
|
||||||
const u8 *peer_addr,
|
const u8 *peer_addr,
|
||||||
u16 config_methods)
|
u16 config_methods, int join)
|
||||||
{
|
{
|
||||||
if (!wpa_s->driver->p2p_prov_disc_req)
|
if (!wpa_s->driver->p2p_prov_disc_req)
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_s->driver->p2p_prov_disc_req(wpa_s->drv_priv, peer_addr,
|
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,
|
static inline u64 wpa_drv_p2p_sd_request(struct wpa_supplicant *wpa_s,
|
||||||
|
|
|
@ -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,
|
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;
|
u16 config_methods;
|
||||||
|
|
||||||
if (os_strcmp(config_method, "display") == 0)
|
if (os_strncmp(config_method, "display", 7) == 0)
|
||||||
config_methods = WPS_CONFIG_DISPLAY;
|
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;
|
config_methods = WPS_CONFIG_KEYPAD;
|
||||||
else if (os_strcmp(config_method, "pbc") == 0 ||
|
else if (os_strncmp(config_method, "pbc", 3) == 0 ||
|
||||||
os_strcmp(config_method, "pushbutton") == 0)
|
os_strncmp(config_method, "pushbutton", 10) == 0)
|
||||||
config_methods = WPS_CONFIG_PUSHBUTTON;
|
config_methods = WPS_CONFIG_PUSHBUTTON;
|
||||||
else
|
else {
|
||||||
|
wpa_printf(MSG_DEBUG, "P2P: Unknown config method");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
|
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
|
||||||
return wpa_drv_p2p_prov_disc_req(wpa_s, peer_addr,
|
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)
|
if (wpa_s->global->p2p == NULL || wpa_s->global->p2p_disabled)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return p2p_prov_disc_req(wpa_s->global->p2p, peer_addr,
|
return p2p_prov_disc_req(wpa_s->global->p2p, peer_addr,
|
||||||
config_methods, 0);
|
config_methods, join);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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,
|
void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
|
||||||
int registrar);
|
int registrar);
|
||||||
int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
|
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,
|
void wpas_send_action_tx_status(struct wpa_supplicant *wpa_s, const u8 *dst,
|
||||||
const u8 *data, size_t data_len,
|
const u8 *data, size_t data_len,
|
||||||
enum p2p_send_action_result result);
|
enum p2p_send_action_result result);
|
||||||
|
|
|
@ -2077,13 +2077,17 @@ static int wpa_cli_cmd_p2p_prov_disc(struct wpa_ctrl *ctrl, int argc,
|
||||||
char cmd[128];
|
char cmd[128];
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2 && argc != 3) {
|
||||||
printf("Invalid P2P_PROV_DISC command: needs two arguments "
|
printf("Invalid P2P_PROV_DISC command: needs at least "
|
||||||
"(address and config method\n"
|
"two arguments, address and config method\n"
|
||||||
"(display, keypad, or pbc)\n");
|
"(display, keypad, or pbc) and an optional join\n");
|
||||||
return -1;
|
return -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",
|
res = os_snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s %s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (res < 0 || (size_t) res >= sizeof(cmd))
|
if (res < 0 || (size_t) res >= sizeof(cmd))
|
||||||
|
|
Loading…
Reference in a new issue