summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2007-08-05 10:05:58 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2007-08-05 10:05:58 +0000
commit06f4e73d9a8502c49c141e026e054966511ca1db (patch)
tree7418da7a0af49ee1494e41721f069e58841dafd3 /sys
parentb687ea83cafbd4ecb3396f1d75f884a96dbeb57d (diff)
Add WEP support, which is done fully by the FW.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pcmcia/if_malo.c94
-rw-r--r--sys/dev/pcmcia/if_maloreg.h3
-rw-r--r--sys/dev/pcmcia/if_malovar.h20
3 files changed, 114 insertions, 3 deletions
diff --git a/sys/dev/pcmcia/if_malo.c b/sys/dev/pcmcia/if_malo.c
index 2ecf0674cc0..0e7d66768d2 100644
--- a/sys/dev/pcmcia/if_malo.c
+++ b/sys/dev/pcmcia/if_malo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_malo.c,v 1.35 2007/08/05 09:09:15 mglocker Exp $ */
+/* $OpenBSD: if_malo.c,v 1.36 2007/08/05 10:05:57 mglocker Exp $ */
/*
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
@@ -89,6 +89,7 @@ int cmalo_tx(struct malo_softc *, struct mbuf *);
void cmalo_tx_done(struct malo_softc *);
void cmalo_select_network(struct malo_softc *);
void cmalo_reflect_network(struct malo_softc *);
+int cmalo_wep(struct malo_softc *);
void cmalo_hexdump(void *, int);
int cmalo_cmd_get_hwspec(struct malo_softc *);
@@ -98,6 +99,8 @@ int cmalo_cmd_set_scan(struct malo_softc *);
int cmalo_cmd_rsp_scan(struct malo_softc *);
int cmalo_parse_elements(struct malo_softc *, void *, int, int);
int cmalo_cmd_set_auth(struct malo_softc *);
+int cmalo_cmd_set_wep(struct malo_softc *, uint16_t,
+ struct ieee80211_key *);
int cmalo_cmd_set_snmp(struct malo_softc *, uint16_t);
int cmalo_cmd_set_radio(struct malo_softc *, uint16_t);
int cmalo_cmd_set_channel(struct malo_softc *, uint16_t);
@@ -622,6 +625,10 @@ cmalo_init(struct ifnet *ifp)
return (EIO);
if (cmalo_cmd_set_channel(sc, sc->sc_curchan) != 0)
return (EIO);
+ if (sc->sc_ic.ic_flags & IEEE80211_F_WEPON) {
+ if (cmalo_wep(sc) != 0)
+ return (EIO);
+ }
cmalo_cmd_set_rate(sc);
@@ -1026,6 +1033,27 @@ cmalo_reflect_network(struct malo_softc *sc)
ic->ic_bss->ni_chan = &ic->ic_channels[chan];
}
+int
+cmalo_wep(struct malo_softc *sc)
+{
+ struct ieee80211com *ic = &sc->sc_ic;
+ int i;
+
+ for (i = 0; i < IEEE80211_WEP_NKID; i++) {
+ struct ieee80211_key *key = &ic->ic_nw_keys[i];
+
+ if (!key->k_len)
+ continue;
+
+ DPRINTF(1, "%s: setting wep key for index %d\n",
+ sc->sc_dev.dv_xname, i);
+
+ cmalo_cmd_set_wep(sc, i, key);
+ }
+
+ return (0);
+}
+
void
cmalo_hexdump(void *buf, int len)
{
@@ -1290,6 +1318,65 @@ cmalo_cmd_set_auth(struct malo_softc *sc)
}
int
+cmalo_cmd_set_wep(struct malo_softc *sc, uint16_t index,
+ struct ieee80211_key *key)
+{
+ struct malo_cmd_header *hdr = sc->sc_cmd;
+ struct malo_cmd_body_wep *body;
+ uint16_t psize;
+
+ bzero(sc->sc_cmd, MALO_CMD_BUFFER_SIZE);
+ psize = sizeof(*hdr) + sizeof(*body);
+
+ hdr->cmd = htole16(MALO_CMD_WEP);
+ hdr->size = htole16(sizeof(*body));
+ hdr->seqnum = htole16(1);
+ hdr->result = 0;
+ body = (struct malo_cmd_body_wep *)(hdr + 1);
+
+ body->action = htole16(MALO_WEP_ACTION_TYPE_ADD);
+ body->key_index = htole16(index);
+
+ if (body->key_index == 0) {
+ if (key->k_len > 5)
+ body->key_type_1 = MALO_WEP_KEY_TYPE_104BIT;
+ else
+ body->key_type_1 = MALO_WEP_KEY_TYPE_40BIT;
+ bcopy(key->k_key, body->key_value_1, key->k_len);
+ }
+ if (body->key_index == 1) {
+ if (key->k_len > 5)
+ body->key_type_2 = MALO_WEP_KEY_TYPE_104BIT;
+ else
+ body->key_type_2 = MALO_WEP_KEY_TYPE_40BIT;
+ bcopy(key->k_key, body->key_value_2, key->k_len);
+ }
+ if (body->key_index == 2) {
+ if (key->k_len > 5)
+ body->key_type_3 = MALO_WEP_KEY_TYPE_104BIT;
+ else
+ body->key_type_3 = MALO_WEP_KEY_TYPE_40BIT;
+ bcopy(key->k_key, body->key_value_3, key->k_len);
+ }
+ if (body->key_index == 3) {
+ if (key->k_len > 5)
+ body->key_type_4 = MALO_WEP_KEY_TYPE_104BIT;
+ else
+ body->key_type_4 = MALO_WEP_KEY_TYPE_40BIT;
+ bcopy(key->k_key, body->key_value_4, key->k_len);
+ }
+
+ /* process command request */
+ if (cmalo_cmd_request(sc, psize, 0) != 0)
+ return (EIO);
+
+ /* process command repsonse */
+ cmalo_cmd_response(sc);
+
+ return (0);
+}
+
+int
cmalo_cmd_set_snmp(struct malo_softc *sc, uint16_t oid)
{
struct malo_cmd_header *hdr = sc->sc_cmd;
@@ -1806,6 +1893,11 @@ cmalo_cmd_response(struct malo_softc *sc)
DPRINTF(1, "%s: got auth cmd response\n",
sc->sc_dev.dv_xname);
break;
+ case MALO_CMD_WEP:
+ /* do nothing */
+ DPRINTF(1, "%s: got wep cmd response\n",
+ sc->sc_dev.dv_xname);
+ break;
case MALO_CMD_SNMP:
/* do nothing */
DPRINTF(1, "%s: got snmp cmd response\n",
diff --git a/sys/dev/pcmcia/if_maloreg.h b/sys/dev/pcmcia/if_maloreg.h
index c242bb78ec9..0ec05cd0d8d 100644
--- a/sys/dev/pcmcia/if_maloreg.h
+++ b/sys/dev/pcmcia/if_maloreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_maloreg.h,v 1.10 2007/06/30 12:08:57 mglocker Exp $ */
+/* $OpenBSD: if_maloreg.h,v 1.11 2007/08/05 10:05:57 mglocker Exp $ */
/*
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
@@ -53,6 +53,7 @@
#define MALO_CMD_RESET 0x0005
#define MALO_CMD_SCAN 0x0006
#define MALO_CMD_AUTH 0x0011
+#define MALO_CMD_WEP 0x0013
#define MALO_CMD_SNMP 0x0016
#define MALO_CMD_RADIO 0x001c
#define MALO_CMD_CHANNEL 0x001d
diff --git a/sys/dev/pcmcia/if_malovar.h b/sys/dev/pcmcia/if_malovar.h
index 6785b4d3739..448f66b7213 100644
--- a/sys/dev/pcmcia/if_malovar.h
+++ b/sys/dev/pcmcia/if_malovar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_malovar.h,v 1.18 2007/08/05 09:09:15 mglocker Exp $ */
+/* $OpenBSD: if_malovar.h,v 1.19 2007/08/05 10:05:57 mglocker Exp $ */
/*
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
@@ -95,6 +95,24 @@ struct malo_cmd_body_auth {
uint8_t authtype;
} __packed;
+#define MALO_WEP_ACTION_TYPE_ADD 0x02
+#define MALO_WEP_ACTION_TYPE_REMOVE 0x04
+#define MALO_WEP_ACTION_TYPE_DEFAULT 0x08
+#define MALO_WEP_KEY_TYPE_40BIT 0x01
+#define MALO_WEP_KEY_TYPE_104BIT 0x02
+struct malo_cmd_body_wep {
+ uint16_t action;
+ uint16_t key_index;
+ uint8_t key_type_1;
+ uint8_t key_type_2;
+ uint8_t key_type_3;
+ uint8_t key_type_4;
+ uint8_t key_value_1[16];
+ uint8_t key_value_2[16];
+ uint8_t key_value_3[16];
+ uint8_t key_value_4[16];
+} __packed;
+
#define MALO_OID_BSS 0x00
#define MALO_OID_RATE 0x01
#define MALO_OID_BCNPERIOD 0x02