commit c971e30e620618b871cd10eef0790328047e8421
Author: Hans Petter Jansson <hpj@cl.no>
Date:   Tue Jan 18 22:21:04 2011 +0100

    Patch 29: nm-supplicant-multiple-drivers.patch

Index: NetworkManager-0.7.1/src/nm-device-ethernet.c
===================================================================
--- NetworkManager-0.7.1.orig/src/nm-device-ethernet.c
+++ NetworkManager-0.7.1/src/nm-device-ethernet.c
@@ -1125,7 +1125,7 @@ supplicant_interface_init (NMDeviceEther
 	iface = nm_device_get_iface (NM_DEVICE (self));
 
 	/* Create supplicant interface */
-	priv->supplicant.iface = nm_supplicant_manager_get_iface (priv->supplicant.mgr, iface, FALSE);
+	priv->supplicant.iface = nm_supplicant_manager_get_iface (priv->supplicant.mgr, iface, NULL, FALSE);
 	if (!priv->supplicant.iface) {
 		nm_warning ("Couldn't initialize supplicant interface for %s.", iface);
 		supplicant_interface_release (self);
Index: NetworkManager-0.7.1/src/nm-device-wifi.c
===================================================================
--- NetworkManager-0.7.1.orig/src/nm-device-wifi.c
+++ NetworkManager-0.7.1/src/nm-device-wifi.c
@@ -588,6 +588,7 @@ supplicant_interface_acquire (NMDeviceWi
 
 	priv->supplicant.iface = nm_supplicant_manager_get_iface (priv->supplicant.mgr,
 	                                                          nm_device_get_iface (NM_DEVICE (self)),
+	                                                          nm_device_get_driver (NM_DEVICE (self)),
 	                                                          TRUE);
 	if (priv->supplicant.iface == NULL) {
 		nm_warning ("Couldn't initialize supplicant interface for %s.",
Index: NetworkManager-0.7.1/src/supplicant-manager/nm-supplicant-interface.c
===================================================================
--- NetworkManager-0.7.1.orig/src/supplicant-manager/nm-supplicant-interface.c
+++ NetworkManager-0.7.1/src/supplicant-manager/nm-supplicant-interface.c
@@ -93,6 +93,7 @@ enum {
 	PROP_STATE,
 	PROP_CONNECTION_STATE,
 	PROP_SCANNING,
+	PROP_DEVICE_DRIVER,
 	LAST_PROP
 };
 
@@ -103,6 +104,7 @@ typedef struct
 	gulong                smgr_state_sig_handler;
 	NMDBusManager *       dbus_mgr;
 	char *                dev;
+	char *                device_driver;
 	gboolean              is_wireless;
 
 	char *                object_path;
@@ -186,7 +188,7 @@ nm_supplicant_info_destroy (gpointer use
 
 
 NMSupplicantInterface *
-nm_supplicant_interface_new (NMSupplicantManager * smgr, const char *ifname, gboolean is_wireless)
+nm_supplicant_interface_new (NMSupplicantManager * smgr, const char *ifname, const char *device_driver, gboolean is_wireless)
 {
 	NMSupplicantInterface * iface;
 
@@ -196,6 +198,7 @@ nm_supplicant_interface_new (NMSupplican
 	iface = g_object_new (NM_TYPE_SUPPLICANT_INTERFACE,
 	                      "supplicant-manager", smgr,
 	                      "device", ifname,
+	                      "device-driver", device_driver,
 	                      NULL);
 	if (iface) {
 		NM_SUPPLICANT_INTERFACE_GET_PRIVATE (iface)->is_wireless = is_wireless;
@@ -245,6 +248,18 @@ nm_supplicant_interface_set_property (GO
 			/* Construct-only */
 			priv->dev = g_strdup (g_value_get_string (value));
 			break;
+		case PROP_DEVICE_DRIVER:
+			/* Construct-only */
+			{
+				const char *device_driver = g_value_get_string (value);
+
+				g_free (priv->device_driver);
+				priv->device_driver = NULL;
+
+				if (device_driver)
+					priv->device_driver = g_strdup (device_driver);
+			}
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 			break;
@@ -266,6 +281,9 @@ nm_supplicant_interface_get_property (GO
 		case PROP_DEVICE:
 			g_value_set_string (value, priv->dev);
 			break;
+		case PROP_DEVICE_DRIVER:
+			g_value_set_string (value, priv->device_driver);
+			break;
 		case PROP_STATE:
 			g_value_set_uint (value, priv->state);
 			break;
@@ -341,6 +359,7 @@ nm_supplicant_interface_dispose (GObject
 	}
 
 	g_free (priv->dev);
+	g_free (priv->device_driver);
 
 	/* Cancel pending calls before unrefing the dbus manager */
 	cancel_all_callbacks (priv->other_pcalls);
@@ -390,6 +409,14 @@ nm_supplicant_interface_class_init (NMSu
 	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
 	g_object_class_install_property (object_class,
+	                                 PROP_DEVICE_DRIVER,
+	                                 g_param_spec_string ("device-driver",
+	                                                      "Device Driver",
+	                                                      "Device driver used for this interface",
+	                                                      NULL,
+	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+	g_object_class_install_property (object_class,
 	                                 PROP_STATE,
 	                                 g_param_spec_uint ("state",
 	                                                    "State",
@@ -854,7 +881,21 @@ nm_supplicant_interface_add_to_supplican
 
 		driver = g_new0 (GValue, 1);
 		g_value_init (driver, G_TYPE_STRING);
-		g_value_set_string (driver, priv->is_wireless ? "wext" : "wired");
+
+		if (priv->is_wireless) {
+			/* wext is used by default */
+			g_value_set_string (driver, "wext");
+			/* iwlagn works well with nl80211, but wpa_supplicant 0.7.1 is needed; use wext with wpa_supplicant 0.6.9 */
+			if (priv->device_driver && (0 == strcmp (priv->device_driver, "iwlagn")))
+				g_value_set_string (driver, "wext");
+			/* Ralink 3090 */
+			if (priv->device_driver && (0 == strcmp (priv->device_driver, "rt3090")))
+				g_value_set_string (driver, "wext");
+			/* exceptions of other wireless extensions put here */
+		} else {
+			g_value_set_string (driver, "wired");
+		}
+
 		g_hash_table_insert (hash, "driver", driver);
 
 		call = dbus_g_proxy_begin_call (proxy, "addInterface",
Index: NetworkManager-0.7.1/src/supplicant-manager/nm-supplicant-interface.h
===================================================================
--- NetworkManager-0.7.1.orig/src/supplicant-manager/nm-supplicant-interface.h
+++ NetworkManager-0.7.1/src/supplicant-manager/nm-supplicant-interface.h
@@ -119,6 +119,7 @@ GType nm_supplicant_interface_get_type (
 
 NMSupplicantInterface * nm_supplicant_interface_new (NMSupplicantManager * smgr,
                                                      const char *ifname,
+													 const char *device_driver,
                                                      gboolean is_wireless);
 
 gboolean nm_supplicant_interface_set_config (NMSupplicantInterface * iface,
Index: NetworkManager-0.7.1/src/supplicant-manager/nm-supplicant-manager.c
===================================================================
--- NetworkManager-0.7.1.orig/src/supplicant-manager/nm-supplicant-manager.c
+++ NetworkManager-0.7.1/src/supplicant-manager/nm-supplicant-manager.c
@@ -266,6 +266,7 @@ nm_supplicant_manager_startup (NMSupplic
 NMSupplicantInterface *
 nm_supplicant_manager_get_iface (NMSupplicantManager * self,
 								 const char *ifname,
+								 const char *device_driver,
 								 gboolean is_wireless)
 {
 	NMSupplicantManagerPrivate *priv;
@@ -288,7 +289,7 @@ nm_supplicant_manager_get_iface (NMSuppl
 	}
 
 	if (!iface) {
-		iface = nm_supplicant_interface_new (self, ifname, is_wireless);
+		iface = nm_supplicant_interface_new (self, ifname, device_driver, is_wireless);
 		if (iface)
 			priv->ifaces = g_slist_append (priv->ifaces, iface);
 	}
Index: NetworkManager-0.7.1/src/supplicant-manager/nm-supplicant-manager.h
===================================================================
--- NetworkManager-0.7.1.orig/src/supplicant-manager/nm-supplicant-manager.h
+++ NetworkManager-0.7.1/src/supplicant-manager/nm-supplicant-manager.h
@@ -78,6 +78,7 @@ guint32 nm_supplicant_manager_get_state
 
 NMSupplicantInterface * nm_supplicant_manager_get_iface (NMSupplicantManager * mgr,
                                                          const char *ifname,
+														 const char *device_driver,
 														 gboolean is_wireless);
 
 void nm_supplicant_manager_release_iface (NMSupplicantManager * mgr,
