aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2012-05-11 16:25:47 +0300
committerJouni Malinen <j@w1.fi>2012-05-11 16:25:47 +0300
commit3bc462cb88e0ffa2fe5b891b7539eb39757a5315 (patch)
tree8df810190c15168725eb29c20cf9e612daa8a3aa
parent1cbe86e2d6d2b5a7d072093ce1a94082b4b3f472 (diff)
downloadexternal_wpa_supplicant_8_ti-3bc462cb88e0ffa2fe5b891b7539eb39757a5315.zip
external_wpa_supplicant_8_ti-3bc462cb88e0ffa2fe5b891b7539eb39757a5315.tar.gz
external_wpa_supplicant_8_ti-3bc462cb88e0ffa2fe5b891b7539eb39757a5315.tar.bz2
P2P: Add option for Provision Discovery before GO Negotiation
This is a workaround for interoperability issues with some deployed P2P implementations that require a Provision Discovery exchange to be used before GO Negotiation. The new provdisc parameter for the p2p_connect command can be used to request this behavior without having to run a separate p2p_prov_disc command. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
-rw-r--r--src/drivers/driver_test.c2
-rw-r--r--src/p2p/p2p.c11
-rw-r--r--src/p2p/p2p.h6
-rw-r--r--src/p2p/p2p_go_neg.c17
-rw-r--r--src/p2p/p2p_i.h1
-rw-r--r--src/p2p/p2p_pd.c9
-rw-r--r--wpa_supplicant/README-P2P7
-rw-r--r--wpa_supplicant/ctrl_iface.c6
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_p2p.c2
-rw-r--r--wpa_supplicant/p2p_supplicant.c14
-rw-r--r--wpa_supplicant/p2p_supplicant.h3
-rw-r--r--wpa_supplicant/wpa_supplicant_i.h1
12 files changed, 65 insertions, 14 deletions
diff --git a/src/drivers/driver_test.c b/src/drivers/driver_test.c
index 06cc349..c18eaad 100644
--- a/src/drivers/driver_test.c
+++ b/src/drivers/driver_test.c
@@ -2868,7 +2868,7 @@ static int wpa_driver_test_p2p_connect(void *priv, const u8 *peer_addr,
return -1;
return p2p_connect(drv->p2p, peer_addr, wps_method, go_intent,
own_interface_addr, force_freq, persistent_group,
- NULL, 0);
+ NULL, 0, 0);
}
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 2b084e7..deccfc0 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1173,16 +1173,17 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
enum p2p_wps_method wps_method,
int go_intent, const u8 *own_interface_addr,
unsigned int force_freq, int persistent_group,
- const u8 *force_ssid, size_t force_ssid_len)
+ const u8 *force_ssid, size_t force_ssid_len,
+ int pd_before_go_neg)
{
struct p2p_device *dev;
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
"P2P: Request to start group negotiation - peer=" MACSTR
" GO Intent=%d Intended Interface Address=" MACSTR
- " wps_method=%d persistent_group=%d",
+ " wps_method=%d persistent_group=%d pd_before_go_neg=%d",
MAC2STR(peer_addr), go_intent, MAC2STR(own_interface_addr),
- wps_method, persistent_group);
+ wps_method, persistent_group, pd_before_go_neg);
if (p2p_prepare_channel(p2p, force_freq) < 0)
return -1;
@@ -1232,6 +1233,10 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
dev->flags &= ~P2P_DEV_USER_REJECTED;
dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE;
dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM;
+ if (pd_before_go_neg)
+ dev->flags |= P2P_DEV_PD_BEFORE_GO_NEG;
+ else
+ dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG;
dev->connect_reqs = 0;
dev->go_neg_req_sent = 0;
dev->go_state = UNKNOWN_GO;
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 92e7048..a759adf 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -880,13 +880,17 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout);
* @force_ssid: Forced SSID for the group if we become GO or %NULL to generate
* a new SSID
* @force_ssid_len: Length of $force_ssid buffer
+ * @pd_before_go_neg: Whether to send Provision Discovery prior to GO
+ * Negotiation as an interoperability workaround when initiating group
+ * formation
* Returns: 0 on success, -1 on failure
*/
int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
enum p2p_wps_method wps_method,
int go_intent, const u8 *own_interface_addr,
unsigned int force_freq, int persistent_group,
- const u8 *force_ssid, size_t force_ssid_len);
+ const u8 *force_ssid, size_t force_ssid_len,
+ int pd_before_go_neg);
/**
* p2p_authorize - Authorize P2P group formation (GO negotiation)
diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
index 230948d..2bf48b3 100644
--- a/src/p2p/p2p_go_neg.c
+++ b/src/p2p/p2p_go_neg.c
@@ -184,6 +184,23 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
struct wpabuf *req;
int freq;
+ if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) {
+ u16 config_method;
+ wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
+ "P2P: Use PD-before-GO-Neg workaround for " MACSTR,
+ MAC2STR(dev->info.p2p_device_addr));
+ if (dev->wps_method == WPS_PIN_DISPLAY)
+ config_method = WPS_CONFIG_KEYPAD;
+ else if (dev->wps_method == WPS_PIN_KEYPAD)
+ config_method = WPS_CONFIG_DISPLAY;
+ else if (dev->wps_method == WPS_PBC)
+ config_method = WPS_CONFIG_PUSHBUTTON;
+ else
+ return -1;
+ return p2p_prov_disc_req(p2p, dev->info.p2p_device_addr,
+ config_method, 0, 0);
+ }
+
freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;
if (freq <= 0) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index 279225c..39e879e 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -90,6 +90,7 @@ struct p2p_device {
#define P2P_DEV_PD_FOR_JOIN BIT(14)
#define P2P_DEV_REPORTED_ONCE BIT(15)
#define P2P_DEV_PREFER_PERSISTENT_RECONN BIT(16)
+#define P2P_DEV_PD_BEFORE_GO_NEG BIT(17)
unsigned int flags;
int status; /* enum p2p_status_code */
diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c
index 6e251c5..7b47927 100644
--- a/src/p2p/p2p_pd.c
+++ b/src/p2p/p2p_pd.c
@@ -288,6 +288,15 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
out:
dev->req_config_methods = 0;
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
+ if (dev->flags & P2P_DEV_PD_BEFORE_GO_NEG) {
+ wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
+ "P2P: Start GO Neg after the PD-before-GO-Neg "
+ "workaround with " MACSTR,
+ MAC2STR(dev->info.p2p_device_addr));
+ dev->flags &= ~P2P_DEV_PD_BEFORE_GO_NEG;
+ p2p_connect_send(p2p, dev);
+ return;
+ }
if (success && p2p->cfg->prov_disc_resp)
p2p->cfg->prov_disc_resp(p2p->cfg->cb_ctx, sa,
report_config_methods);
diff --git a/wpa_supplicant/README-P2P b/wpa_supplicant/README-P2P
index 090b3a9..1011fd8 100644
--- a/wpa_supplicant/README-P2P
+++ b/wpa_supplicant/README-P2P
@@ -119,7 +119,7 @@ join-a-group style PD instead of GO Negotiation style PD.
p2p_connect <peer device address> <pbc|pin|PIN#> [display|keypad]
[persistent|persistent=<network id>] [join|auth]
- [go_intent=<0..15>] [freq=<in MHz>]
+ [go_intent=<0..15>] [freq=<in MHz>] [provdisc]
Start P2P group formation with a discovered P2P peer. This includes
optional group owner negotiation, group interface setup, provisioning,
@@ -155,6 +155,11 @@ Negotiation.
"freq" can be used to set a forced operating channel (e.g., freq=2412
to select 2.4 GHz channel 1).
+"provdisc" can be used to request a Provision Discovery exchange to be
+used prior to starting GO Negotiation as a workaround with some deployed
+P2P implementations that require this to allow the user to accept the
+connection.
+
p2p_group_add [persistent|persistent=<network id>] [freq=<freq in MHz>]
Set up a P2P group owner manually (i.e., without group owner
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 4361f79..2d17c48 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2824,10 +2824,11 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
int automatic;
int go_intent = -1;
int freq = 0;
+ int pd;
/* <addr> <"pbc" | "pin" | PIN> [label|display|keypad]
* [persistent|persistent=<network id>]
- * [join] [auth] [go_intent=<0..15>] [freq=<in MHz>] */
+ * [join] [auth] [go_intent=<0..15>] [freq=<in MHz>] [provdisc] */
if (hwaddr_aton(cmd, addr))
return -1;
@@ -2854,6 +2855,7 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
join = os_strstr(pos, " join") != NULL;
auth = os_strstr(pos, " auth") != NULL;
automatic = os_strstr(pos, " auto") != NULL;
+ pd = os_strstr(pos, " provdisc") != NULL;
pos2 = os_strstr(pos, " go_intent=");
if (pos2) {
@@ -2889,7 +2891,7 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
persistent_group, automatic, join,
- auth, go_intent, freq, persistent_id);
+ auth, go_intent, freq, persistent_id, pd);
if (new_pin == -2) {
os_memcpy(buf, "FAIL-CHANNEL-UNAVAILABLE\n", 25);
return 25;
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index 45d6906..f4541f7 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -504,7 +504,7 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
persistent_group, 0, join, authorize_only,
- go_intent, freq, -1);
+ go_intent, freq, -1, 0);
if (new_pin >= 0) {
char npin[9];
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index c9d075f..585384a 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -2611,7 +2611,8 @@ static int wpas_p2p_start_go_neg(struct wpa_supplicant *wpa_s,
return p2p_connect(wpa_s->global->p2p, peer_addr, wps_method,
go_intent, own_interface_addr, force_freq,
persistent_group, ssid ? ssid->ssid : NULL,
- ssid ? ssid->ssid_len : 0);
+ ssid ? ssid->ssid_len : 0,
+ wpa_s->p2p_pd_before_go_neg);
}
@@ -2791,7 +2792,8 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
wpa_s->p2p_persistent_group, 0, 0, 0,
wpa_s->p2p_go_intent,
wpa_s->p2p_connect_freq,
- wpa_s->p2p_persistent_id);
+ wpa_s->p2p_persistent_id,
+ wpa_s->p2p_pd_before_go_neg);
return;
}
@@ -3064,6 +3066,8 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s)
* @freq: Frequency for the group or 0 for auto-selection
* @persistent_id: Persistent group credentials to use for forcing GO
* parameters or -1 to generate new values (SSID/passphrase)
+ * @pd: Whether to send Provision Discovery prior to GO Negotiation as an
+ * interoperability workaround when initiating group formation
* Returns: 0 or new PIN (if pin was %NULL) on success, -1 on unspecified
* failure, -2 on failure due to channel not currently available,
* -3 if forced channel is not supported
@@ -3071,7 +3075,7 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s)
int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
const char *pin, enum p2p_wps_method wps_method,
int persistent_group, int auto_join, int join, int auth,
- int go_intent, int freq, int persistent_id)
+ int go_intent, int freq, int persistent_id, int pd)
{
int force_freq = 0, oper_freq = 0;
u8 bssid[ETH_ALEN];
@@ -3102,6 +3106,7 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
wpa_s->p2p_go_intent = go_intent;
wpa_s->p2p_connect_freq = freq;
wpa_s->p2p_fallback_to_go_neg = 0;
+ wpa_s->p2p_pd_before_go_neg = !!pd;
if (pin)
os_strlcpy(wpa_s->p2p_pin, pin, sizeof(wpa_s->p2p_pin));
@@ -4845,7 +4850,8 @@ static void wpas_p2p_fallback_to_go_neg(struct wpa_supplicant *wpa_s,
wpas_p2p_connect(wpa_s, wpa_s->pending_join_dev_addr, wpa_s->p2p_pin,
wpa_s->p2p_wps_method, wpa_s->p2p_persistent_group, 0,
0, 0, wpa_s->p2p_go_intent, wpa_s->p2p_connect_freq,
- wpa_s->p2p_persistent_id);
+ wpa_s->p2p_persistent_id,
+ wpa_s->p2p_pd_before_go_neg);
}
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index 87fde00..e2fe259 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -20,7 +20,8 @@ void wpas_p2p_deinit_global(struct wpa_global *global);
int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
const char *pin, enum p2p_wps_method wps_method,
int persistent_group, int auto_join, int join,
- int auth, int go_intent, int freq, int persistent_id);
+ int auth, int go_intent, int freq, int persistent_id,
+ int pd);
void wpas_p2p_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
unsigned int freq, unsigned int duration);
void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 012732b..23ffd7d 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -520,6 +520,7 @@ struct wpa_supplicant {
unsigned int p2p_auto_pd:1;
unsigned int p2p_persistent_group:1;
unsigned int p2p_fallback_to_go_neg:1;
+ unsigned int p2p_pd_before_go_neg:1;
int p2p_persistent_id;
int p2p_go_intent;
int p2p_connect_freq;