diff options
| author | onoe <onoe@NetBSD.org> | 2000-07-18 15:01:55 +0000 |
|---|---|---|
| committer | onoe <onoe@NetBSD.org> | 2000-07-18 15:01:55 +0000 |
| commit | 47f692248ffdc53d7f27aa7bf52ef0d4fd56bf0a (patch) | |
| tree | 2668b96fbe945f28cc41eb91ca52125d0754e3d5 /sys/dev | |
| parent | 65d37eff7f56dfddf765f2e596abc63e19942497 (diff) | |
add WEP support also for PRISM2 cards.
Corega works fine with WEP, but farallon doesn't work well with WEP for now..
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/pcmcia/if_wi.c | 91 | ||||
| -rw-r--r-- | sys/dev/pcmcia/if_wi_ieee.h | 8 |
2 files changed, 97 insertions, 2 deletions
diff --git a/sys/dev/pcmcia/if_wi.c b/sys/dev/pcmcia/if_wi.c index 64342742438..ab4838dcd0d 100644 --- a/sys/dev/pcmcia/if_wi.c +++ b/sys/dev/pcmcia/if_wi.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wi.c,v 1.24 2000/07/18 14:53:26 onoe Exp $ */ +/* $NetBSD: if_wi.c,v 1.25 2000/07/18 15:01:55 onoe Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -773,6 +773,41 @@ static int wi_read_record(sc, ltv) { u_int16_t *ptr; int i, len, code; + struct wi_ltv_gen *oltv, p2ltv; + + if (sc->sc_prism2) { + oltv = ltv; + switch (ltv->wi_type) { + case WI_RID_ENCRYPTION: + p2ltv.wi_type = WI_RID_P2_ENCRYPTION; + p2ltv.wi_len = 2; + ltv = &p2ltv; + break; + case WI_RID_TX_CRYPT_KEY: + p2ltv.wi_type = WI_RID_P2_TX_CRYPT_KEY; + p2ltv.wi_len = 2; + ltv = &p2ltv; + break; + case WI_RID_DEFLT_CRYPT_KEYS: + { + int error; + struct wi_ltv_str ws; + struct wi_ltv_keys *wk = (struct wi_ltv_keys *)ltv; + + for (i = 0; i < 4; i++) { + ws.wi_len = 4; + ws.wi_type = WI_RID_P2_CRYPT_KEY0 + i; + error = wi_read_record(sc, + (struct wi_ltv_gen *)&ws); + if (error) + return error; + memcpy(&wk->wi_keys[i].wi_keydat, ws.wi_str, 5); + wk->wi_keys[i].wi_keylen = 5; + } + return 0; + } + } + } /* Tell the NIC to enter record read mode. */ if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_READ, ltv->wi_type)) @@ -802,6 +837,22 @@ static int wi_read_record(sc, ltv) for (i = 0; i < ltv->wi_len - 1; i++) ptr[i] = CSR_READ_2(sc, WI_DATA1); + if (sc->sc_prism2) { + switch (code) { + case WI_RID_P2_ENCRYPTION: + oltv->wi_len = 2; + if (ltv->wi_val & 0x01) + oltv->wi_val = 1; + else + oltv->wi_val = 0; + break; + case WI_RID_P2_TX_CRYPT_KEY: + oltv->wi_len = 2; + oltv->wi_val = ltv->wi_val; + break; + } + } + return(0); } @@ -814,6 +865,44 @@ static int wi_write_record(sc, ltv) { u_int16_t *ptr; int i; + struct wi_ltv_gen p2ltv; + + if (sc->sc_prism2) { + switch (ltv->wi_type) { + case WI_RID_ENCRYPTION: + p2ltv.wi_type = WI_RID_P2_ENCRYPTION; + p2ltv.wi_len = 2; + if (ltv->wi_val) + p2ltv.wi_val = 0x03; + else + p2ltv.wi_val = 0x90; + ltv = &p2ltv; + break; + case WI_RID_TX_CRYPT_KEY: + p2ltv.wi_type = WI_RID_P2_TX_CRYPT_KEY; + p2ltv.wi_len = 2; + p2ltv.wi_val = ltv->wi_val; + ltv = &p2ltv; + break; + case WI_RID_DEFLT_CRYPT_KEYS: + { + int error; + struct wi_ltv_str ws; + struct wi_ltv_keys *wk = (struct wi_ltv_keys *)ltv; + for (i = 0; i < 4; i++) { + ws.wi_len = 4; + ws.wi_type = WI_RID_P2_CRYPT_KEY0 + i; + memcpy(ws.wi_str, &wk->wi_keys[i].wi_keydat, 5); + ws.wi_str[5] = '\0'; + error = wi_write_record(sc, + (struct wi_ltv_gen *)&ws); + if (error) + return error; + } + return 0; + } + } + } if (wi_seek(sc, ltv->wi_type, 0, WI_BAP1)) return(EIO); diff --git a/sys/dev/pcmcia/if_wi_ieee.h b/sys/dev/pcmcia/if_wi_ieee.h index 55acd14222f..6afcd93268a 100644 --- a/sys/dev/pcmcia/if_wi_ieee.h +++ b/sys/dev/pcmcia/if_wi_ieee.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_wi_ieee.h,v 1.4 2000/02/04 07:48:29 explorer Exp $ */ +/* $NetBSD: if_wi_ieee.h,v 1.5 2000/07/18 15:01:55 onoe Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -230,6 +230,12 @@ struct wi_counters { #define WI_RID_MCAST_PM_BUF 0xFC17 /* PM buffering of mcast */ #define WI_RID_ENCRYPTION 0xFC20 /* enable/disable WEP */ #define WI_RID_AUTHTYPE 0xFC21 /* specify authentication type */ +#define WI_RID_P2_TX_CRYPT_KEY 0xFC23 +#define WI_RID_P2_CRYPT_KEY0 0xFC24 +#define WI_RID_P2_CRYPT_KEY1 0xFC25 +#define WI_RID_P2_CRYPT_KEY2 0xFC26 +#define WI_RID_P2_CRYPT_KEY3 0xFC27 +#define WI_RID_P2_ENCRYPTION 0xFC28 /* * Network parameters, dynamic configuration entities |
