summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2000-02-02 17:59:13 +0000
committerwpaul <wpaul@FreeBSD.org>2000-02-02 17:59:13 +0000
commit648f1c0043b77da223e3c4418ee52d4d86c48f92 (patch)
tree4565ff7da1c5bedcc9c7b406a9c9112264a665d3 /sys/i386
parent9ec448d8ca74d7b5cd8a49b34bf919870bd0a75c (diff)
downloadFreeBSD-src-648f1c0043b77da223e3c4418ee52d4d86c48f92.zip
FreeBSD-src-648f1c0043b77da223e3c4418ee52d4d86c48f92.tar.gz
Add support for WEP (encryption) for silver and gold WaveLAN/IEEE turbo cards.
Also update wicontrol to enable/disable encryption, set WEP keys and set the TX key index. Silver cards only have 40-bit keys. This is something of a quick hack, but it works well enough for me to commit this from the LinuxWorld exhibit floor. The WEP support only shows up if you have a card that supports it. Would have been approved by: jkh, if he hadn't wandered off somewhere Approved in his place by: msmith, who's standing right here
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/include/if_wavelan_ieee.h15
-rw-r--r--sys/i386/isa/if_wi.c30
-rw-r--r--sys/i386/isa/if_wireg.h27
3 files changed, 71 insertions, 1 deletions
diff --git a/sys/i386/include/if_wavelan_ieee.h b/sys/i386/include/if_wavelan_ieee.h
index 5e5d2e3..5e1046a 100644
--- a/sys/i386/include/if_wavelan_ieee.h
+++ b/sys/i386/include/if_wavelan_ieee.h
@@ -210,6 +210,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
@@ -241,8 +243,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/i386/isa/if_wi.c b/sys/i386/isa/if_wi.c
index 6f005f7..e678b02 100644
--- a/sys/i386/isa/if_wi.c
+++ b/sys/i386/isa/if_wi.c
@@ -310,6 +310,14 @@ static int wi_pccard_attach(device_t dev)
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));
wi_init(sc);
@@ -932,6 +940,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;
}
@@ -999,6 +1017,9 @@ 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) {
+ bcopy((char *)&sc->wi_keys, (char *)&wreq,
+ sizeof(struct wi_ltv_keys));
}
#ifdef WICACHE
else if (wreq.wi_type == WI_RID_ZERO_CACHE) {
@@ -1111,6 +1132,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/i386/isa/if_wireg.h b/sys/i386/isa/if_wireg.h
index 65cba4d..42e4637 100644
--- a/sys/i386/isa/if_wireg.h
+++ b/sys/i386/isa/if_wireg.h
@@ -56,6 +56,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 {
struct arpcom arpcom;
struct ifmedia ifmedia;
@@ -84,8 +105,12 @@ 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];
struct wi_counters wi_stats;
+ int wi_has_wep;
+ int wi_use_wep;
+ int wi_tx_key;
+ struct wi_ltv_keys wi_keys;
#ifdef WICACHE
int wi_sigitems;
struct wi_sigcache wi_sigcache[MAXWICACHE];
OpenPOWER on IntegriCloud