Skip to contentSkip to conversation

nl80211 connect API support

PATCH In review Zhu Yi 2 participants 3 messages Aug 17, 2009 – Sep 4, 2009

lore
Share & tools
lore

Zhu Yi

author
#0 lore raw

PATCH v2 1/1 nl80211 connect API support

nl80211 driver connect API support.

Cc Johannes Berg <[email protected]>
Cc Samuel Ortiz <[email protected]>

---
V2: Use auth/assoc as the default operations if they are supported.

src/common/ieee802_11_defs.h +15 -0
index b4c804e..e1bd487 100644
@@ -679,4 +679,19 @@ enum {
 
 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
 
+/* cipher suite selectors */
+#define WLAN_CIPHER_SUITE_USE_GROUP	0x000FAC00
+#define WLAN_CIPHER_SUITE_WEP40		0x000FAC01
+#define WLAN_CIPHER_SUITE_TKIP		0x000FAC02
+/* reserved: 				0x000FAC03 */
+#define WLAN_CIPHER_SUITE_CCMP		0x000FAC04
+#define WLAN_CIPHER_SUITE_WEP104	0x000FAC05
+#define WLAN_CIPHER_SUITE_AES_CMAC	0x000FAC06
+
+/* AKM suite selectors */
+#define WLAN_AKM_SUITE_8021X		0x000FAC01
+#define WLAN_AKM_SUITE_PSK		0x000FAC02
+
+#define WLAN_MAX_KEY_LEN		32
+
 #endif /* IEEE802_11_DEFS_H */
src/common/nl80211_copy.h +65 -0

81 lines not on this page · raw message

src/drivers/driver.h +18 -1
index 2ae5b1a..fcb602b 100644
@@ -441,9 +441,11 @@ struct wpa_driver_capa {
 #define WPA_DRIVER_FLAGS_WIRED		0x00000010
 /* Driver provides separate commands for authentication and association (SME in
  * wpa_supplicant). */
-#define WPA_DRIVER_FLAGS_SME		0x00000020
+#define WPA_DRIVER_FLAGS_SME_AUTH	0x00000020
 /* Driver supports AP mode */
 #define WPA_DRIVER_FLAGS_AP		0x00000040
+/* Driver supports connect API */
+#define WPA_DRIVER_FLAGS_SME_CONNECT	0x00000080
 	unsigned int flags;
 
 	int max_scan_ssids;
@@ -1333,6 +1335,21 @@ struct wpa_driver_ops {
 	 * Returns: 0 on success, -1 on failure
 	 */
 	int (*set_supp_port)(void *priv, int authorized);
+
+	/**
+	 * connect - Request driver to connect
+	 * @priv: private driver interface data
+	 * @params: connect parameters
+	 * Returns: 0 on success, -1 on failure
+	 *
+	 * This is an optional function that can be used with drivers that
+	 * support connect (both authentication and association) API. If
+	 * driver SME is not supported (both connect and authenticate are
+	 * not implemented), associate() function is expected to take care
+	 * of IEEE 802.11 authentication and association, too.
+	 */
+	int (*connect)(void *priv, struct wpa_driver_associate_params *params);
+	int (*disconnect)(void *priv, u8 *addr, int reason_code);
 };
 
 /**
src/drivers/driver_nl80211.c +288 -7

363 lines not on this page · raw message

wpa_supplicant/driver_i.h +18 -0
index 4cb5372..e5a8ef4 100644
@@ -448,4 +448,22 @@ static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s,
 	return 0;
 }
 
+static inline int wpa_drv_connect(struct wpa_supplicant *wpa_s,
+				  struct wpa_driver_associate_params *params)
+{
+	if (wpa_s->driver->connect)
+		return wpa_s->driver->connect(wpa_s->drv_priv, params);
+
+	return -1;
+}
+
+static inline int wpa_drv_disconnect(struct wpa_supplicant *wpa_s, u8 *addr,
+				     int reason_code)
+{
+	if (wpa_s->driver->disconnect)
+		return wpa_s->driver->disconnect(wpa_s->drv_priv, addr,
+						 reason_code);
+	return -1;
+}
+
 #endif /* DRIVER_I_H */
wpa_supplicant/sme.c +169 -0

175 lines not on this page · raw message

wpa_supplicant/sme.h +8 -0
index 2780041..fd5ea9c 100644
@@ -19,6 +19,8 @@
 
 void sme_authenticate(struct wpa_supplicant *wpa_s,
 		      struct wpa_scan_res *bss, struct wpa_ssid *ssid);
+void sme_connect(struct wpa_supplicant *wpa_s, struct wpa_scan_res *bss,
+		 struct wpa_ssid *ssid);
 void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data);
 int sme_update_ft_ies(struct wpa_supplicant *wpa_s, const u8 *md,
 		      const u8 *ies, size_t ies_len);
@@ -37,6 +39,12 @@ static inline void sme_authenticate(struct wpa_supplicant *wpa_s,
 {
 }
 
+static inline void sme_connect(struct wpa_supplicant *wpa_s,
+			       struct wpa_scan_res *bss,
+			       struct wpa_ssid *ssid)
+{
+}
+
 static inline void sme_event_auth(struct wpa_supplicant *wpa_s,
 				  union wpa_event_data *data)
 {
wpa_supplicant/wpa_supplicant.c +12 -4
index f1f929a..4282b14 100644
@@ -640,7 +640,7 @@ static void wpa_supplicant_reconfig(int sig, void *eloop_ctx,
 }
 
 
-static wpa_cipher cipher_suite2driver(int cipher)
+wpa_cipher cipher_suite2driver(int cipher)
 {
 	switch (cipher) {
 	case WPA_CIPHER_NONE:
@@ -658,7 +658,7 @@ static wpa_cipher cipher_suite2driver(int cipher)
 }
 
 
-static wpa_key_mgmt key_mgmt2driver(int key_mgmt)
+wpa_key_mgmt key_mgmt2driver(int key_mgmt)
 {
 	switch (key_mgmt) {
 	case WPA_KEY_MGMT_NONE:
@@ -965,11 +965,16 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
 		return;
 	}
 
-	if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) {
+	if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME_AUTH) {
 		sme_authenticate(wpa_s, bss, ssid);
 		return;
 	}
 
+	if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME_CONNECT) {
+		sme_connect(wpa_s, bss, ssid);
+		return;
+	}
+
 	wpa_s->reassociate = 0;
 	if (bss) {
 #ifdef CONFIG_IEEE80211R
@@ -1303,9 +1308,12 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
 	if (!is_zero_ether_addr(wpa_s->bssid)) {
 		if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
 			ieee80211_sta_deauthenticate(wpa_s, reason_code);
-		else
+		else if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME_AUTH)
 			wpa_drv_deauthenticate(wpa_s, wpa_s->bssid,
 					       reason_code);
+		else if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME_CONNECT)
+			wpa_drv_disconnect(wpa_s, wpa_s->bssid, reason_code);
+
 		addr = wpa_s->bssid;
 	}
 	wpa_clear_keys(wpa_s, addr);
wpa_supplicant/wpa_supplicant_i.h +2 -0
index 63984d8..13896d9 100644
@@ -392,6 +392,8 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
 
 const char * wpa_supplicant_state_txt(int state);
 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
+wpa_cipher cipher_suite2driver(int cipher);
+wpa_key_mgmt key_mgmt2driver(int key_mgmt);
 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
 			      struct wpa_scan_res *bss,
 			      struct wpa_ssid *ssid,
wpa_supplicant/wpas_glue.c +1 -1
index b1f8bf8..3cfcd32 100644
@@ -478,7 +478,7 @@ static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
 	struct wpa_supplicant *wpa_s = ctx;
 	if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
 		return ieee80211_sta_update_ft_ies(wpa_s, md, ies, ies_len);
-	if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
+	if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME_AUTH)
 		return sme_update_ft_ies(wpa_s, md, ies, ies_len);
 	return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
 }
#1 lore raw
Quoted 3 lines · Zhu Yi

nl80211 driver connect API support.

V2: Use auth/assoc as the default operations if they are supported.

Thanks!

It looks like there is still some misunderstanding regarding the SME design in wpa_supplicant. It was designed to be used when the driver does provide the separate authentication and association commands. There is not much point in trying to convert the SME implementation to work with the case where connect command is used. It is just duplicating functionality that is already present in the old associate (pre-auth/assoc SME case) operation.

I took about half of the patch, i.e., the changes to add driver capability query, connect events, and actual connect/disconnect functions. Instead of the changes in sme.c and driver interface, I glued the new functions together within driver_nl80211.c since rest of wpa_supplicant do not really need to (nor should) know about yet another driver operation for connecting in a single step. The driver capabilities are used to select which functions to use within driver_nl80211.c. Since the WPA_DRIVER_FLAGS_SME is now set based on driver capabilities, core wpa_supplicant code is able to switch between the SME (separate auth/assoc calls) and single associate ("connect" in nl80211 terminology) call.

I did not go through the details of sme_connect() function, but I would expect that it was providing the same conversion from configuration to driver parameters that was already done in wpa_supplicant.c. If there was something else there, it should be added to the version in wpa_supplicant.c instead of introducing a new, duplicated function.

It looks like the end result works fine at least with mac80211_hwsim (with hardcoded driver capability detection that does not find the separate authenticate command). This version is now in my git repository and it would be good if you could verify that it works with your driver, too.

Signature · 1 line
Jouni Malinen                                            PGP id EFC895FA
author
#2 lore raw
Quoted 7 lines · Jouni Malinen

It looks like there is still some misunderstanding regarding the SME design in wpa_supplicant. It was designed to be used when the driver does provide the separate authentication and association commands. There is not much point in trying to convert the SME implementation to work with the case where connect command is used. It is just duplicating functionality that is already present in the old associate (pre-auth/assoc SME case) operation.

I searched WPA_DRIVER_FLAGS_SME is set only by driver_nl80211. So I thought you might also want the connect API more visible for the whole wpa_supplicant. But it turns I was wrong.

Quoted 18 lines

I took about half of the patch, i.e., the changes to add driver capability query, connect events, and actual connect/disconnect functions. Instead of the changes in sme.c and driver interface, I glued the new functions together within driver_nl80211.c since rest of wpa_supplicant do not really need to (nor should) know about yet another driver operation for connecting in a single step. The driver capabilities are used to select which functions to use within driver_nl80211.c. Since the WPA_DRIVER_FLAGS_SME is now set based on driver capabilities, core wpa_supplicant code is able to switch between the SME (separate auth/assoc calls) and single associate ("connect" in nl80211 terminology) call.

I did not go through the details of sme_connect() function, but I would expect that it was providing the same conversion from configuration to driver parameters that was already done in wpa_supplicant.c. If there was something else there, it should be added to the version in wpa_supplicant.c instead of introducing a new, duplicated function.

Quoted 5 lines

It looks like the end result works fine at least with mac80211_hwsim (with hardcoded driver capability detection that does not find the separate authenticate command). This version is now in my git repository and it would be good if you could verify that it works with your driver, too.

I confirm it also works for iwmc3200wifi. Tested for WEP, PSK and EAP.

Thanks,
-yi