patch-2.3.30 linux/drivers/net/wavelan.c
Next file: linux/drivers/net/wavelan.p.h
Previous file: linux/drivers/net/tokenring/tms380tr.c
Back to the patch index
Back to the overall index
- Lines: 229
- Date:
Sat Nov 27 15:27:48 1999
- Orig file:
v2.3.29/linux/drivers/net/wavelan.c
- Orig date:
Mon Oct 4 15:49:29 1999
diff -u --recursive --new-file v2.3.29/linux/drivers/net/wavelan.c linux/drivers/net/wavelan.c
@@ -1910,18 +1910,18 @@
case SIOCSIWNWID:
/* Set NWID in WaveLAN. */
- if(wrq->u.nwid.on)
+ if(!wrq->u.nwid.disabled)
{
- /* Set NWID in psa. */
- psa.psa_nwid[0] = (wrq->u.nwid.nwid & 0xFF00) >> 8;
- psa.psa_nwid[1] = wrq->u.nwid.nwid & 0xFF;
+ /* Set NWID in psa */
+ psa.psa_nwid[0] = (wrq->u.nwid.value & 0xFF00) >> 8;
+ psa.psa_nwid[1] = wrq->u.nwid.value & 0xFF;
psa.psa_nwid_select = 0x01;
psa_write(ioaddr, lp->hacr, (char *)psa.psa_nwid - (char *)&psa,
(unsigned char *)psa.psa_nwid, 3);
/* Set NWID in mmc. */
- m.w.mmw_netw_id_l = wrq->u.nwid.nwid & 0xFF;
- m.w.mmw_netw_id_h = (wrq->u.nwid.nwid & 0xFF00) >> 8;
+ m.w.mmw_netw_id_l = psa.psa_nwid[1];
+ m.w.mmw_netw_id_h = psa.psa_nwid[0];
mmc_write(ioaddr, (char *)&m.w.mmw_netw_id_l - (char *)&m,
(unsigned char *)&m.w.mmw_netw_id_l, 2);
mmc_out(ioaddr, mmwoff(0, mmw_loopt_sel), 0x00);
@@ -1945,8 +1945,9 @@
/* Read the NWID. */
psa_read(ioaddr, lp->hacr, (char *)psa.psa_nwid - (char *)&psa,
(unsigned char *)psa.psa_nwid, 3);
- wrq->u.nwid.nwid = (psa.psa_nwid[0] << 8) + psa.psa_nwid[1];
- wrq->u.nwid.on = psa.psa_nwid_select;
+ wrq->u.nwid.value = (psa.psa_nwid[0] << 8) + psa.psa_nwid[1];
+ wrq->u.nwid.disabled = !(psa.psa_nwid_select);
+ wrq->u.nwid.fixed = 1; /* Superfluous */
break;
case SIOCSIWFREQ:
@@ -2006,83 +2007,96 @@
wrq->u.sens.fixed = 1;
break;
- case SIOCSIWENCODE:
- /* Set encryption key. */
- if(!mmc_encr(ioaddr))
- {
- ret = -EOPNOTSUPP;
- break;
- }
-
- if(wrq->u.encoding.method)
- { /* Enable encryption. */
- int i;
- long long key = wrq->u.encoding.code;
-
- for(i = 7; i >= 0; i--)
- {
- psa.psa_encryption_key[i] = key & 0xFF;
- key >>= 8;
- }
- psa.psa_encryption_select = 1;
- psa_write(ioaddr, lp->hacr,
- (char *) &psa.psa_encryption_select - (char *) &psa,
- (unsigned char *) &psa.psa_encryption_select, 8+1);
-
- mmc_out(ioaddr, mmwoff(0, mmw_encr_enable),
- MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE);
- mmc_write(ioaddr, mmwoff(0, mmw_encr_key),
- (unsigned char *) &psa.psa_encryption_key, 8);
- }
- else
- { /* Disable encryption. */
- psa.psa_encryption_select = 0;
- psa_write(ioaddr, lp->hacr,
- (char *) &psa.psa_encryption_select - (char *) &psa,
- (unsigned char *) &psa.psa_encryption_select, 1);
-
- mmc_out(ioaddr, mmwoff(0, mmw_encr_enable), 0);
- }
- /* update the Wavelan checksum */
- update_psa_checksum(dev, ioaddr, lp->hacr);
- break;
-
- case SIOCGIWENCODE:
- /* Read the encryption key. */
- if(!mmc_encr(ioaddr))
- {
- ret = -EOPNOTSUPP;
- break;
- }
-
- /* Only super-user can see encryption key. */
- if(!suser())
- {
- ret = -EPERM;
- break;
- }
- else
- {
- int i;
- long long key = 0;
+ case SIOCSIWENCODE:
+ /* Set encryption key */
+ if(!mmc_encr(ioaddr))
+ {
+ ret = -EOPNOTSUPP;
+ break;
+ }
+
+ /* Basic checking... */
+ if(wrq->u.encoding.pointer != (caddr_t) 0)
+ {
+ /* Check the size of the key */
+ if(wrq->u.encoding.length != 8)
+ {
+ ret = -EINVAL;
+ break;
+ }
- psa_read(ioaddr, lp->hacr,
+ /* Copy the key in the driver */
+ if(copy_from_user(psa.psa_encryption_key, wrq->u.encoding.pointer,
+ wrq->u.encoding.length))
+ {
+ ret = -EFAULT;
+ break;
+ }
+
+ psa.psa_encryption_select = 1;
+ psa_write(ioaddr, lp->hacr,
(char *) &psa.psa_encryption_select - (char *) &psa,
- (unsigned char *) &psa.psa_encryption_select, 1+8);
- for(i = 0; i < 8; i++)
- {
- key <<= 8;
- key += psa.psa_encryption_key[i];
- }
- wrq->u.encoding.code = key;
-
- /* encryption is enabled */
- if(psa.psa_encryption_select)
- wrq->u.encoding.method = mmc_encr(ioaddr);
- else
- wrq->u.encoding.method = 0;
- }
- break;
+ (unsigned char *) &psa.psa_encryption_select, 8+1);
+
+ mmc_out(ioaddr, mmwoff(0, mmw_encr_enable),
+ MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE);
+ mmc_write(ioaddr, mmwoff(0, mmw_encr_key),
+ (unsigned char *) &psa.psa_encryption_key, 8);
+ }
+
+ if(wrq->u.encoding.flags & IW_ENCODE_DISABLED)
+ { /* disable encryption */
+ psa.psa_encryption_select = 0;
+ psa_write(ioaddr, lp->hacr,
+ (char *) &psa.psa_encryption_select - (char *) &psa,
+ (unsigned char *) &psa.psa_encryption_select, 1);
+
+ mmc_out(ioaddr, mmwoff(0, mmw_encr_enable), 0);
+ }
+ /* update the Wavelan checksum */
+ update_psa_checksum(dev, ioaddr, lp->hacr);
+ break;
+
+ case SIOCGIWENCODE:
+ /* Read the encryption key */
+ if(!mmc_encr(ioaddr))
+ {
+ ret = -EOPNOTSUPP;
+ break;
+ }
+
+ /* only super-user can see encryption key */
+ if(!suser())
+ {
+ ret = -EPERM;
+ break;
+ }
+
+ /* Basic checking... */
+ if(wrq->u.encoding.pointer != (caddr_t) 0)
+ {
+ /* Verify the user buffer */
+ ret = verify_area(VERIFY_WRITE, wrq->u.encoding.pointer, 8);
+ if(ret)
+ break;
+
+ psa_read(ioaddr, lp->hacr,
+ (char *) &psa.psa_encryption_select - (char *) &psa,
+ (unsigned char *) &psa.psa_encryption_select, 1+8);
+
+ /* encryption is enabled ? */
+ if(psa.psa_encryption_select)
+ wrq->u.encoding.flags = IW_ENCODE_ENABLED;
+ else
+ wrq->u.encoding.flags = IW_ENCODE_DISABLED;
+ wrq->u.encoding.flags |= mmc_encr(ioaddr);
+
+ /* Copy the key to the user buffer */
+ wrq->u.encoding.length = 8;
+ if(copy_to_user(wrq->u.encoding.pointer, psa.psa_encryption_key, 8))
+ ret = -EFAULT;
+ }
+ break;
case SIOCGIWRANGE:
/* basic checking */
@@ -2116,6 +2130,19 @@
range.num_bitrates = 1;
range.bitrate[0] = 2000000; /* 2 Mb/s */
+
+ /* Encryption supported ? */
+ if(mmc_encr(ioaddr))
+ {
+ range.encoding_size[0] = 8; /* DES = 64 bits key */
+ range.num_encoding_sizes = 1;
+ range.max_encoding_tokens = 1; /* Only one key possible */
+ }
+ else
+ {
+ range.num_encoding_sizes = 0;
+ range.max_encoding_tokens = 0;
+ }
/* Copy structure to the user buffer. */
if (copy_to_user(wrq->u.data.pointer, &range, sizeof(struct iw_range)))
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)