Hi,
I recently converted my WRT54GS to OpenWRT. Unfortunately I could not get the WEP encryption to work. At one point I discovered that the keys shown by iwconfig for key 1 and key 4 was the same. So I took a look in the sourcecode for the wifi utility.
In the setup_wext_wep function (line 337 of wificonf.c), all the 4 keys are set, one at a time. If the code also finds a wl0_key nvram attribute, it does the following:
wrq.u.data.flags = i | IW_ENCODE_RESTRICTED;
IW_SET_EXT_ERR(skfd, ifname, SIOCSIWENCODE, &wrq, "Set Encode");
The trouble is that wrq still contains the last key that was configured, so in effect the above code overwrites the key that wl0_key points to.
The following (untested, as I don't have the tool-chain setup) patch should fix the problem
--- wificonf.c 2005-07-17 14:59:44.000000000 +0200
+++ wificonf2.c 2005-07-29 14:46:10.163466731 +0200
@@ -376,13 +376,16 @@
}
void setup_wext_wep(int skfd, char *ifname)
{
- int i, keylen;
+ int i, keylen, select_key;
struct iwreq wrq;
char keystr[5];
char *keyval;
unsigned char key[IW_ENCODING_TOKEN_MAX];
strcpy(keystr, "key1");
+
+ select_key = atoi(nvram_safe_get(wl_var("key")));
+
for (i = 1; i <= 4; i++) {
if (keyval = nvram_get(wl_var(keystr))) {
keylen = iw_in_key(keyval, key);
@@ -391,18 +394,13 @@
wrq.u.data.length = keylen;
wrq.u.data.pointer = (caddr_t) key;
wrq.u.data.flags = i;
+ if (i == select_key)
+ wrq.u.data.flags |= IW_ENCODE_RESTRICTED;
IW_SET_EXT_ERR(skfd, ifname, SIOCSIWENCODE, &wrq, "Set Encode");
}
}
keystr[3]++;
}
-
-
- i = atoi(nvram_safe_get(wl_var("key")));
- if (i > 0 && i < 4) {
- wrq.u.data.flags = i | IW_ENCODE_RESTRICTED;
- IW_SET_EXT_ERR(skfd, ifname, SIOCSIWENCODE, &wrq, "Set Encode");
- }
}