diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2004-12-04 23:56:51 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2004-12-04 23:56:51 +0000 |
commit | 07a5f4616f006459591a72a1877123ba83c8519b (patch) | |
tree | d6dfeb954703b5bf05bd76468bd5d07f73ce4af7 /sys | |
parent | c53e29df38d74e5ae2e874097c4db7174be5803b (diff) |
remove code that is now unused because of the move to net80211 and the
rx/tx cleanup
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/if_atu.c | 757 | ||||
-rw-r--r-- | sys/dev/usb/if_atureg.h | 89 |
2 files changed, 6 insertions, 840 deletions
diff --git a/sys/dev/usb/if_atu.c b/sys/dev/usb/if_atu.c index b9db4320b28..68ed5d99e88 100644 --- a/sys/dev/usb/if_atu.c +++ b/sys/dev/usb/if_atu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atu.c,v 1.29 2004/12/04 23:36:15 dlg Exp $ */ +/* $OpenBSD: if_atu.c,v 1.30 2004/12/04 23:56:49 dlg Exp $ */ /* * Copyright (c) 2003, 2004 * Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved. @@ -136,11 +136,9 @@ struct atu_type atu_devs[] = { }; int atu_newbuf(struct atu_softc *, struct atu_chain *, struct mbuf *); -int atu_encap(struct atu_softc *sc, struct mbuf *m, struct atu_chain *c); void atu_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status); void atu_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status); void atu_start(struct ifnet *); -void atu_mgmt_loop(void *arg); int atu_ioctl(struct ifnet *, u_long, caddr_t); int atu_init(struct ifnet *); void atu_stop(struct ifnet *, int); @@ -163,17 +161,11 @@ int atu_start_scan(struct atu_softc *sc); int atu_switch_radio(struct atu_softc *sc, int state); int atu_initial_config(struct atu_softc *sc); int atu_join(struct atu_softc *sc, struct ieee80211_node *node); -int atu_send_packet(struct atu_softc *sc, struct atu_chain *c); -int atu_send_mgmt_packet(struct atu_softc *sc, - struct atu_chain *c, u_int16_t length); -int atu_authenticate(struct atu_softc *sc); -int atu_associate(struct atu_softc *sc); int8_t atu_get_dfu_state(struct atu_softc *sc); u_int8_t atu_get_opmode(struct atu_softc *sc, u_int8_t *mode); int atu_upload_internal_firmware(struct atu_softc *sc); int atu_upload_external_firmware(struct atu_softc *sc); int atu_get_card_config(struct atu_softc *sc); -int atu_mgmt_state_machine(struct atu_softc *sc); int atu_media_change(struct ifnet *ifp); void atu_media_status(struct ifnet *ifp, struct ifmediareq *req); int atu_xfer_list_init(struct atu_softc *sc, struct atu_chain *ch, @@ -181,8 +173,6 @@ int atu_xfer_list_init(struct atu_softc *sc, struct atu_chain *ch, int atu_rx_list_init(struct atu_softc *); void atu_xfer_list_free(struct atu_softc *sc, struct atu_chain *ch, int listlen); -void atu_print_beacon(struct atu_softc *sc, struct atu_rxpkt *pkt); -void atu_handle_mgmt_packet(struct atu_softc *sc, struct atu_rxpkt *pkt); void atu_print_a_bunch_of_debug_things(struct atu_softc *sc); int atu_set_wepkey(struct atu_softc *sc, int nr, u_int8_t *key, int len); @@ -749,197 +739,6 @@ atu_join(struct atu_softc *sc, struct ieee80211_node *node) return err; } -int -atu_send_packet(struct atu_softc *sc, struct atu_chain *c) -{ - usbd_status err; - struct atu_txpkt *pkt; - - /* Don't try to send when we're shutting down the driver */ - if (sc->atu_dying) - return(EIO); - - pkt = (struct atu_txpkt *)c->atu_buf; - - usbd_setup_xfer(c->atu_xfer, sc->atu_ep[ATU_ENDPT_TX], - c, c->atu_buf, c->atu_length, USBD_NO_COPY, ATU_TX_TIMEOUT, - atu_txeof); - - /* Let's get this thing into the air! */ - c->atu_in_xfer = 1; - err = usbd_transfer(c->atu_xfer); - if (err != USBD_IN_PROGRESS) { - atu_stop(&sc->sc_ic.ic_if, 0); - return(EIO); - } - - DPRINTFN(10, ("%s: tx packet...\n", USBDEVNAME(sc->atu_dev))); - return 0; -} - -int -atu_send_mgmt_packet(struct atu_softc *sc, struct atu_chain *c, - u_int16_t length) -{ - struct ieee80211com *ic = &sc->sc_ic; - struct atu_mgmt_packet *packet; - - packet = (struct atu_mgmt_packet *)c->atu_buf; - - packet->athdr.wlength = length - sizeof(packet->athdr); - packet->athdr.tx_rate = 4; - packet->athdr.padding = 0; - memset(packet->athdr.reserved, 0x00, 4); - - packet->mgmt_hdr.duration = 0x8000; - memcpy(packet->mgmt_hdr.dst_addr, sc->atu_bssid, ETHER_ADDR_LEN); - memcpy(packet->mgmt_hdr.src_addr, ic->ic_myaddr, IEEE80211_ADDR_LEN); - memcpy(packet->mgmt_hdr.bssid, sc->atu_bssid, ETHER_ADDR_LEN); - packet->mgmt_hdr.seq_ctl = 0; - - c->atu_length = length; - return atu_send_packet(sc, c); -} - -int -atu_authenticate(struct atu_softc *sc) -{ - usbd_status err; - struct atu_chain *ch; - struct atu_auth_packet *packet; - - /* - * now we should authenticate : - * 7.2.3.10 - page 64 of 802.11b spec - * 8.1 - page 74 of 802.11b spec - * see 7.3.1.9 - page 69 for status codes - * - * open systems : - * send: seq_nr=1 auth req - * recv: seq_nr=2 auth resp. (with status code) - * - * shared key systems : - * send: seq_nr=1 auth req - * recv: seq_nr=2 auth challenge (with status code & challenge - * text) - * send: seq_nr=3 auth reponse (wep encr challenge text) - * recv: seq_nr=4 auth result - * - * algorithm number : - * 0 = open - * 1 = shared - */ - - ch = SLIST_FIRST(&sc->atu_cdata.atu_mgmt_free); - if (ch == NULL) { - DPRINTF(("%s: authenticate: no mgmt transfers available\n", - USBDEVNAME(sc->atu_dev))); - return ENOMEM; - } - SLIST_REMOVE_HEAD(&sc->atu_cdata.atu_mgmt_free, atu_list); - - packet = (struct atu_auth_packet *)ch->atu_buf; - - packet->mgmt_hdr.frame_ctl = WI_FTYPE_MGMT | - IEEE80211_FC0_SUBTYPE_AUTH; - - packet->auth_hdr.wi_algo = 0; - packet->auth_hdr.wi_seq = 1; - packet->auth_hdr.wi_status = 0; - - DPRINTFN(15, ("%s: auth packet: %30D\n", USBDEVNAME(sc->atu_dev), - ((u_int8_t *)packet)+8, " ")); - - err = atu_send_mgmt_packet(sc, ch, sizeof(*packet)); - if (err) { - DPRINTF(("%s: could not send auth packet\n", - USBDEVNAME(sc->atu_dev))); - } - - /* - * TODO: implement shared key auth - */ - /* - packet->algoritm = 1; - packet->sequence = 3; - packet->status = 0; - - memcpy(packet->challenge, the_challenge_text, the_challenge_length); - - DPRINTFN(15, ("%s: auth packet: %30D\n", USBDEVNAME(sc->atu_dev), - ((u_int8_t *)packet)+8, " ")); - - if (sc->atu_encrypt & ATU_WEP_TX) { - packet->mgmt_hdr.frame_ctl |= WI_FCTL_WEP; - DPRINTFN(20, ("%s: ==> WEP on please\n", - USBDEVNAME(sc->atu_dev))); - } - - err = atu_send_mgmt_packet(sc, ch, sizeof(*packet) + challenge_len); - if (err) { - DPRINTF(("%s: could not send auth packet 2\n", - USBDEVNAME(sc->atu_dev))); - } - */ - return 0; -} - -int -atu_associate(struct atu_softc *sc) -{ - usbd_status err; - struct atu_chain *ch; - u_int8_t *ptr; - struct atu_assoc_packet *packet; - - /* - * associate : - * 7.2.3.4 - page 62 of 802.11b spec - * - */ - - ch = SLIST_FIRST(&sc->atu_cdata.atu_mgmt_free); - if (ch == NULL) { - DPRINTF(("%s: associate: no mgmt transfers left\n", - USBDEVNAME(sc->atu_dev))); - return ENOMEM; - } - SLIST_REMOVE_HEAD(&sc->atu_cdata.atu_mgmt_free, atu_list); - - packet = (struct atu_assoc_packet *)ch->atu_buf; - - packet->mgmt_hdr.frame_ctl = WI_FTYPE_MGMT | - IEEE80211_FC0_SUBTYPE_ASSOC_REQ; - - packet->capability = 1 + 32; /* ess & short preamble */ - packet->capability = 1; - packet->listen_interval = 100; /* beacon interval */ - - ptr = packet->data; - *ptr++ = WI_VAR_SSID; /* SSID */ - *ptr++ = sc->atu_ssidlen; - memcpy(ptr, sc->atu_ssid, sc->atu_ssidlen); - ptr += sc->atu_ssidlen; - - *ptr++ = WI_VAR_SRATES; /* supported rates */ - *ptr++ = 0x04; - *ptr++ = 0x82; - *ptr++ = 0x84; - *ptr++ = 0x8b; - *ptr++ = 0x96; - - DPRINTFN(15, ("%s: associate packet: %50D\n", - USBDEVNAME(sc->atu_dev), (u_int8_t *)packet, " ")); - - err = atu_send_mgmt_packet(sc, ch, sizeof(*packet) + 2 + - sc->atu_ssidlen + 6); - if (err) { - DPRINTF(("%s: could not send associate packet\n", - USBDEVNAME(sc->atu_dev))); - } - return 0; -} - /* * Get the state of the DFU unit */ @@ -1290,222 +1089,6 @@ USB_MATCH(atu) return(UMATCH_NONE); } -/* - * this routine gets called from the mgmt thread at least once a second. - * if we return 0 the thread will go to sleep, if we return 1 we will be - * called again immediately (like 'continue' does in a while-loop) - */ -int -atu_mgmt_state_machine(struct atu_softc *sc) -{ - struct atu_mgmt *vars = &sc->atu_mgmt_vars; - usbd_status err; - u_int8_t statusreq[6]; - int s; - - if (sc->atu_mgmt_flags & ATU_CHANGED_SETTINGS) { - sc->atu_mgmt_flags &= ~ATU_CHANGED_SETTINGS; - sc->atu_mgmt_flags &= ~ATU_FOUND_BSSID; - sc->atu_mgmt_flags &= ~ATU_AUTH_OK; - sc->atu_mgmt_flags &= ~ATU_RE_AUTH; - sc->atu_mgmt_flags &= ~ATU_ASSOC_OK; - sc->atu_mgmt_flags |= ATU_SEARCHING; - vars->state = STATE_LISTENING; - vars->retry = 0; - } - - DPRINTFN(5, ("%s: [state=%s, retry=%d, chan=%d d-chan=%d enc=%d]\n", - USBDEVNAME(sc->atu_dev), atu_mgmt_statename[vars->state], - vars->retry, sc->atu_channel, sc->atu_desired_channel, - sc->atu_encrypt)); - - /* Fall back to authentication if needed */ - /* TODO: should we only allow this when in infra-mode? */ - if ((sc->atu_mgmt_flags & ATU_RE_AUTH) && - (vars->state >= STATE_AUTHENTICATING)) { - vars->state = STATE_AUTHENTICATING; - sc->atu_mgmt_flags &= ~(ATU_RE_AUTH | ATU_AUTH_OK | - ATU_ASSOC_OK); - vars->retry = 0; - } - - /* Fall back to association if needed */ - /* TODO: should we only allow this when in infra-mode? */ - if ((sc->atu_mgmt_flags & ATU_RE_ASSOC) && - (vars->state >= STATE_ASSOCIATING)) { - vars->state = STATE_ASSOCIATING; - sc->atu_mgmt_flags &= ~(ATU_RE_ASSOC | ATU_AUTH_OK | - ATU_ASSOC_OK); - vars->retry = 0; - } - - switch (vars->state) { - case STATE_NONE: - /* awaiting orders */ - break; - case STATE_LISTENING: - /* do some nifty scanning here */ - - if (sc->atu_mgmt_flags & ATU_FOUND_BSSID) { - vars->state = STATE_JOINING; - vars->retry = 0; - return 1; - } - s = splusb(); - err = atu_get_cmd_status(sc, CMD_JOIN, statusreq); - if (err) { - DPRINTF(("%s: get_cmd_status failed in mgmt_loop\n", - USBDEVNAME(sc->atu_dev))); - vars->state = STATE_GIVEN_UP; - vars->retry = 0; - } - if (statusreq[5]==STATUS_IN_PROGRESS) { - DPRINTFN(10, ("%s: scanning in progress...\n", - USBDEVNAME(sc->atu_dev))); - } else { - err = atu_start_scan(sc); - if (vars->retry++ > ATU_SCAN_RETRIES && - sc->atu_mode == AD_HOC_MODE) { - DPRINTFN(10, ("%s: scanned long enough\n", - USBDEVNAME(sc->atu_dev))); - sc->atu_mgmt_flags &= ~ATU_SEARCHING; - vars->state = STATE_CREATING_IBSS; - vars->retry = 0; - } - if (err) { - DPRINTF(("%s: get_cmd_failed in mgmt_loop\n", - USBDEVNAME(sc->atu_dev))); - vars->state = STATE_GIVEN_UP; - vars->retry = 0; - } - } - splx(s); - break; - case STATE_JOINING: - DPRINTFN(10, ("%s: going to join\n", - USBDEVNAME(sc->atu_dev))); - //err = atu_join(sc, ); - if (err) { - if (vars->retry++ > ATU_JOIN_RETRIES) { - if (sc->atu_mode == AD_HOC_MODE) - vars->state = STATE_CREATING_IBSS; - else - vars->state = STATE_GIVEN_UP; - vars->retry = 0; - } - DPRINTF(("%s: error joining\n", - USBDEVNAME(sc->atu_dev))); - } else { - if (sc->atu_mode == AD_HOC_MODE) - vars->state = STATE_HAPPY_NETWORKING; - else - vars->state = STATE_AUTHENTICATING; - vars->retry = 0; - } - break; - case STATE_AUTHENTICATING: - if (sc->atu_mgmt_flags & ATU_AUTH_OK) { - vars->state = STATE_ASSOCIATING; - vars->retry = 0; - return 1; - } - - DPRINTFN(10, ("%s: trying authentication\n", - USBDEVNAME(sc->atu_dev))); - atu_authenticate(sc); - if (vars->retry++ > ATU_AUTH_RETRIES) { - vars->state = STATE_GIVEN_UP; - DPRINTF(("%s: error authenticating...\n", - USBDEVNAME(sc->atu_dev))); - } - break; - case STATE_ASSOCIATING: - if (sc->atu_mgmt_flags & ATU_ASSOC_OK) { - vars->state = STATE_HAPPY_NETWORKING; - vars->retry = 0; - return 1; - } - DPRINTFN(10, ("%s: trying to associate\n", - USBDEVNAME(sc->atu_dev))); - atu_associate(sc); - if (vars->retry++ > ATU_ASSOC_RETRIES) { - vars->state = STATE_GIVEN_UP; - DPRINTF(("%s: error associating...\n", - USBDEVNAME(sc->atu_dev))); - } - break; - case STATE_CREATING_IBSS: - DPRINTFN(10, ("%s: trying to create IBSS\n", - USBDEVNAME(sc->atu_dev))); - err = atu_start_ibss(sc); - if (err) { - if (vars->retry++ > ATU_IBSS_RETRIES) - vars->state = STATE_GIVEN_UP; - DPRINTF(("%s: error creating IBSS...\n", - USBDEVNAME(sc->atu_dev))); - } else { - vars->state = STATE_HAPPY_NETWORKING; - vars->retry = 0; - } - break; - case STATE_HAPPY_NETWORKING: - /* happy networking - * - * TODO: - * we should bounce back to previous states from here - * on beacon timeout. - */ - break; - case STATE_GIVEN_UP: - /* - * can only leave this state if someone changes the - * config - */ - break; - } - - if (vars->state == STATE_HAPPY_NETWORKING) - sc->atu_mgmt_flags |= ATU_NETWORK_OK; - else - sc->atu_mgmt_flags &= ~ATU_NETWORK_OK; - return 0; -} - -void -atu_mgmt_loop(void *arg) -{ - struct atu_softc *sc = arg; - int again; - int s; - - DPRINTFN(10, ("%s: mgmt task initialised\n", - USBDEVNAME(sc->atu_dev))); - - sc->atu_mgmt_vars.state = STATE_NONE; - sc->atu_mgmt_vars.retry = 0; - - while (!sc->atu_dying) { - s = splnet(); - again = atu_mgmt_state_machine(sc); - while (again) - again = atu_mgmt_state_machine(sc); - splx(s); - - /* - * wait for something to happen (but not too long :) - * if someone changes the config or a mgmt packet is received - * we will be waken up - */ - tsleep(sc, PZERO | PCATCH, "atum", ATU_MGMT_INTERVAL); - } - - DPRINTFN(10, ("%s: mgmt thread stops now...\n", - USBDEVNAME(sc->atu_dev))); - sc->atu_dying++; - sc->atu_mgmt_flags &= ~ATU_TASK_RUNNING; - kthread_exit(0); -} - int atu_media_change(struct ifnet *ifp) { @@ -1962,310 +1545,6 @@ atu_xfer_list_free(struct atu_softc *sc, struct atu_chain *ch, } } -void -atu_print_beacon(struct atu_softc *sc, struct atu_rxpkt *pkt) -{ - u_int8_t *ptr; - struct tlv *tlv; - u_int8_t *end; - u_int8_t tmp; - u_int8_t rate; - - /* Let's have a closer look at this beacon... */ - ptr = (u_int8_t *)pkt->WiHeader.addr4 + 12; - end = ptr + pkt->AtHeader.wlength - 24 - 12 - 4; - tlv = (struct tlv *)ptr; - - while ((ptr<end) && (ptr + 2 + tlv->length <= end)) { - switch (tlv->type) { - case WI_VAR_SSID: /* SSID */ - /* sanity check */ - if (tlv->length > 32) - break; - - tmp = tlv->value[tlv->length]; - tlv->value[tlv->length] = 0; - DPRINTF(("%s: ssid=[%s]\n", USBDEVNAME(sc->atu_dev), - tlv->value)); - tlv->value[tlv->length] = tmp; - break; - case WI_VAR_SRATES: /* Supported rates */ - for (rate=0; rate<tlv->length; rate++) { - tmp = tlv->value[rate] & (~0x80); - DPRINTF(("%s: rate: %d kbps (%02x)\n", - USBDEVNAME(sc->atu_dev), 500 * tmp, - tlv->value[rate])); - } - break; - case WI_VAR_DS: /* DS (channel) */ - DPRINTF(("%s: channel=%d\n", - USBDEVNAME(sc->atu_dev), *tlv->value)); - break; - default : - DPRINTF(("%s: tlv: t=%02x l=%02x v[0]=%02x\n", - USBDEVNAME(sc->atu_dev), tlv->type, tlv->length, - tlv->value[0])); - } - - ptr += 2 + tlv->length; - tlv = (struct tlv *)ptr; - } -} - -void -atu_handle_mgmt_packet(struct atu_softc *sc, struct atu_rxpkt *pkt) -{ - u_int8_t *ptr; - struct tlv *tlv; - u_int8_t *end; - u_int8_t tmp; - int match; - int match_channel = 1; - struct wi_80211_beacon *beacon; - struct wi_mgmt_auth_hdr *auth; - struct wi_mgmt_deauth_hdr *deauth; - struct wi_mgmt_disas_hdr *deassoc; - struct wi_mgmt_asresp_hdr *assoc; - - switch (pkt->WiHeader.frame_ctl & WI_FCTL_STYPE) { - case WI_STYPE_MGMT_AUTH: - DPRINTFN(15, ("%s: received auth response...\n", - USBDEVNAME(sc->atu_dev))); - - auth = (struct wi_mgmt_auth_hdr *)pkt->WiHeader.addr4; - - if (auth->wi_seq != 2) { - DPRINTF(("%s: auth wrong seq.nr (%x)\n", - USBDEVNAME(sc->atu_dev), auth->wi_seq)); - break; - } - if (auth->wi_status != 0) { - DPRINTF(("%s: auth status error (%x)\n", - USBDEVNAME(sc->atu_dev), auth->wi_status)); - break; - } - - /* TODO: should check bssid & mac ! */ - - sc->atu_mgmt_flags |= ATU_AUTH_OK; - wakeup(sc); - - /* - * TODO: DAAN Daan daan - Add challenge text blah blah - * (for shared-key systems) - */ - /* - memcpy(the_challenge_text, ((u_int8_t *)&pkt->WiHeader) + 30, - the_challenge_length); - DPRINTFN(15, ("%s: challenge= %100D\n", - USBDEVNAME(sc->atu_dev), the_challende_text, " ")); - */ - break; - - case WI_STYPE_MGMT_DEAUTH: - DPRINTF(("%s: the AP has de-authenticated us\n", - USBDEVNAME(sc->atu_dev))); - - deauth = (struct wi_mgmt_deauth_hdr *)pkt->WiHeader.addr4; - - DPRINTF(("%s: de-authentication reason: %04x\n", - USBDEVNAME(sc->atu_dev), deauth->wi_reason)); - - /* TODO: should check bssid & mac ! */ - - /* wake up the state machine to get us re-authenticated */ - sc->atu_mgmt_flags |= ATU_RE_AUTH; - wakeup(sc); - break; - - case WI_STYPE_MGMT_ASRESP: - DPRINTFN(15, ("%s: received assoc response...\n", - USBDEVNAME(sc->atu_dev))); - - assoc = (struct wi_mgmt_asresp_hdr *)pkt->WiHeader.addr4; - - if (assoc->wi_status == 0) { - sc->atu_mgmt_flags |= ATU_ASSOC_OK; - wakeup(sc); - } else { - DPRINTF(("%s: assoc status error (%x)\n", - USBDEVNAME(sc->atu_dev), assoc->wi_status)); - break; - } - - /* TODO: should check bssid & mac ! */ - wakeup(sc); - - break; - - case WI_STYPE_MGMT_DISAS: - DPRINTF(("%s: the AP has de-associated us", - USBDEVNAME(sc->atu_dev))); - - deassoc = (struct wi_mgmt_disas_hdr *)pkt->WiHeader.addr4; - - DPRINTF(("%s: de-association reason: %04x\n", - USBDEVNAME(sc->atu_dev), deassoc->wi_reason)); - - /* TODO: should check bssid & mac ! */ - - /* wake up the state machine to get us re-authenticated */ - sc->atu_mgmt_flags |= ATU_RE_ASSOC; - wakeup(sc); - break; - - case WI_STYPE_MGMT_PROBERESP: - DPRINTFN(20, ("%s: PROBE RESPONSE\n", - USBDEVNAME(sc->atu_dev))); - /* FALLTHROUGH */ - case WI_STYPE_MGMT_BEACON: - - beacon = (struct wi_80211_beacon *)&pkt->WiHeader.addr4; - - /* Show beacon src MAC & signal strength */ - DPRINTFN(18, ("%s: mgmt bssid=%s", USBDEVNAME(sc->atu_dev), - ether_sprintf(pkt->WiHeader.addr3))); - DPRINTFN(18, (" mac=%s signal=%d\n", - ether_sprintf(pkt->WiHeader.addr2), pkt->AtHeader.rssi)); - -#ifdef ATU_DEBUG - if (atudebug > 20) { - /* - * calculate average signal strength, can be very - * usefull when precisely aiming antenna's - * NOTE: this is done on ALL beacons, so multiple - * stations can end up in the average. this only - * works well if we're only receiving one station. - */ - sc->atu_signaltotal += pkt->AtHeader.rssi; - sc->atu_signaltotal -= - sc->atu_signalarr[sc->atu_signalptr]; - sc->atu_signalarr[sc->atu_signalptr] = - pkt->AtHeader.rssi; - sc->atu_signalptr=(sc->atu_signalptr+1) % - ATU_AVG_TIME; - DPRINTF(("%s: mgmt mac=%s signal=%02d ptr=%02d " - "avg=%02d.%02d\n", USBDEVNAME(sc->atu_dev), - ether_sprintf(pkt->WiHeader.addr2), - pkt->AtHeader.rssi, sc->atu_signalptr, - sc->atu_signaltotal / ATU_AVG_TIME, - (sc->atu_signaltotal * 100 / ATU_AVG_TIME) % - 100)); - } -#endif - - DPRINTFN(18, ("%s: mgmt capabilities=%04x (mode=%s, wep=%s, " - "short-preamble=%s)\n", USBDEVNAME(sc->atu_dev), - beacon->flags, - (beacon->flags & IEEE80211_CAPINFO_ESS) ? - "infra" : "ad-hoc", - (beacon->flags & IEEE80211_CAPINFO_PRIVACY) ? - "on" : "off", - (beacon->flags & IEEE80211_CAPINFO_SHORT_PREAMBLE) ? - "yes" : "no")); - -#ifdef ATU_DEBUG - if (atudebug > 18) - atu_print_beacon(sc, pkt); -#endif - if (!(sc->atu_mgmt_flags & ATU_SEARCHING)) - break; - - /* Let's have a closer look at this beacon... */ - ptr = (u_int8_t *)pkt->WiHeader.addr4 + 12; - end = ptr + pkt->AtHeader.wlength - 24 - 12 - 4; - tlv = (struct tlv *)ptr; - match = 0; - while ((ptr<end) && (ptr + 2 + tlv->length <= end)) { - switch (tlv->type) { - case WI_VAR_SSID: /* SSID */ - /* sanity check */ - if (tlv->length > 32) - break; - - tmp = tlv->value[tlv->length]; - tlv->value[tlv->length] = 0; - sc->atu_ssid[sc->atu_ssidlen] = 0; - if (!strcmp(tlv->value, sc->atu_ssid)) { - match = 1; - } - tlv->value[tlv->length] = tmp; - break; - case WI_VAR_SRATES: /* Supported rates */ - /* - * TODO: should check if we support all - * mandatory rates - */ - break; - case WI_VAR_DS: /* DS (channel) */ - if (match) - match_channel = *tlv->value; - break; - } - - ptr += 2 + tlv->length; - tlv = (struct tlv *)ptr; - } - - /* check mode... */ - beacon = (struct wi_80211_beacon *)&pkt->WiHeader.addr4; - if (match) { - if ((sc->atu_mode == AD_HOC_MODE) && - (beacon->flags & IEEE80211_CAPINFO_ESS)) { - match = 0; - DPRINTF(("%s: SSID matches, but we're in " - "adhoc mode instead of infra\n", - USBDEVNAME(sc->atu_dev))); - } - if ((sc->atu_mode == INFRASTRUCTURE_MODE) && - (!(beacon->flags & IEEE80211_CAPINFO_ESS))) { - match = 0; - DPRINTF(("%s: SSID matches, but we're in " - "infra mode instead of adhoc\n", - USBDEVNAME(sc->atu_dev))); - } - if ((sc->atu_desired_channel != IEEE80211_CHAN_ANY) && - (match_channel != sc->atu_desired_channel)) { - match = 0; - DPRINTF(("%s: SSID matches, but the channel " - "doesn't (%d != %d)\n", - USBDEVNAME(sc->atu_dev), match_channel, - sc->atu_desired_channel)); - } - - if (!match) { - break; - } - } - - if (match) { - DPRINTF(("%s: ==> MATCH! (BSSID=%s, ch=%d)\n", - USBDEVNAME(sc->atu_dev), - ether_sprintf(pkt->WiHeader.addr3), - match_channel)); - - /* - * TODO: should do some channel-checking here instead - * of just ignoring the channel the user sets - */ - - memcpy(sc->atu_bssid, pkt->WiHeader.addr3, - ETHER_ADDR_LEN); - sc->atu_channel = match_channel; - - sc->atu_mgmt_flags &= ~ATU_SEARCHING; - sc->atu_mgmt_flags |= ATU_FOUND_BSSID; - } - - break; - - default: - DPRINTF(("%s: FIXME: unhandled mgmt type! (stype=%x)\n", - USBDEVNAME(sc->atu_dev), - pkt->WiHeader.frame_ctl & WI_FCTL_STYPE)); - } -} - /* XXX Horrible hack to fix channel number of beacons and probe responses */ void atu_fix_channel(struct ieee80211com *ic, struct mbuf *m) @@ -2488,40 +1767,6 @@ atu_calculate_padding(int size) #endif /* ATU_TX_PADDING */ int -atu_encap(struct atu_softc *sc, struct mbuf *m, struct atu_chain *c) -{ - int total_len; - struct atu_txpkt *pkt; -#ifdef ATU_TX_PADDING - u_int8_t padding; -#endif /* ATU_TX_PADDING */ - - /* - * Copy the mbuf data into a contiguous buffer, leaving - * enough room for the atmel & 802.11 headers - */ - total_len = m->m_pkthdr.len; - - m_copydata(m, 0, m->m_pkthdr.len, c->atu_buf + sizeof(pkt->AtHeader)); - - pkt = (struct atu_txpkt *)c->atu_buf; - pkt->AtHeader.wlength = total_len; - pkt->AtHeader.tx_rate = 4; /* rate = auto */ - pkt->AtHeader.padding = 0; - memset(pkt->AtHeader.reserved, 0x00, sizeof(pkt->AtHeader.reserved)); - - total_len += sizeof(pkt->AtHeader); -#ifdef ATU_TX_PADDING - padding = atu_calculate_padding(total_len % 64); - total_len += padding; - pkt->AtHeader.padding = padding; -#endif /* ATU_TX_PADDING */ - c->atu_length = total_len; - c->atu_mbuf = m; - return(0); -} - -int atu_tx_start(struct atu_softc *sc, struct ieee80211_node *ni, struct atu_chain *c, struct mbuf *m) { diff --git a/sys/dev/usb/if_atureg.h b/sys/dev/usb/if_atureg.h index b2c2e3ca764..f0a64accfe2 100644 --- a/sys/dev/usb/if_atureg.h +++ b/sys/dev/usb/if_atureg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atureg.h,v 1.11 2004/12/04 23:36:15 dlg Exp $ */ +/* $OpenBSD: if_atureg.h,v 1.12 2004/12/04 23:56:50 dlg Exp $ */ /* * Copyright (c) 2003 * Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved. @@ -32,7 +32,7 @@ * */ -/* $ATUWI: $Id: if_atureg.h,v 1.11 2004/12/04 23:36:15 dlg Exp $ */ +/* $ATUWI: $Id: if_atureg.h,v 1.12 2004/12/04 23:56:50 dlg Exp $ */ /************ driver options ************/ @@ -165,12 +165,12 @@ /* * According to the 802.11 spec (7.1.2) the frame body can be up to 2312 bytes */ -#define ATU_RX_BUFSZ (sizeof(struct at76c503_rx_buffer) + \ +#define ATU_RX_BUFSZ (ATU_RX_HDRLEN + \ sizeof(struct wi_80211_hdr) + 2312 + 4) /* BE CAREFULL! should add ATU_TX_PADDING */ -#define ATU_TX_BUFSZ (sizeof(struct at76c503_tx_buffer) + \ +#define ATU_TX_BUFSZ (ATU_TX_HDRLEN + \ sizeof(struct wi_80211_hdr) + 2312) -#define ATU_MGMT_BUFSZ (sizeof(struct at76c503_tx_buffer) + 300) +#define ATU_MGMT_BUFSZ (ATU_TX_HDRLEN + 300) #define ATU_MIN_FRAMELEN 60 @@ -569,24 +569,6 @@ struct atu_rx_hdr { }; #define ATU_RX_HDRLEN sizeof(struct atu_rx_hdr) -struct at76c503_rx_buffer { - u_int16_t wlength; - u_int8_t rx_rate; - u_int8_t newbss; - u_int8_t fragmentation; - u_int8_t rssi; - u_int8_t link_quality; - u_int8_t noise_level; - u_int32_t rx_time; -}; - -/* The total packet the AT76c503 spits out looks like this */ -struct atu_rxpkt { - struct at76c503_rx_buffer AtHeader; - struct wi_80211_hdr WiHeader; - u_int8_t Packet[2312 + 4]; -}; - /* * The header we have to put in front of a TX packet before sending it to the * AT76c503 @@ -599,67 +581,6 @@ struct atu_tx_hdr { }; #define ATU_TX_HDRLEN sizeof(struct atu_tx_hdr) -struct at76c503_tx_buffer { - u_int16_t wlength; - u_int8_t tx_rate; - u_int8_t padding; - u_int8_t reserved[4]; -}; - -/* The total packet we send to the AT76c503 looks like this */ -struct atu_txpkt { - struct at76c503_tx_buffer AtHeader; - struct wi_80211_hdr WiHeader; - /* TODO - change this to a more correct value */ - u_int8_t Packet[2312]; -}; - -/* Managment packet */ -struct atu_mgmt_packet { - struct at76c503_tx_buffer athdr; - struct wi_mgmt_hdr mgmt_hdr; - - u_int8_t payload[0]; -}; - -/* Authentication packet */ -struct atu_auth_packet { - struct at76c503_tx_buffer athdr; - struct wi_mgmt_hdr mgmt_hdr; - struct wi_mgmt_auth_hdr auth_hdr; - - u_int8_t challenge[0]; -}; - -/* Association packet */ -struct atu_assoc_packet { - struct at76c503_tx_buffer athdr; - struct wi_mgmt_hdr mgmt_hdr; - u_int16_t capability; - u_int16_t listen_interval; - - u_int8_t data[0]; -}; - - -struct wi_80211_beacon { - u_int8_t timestamp[8]; - u_int16_t interval; - u_int16_t flags; - u_int8_t data[1500]; -}; - -struct tlv { - u_int8_t type; - u_int8_t length; - u_int8_t value[255]; -}; - -#define TYPE_MASK 0x000c - - - - #define NR(x) (void *)((long)x) /* |