--- NetworkManager-0.5.2/src/nm-device-802-11-wireless.c	2006-02-21 11:39:33.000000000 +0100
+++ /root/Desktop/nm-device-802-11-wireless.c	2006-03-03 13:55:08.000000000 +0100
@@ -1808,7 +1808,10 @@
 			/* 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);
+
+			if (nm_device_802_11_wireless_get_mode (self) == 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;
@@ -2282,13 +2285,27 @@
 	const char *		iface = nm_device_get_iface (NM_DEVICE (self));
 	gboolean			success = FALSE;
 	int				tries = 0;
+	char *	driver;
 
 	if (!(ctrl = wpa_ctrl_open (WPA_SUPPLICANT_GLOBAL_SOCKET, NM_RUN_DIR)))
 		goto exit;
 
+	if (!strcmp (nm_device_get_driver (NM_DEVICE (self)), "ndiswrapper")) {
+		driver= g_malloc(sizeof(char)*(strlen("ndiswrapper")+1));
+		driver= strcpy(driver, "ndiswrapper");
+		}
+	else if (!strcmp (nm_device_get_driver (NM_DEVICE (self)), "ath_pci")) {
+		driver= g_malloc(sizeof(char)*(strlen("madwifi")+1));
+		driver= strcpy(driver, "madwifi");
+		}
+	else {
+		driver= g_malloc(sizeof(char)*(strlen("wext")+1));
+		driver= strcpy(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, driver))
 		goto exit;
 	wpa_ctrl_close (ctrl);
 
@@ -2308,6 +2325,7 @@
 	success = TRUE;
 
 exit:
+	g_free (driver);
 	return success;
 }
 



