* [PATH] acxsm: Move WEP code into softmac
@ 2006-01-29 14:26 Carlos Martín
2006-01-30 7:18 ` Denis Vlasenko
0 siblings, 1 reply; 3+ messages in thread
From: Carlos Martín @ 2006-01-29 14:26 UTC (permalink / raw)
To: acx100-devel; +Cc: netdev
[-- Attachment #1.1: Type: text/plain, Size: 650 bytes --]
Hi,
This patch moves the WEP handling code to use the softmac layer and
implements acx_e_ieee80211_set_security(), based on the rt2x00 project's one.
I do have a couple of questions though:
1) adev->wep_restricted = 0 is the same as an open auth system, and
adev->wep_restricted = 1 is the same as having a shared key auth system,
right?
2) What is the purpose of the index field in key_struct_t? I've assumed it is
the same as adev->wep_current_index, but I'm not sure this is correct.
cmn
--
Carlos Martín http://www.cmartin.tk
"Erdbeben? Sicherlich etwas, das mit Erdberen zu tun hat." -- me, paraphrased
[-- Attachment #1.2: acxsm-move-wep-into-softmac.patch --]
[-- Type: text/x-diff, Size: 13570 bytes --]
diff -urp acxsm-0123.orig/acx_struct.h acxsm-0123/acx_struct.h
--- acxsm-0123.orig/acx_struct.h 2006-01-16 15:25:41.000000000 +0100
+++ acxsm-0123/acx_struct.h 2006-01-29 14:06:17.000000000 +0100
@@ -603,31 +603,6 @@ typedef struct fw_ver {
#define FW_ID_SIZE 20
-
-/*--- WEP stuff --------------------------------------------------------------*/
-#define DOT11_MAX_DEFAULT_WEP_KEYS 4
-
-/* non-firmware struct, no packing necessary */
-typedef struct wep_key {
- size_t size; /* most often used member first */
- u8 index;
- u8 key[29];
- u16 strange_filler;
-} wep_key_t; /* size = 264 bytes (33*8) */
-/* FIXME: We don't have size 264! Or is there 2 bytes beyond the key
- * (strange_filler)? */
-
-/* non-firmware struct, no packing necessary */
-typedef struct key_struct {
- u8 addr[ETH_ALEN]; /* 0x00 */
- u16 filler1; /* 0x06 */
- u32 filler2; /* 0x08 */
- u32 index; /* 0x0c */
- u16 len; /* 0x10 */
- u8 key[29]; /* 0x12; is this long enough??? */
-} key_struct_t; /* size = 276. FIXME: where is the remaining space?? */
-
-
/*--- Client (peer) info -----------------------------------------------------*/
/* adev->sta_list[] is used for:
** accumulating and processing of scan results
@@ -1286,14 +1261,6 @@ struct acx_device {
u8 rate_supported_len;
u8 rate_supported[13];
- /*** Encryption settings (WEP) ***/
- u32 auth_alg; /* used in transmit_authen1 */
- u8 wep_enabled;
- u8 wep_restricted;
- u8 wep_current_index;
- wep_key_t wep_keys[DOT11_MAX_DEFAULT_WEP_KEYS]; /* the default WEP keys */
- key_struct_t wep_key_struct[10];
-
/*** Unknown ***/
u8 dtim_interval;
diff -urp acxsm-0123.orig/common.c acxsm-0123/common.c
--- acxsm-0123.orig/common.c 2006-01-19 11:28:23.000000000 +0100
+++ acxsm-0123/common.c 2006-01-29 14:59:46.000000000 +0100
@@ -1137,8 +1137,8 @@ acx_s_proc_diag_output(char *buf, acx_de
"WEP ena %d, restricted %d, idx %d\n",
adev->essid, adev->essid_active, (int)adev->essid_len,
adev->essid_for_assoc, adev->nick,
- adev->wep_enabled, adev->wep_restricted,
- adev->wep_current_index);
+ adev->ieee->sec.enabled, adev->ieee->sec.auth_mode,
+ adev->ieee->sec.active_key);
p += sprintf(p, "dev_addr "MACSTR"\n", MAC(adev->dev_addr));
p += sprintf(p, "bssid "MACSTR"\n", MAC(adev->bssid));
p += sprintf(p, "ap_filter "MACSTR"\n", MAC(adev->ap));
@@ -2143,7 +2143,7 @@ acx_s_set_defaults(acx_device_t *adev)
/* reported to break scanning: adev->scan_probe_delay = adev->cfgopt_probe_delay; */
adev->scan_rate = ACX_SCAN_RATE_1;
- adev->auth_alg = WLAN_AUTH_ALG_OPENSYSTEM;
+ adev->ieee->sec.auth_mode = WLAN_AUTH_OPEN;
adev->preamble_mode = 2; /* auto */
adev->listen_interval = 100;
adev->beacon_interval = DEFAULT_BEACON_INTERVAL;
@@ -5435,14 +5435,14 @@ acx100_s_set_wepkey(acx_device_t *adev)
ie_dot11WEPDefaultKey_t dk;
int i;
- for (i = 0; i < DOT11_MAX_DEFAULT_WEP_KEYS; i++) {
- if (adev->wep_keys[i].size != 0) {
+ for (i = 0; i < WEP_KEYS; i++) {
+ if (adev->ieee->sec.key_sizes[i] != 0) {
log(L_INIT, "setting WEP key: %d with "
- "total size: %d\n", i, (int) adev->wep_keys[i].size);
+ "total size: %d\n", i, (int) adev->ieee->sec.key_sizes[i]);
dk.action = 1;
- dk.keySize = adev->wep_keys[i].size;
+ dk.keySize = adev->ieee->sec.key_sizes[i];
dk.defaultKeyNum = i;
- memcpy(dk.key, adev->wep_keys[i].key, dk.keySize);
+ memcpy(dk.key, adev->ieee->sec.keys[i], dk.keySize);
acx_s_configure(adev, &dk, ACX100_IE_DOT11_WEP_DEFAULT_KEY_WRITE);
}
}
@@ -5454,20 +5454,20 @@ acx111_s_set_wepkey(acx_device_t *adev)
acx111WEPDefaultKey_t dk;
int i;
- for (i = 0; i < DOT11_MAX_DEFAULT_WEP_KEYS; i++) {
- if (adev->wep_keys[i].size != 0) {
+ for (i = 0; i < WEP_KEYS; i++) {
+ if (adev->ieee->sec.key_sizes[i] != 0) {
log(L_INIT, "setting WEP key: %d with "
- "total size: %d\n", i, (int) adev->wep_keys[i].size);
+ "total size: %d\n", i, (int) adev->ieee->sec.key_sizes[i]);
memset(&dk, 0, sizeof(dk));
dk.action = cpu_to_le16(1); /* "add key"; yes, that's a 16bit value */
- dk.keySize = adev->wep_keys[i].size;
+ dk.keySize = adev->ieee->sec.key_sizes[i];
/* are these two lines necessary? */
dk.type = 0; /* default WEP key */
dk.index = 0; /* ignored when setting default key */
dk.defaultKeyNum = i;
- memcpy(dk.key, adev->wep_keys[i].key, dk.keySize);
+ memcpy(dk.key, adev->ieee->sec.keys[i], dk.keySize);
acx_s_issue_cmd(adev, ACX1xx_CMD_WEP_MGMT, &dk, sizeof(dk));
}
}
@@ -5514,7 +5514,7 @@ acx100_s_init_wep(acx_device_t *adev)
}
/* let's choose maximum setting: 4 default keys, plus 10 other keys: */
- options.NumKeys = cpu_to_le16(DOT11_MAX_DEFAULT_WEP_KEYS + 10);
+ options.NumKeys = cpu_to_le16(WEP_KEYS + 10);
options.WEPOption = 0x00;
log(L_ASSOC, "%s: writing WEP options\n", __func__);
@@ -5522,10 +5522,10 @@ acx100_s_init_wep(acx_device_t *adev)
acx100_s_set_wepkey(adev);
- if (adev->wep_keys[adev->wep_current_index].size != 0) {
+ if (adev->ieee->sec.key_sizes[adev->ieee->sec.active_key] != 0) {
log(L_ASSOC, "setting active default WEP key number: %d\n",
- adev->wep_current_index);
- dk.KeyID = adev->wep_current_index;
+ adev->ieee->sec.active_key);
+ dk.KeyID = adev->ieee->sec.active_key;
acx_s_configure(adev, &dk, ACX1xx_IE_DOT11_WEP_DEFAULT_KEY_SET); /* 0x1010 */
}
/* FIXME!!! wep_key_struct is filled nowhere! But adev
@@ -6581,7 +6581,7 @@ acx_s_update_card_settings(acx_device_t
acx_s_set_wepkey(adev);
- dkey.KeyID = adev->wep_current_index;
+ dkey.KeyID = adev->ieee->sec.active_key;
log(L_INIT, "setting WEP key %u as default\n", dkey.KeyID);
acx_s_configure(adev, &dkey, ACX1xx_IE_DOT11_WEP_DEFAULT_KEY_SET);
#ifdef DEBUG_WEP
@@ -6602,7 +6602,7 @@ acx_s_update_card_settings(acx_device_t
/* let's choose maximum setting: 4 default keys,
* plus 10 other keys: */
- options.NumKeys = cpu_to_le16(DOT11_MAX_DEFAULT_WEP_KEYS + 10);
+ options.NumKeys = cpu_to_le16(WEP_KEYS + 10);
/* don't decrypt default key only,
* don't override decryption: */
options.WEPOption = 0;
@@ -6905,7 +6905,7 @@ acx_update_capabilities(acx_device_t *ad
/* other types of stations do not emit beacons */
}
- if (adev->wep_restricted) {
+ if (adev->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY) {
SET_BIT(cap, WF_MGMT_CAP_PRIVACY);
}
if (adev->cfgopt_dot11ShortPreambleOption) {
@@ -7135,10 +7135,74 @@ module_exit(acx_e_cleanup_module)
//SM
void
-acx_e_ieee80211_set_security(struct net_device *dev,
+acx_e_ieee80211_set_security(struct net_device *ndev,
struct ieee80211_security *sec)
{
-//todo
+/* Shamelessly copied from the rt2x00 project. */
+ acx_device_t *adev = ndev2adev(ndev);
+ unsigned long flags;
+ int i;
+
+ acx_sem_lock(adev);
+ acx_lock(adev, flags);
+
+ for (i = 0; i < WEP_KEYS; ++i) {
+ /* This gives us the flag for the 4 WEP keys. */
+ if (sec->flags & (1 << i)) {
+ adev->ieee->sec.encode_alg[i] = sec->encode_alg[i];
+ adev->ieee->sec.key_sizes[i] = sec->key_sizes[i];
+
+ if (sec->key_sizes[i] != 0) {
+ memcpy(adev->ieee->sec.keys[i], sec->keys[i],
+ sec->key_sizes[i]);
+ /* Make sure WEP flag is set. */
+ adev->ieee->sec.flags |= (1 << i);
+ } else if (sec->level != SEC_LEVEL_1)
+ /* Make sure WEP flag isn't set. */
+ adev->ieee->sec.flags &= ~(1 << i);
+ }
+ SET_BIT(adev->set_mask, SET_WEP_OPTIONS);
+ }
+
+ if (sec->flags & SEC_ACTIVE_KEY) {
+ /* Check the key number is valid. */
+ if (sec->active_key < WEP_KEYS) {
+ adev->ieee->sec.active_key = sec->active_key;
+ adev->ieee->sec.flags |= SEC_ACTIVE_KEY;
+ } else
+ adev->ieee->sec.flags &= ~SEC_ACTIVE_KEY;
+
+ } else
+ adev->ieee->sec.flags &= ~SEC_ACTIVE_KEY;
+
+ if (sec->flags & SEC_AUTH_MODE) {
+ adev->ieee->sec.auth_mode = sec->auth_mode;
+ adev->ieee->sec.flags |= SEC_AUTH_MODE;
+ SET_BIT(adev->set_mask, SET_WEP_OPTIONS);
+ }
+
+ if (sec->flags & SEC_ENCRYPT) {
+ adev->ieee->sec.encrypt = sec->encrypt;
+ adev->ieee->sec.flags |= SEC_ENCRYPT;
+ SET_BIT(adev->set_mask, GETSET_WEP);
+ }
+
+ if (sec->flags & SEC_ENABLED) {
+ adev->ieee->sec.enabled = sec->enabled;
+ adev->ieee->sec.flags |= SEC_ENABLED;
+ SET_BIT(adev->set_mask, GETSET_WEP);
+ }
+
+ if (sec->flags & SEC_LEVEL) {
+ adev->ieee->sec.level = sec->level;
+ adev->ieee->sec.flags |= SEC_LEVEL;
+ SET_BIT(adev->set_mask, GETSET_WEP);
+ }
+
+ acx_unlock(adev, flags);
+ acx_sem_unlock(adev);
+
+ acx_s_update_card_settings(adev);
}
diff -urp acxsm-0123.orig/ioctl.c acxsm-0123/ioctl.c
--- acxsm-0123.orig/ioctl.c 2006-01-16 15:25:41.000000000 +0100
+++ acxsm-0123/ioctl.c 2006-01-29 14:07:08.000000000 +0100
@@ -1024,7 +1024,7 @@ acx_ioctl_set_encode(
if (dwrq->length > 0) {
/* if index is 0 or invalid, use default key */
if ((index < 0) || (index > 3))
- index = (int)adev->wep_current_index;
+ index = (int)adev->ieee->sec.active_key;
if (0 == (dwrq->flags & IW_ENCODE_NOKEY)) {
if (dwrq->length > 29)
@@ -1032,26 +1032,26 @@ acx_ioctl_set_encode(
if (dwrq->length > 13) {
/* 29*8 == 232, WEP256 */
- adev->wep_keys[index].size = 29;
+ adev->ieee->sec.key_sizes[index] = 29;
} else if (dwrq->length > 5) {
/* 13*8 == 104bit, WEP128 */
- adev->wep_keys[index].size = 13;
+ adev->ieee->sec.key_sizes[index] = 13;
} else if (dwrq->length > 0) {
/* 5*8 == 40bit, WEP64 */
- adev->wep_keys[index].size = 5;
+ adev->ieee->sec.key_sizes[index] = 5;
} else {
/* disable key */
- adev->wep_keys[index].size = 0;
+ adev->ieee->sec.key_sizes[index] = 0;
}
- memset(adev->wep_keys[index].key, 0,
- sizeof(adev->wep_keys[index].key));
- memcpy(adev->wep_keys[index].key, extra, dwrq->length);
+ memset(adev->ieee->sec.keys[index], 0,
+ sizeof(adev->ieee->sec.keys[index]));
+ memcpy(adev->ieee->sec.keys[index], extra, dwrq->length);
}
} else {
/* set transmit key */
if ((index >= 0) && (index <= 3))
- adev->wep_current_index = index;
+ adev->ieee->sec.active_key = index;
else if (0 == (dwrq->flags & IW_ENCODE_MODE)) {
/* complain if we were not just setting
* the key mode */
@@ -1060,15 +1060,13 @@ acx_ioctl_set_encode(
}
}
- adev->wep_enabled = !(dwrq->flags & IW_ENCODE_DISABLED);
+ adev->ieee->sec.enabled = !(dwrq->flags & IW_ENCODE_DISABLED);
if (dwrq->flags & IW_ENCODE_OPEN) {
- adev->auth_alg = WLAN_AUTH_ALG_OPENSYSTEM;
- adev->wep_restricted = 0;
+ adev->ieee->sec.auth_mode = WLAN_AUTH_OPEN;
} else if (dwrq->flags & IW_ENCODE_RESTRICTED) {
- adev->auth_alg = WLAN_AUTH_ALG_SHAREDKEY;
- adev->wep_restricted = 1;
+ adev->ieee->sec.auth_mode = WLAN_AUTH_SHARED_KEY;
}
/* set flag to make sure the card WEP settings get updated */
@@ -1078,11 +1076,11 @@ acx_ioctl_set_encode(
dwrq->length, extra, dwrq->flags);
for (index = 0; index <= 3; index++) {
- if (adev->wep_keys[index].size) {
+ if (adev->ieee->sec.key_sizes[index]) {
log(L_IOCTL, "index=%d, size=%d, key at 0x%p\n",
- adev->wep_keys[index].index,
- (int) adev->wep_keys[index].size,
- adev->wep_keys[index].key);
+ adev->ieee->sec.active_key,
+ (int) adev->ieee->sec.key_sizes[index],
+ adev->ieee->sec.keys[index]);
}
}
result = -EINPROGRESS;
@@ -1111,18 +1109,18 @@ acx_ioctl_get_encode(
FN_ENTER;
- if (adev->wep_enabled == 0) {
+ if (adev->ieee->sec.enabled == 0) {
dwrq->flags = IW_ENCODE_DISABLED;
} else {
if ((index < 0) || (index > 3))
- index = (int)adev->wep_current_index;
+ index = (int)adev->ieee->sec.active_key;
- dwrq->flags = (adev->wep_restricted == 1) ?
+ dwrq->flags = (adev->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY) ?
IW_ENCODE_RESTRICTED : IW_ENCODE_OPEN;
- dwrq->length = adev->wep_keys[index].size;
+ dwrq->length = adev->ieee->sec.key_sizes[index];
- memcpy(extra, adev->wep_keys[index].key,
- adev->wep_keys[index].size);
+ memcpy(extra, adev->ieee->sec.keys[index],
+ adev->ieee->sec.key_sizes[index]);
}
/* set the current index */
diff -urp acxsm-0123.orig/pci.c acxsm-0123/pci.c
--- acxsm-0123.orig/pci.c 2006-01-22 16:48:35.000000000 +0100
+++ acxsm-0123/pci.c 2006-01-29 15:23:51.000000000 +0100
@@ -1641,6 +1641,10 @@ acxpci_e_probe(struct pci_dev *pdev, con
adev->softmac = ieee80211_priv(ndev);
adev->softmac->set_channel = acx_e_ieee80211_set_chan;
+ adev->ieee->sec.encrypt = 0;
+ adev->ieee->sec.enabled = 0;
+ adev->ieee->sec.auth_mode = WLAN_AUTH_OPEN;
+
#ifdef NONESSENTIAL_FEATURES
acx_show_card_eeprom_id(adev);
#endif /* NONESSENTIAL_FEATURES */
diff -urp acxsm-0123.orig/usb.c acxsm-0123/usb.c
--- acxsm-0123.orig/usb.c 2006-01-15 23:55:25.000000000 +0100
+++ acxsm-0123/usb.c 2006-01-28 20:59:40.000000000 +0100
@@ -677,6 +677,10 @@ acxusb_e_probe(struct usb_interface *int
adev->softmac = ieee80211_priv(ndev);
adev->softmac->set_channel = acx_e_ieee80211_set_chan;
+ adev->ieee->sec.enabled = 0;
+ adev->ieee->sec.encrypt = 0;
+ adev->ieee->sec.auth_mode = WLAN_AUTH_OPEN;
+
/* Check that this is really the hardware we know about.
** If not sure, at least notify the user that he
** may be in trouble...
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATH] acxsm: Move WEP code into softmac
2006-01-29 14:26 [PATH] acxsm: Move WEP code into softmac Carlos Martín
@ 2006-01-30 7:18 ` Denis Vlasenko
2006-01-30 15:46 ` Carlos Martín
0 siblings, 1 reply; 3+ messages in thread
From: Denis Vlasenko @ 2006-01-30 7:18 UTC (permalink / raw)
To: acx100-devel; +Cc: Carlos Martín, netdev
On Sunday 29 January 2006 16:26, Carlos Martín wrote:
> Hi,
>
> This patch moves the WEP handling code to use the softmac layer and
> implements acx_e_ieee80211_set_security(), based on the rt2x00 project's one.
Applied, thanks!
> I do have a couple of questions though:
>
> 1) adev->wep_restricted = 0 is the same as an open auth system, and
> adev->wep_restricted = 1 is the same as having a shared key auth system,
> right?
>
> 2) What is the purpose of the index field in key_struct_t? I've assumed it is
> the same as adev->wep_current_index, but I'm not sure this is correct.
To be honest, I did not pay much attention to inner WEP workings...
--
vda
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x103432&bid#0486&dat\x121642
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATH] acxsm: Move WEP code into softmac
2006-01-30 7:18 ` Denis Vlasenko
@ 2006-01-30 15:46 ` Carlos Martín
0 siblings, 0 replies; 3+ messages in thread
From: Carlos Martín @ 2006-01-30 15:46 UTC (permalink / raw)
To: Denis Vlasenko; +Cc: acx100-devel, netdev
On Monday 30 January 2006 08:18, Denis Vlasenko wrote:
>
> To be honest, I did not pay much attention to inner WEP workings...
That's alright then, it can always be fixed later.
cmn
--
Carlos Martín http://www.cmartin.tk
"Erdbeben? Sicherlich etwas, das mit Erdberen zu tun hat." -- me, paraphrased
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x103432&bid#0486&dat\x121642
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-01-30 15:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-29 14:26 [PATH] acxsm: Move WEP code into softmac Carlos Martín
2006-01-30 7:18 ` Denis Vlasenko
2006-01-30 15:46 ` Carlos Martín
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).