aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/airo.c59
1 files changed, 27 insertions, 32 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index a08aadfa09ac..e4ca5f84d610 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1233,6 +1233,9 @@ struct airo_info {
1233#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE 1233#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE
1234 char proc_name[IFNAMSIZ]; 1234 char proc_name[IFNAMSIZ];
1235 1235
1236 int wep_capable;
1237 int max_wep_idx;
1238
1236 /* WPA-related stuff */ 1239 /* WPA-related stuff */
1237 unsigned int bssListFirst; 1240 unsigned int bssListFirst;
1238 unsigned int bssListNext; 1241 unsigned int bssListNext;
@@ -2836,6 +2839,9 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2836 rc = -EIO; 2839 rc = -EIO;
2837 goto err_out_wifi; 2840 goto err_out_wifi;
2838 } 2841 }
2842 /* WEP capability discovery */
2843 ai->wep_capable = (cap_rid.softCap & cpu_to_le16(0x02)) ? 1 : 0;
2844 ai->max_wep_idx = (cap_rid.softCap & cpu_to_le16(0x80)) ? 3 : 0;
2839 2845
2840 airo_print_info(dev->name, "Firmware version %x.%x.%02x", 2846 airo_print_info(dev->name, "Firmware version %x.%x.%02x",
2841 ((le16_to_cpu(cap_rid.softVer) >> 8) & 0xF), 2847 ((le16_to_cpu(cap_rid.softVer) >> 8) & 0xF),
@@ -6265,11 +6271,9 @@ static int airo_get_mode(struct net_device *dev,
6265 return 0; 6271 return 0;
6266} 6272}
6267 6273
6268static inline int valid_index(CapabilityRid *p, int index) 6274static inline int valid_index(struct airo_info *ai, int index)
6269{ 6275{
6270 if (index < 0) 6276 return (index >= 0) && (index <= ai->max_wep_idx);
6271 return 0;
6272 return index < (p->softCap & cpu_to_le16(0x80) ? 4 : 1);
6273} 6277}
6274 6278
6275/*------------------------------------------------------------------*/ 6279/*------------------------------------------------------------------*/
@@ -6282,16 +6286,12 @@ static int airo_set_encode(struct net_device *dev,
6282 char *extra) 6286 char *extra)
6283{ 6287{
6284 struct airo_info *local = dev->ml_priv; 6288 struct airo_info *local = dev->ml_priv;
6285 CapabilityRid cap_rid; /* Card capability info */
6286 int perm = ( dwrq->flags & IW_ENCODE_TEMP ? 0 : 1 ); 6289 int perm = ( dwrq->flags & IW_ENCODE_TEMP ? 0 : 1 );
6287 __le16 currentAuthType = local->config.authType; 6290 __le16 currentAuthType = local->config.authType;
6288 6291
6289 /* Is WEP supported ? */ 6292 if (!local->wep_capable)
6290 readCapabilityRid(local, &cap_rid, 1);
6291 /* Older firmware doesn't support this...
6292 if(!(cap_rid.softCap & cpu_to_le16(2))) {
6293 return -EOPNOTSUPP; 6293 return -EOPNOTSUPP;
6294 } */ 6294
6295 readConfigRid(local, 1); 6295 readConfigRid(local, 1);
6296 6296
6297 /* Basic checking: do we have a key to set ? 6297 /* Basic checking: do we have a key to set ?
@@ -6304,13 +6304,16 @@ static int airo_set_encode(struct net_device *dev,
6304 wep_key_t key; 6304 wep_key_t key;
6305 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 6305 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
6306 int current_index = get_wep_key(local, 0xffff); 6306 int current_index = get_wep_key(local, 0xffff);
6307
6307 /* Check the size of the key */ 6308 /* Check the size of the key */
6308 if (dwrq->length > MAX_KEY_SIZE) { 6309 if (dwrq->length > MAX_KEY_SIZE) {
6309 return -EINVAL; 6310 return -EINVAL;
6310 } 6311 }
6312
6311 /* Check the index (none -> use current) */ 6313 /* Check the index (none -> use current) */
6312 if (!valid_index(&cap_rid, index)) 6314 if (!valid_index(local, index))
6313 index = current_index; 6315 index = current_index;
6316
6314 /* Set the length */ 6317 /* Set the length */
6315 if (dwrq->length > MIN_KEY_SIZE) 6318 if (dwrq->length > MIN_KEY_SIZE)
6316 key.len = MAX_KEY_SIZE; 6319 key.len = MAX_KEY_SIZE;
@@ -6339,12 +6342,13 @@ static int airo_set_encode(struct net_device *dev,
6339 } else { 6342 } else {
6340 /* Do we want to just set the transmit key index ? */ 6343 /* Do we want to just set the transmit key index ? */
6341 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 6344 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
6342 if (valid_index(&cap_rid, index)) { 6345 if (valid_index(local, index))
6343 set_wep_key(local, index, NULL, 0, perm, 1); 6346 set_wep_key(local, index, NULL, 0, perm, 1);
6344 } else 6347 else {
6345 /* Don't complain if only change the mode */ 6348 /* Don't complain if only change the mode */
6346 if (!(dwrq->flags & IW_ENCODE_MODE)) 6349 if (!(dwrq->flags & IW_ENCODE_MODE))
6347 return -EINVAL; 6350 return -EINVAL;
6351 }
6348 } 6352 }
6349 /* Read the flags */ 6353 /* Read the flags */
6350 if(dwrq->flags & IW_ENCODE_DISABLED) 6354 if(dwrq->flags & IW_ENCODE_DISABLED)
@@ -6370,14 +6374,12 @@ static int airo_get_encode(struct net_device *dev,
6370{ 6374{
6371 struct airo_info *local = dev->ml_priv; 6375 struct airo_info *local = dev->ml_priv;
6372 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 6376 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
6373 CapabilityRid cap_rid; /* Card capability info */
6374 6377
6375 /* Is it supported ? */ 6378 if (!local->wep_capable)
6376 readCapabilityRid(local, &cap_rid, 1);
6377 if(!(cap_rid.softCap & cpu_to_le16(2))) {
6378 return -EOPNOTSUPP; 6379 return -EOPNOTSUPP;
6379 } 6380
6380 readConfigRid(local, 1); 6381 readConfigRid(local, 1);
6382
6381 /* Check encryption mode */ 6383 /* Check encryption mode */
6382 switch(local->config.authType) { 6384 switch(local->config.authType) {
6383 case AUTH_ENCRYPT: 6385 case AUTH_ENCRYPT:
@@ -6396,7 +6398,7 @@ static int airo_get_encode(struct net_device *dev,
6396 memset(extra, 0, 16); 6398 memset(extra, 0, 16);
6397 6399
6398 /* Which key do we want ? -1 -> tx index */ 6400 /* Which key do we want ? -1 -> tx index */
6399 if (!valid_index(&cap_rid, index)) 6401 if (!valid_index(local, index))
6400 index = get_wep_key(local, 0xffff); 6402 index = get_wep_key(local, 0xffff);
6401 dwrq->flags |= index + 1; 6403 dwrq->flags |= index + 1;
6402 /* Copy the key to the user buffer */ 6404 /* Copy the key to the user buffer */
@@ -6419,24 +6421,20 @@ static int airo_set_encodeext(struct net_device *dev,
6419 struct airo_info *local = dev->ml_priv; 6421 struct airo_info *local = dev->ml_priv;
6420 struct iw_point *encoding = &wrqu->encoding; 6422 struct iw_point *encoding = &wrqu->encoding;
6421 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 6423 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6422 CapabilityRid cap_rid; /* Card capability info */
6423 int perm = ( encoding->flags & IW_ENCODE_TEMP ? 0 : 1 ); 6424 int perm = ( encoding->flags & IW_ENCODE_TEMP ? 0 : 1 );
6424 __le16 currentAuthType = local->config.authType; 6425 __le16 currentAuthType = local->config.authType;
6425 int idx, key_len, alg = ext->alg, set_key = 1; 6426 int idx, key_len, alg = ext->alg, set_key = 1;
6426 wep_key_t key; 6427 wep_key_t key;
6427 6428
6428 /* Is WEP supported ? */ 6429 if (!local->wep_capable)
6429 readCapabilityRid(local, &cap_rid, 1);
6430 /* Older firmware doesn't support this...
6431 if(!(cap_rid.softCap & cpu_to_le16(2))) {
6432 return -EOPNOTSUPP; 6430 return -EOPNOTSUPP;
6433 } */ 6431
6434 readConfigRid(local, 1); 6432 readConfigRid(local, 1);
6435 6433
6436 /* Determine and validate the key index */ 6434 /* Determine and validate the key index */
6437 idx = encoding->flags & IW_ENCODE_INDEX; 6435 idx = encoding->flags & IW_ENCODE_INDEX;
6438 if (idx) { 6436 if (idx) {
6439 if (!valid_index(&cap_rid, idx - 1)) 6437 if (!valid_index(local, idx - 1))
6440 return -EINVAL; 6438 return -EINVAL;
6441 idx--; 6439 idx--;
6442 } else 6440 } else
@@ -6505,14 +6503,11 @@ static int airo_get_encodeext(struct net_device *dev,
6505 struct airo_info *local = dev->ml_priv; 6503 struct airo_info *local = dev->ml_priv;
6506 struct iw_point *encoding = &wrqu->encoding; 6504 struct iw_point *encoding = &wrqu->encoding;
6507 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 6505 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6508 CapabilityRid cap_rid; /* Card capability info */
6509 int idx, max_key_len; 6506 int idx, max_key_len;
6510 6507
6511 /* Is it supported ? */ 6508 if (!local->wep_capable)
6512 readCapabilityRid(local, &cap_rid, 1);
6513 if(!(cap_rid.softCap & cpu_to_le16(2))) {
6514 return -EOPNOTSUPP; 6509 return -EOPNOTSUPP;
6515 } 6510
6516 readConfigRid(local, 1); 6511 readConfigRid(local, 1);
6517 6512
6518 max_key_len = encoding->length - sizeof(*ext); 6513 max_key_len = encoding->length - sizeof(*ext);
@@ -6521,7 +6516,7 @@ static int airo_get_encodeext(struct net_device *dev,
6521 6516
6522 idx = encoding->flags & IW_ENCODE_INDEX; 6517 idx = encoding->flags & IW_ENCODE_INDEX;
6523 if (idx) { 6518 if (idx) {
6524 if (!valid_index(&cap_rid, idx - 1)) 6519 if (!valid_index(local, idx - 1))
6525 return -EINVAL; 6520 return -EINVAL;
6526 idx--; 6521 idx--;
6527 } else 6522 } else