[PATCH 2/2] nl80211: change vif type to P2P_CLI upon p2p authentication

Eliad Peller eliad at wizery.com
Mon Feb 28 06:10:43 EST 2011


Currently, wpa_driver_nl80211_authenticate() changes the
interface type to station. however, in case of p2p, we
need to change the interface type to p2p_cli.

Add p2p field to the authentication params, and
consider it for choosing the correct interface type.

Signed-off-by: Eliad Peller <eliad at wizery.com>
---
 src/drivers/driver.h         |    6 ++++++
 src/drivers/driver_nl80211.c |    7 +++++--
 wpa_supplicant/sme.c         |    1 +
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index b8684fa..27e44ec 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -282,6 +282,12 @@ struct wpa_driver_auth_params {
 	size_t wep_key_len[4];
 	int wep_tx_keyidx;
 	int local_state_change;
+
+	/**
+	 * p2p - Whether this connection is a P2P group
+	 */
+	int p2p;
+
 };
 
 enum wps_mode {
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 52a656d..88b85c3 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -2964,13 +2964,16 @@ static int wpa_driver_nl80211_authenticate(
 	int ret = -1, i;
 	struct nl_msg *msg;
 	enum nl80211_auth_type type;
+	enum nl80211_iftype nlmode;
 	int count = 0;
 
 	drv->associated = 0;
 	os_memset(drv->auth_bssid, 0, ETH_ALEN);
 	/* FIX: IBSS mode */
-	if (drv->nlmode != NL80211_IFTYPE_STATION &&
-	    wpa_driver_nl80211_set_mode(priv, NL80211_IFTYPE_STATION) < 0)
+	nlmode = params->p2p ?
+		NL80211_IFTYPE_P2P_CLIENT : NL80211_IFTYPE_STATION;
+	if (drv->nlmode != nlmode &&
+	    wpa_driver_nl80211_set_mode(priv, nlmode) < 0)
 		return -1;
 
 retry:
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 325ffc5..86d6b6a 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -72,6 +72,7 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
 	params.bssid = bss->bssid;
 	params.ssid = bss->ssid;
 	params.ssid_len = bss->ssid_len;
+	params.p2p = ssid->p2p_group;
 
 	if (wpa_s->sme.ssid_len != params.ssid_len ||
 	    os_memcmp(wpa_s->sme.ssid, params.ssid, params.ssid_len) != 0)
-- 
1.7.0.4



More information about the HostAP mailing list