wireless driver workarounds



Attached patch is a collection of workarounds for madwifi, orinoco, and
ndiswrapper that I have worked on or that have been posted to this list.

We are probably not going to merge any of this.  If NM does not work for
you but works with this patch, we would like to know.

	Robert Love

Index: src/nm-device-802-11-wireless.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-device-802-11-wireless.c,v
retrieving revision 1.59
diff -u -r1.59 nm-device-802-11-wireless.c
--- src/nm-device-802-11-wireless.c	2 Mar 2006 23:01:33 -0000	1.59
+++ src/nm-device-802-11-wireless.c	3 Mar 2006 15:19:13 -0000
@@ -1834,14 +1834,16 @@
 
 			/* Must be in infrastructure mode during scan, otherwise we don't get a full
 			 * list of scan results.  Scanning doesn't work well in Ad-Hoc mode :( 
-			 */
-			nm_device_802_11_wireless_set_mode (self, IW_MODE_INFRA);
-
-			/* We only unlock the frequency if the card is in adhoc mode, in case it is
-			 * a costly operation for the driver.
+			 *
+			 * We only set the mode and unlock the frequency if the card is in adhoc mode,
+			 * in case doing so is a costly operation for the driver or the driver prefers
+			 * IW_MODE_AUTO.
 			 */
 			if (orig_mode == IW_MODE_ADHOC)
+			{
+				nm_device_802_11_wireless_set_mode (self, IW_MODE_INFRA);
 				nm_device_802_11_wireless_set_frequency (self, 0);
+			}
 
 			wrq.u.data.pointer = NULL;
 			wrq.u.data.flags = 0;
@@ -2415,13 +2417,28 @@
 	const char *		iface = nm_device_get_iface (NM_DEVICE (self));
 	gboolean			success = FALSE;
 	int				tries = 0;
+	const char *		wpa_driver;
+	const char *		kernel_driver;
 
 	if (!(ctrl = wpa_ctrl_open (WPA_SUPPLICANT_GLOBAL_SOCKET, NM_RUN_DIR)))
 		goto exit;
 
+	kernel_driver = nm_device_get_driver (NM_DEVICE (self));
+
+	/*
+	 * We want to work with the generic "wext" wpa_supplicant driver, but some kernel drivers
+	 * are just utter junk.  For those losers, we use a specific wpa_supplicant driver.
+	 */
+	if (!strcmp (kernel_driver, "ath_pci"))
+		wpa_driver = "madwifi";
+	else if (!strcmp (kernel_driver, "ndiswrapper"))
+		wpa_driver = "ndiswrapper";
+	else
+		wpa_driver = "wext";
+
 	/* wpa_cli -g/var/run/wpa_supplicant-global interface_add eth1 "" wext /var/run/wpa_supplicant */
 	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
-			"INTERFACE_ADD %s\t\twext\t" WPA_SUPPLICANT_CONTROL_SOCKET "\t", iface))
+			"INTERFACE_ADD %s\t\t%s\t" WPA_SUPPLICANT_CONTROL_SOCKET "\t", iface, wpa_driver))
 		goto exit;
 	wpa_ctrl_close (ctrl);
 
@@ -2457,7 +2474,8 @@
 	struct wpa_ctrl *	ctrl;
 	gboolean			user_created;
 	char *			hex_essid;
-	char *			ap_scan = "AP_SCAN 1";
+	const char *		ap_scan;
+	const char *		kernel_driver;
 
 	g_return_val_if_fail (self != NULL, FALSE);
 	g_return_val_if_fail (req != NULL, FALSE);
@@ -2468,14 +2486,25 @@
 	ctrl = self->priv->supplicant.ctrl;
 	g_assert (ctrl);
 
-	/* Ad-Hoc and non-broadcasting networks need AP_SCAN 2 */
 	user_created = nm_ap_get_user_created (ap);
-	if (!nm_ap_get_broadcast (ap) || user_created)
+	kernel_driver = nm_device_get_driver (NM_DEVICE (self));
+
+	/*
+	 * We want to use "AP_SCAN 1", which tells wpa_supplicant to perform scanning.  This seems
+	 * to work better with some drivers.  But we want "AP_SCAN 2", telling wpa_supplicant that
+	 * we will do our own scanning, if
+	 *
+	 *	- The driver is orinoco_cs.  It chokes on "AP_SCAN 1".
+	 *	- The AP is non-broadcast or Ad-Hoc.  Unless the driver is madwifi.
+	 */
+	if (!strcmp (kernel_driver, "orinoco_cs"))
 		ap_scan = "AP_SCAN 2";
+	else if ((!nm_ap_get_broadcast (ap) || user_created) && strcmp (kernel_driver, "ath_pci"))
+		ap_scan = "AP_SCAN 2";
+	else
+		ap_scan = "AP_SCAN 1";
 
-	/* Tell wpa_supplicant that we'll do the scanning */
-	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
-			ap_scan))
+	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, ap_scan))
 		goto out;
 
 	/* Standard network setup info */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]