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

Bug#490382: netcfg: Wireless configuration issues with ath5k



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

As all mac80211 drivers will have this problem, I have made a few more
changes in netcfg. When iw_get_basic_config is called, the current freq
is stored. Non mac80211 drivers appear to ignore this after a trigger to
associate, but mac80211 drivers appear to keep this set when
iw_set_basic_config is called. This patch uses iw_set_ext  instead to
set the various values. Also because mac80211 drivers only trigger an
association event after values are set, and then finally essid, it now
resets essid after wep key is set.  Appears to still work ok with
madwifi, ath5k will now associate but not get a lease (Due to the 2.6.25
issues with ath5k, I suspect the driver not netcfg) and iwl3945 works,
but only after reconfiguring the wireless (need to investigate this further)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkiIu6MACgkQV8GyuTwyskOr6ACgiJAAwIADAjhHtPbQaJHpF2Jt
6FEAnjYx0C2RbBO+kw0Io4Sz7kOMwiDL
=MBW+
-----END PGP SIGNATURE-----
diff --git a/packages/netcfg/wireless.c b/packages/netcfg/wireless.c
index ed07b8a..c5fd54a 100644
--- a/packages/netcfg/wireless.c
+++ b/packages/netcfg/wireless.c
@@ -32,7 +32,8 @@ int netcfg_wireless_set_essid (struct debconfclient * client, char *iface, char*
 {
     int ret, couldnt_associate = 0;
     wireless_config wconf;
-    char* tf = NULL, *user_essid = NULL, *ptr = wconf.essid;
+    struct iwreq wrq;
+    char* tf = NULL, *user_essid = NULL;
     
     iw_get_basic_config (wfd, iface, &wconf);
     
@@ -50,10 +51,24 @@ int netcfg_wireless_set_essid (struct debconfclient * client, char *iface, char*
     if (!strcmp(client->value, "Ad-hoc network (Peer to peer)"))
         mode = ADHOC;
     
-    wconf.has_mode = 1;
-    wconf.mode = mode;
+    wrq.u.essid.flags = 1;
+    wrq.u.mode = mode;
+    
+    if (iw_set_ext(wfd, iface, SIOCSIWMODE, &wrq) < 0) {
+        di_warning("Set mode failed");
+        return 1;
+    }
+    /* set freq to auto, this has been set earlier, checking for ifaces */
     
-    debconf_input(client, priority ? priority : "low", "netcfg/wireless_essid");
+    wrq.u.freq.m = -1;
+    wrq.u.freq.e = 0;
+    wrq.u.freq.flags = 0;
+    
+    if (iw_set_ext(skfd, iface, SIOCSIWFREQ, &wrq) < 0) {
+        di_warning("Setting freq to auto failed");
+        return -1;
+    }
+    debconf_input(client, priority ? priority : "high", "netcfg/wireless_essid");
     
     if (debconf_go(client) == 30)
         return GO_BACK;
@@ -63,16 +78,24 @@ int netcfg_wireless_set_essid (struct debconfclient * client, char *iface, char*
     
 automatic:
     /* question not asked or user doesn't care or we're successfully associated */
-    if (!empty_str(wconf.essid) || empty_str(client->value)) 
+    if (empty_str(client->value)) 
     {
         int i, success = 0;
         
         /* Default to any AP */
-        wconf.essid[0] = '\0';
-        wconf.essid_on = 0;
-        
-        iw_set_basic_config (wfd, iface, &wconf);
+        essid = malloc(IW_ESSID_MAX_SIZE +1);
+        essid[0] = '\0';
+        wrq.u.essid.pointer = essid;
+        wrq.u.essid.flags = 0;
         
+        if (iw_set_ext(skfd, iface, SIOCSIWESSID, &wrq) < 0) {
+            di_warning("Setting essid to any/off failed");
+            free(essid);
+            essid = NULL;
+            return 1;
+        }
+        free(essid);
+        essid = NULL;
         /* Wait for association.. (MAX_SECS seconds)*/
 #define MAX_SECS 3
         
@@ -164,29 +187,30 @@ automatic:
     
     essid = user_essid;
     
-    memset(ptr, 0, IW_ESSID_MAX_SIZE + 1);
-    snprintf(wconf.essid, IW_ESSID_MAX_SIZE + 1, "%s", essid);
-    wconf.has_essid = 1;
-    wconf.essid_on = 1;
+    wrq.u.essid.pointer = essid;
+    wrq.u.essid.flags = 1;
+    wrq.u.essid.length = strlen(essid);
     
-    iw_set_basic_config (wfd, iface, &wconf);
+    if (iw_set_ext(skfd, iface, SIOCSIWESSID, &wrq) < 0) {
+        di_warning("Set essid %s failed", essid);
+        return 1;
+    }
     
     return 0;
 }
 
 static void unset_wep_key (char* iface)
 {
-    wireless_config wconf;
-    int ret;
-    
-    iw_get_basic_config(wfd, iface, &wconf);
+    struct iwreq wrq;
     
-    wconf.has_key = 1;
-    wconf.key[0] = '\0';
-    wconf.key_flags = IW_ENCODE_DISABLED | IW_ENCODE_NOKEY;
-    wconf.key_size = 0;
+    wrq.u.data.pointer = (caddr_t) NULL;
+    wrq.u.data.flags = IW_ENCODE_DISABLED | IW_ENCODE_NOKEY;
+    wrq.u.data.length = 0;
     
-    ret = iw_set_basic_config (wfd, iface, &wconf);
+    if (iw_set_ext(skfd, iface, SIOCSIWENCODE, &wrq) < 0) {
+        di_warning("Clear wepkey failed");
+        return -1;
+    }
 }
 
 int netcfg_wireless_set_wep (struct debconfclient * client, char* iface)
@@ -247,6 +271,15 @@ int netcfg_wireless_set_wep (struct debconfclient * client, char* iface)
         return -1;
     }
     
+    /* Reset essid for mac80211 based drivers */
+    wrq.u.essid.pointer = essid;
+    wrq.u.essid.length = strlen(essid);
+    wrq.u.essid.flags = 1;
+    
+    if (iw_set_ext(skfd, iface, SIOCSIWESSID, &wrq) < 0) {
+        di_warning("Resetting essid %s failed", essid);
+        return -1;
+    }
     return 0;
 }
 

Reply to: