diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pcmcia/if_wavelan_ieee.h | 17 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_wi.c | 39 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_wireg.h | 34 |
3 files changed, 80 insertions, 10 deletions
diff --git a/sys/dev/pcmcia/if_wavelan_ieee.h b/sys/dev/pcmcia/if_wavelan_ieee.h index 9c9077b71f8..3ef054b76be 100644 --- a/sys/dev/pcmcia/if_wavelan_ieee.h +++ b/sys/dev/pcmcia/if_wavelan_ieee.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wavelan_ieee.h,v 1.1 1999/07/11 16:25:36 niklas Exp $ */ +/* $OpenBSD: if_wavelan_ieee.h,v 1.2 2000/02/03 00:56:45 angelos Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -195,6 +195,8 @@ struct wi_counters { #define WI_RID_WDS_ADDR5 0xFC15 /* port 1 MAC of WDS link node */ #define WI_RID_WDS_ADDR6 0xFC16 /* port 1 MAC of WDS link node */ #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 */ /* * Network parameters, dynamic configuration entities @@ -226,8 +228,21 @@ struct wi_counters { #define WI_RID_TX_RATE4 0xFCA2 #define WI_RID_TX_RATE5 0xFCA3 #define WI_RID_TX_RATE6 0xFCA4 +#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0 +#define WI_RID_TX_CRYPT_KEY 0xFCB1 #define WI_RID_TICK_TIME 0xFCE0 +struct wi_key { + u_int16_t wi_keylen; + u_int8_t wi_keydat[14]; +}; + +struct wi_ltv_keys { + u_int16_t wi_len; + u_int16_t wi_type; + struct wi_key wi_keys[4]; +}; + /* * NIC information */ diff --git a/sys/dev/pcmcia/if_wi.c b/sys/dev/pcmcia/if_wi.c index a89b6302168..1987185b837 100644 --- a/sys/dev/pcmcia/if_wi.c +++ b/sys/dev/pcmcia/if_wi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi.c,v 1.7 2000/02/02 18:47:02 deraadt Exp $ */ +/* $OpenBSD: if_wi.c,v 1.8 2000/02/03 00:56:45 angelos Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -135,7 +135,7 @@ u_int32_t widebug = WIDEBUG; #if !defined(lint) static const char rcsid[] = - "$OpenBSD: if_wi.c,v 1.7 2000/02/02 18:47:02 deraadt Exp $"; + "$OpenBSD: if_wi.c,v 1.8 2000/02/03 00:56:45 angelos Exp $"; #endif /* lint */ #ifdef foo @@ -302,6 +302,14 @@ wi_pcmcia_attach(parent, self, aux) wi_read_record(sc, &gen); sc->wi_channel = gen.wi_val; + /* + * Find out if we support WEP on this card. + */ + gen.wi_type = WI_RID_WEP_AVAIL; + gen.wi_len = 2; + wi_read_record(sc, &gen); + sc->wi_has_wep = gen.wi_val; + bzero((char *)&sc->wi_stats, sizeof(sc->wi_stats)); /* @@ -995,6 +1003,16 @@ STATIC void wi_setdef(sc, wreq) case WI_RID_MAX_SLEEP: sc->wi_max_sleep = wreq->wi_val[0]; break; + case WI_RID_ENCRYPTION: + sc->wi_use_wep = wreq->wi_val[0]; + break; + case WI_RID_TX_CRYPT_KEY: + sc->wi_tx_key = wreq->wi_val[0]; + break; + case WI_RID_DEFLT_CRYPT_KEYS: + bcopy((char *)wreq, (char *)&sc->wi_keys, + sizeof(struct wi_ltv_keys)); + break; default: break; } @@ -1081,6 +1099,14 @@ STATIC int wi_ioctl(ifp, command, data) bcopy((char *)&sc->wi_stats, (char *)&wreq.wi_val, sizeof(sc->wi_stats)); wreq.wi_len = (sizeof(sc->wi_stats) / 2) + 1; + } else if (wreq.wi_type == WI_RID_DEFLT_CRYPT_KEYS) { + /* For non-root user, return all-zeroes keys */ + if (suser(p->p_ucred, &p->p_acflag)) + bzero((char *)&wreq, + sizeof(struct wi_ltv_keys)); + else + bcopy((char *)&sc->wi_keys, (char *)&wreq, + sizeof(struct wi_ltv_keys)); } else { if (wi_read_record(sc, (struct wi_ltv_gen *)&wreq)) { error = EINVAL; @@ -1182,6 +1208,15 @@ STATIC void wi_init(xsc) (char *)&mac.wi_mac_addr, ETHER_ADDR_LEN); wi_write_record(sc, (struct wi_ltv_gen *)&mac); + /* Configure WEP. */ + if (sc->wi_has_wep) { + WI_SETVAL(WI_RID_ENCRYPTION, sc->wi_use_wep); + WI_SETVAL(WI_RID_TX_CRYPT_KEY, sc->wi_tx_key); + sc->wi_keys.wi_len = (sizeof(struct wi_ltv_keys) / 2) + 1; + sc->wi_keys.wi_type = WI_RID_DEFLT_CRYPT_KEYS; + wi_write_record(sc, (struct wi_ltv_gen *)&sc->wi_keys); + } + /* Initialize promisc mode. */ if (ifp->if_flags & IFF_PROMISC) { WI_SETVAL(WI_RID_PROMISC, 1); diff --git a/sys/dev/pcmcia/if_wireg.h b/sys/dev/pcmcia/if_wireg.h index d9c72d758d5..34759fd2a9c 100644 --- a/sys/dev/pcmcia/if_wireg.h +++ b/sys/dev/pcmcia/if_wireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wireg.h,v 1.4 1999/11/05 04:25:30 angelos Exp $ */ +/* $OpenBSD: if_wireg.h,v 1.5 2000/02/03 00:56:45 angelos Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -58,6 +58,27 @@ struct wi_counters { u_int32_t wi_rx_msg_in_bad_msg_frags; }; +/* + * Encryption controls. We can enable or disable encryption as + * well as specify up to 4 encryption keys. We can also specify + * which of the four keys will be used for transmit encryption. + */ +#define WI_RID_ENCRYPTION 0xFC20 +#define WI_RID_AUTHTYPE 0xFC21 +#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0 +#define WI_RID_TX_CRYPT_KEY 0xFCB1 +#define WI_RID_WEP_AVAIL 0xFD4F +struct wi_key { + u_int16_t wi_keylen; + u_int8_t wi_keydat[14]; +}; + +struct wi_ltv_keys { + u_int16_t wi_len; + u_int16_t wi_type; + struct wi_key wi_keys[4]; +}; + struct wi_softc { #ifndef __FreeBSD__ struct device sc_dev; @@ -83,17 +104,16 @@ struct wi_softc { char wi_node_name[32]; char wi_net_name[32]; char wi_ibss_name[32]; - u_int8_t wi_txbuf[1536]; + u_int8_t wi_txbuf[1596]; + int wi_has_wep; + int wi_use_wep; + int wi_tx_key; + struct wi_ltv_keys wi_keys; struct wi_counters wi_stats; -#ifdef __FreeBSD__ - int wi_unit; - struct callout_handle wi_stat_ch; -#else void *sc_ih; struct pcmcia_io_handle sc_pcioh; int sc_io_window; struct pcmcia_function *sc_pf; -#endif /* __FreeBSD__ */ }; #define WI_TIMEOUT 65536 |