NetworkManager r3230 - in trunk: . src src/supplicant-manager



Author: dcbw
Date: Thu Jan 10 23:15:46 2008
New Revision: 3230
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3230&view=rev

Log:
2008-01-10  Dan Williams  <dcbw redhat com>

	Fix gnome.org #464215.  Requires the kernel patch titled
	"Introduce WEXT scan capabilities" but will handle the patch not being
	present, you'll just continue to have problems with hidden SSIDs when
	using mac80211-based drivers.

	* src/supplicant-manager/nm-supplicant-config.h
	  src/supplicant-manager/nm-supplicant-config.c
		- (nm_supplicant_config_add_setting_wireless): new parameter to indicate
			whether the driver supports SSID scans or not.  If it does, and if
			the AP is hidden, use ap_scan=1 instead of ap_scan=2

	* src/nm-device-802-11-wireless.c
		- (constructor): check whether or not the driver supports SSID scans
		- (build_supplicant_config): pass driver SSID scan capability when
			building the wireless bits of the supplicant config



Modified:
   trunk/ChangeLog
   trunk/src/nm-device-802-11-wireless.c
   trunk/src/supplicant-manager/nm-supplicant-config.c
   trunk/src/supplicant-manager/nm-supplicant-config.h

Modified: trunk/src/nm-device-802-11-wireless.c
==============================================================================
--- trunk/src/nm-device-802-11-wireless.c	(original)
+++ trunk/src/nm-device-802-11-wireless.c	Thu Jan 10 23:15:46 2008
@@ -142,6 +142,7 @@
 	/* Static options from driver */
 	guint8			we_version;
 	guint32			capabilities;
+	gboolean		has_scan_capa_ssid;
 };
 
 
@@ -370,6 +371,27 @@
 	return (guint32) (iw_freq2float (freq) / 1000000);
 }
 
+
+/* Until a new wireless-tools comes out that has the defs and the structure,
+ * need to copy them here.
+ */
+/* Scan capability flags - in (struct iw_range *)->scan_capa */
+#define NM_IW_SCAN_CAPA_NONE		0x00
+#define NM_IW_SCAN_CAPA_ESSID		0x01
+
+struct iw_range_with_scan_capa
+{
+	guint32		throughput;
+	guint32		min_nwid;
+	guint32		max_nwid;
+	guint16		old_num_channels;
+	guint8		old_num_frequency;
+
+	guint8		scan_capa;
+/* don't need the rest... */
+};
+
+
 static GObject*
 constructor (GType type,
 			 guint n_construct_params,
@@ -382,6 +404,7 @@
 	const char *iface;
 	NMSock *sk = NULL;
 	struct iw_range range;
+	struct iw_range_with_scan_capa *scan_capa_range;
 	struct iwreq wrq;
 	int i;
 
@@ -423,6 +446,14 @@
 
 	priv->we_version = range.we_version_compiled;
 
+	/* Check for the ability to scan specific SSIDs.  Until the scan_capa
+	 * field gets added to wireless-tools, need to work around that by casting
+	 * to the custom structure.
+	 */
+	scan_capa_range = (struct iw_range_with_scan_capa *) &range;
+	if (scan_capa_range->scan_capa & NM_IW_SCAN_CAPA_ESSID)
+		priv->has_scan_capa_ssid = TRUE;
+
 	/* 802.11 wireless-specific capabilities */
 	priv->capabilities = get_wireless_capabilities (self, &range, wrq.u.data.length);
 
@@ -2404,8 +2435,9 @@
                          NMConnection *connection,
                          NMAccessPoint *ap)
 {
-	NMSupplicantConfig * config = NULL;
-	NMSettingWireless * s_wireless;
+	NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
+	NMSupplicantConfig *config = NULL;
+	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wireless_sec;
 	guint32 adhoc_freq = 0;
 
@@ -2444,7 +2476,8 @@
 	if (!nm_supplicant_config_add_setting_wireless (config,
 	                                                s_wireless,
 	                                                nm_ap_get_broadcast (ap),
-	                                                adhoc_freq)) {
+	                                                adhoc_freq,
+	                                                priv->has_scan_capa_ssid)) {
 		nm_warning ("Couldn't add 802-11-wireless setting to supplicant config.");
 		goto error;
 	}

Modified: trunk/src/supplicant-manager/nm-supplicant-config.c
==============================================================================
--- trunk/src/supplicant-manager/nm-supplicant-config.c	(original)
+++ trunk/src/supplicant-manager/nm-supplicant-config.c	Thu Jan 10 23:15:46 2008
@@ -327,7 +327,8 @@
 nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
                                            NMSettingWireless * setting,
                                            gboolean is_broadcast,
-                                           guint32 adhoc_freq)
+                                           guint32 adhoc_freq,
+                                           gboolean has_scan_capa_ssid)
 {
 	NMSupplicantConfigPrivate *priv;
 	gboolean is_adhoc;
@@ -338,8 +339,14 @@
 	priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self);
 	
 	is_adhoc = (setting->mode && !strcmp (setting->mode, "adhoc")) ? TRUE : FALSE;
-	if (!is_broadcast || is_adhoc)
+	if (is_adhoc)
 		priv->ap_scan = 2;
+	else if (is_broadcast == FALSE) {
+		/* drivers that support scanning specific SSIDs should use
+		 * ap_scan=1, while those that do not should use ap_scan=2.
+		 */
+		priv->ap_scan = has_scan_capa_ssid ? 1 : 2;
+	}
 
 	if (!nm_supplicant_config_add_option (self, "ssid",
 					      (char *) setting->ssid->data,

Modified: trunk/src/supplicant-manager/nm-supplicant-config.h
==============================================================================
--- trunk/src/supplicant-manager/nm-supplicant-config.h	(original)
+++ trunk/src/supplicant-manager/nm-supplicant-config.h	Thu Jan 10 23:15:46 2008
@@ -68,7 +68,8 @@
 gboolean nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
                                                     NMSettingWireless * setting,
                                                     gboolean is_broadcast,
-                                                    guint32 adhoc_freq);
+                                                    guint32 adhoc_freq,
+                                                    gboolean has_scan_capa_ssid);
 
 gboolean nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig * self,
                                                              NMSettingWirelessSecurity * setting,



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