diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-06-17 10:18:29 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-06-17 10:18:29 +0000 |
commit | 30d20bf38a299122b405e75d2bf131e4801b0f95 (patch) | |
tree | 4f4e7b38c4123a71b6655e719bfaf2e97adf6a5d | |
parent | 67f5e8a89135315427dee855af1347d2ecaff15b (diff) |
Add first shoot of SCAN command.
-rw-r--r-- | sys/dev/pcmcia/if_malo.c | 104 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_maloreg.h | 3 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_malovar.h | 75 |
3 files changed, 151 insertions, 31 deletions
diff --git a/sys/dev/pcmcia/if_malo.c b/sys/dev/pcmcia/if_malo.c index 306ed78248c..7468aeb40de 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.16 2007/06/16 19:45:24 mglocker Exp $ */ +/* $OpenBSD: if_malo.c,v 1.17 2007/06/17 10:18:28 mglocker Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -91,6 +91,7 @@ void cmalo_hexdump(void *, int); int cmalo_cmd_get_hwspec(struct malo_softc *); int cmalo_cmd_rsp_hwspec(struct malo_softc *); int cmalo_cmd_set_reset(struct malo_softc *); +int cmalo_cmd_set_scan(struct malo_softc *); int cmalo_cmd_set_auth(struct malo_softc *); int cmalo_cmd_set_snmp(struct malo_softc *, uint16_t); int cmalo_cmd_set_radio(struct malo_softc *, uint16_t); @@ -246,12 +247,14 @@ malo_pcmcia_activate(struct device *dev, enum devact act) */ /* XXX experimental */ +#if 0 uint8_t ap[] = { 0x00, 0x17, 0x9a, 0x44, 0xda, 0x83 }; uint8_t chan[] = { 0x01 }; -#if 0 +uint8_t ssid[] = "nazgul"; +#endif uint8_t ap[] = { 0x00, 0x15, 0xe9, 0xa4, 0x6e, 0xd1 }; uint8_t chan[] = { 0x04 }; -#endif +uint8_t ssid[] = "foobar"; void cmalo_attach(void *arg) @@ -588,6 +591,8 @@ cmalo_init(struct ifnet *ifp) cmalo_cmd_set_snmp(sc, MALO_OID_SHORTRETRY); cmalo_cmd_set_snmp(sc, MALO_OID_FRAGTRESH); + //cmalo_cmd_set_scan(sc); + cmalo_cmd_set_assoc(sc); /* device up */ @@ -996,6 +1001,72 @@ cmalo_cmd_set_reset(struct malo_softc *sc) } int +cmalo_cmd_set_scan(struct malo_softc *sc) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct malo_cmd_header *hdr = sc->sc_cmd; + struct malo_cmd_body_scan *body; + struct malo_cmd_tlv_ssid *body_ssid; + struct malo_cmd_tlv_chanlist *body_chanlist; + struct malo_cmd_tlv_rates *body_rates; + struct malo_cmd_tlv_numprobes *body_numprobes; + uint16_t psize; + int i; + + bzero(sc->sc_cmd, MALO_CMD_BUFFER_SIZE); + psize = sizeof(*hdr) + sizeof(*body); + + hdr->cmd = htole16(MALO_CMD_SCAN); + hdr->seqnum = htole16(1); + hdr->result = 0; + body = (struct malo_cmd_body_scan *)(hdr + 1); + + body->bsstype = 0x03; /* any BSS */ + + body_ssid = sc->sc_cmd + psize; + body_ssid->type = htole16(MALO_TLV_TYPE_SSID); + body_ssid->size = htole16(0); + psize += sizeof(*body_ssid); + + body_chanlist = sc->sc_cmd + psize; + body_chanlist->type = htole16(MALO_TLV_TYPE_CHANLIST); + body_chanlist->size = htole16(sizeof(body_chanlist->data)); + for (i = 0; i < CHANNELS; i++) { + body_chanlist->data[i].radiotype = 0x00; + body_chanlist->data[i].channumber = (i + 1); + body_chanlist->data[i].scantype = 0x00; /* active */ + body_chanlist->data[i].minscantime = htole16(6); + body_chanlist->data[i].maxscantime = htole16(100); + } + psize += sizeof(*body_chanlist); + + body_rates = sc->sc_cmd + psize; + body_rates->type = htole16(MALO_TLV_TYPE_RATES); + body_rates->size = + htole16(ic->ic_sup_rates[IEEE80211_MODE_11G].rs_nrates); + bcopy(ic->ic_sup_rates[IEEE80211_MODE_11G].rs_rates, body_rates->data, + ic->ic_sup_rates[IEEE80211_MODE_11G].rs_nrates); + psize += (sizeof(*body_rates) - 1) + body_rates->size; + + body_numprobes = sc->sc_cmd + psize; + body_numprobes->type = htole16(MALO_TLV_TYPE_NUMPROBES); + body_numprobes->size = htole16(2); + body_numprobes->numprobes = htole16(1); + psize += sizeof(*body_numprobes); + + hdr->size = htole16(psize - sizeof(*hdr)); + + /* 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_auth(struct malo_softc *sc) { struct malo_cmd_header *hdr = sc->sc_cmd; @@ -1238,10 +1309,10 @@ cmalo_cmd_set_assoc(struct malo_softc *sc) struct ieee80211com *ic = &sc->sc_ic; struct malo_cmd_header *hdr = sc->sc_cmd; struct malo_cmd_body_assoc *body; - struct malo_cmd_body_assoc_ssid *body_ssid; - struct malo_cmd_body_assoc_phy *body_phy; - struct malo_cmd_body_assoc_cf *body_cf; - struct malo_cmd_body_assoc_rate *body_rate; + struct malo_cmd_tlv_ssid *body_ssid; + struct malo_cmd_tlv_phy *body_phy; + struct malo_cmd_tlv_cf *body_cf; + struct malo_cmd_tlv_rates *body_rates; uint16_t psize; bzero(sc->sc_cmd, MALO_CMD_BUFFER_SIZE); @@ -1259,7 +1330,7 @@ cmalo_cmd_set_assoc(struct malo_softc *sc) body_ssid = sc->sc_cmd + psize; body_ssid->type = htole16(MALO_TLV_TYPE_SSID); body_ssid->size = htole16(6); - bcopy("nazgul", body_ssid->data, 6); + bcopy(ssid, body_ssid->data, 6); psize += (sizeof(*body_ssid) - 1) + body_ssid->size; body_phy = sc->sc_cmd + psize; @@ -1273,13 +1344,13 @@ cmalo_cmd_set_assoc(struct malo_softc *sc) body_cf->size = htole16(0); psize += sizeof(*body_cf); - body_rate = sc->sc_cmd + psize; - body_rate->type = htole16(MALO_TLV_TYPE_RATES); - body_rate->size = + body_rates = sc->sc_cmd + psize; + body_rates->type = htole16(MALO_TLV_TYPE_RATES); + body_rates->size = htole16(ic->ic_sup_rates[IEEE80211_MODE_11G].rs_nrates); - bcopy(ic->ic_sup_rates[IEEE80211_MODE_11G].rs_rates, body_rate->data, + bcopy(ic->ic_sup_rates[IEEE80211_MODE_11G].rs_rates, body_rates->data, ic->ic_sup_rates[IEEE80211_MODE_11G].rs_nrates); - psize += (sizeof(*body_rate) - 1) + body_rate->size; + psize += (sizeof(*body_rates) - 1) + body_rates->size; hdr->size = htole16(psize - sizeof(*hdr)); @@ -1345,7 +1416,7 @@ cmalo_cmd_request(struct malo_softc *sc, uint16_t psize, int no_response) /* wait for the command response */ sc->sc_cmd_running = 1; - for (i = 0; i < 100; i++) { + for (i = 0; i < 1000; i++) { if (sc->sc_cmd_running == 0) break; tsleep(sc, 0, "malocmd", 1); @@ -1407,6 +1478,11 @@ cmalo_cmd_response(struct malo_softc *sc) case MALO_CMD_RESET: /* reset will not send back a response */ break; + case MALO_CMD_SCAN: + /* do nothing */ + DPRINTF(1, "%s: got scan cmd response\n", + sc->sc_dev.dv_xname); + break; case MALO_CMD_AUTH: /* do nothing */ DPRINTF(1, "%s: got auth cmd response\n", diff --git a/sys/dev/pcmcia/if_maloreg.h b/sys/dev/pcmcia/if_maloreg.h index 5dc69c510c9..38dd0cc58e5 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.7 2007/06/16 19:45:24 mglocker Exp $ */ +/* $OpenBSD: if_maloreg.h,v 1.8 2007/06/17 10:18:28 mglocker Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -51,6 +51,7 @@ #define MALO_CMD_RESP 0x8000 #define MALO_CMD_HWSPEC 0x0003 #define MALO_CMD_RESET 0x0005 +#define MALO_CMD_SCAN 0x0006 #define MALO_CMD_AUTH 0x0011 #define MALO_CMD_SNMP 0x0016 #define MALO_CMD_RADIO 0x001c diff --git a/sys/dev/pcmcia/if_malovar.h b/sys/dev/pcmcia/if_malovar.h index 30b969e519c..2ec1c063fd4 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.10 2007/06/16 19:45:24 mglocker Exp $ */ +/* $OpenBSD: if_malovar.h,v 1.11 2007/06/17 10:18:28 mglocker Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -42,7 +42,9 @@ #define MALO_DEVICE_ATTACHED (1 << 0) #define MALO_FW_LOADED (1 << 1) -/* FW command header */ +/* + * FW command structures + */ struct malo_cmd_header { uint16_t cmd; uint16_t size; @@ -51,7 +53,6 @@ struct malo_cmd_header { /* malo_cmd_body */ }; -/* FW command bodies */ struct malo_cmd_body_spec { uint16_t hw_if_version; uint16_t hw_version; @@ -67,6 +68,15 @@ struct malo_cmd_body_spec { uint32_t fw_capinfo; } __packed; +struct malo_cmd_body_scan { + uint8_t bsstype; + uint8_t bssid[ETHER_ADDR_LEN]; + /* malo_cmd_tlv_ssid */ + /* malo_cmd_tlv_chanlist */ + /* malo_cmd_tlv_rates */ + /* malo_cmd_tlv_numprobes */ +} __packed; + struct malo_cmd_body_auth { uint8_t peermac[ETHER_ADDR_LEN]; uint8_t authtype; @@ -124,40 +134,70 @@ struct malo_cmd_body_assoc { uint16_t listenintrv; uint16_t bcnperiod; uint8_t dtimperiod; - /* malo_cmd_body_assoc_ssid */ - /* malo_cmd_body_assoc_phy */ - /* malo_cmd_body_assoc_cf */ - /* malo_cmd_body_assoc_rate */ + /* malo_cmd_tlv_ssid */ + /* malo_cmd_tlv_phy */ + /* malo_cmd_tlv_cf */ + /* malo_cmd_tlv_rate */ +} __packed; + +struct malo_cmd_body_rate { + uint16_t action; + uint16_t hwauto; + uint16_t ratebitmap; } __packed; + +/* + * FW command TLV structures + */ #define MALO_TLV_TYPE_SSID 0x0000 +#define MALO_TLV_TYPE_RATES 0x0001 #define MALO_TLV_TYPE_PHY 0x0003 #define MALO_TLV_TYPE_CF 0x0004 -#define MALO_TLV_TYPE_RATES 0x0001 -struct malo_cmd_body_assoc_ssid { +#define MALO_TLV_TYPE_CHANLIST 0x0101 +#define MALO_TLV_TYPE_NUMPROBES 0x0102 + +struct malo_cmd_tlv_ssid { uint16_t type; uint16_t size; uint8_t data[1]; } __packed; -struct malo_cmd_body_assoc_phy { + +struct malo_cmd_tlv_rates { uint16_t type; uint16_t size; uint8_t data[1]; } __packed; -struct malo_cmd_body_assoc_cf { + +struct malo_cmd_tlv_phy { uint16_t type; uint16_t size; uint8_t data[1]; } __packed; -struct malo_cmd_body_assoc_rate { + +struct malo_cmd_tlv_cf { uint16_t type; uint16_t size; uint8_t data[1]; } __packed; -struct malo_cmd_body_rate { - uint16_t action; - uint16_t hwauto; - uint16_t ratebitmap; +struct malo_cmd_tlv_chanlist_param { + uint8_t radiotype; + uint8_t channumber; + uint8_t scantype; + uint16_t minscantime; + uint16_t maxscantime; +} __packed; +#define CHANNELS 12 +struct malo_cmd_tlv_chanlist { + uint16_t type; + uint16_t size; + struct malo_cmd_tlv_chanlist_param data[CHANNELS]; +} __packed; + +struct malo_cmd_tlv_numprobes { + uint16_t type; + uint16_t size; + uint16_t numprobes; } __packed; /* RX descriptor */ @@ -188,6 +228,9 @@ struct malo_tx_desc { uint8_t reserved[2]; } __packed; +/* + * Softc + */ struct malo_softc { struct device sc_dev; struct ieee80211com sc_ic; |