P2P: Set user_initiated_pd separately from the join parameter

p2p_prov_disc_req() used the join parameter to figure out whether the PD
request was a user initiated or not. This does not cover all use cases
of PD, so add a separate parameter to allow caller to indicate whether
the user requested the operation.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Sunil Dutt 2012-11-23 00:48:58 +02:00 committed by Jouni Malinen
parent 16e38f2e34
commit 6752716663
5 changed files with 13 additions and 11 deletions

View file

@ -958,6 +958,7 @@ int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr);
* @config_methods: WPS Config Methods value (only one bit set)
* @join: Whether this is used by a client joining an active group
* @force_freq: Forced TX frequency for the frame (mainly for the join case)
* @user_initiated_pd: Flag to indicate if initiated by user or not
* Returns: 0 on success, -1 on failure
*
* This function can be used to request a discovered P2P peer to display a PIN
@ -969,7 +970,8 @@ int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr);
* indicated with the p2p_config::prov_disc_resp() callback.
*/
int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
u16 config_methods, int join, int force_freq);
u16 config_methods, int join, int force_freq,
int user_initiated_pd);
/**
* p2p_sd_request - Schedule a service discovery query

View file

@ -211,7 +211,7 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
else
return -1;
return p2p_prov_disc_req(p2p, dev->info.p2p_device_addr,
config_method, 0, 0);
config_method, 0, 0, 1);
}
freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;

View file

@ -408,7 +408,8 @@ int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
u16 config_methods, int join, int force_freq)
u16 config_methods, int join, int force_freq,
int user_initiated_pd)
{
struct p2p_device *dev;
@ -446,11 +447,7 @@ int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
return 0;
}
/*
* We use the join param as a cue to differentiate between user
* initiated PD request and one issued during finds (internal).
*/
p2p->user_initiated_pd = !join;
p2p->user_initiated_pd = user_initiated_pd;
if (p2p->user_initiated_pd)
p2p->pd_retries = MAX_PROV_DISC_REQ_RETRIES;

View file

@ -2420,6 +2420,7 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid,
wpas_p2p_group_add_persistent(
wpa_s, s, go, go ? op_freq : 0, 0);
} else if (bssid) {
wpa_s->user_initiated_pd = 0;
wpas_p2p_join(wpa_s, bssid, go_dev_addr,
wpa_s->p2p_wps_method, 0);
}
@ -3251,7 +3252,7 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
if (p2p_prov_disc_req(wpa_s->global->p2p,
wpa_s->pending_join_dev_addr,
wpa_s->pending_pd_config_methods, join,
0) < 0) {
0, wpa_s->user_initiated_pd) < 0) {
wpa_s->p2p_auto_pd = 0;
wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_FAILURE
" p2p_dev_addr=" MACSTR " status=N/A",
@ -3361,7 +3362,7 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
if (p2p_prov_disc_req(wpa_s->global->p2p,
wpa_s->pending_join_dev_addr, method, 1,
freq) < 0) {
freq, wpa_s->user_initiated_pd) < 0) {
wpa_printf(MSG_DEBUG, "P2P: Failed to send Provision "
"Discovery Request before joining an "
"existing group");
@ -3636,6 +3637,7 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
wpa_s->p2p_auto_started.sec,
wpa_s->p2p_auto_started.usec);
}
wpa_s->user_initiated_pd = 1;
if (wpas_p2p_join(wpa_s, iface_addr, dev_addr, wps_method,
auto_join) < 0)
return -1;
@ -4334,7 +4336,7 @@ int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
return p2p_prov_disc_req(wpa_s->global->p2p, peer_addr,
config_methods, use == WPAS_P2P_PD_FOR_JOIN,
0);
0, 1);
}

View file

@ -565,6 +565,7 @@ struct wpa_supplicant {
unsigned int p2p_fallback_to_go_neg:1;
unsigned int p2p_pd_before_go_neg:1;
unsigned int p2p_go_ht40:1;
unsigned int user_initiated_pd:1;
int p2p_persistent_go_freq;
int p2p_persistent_id;
int p2p_go_intent;