Date: Tue, 2 Jan 2007 07:26:32 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 112415 for review Message-ID: <200701020726.l027QWfQ056035@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=112415 Change 112415 by kmacy@kmacy_serendipity:sam_wifi on 2007/01/02 07:26:15 remove the added ioctls for initiating and querying scan results - we new pass that back to the 802.11 stack when we're notified by the firmware not everything is formatted in the way the 802.11 layer expects it, but this a workable first cut Affected files ... .. //depot/projects/wifi/sys/dev/wi/if_wi.c#25 edit Differences ... ==== //depot/projects/wifi/sys/dev/wi/if_wi.c#25 (text+ko) ==== @@ -1335,57 +1335,17 @@ static int wi_ioctl_get(struct ifnet *ifp, u_long cmd, caddr_t data) { - int error, i, len; + int error; struct wi_softc *sc; struct ieee80211req *ireq; struct ieee80211com *ic; - struct wi_apinfo *ap; - struct ieee80211req_scan_result *sr, *bsr; - char *cp; - uint16_t *bssid; + + sc = ifp->if_softc; ic = &sc->sc_ic; ireq = (struct ieee80211req *) data; switch (ireq->i_type) { - case IEEE80211_IOC_SCAN_RESULTS: - sr = bsr = malloc(ireq->i_len, M_DEVBUF, M_NOWAIT | M_ZERO); - if (sr == NULL) { - error = ENOMEM; - break; - } - len = 0; - for (i = 0; i < sc->sc_naps; i++) { - ap = &sc->sc_aps[i]; - if (len + sizeof(*sr) + ap->namelen > ireq->i_len) - break; - bssid = (uint16_t *)&ap->bssid; - /* Lucent firmware will return empty records */ - if (bssid[0] == 0 && bssid[1] == 0 && bssid[2] == 0) - break; - - sr->isr_rssi = ap->signal; - sr->isr_freq = ieee80211_ieee2mhz(ap->channel, - IEEE80211_CHAN_B); - sr->isr_intval = ap->interval; - sr->isr_rates[0] = ap->rate; - sr->isr_nrates = 1; - sr->isr_ssid_len = ap->namelen; - sr->isr_ie_len = 0; - sr->isr_capinfo = ap->capinfo; /* XXX */ - sr->isr_noise = ap->noise; /* XXX */ - bcopy(ap->bssid, sr->isr_bssid, sizeof(sr->isr_bssid)); - cp = (char *)sr + sizeof(*sr); - bcopy(ap->name, cp, sr->isr_ssid_len); - cp += sr->isr_ssid_len; - sr->isr_len = roundup(sizeof(*sr) + sr->isr_ssid_len, - sizeof(uint32_t)); - len += sr->isr_len; - } - ireq->i_len = len; - error = copyout(bsr, ireq->i_data, len); - free(bsr, M_DEVBUF); - break; case IEEE80211_IOC_STATIONNAME: ireq->i_len = sc->sc_nodelen + 1; error = copyout(sc->sc_nodename, ireq->i_data, @@ -1418,11 +1378,6 @@ sc = ifp->if_softc; ireq = (struct ieee80211req *) data; switch (ireq->i_type) { - case IEEE80211_IOC_SCAN_REQ: - WI_LOCK(sc); - error = wi_scan_ap(sc, 0x3fff, 0x000f); - WI_UNLOCK(sc); - break; case IEEE80211_IOC_STATIONNAME: if (ireq->i_val != 0 || ireq->i_len > IEEE80211_NWID_LEN) { @@ -1962,8 +1917,9 @@ case WI_INFO_SCAN_RESULTS: case WI_INFO_HOST_SCAN_RESULTS: wi_scan_result(sc, fid, le16toh(ltbuf[0])); + ieee80211_notify_scan_done(ic); break; - + default: DPRINTF(("wi_info_intr: got fid %x type %x len %d\n", fid, le16toh(ltbuf[1]), le16toh(ltbuf[0]))); @@ -3079,6 +3035,16 @@ struct wi_scan_header ws_hdr; /* Prism2 header */ struct wi_scan_data_p2 ws_dat; /* Prism2 scantable*/ struct wi_apinfo *ap; + struct ieee80211_scanparams sp; + struct ieee80211_frame wh; + static long rstamp; + struct ieee80211com *ic; + uint8_t ssid[2+IEEE80211_NWID_LEN]; + + printf("wi_scan_result\n"); + ic = &sc->sc_ic; + rstamp++; + memset(&sp, 0, sizeof(sp)); off = sizeof(u_int16_t) * 2; memset(&ws_hdr, 0, sizeof(ws_hdr)); @@ -3108,25 +3074,44 @@ /* Read Data */ ap = sc->sc_aps; memset(&ws_dat, 0, sizeof(ws_dat)); + for (i = 0; i < naps; i++, ap++) { + uint8_t rates[2]; + uint16_t *bssid; wi_read_bap(sc, fid, off, &ws_dat, (sizeof(ws_dat) < szbuf ? sizeof(ws_dat) : szbuf)); DPRINTF2(("wi_scan_result: #%d: off %d bssid %s\n", i, off, ether_sprintf(ws_dat.wi_bssid))); + off += szbuf; - ap->scanreason = le16toh(ws_hdr.wi_reason); + ap->scanreason = le16toh(ws_hdr.wi_reason); memcpy(ap->bssid, ws_dat.wi_bssid, sizeof(ap->bssid)); - ap->channel = le16toh(ws_dat.wi_chid); + + bssid = (uint16_t *)&ap->bssid; + if (bssid[0] == 0 && bssid[1] == 0 && bssid[2] == 0) + break; + + memcpy(wh.i_addr2, ws_dat.wi_bssid, sizeof(ap->bssid)); + memcpy(wh.i_addr3, ws_dat.wi_bssid, sizeof(ap->bssid)); + sp.chan = ap->channel = le16toh(ws_dat.wi_chid); ap->signal = le16toh(ws_dat.wi_signal); ap->noise = le16toh(ws_dat.wi_noise); ap->quality = ap->signal - ap->noise; - ap->capinfo = le16toh(ws_dat.wi_capinfo); + sp.capinfo = ap->capinfo = le16toh(ws_dat.wi_capinfo); ap->interval = le16toh(ws_dat.wi_interval); - ap->rate = le16toh(ws_dat.wi_rate); + rates[0] = ap->rate = le16toh(ws_dat.wi_rate); + rates[1] = 0; ap->namelen = le16toh(ws_dat.wi_namelen); if (ap->namelen > sizeof(ap->name)) ap->namelen = sizeof(ap->name); memcpy(ap->name, ws_dat.wi_name, ap->namelen); + sp.ssid = (uint8_t *)&ssid[0]; + memcpy(sp.ssid + 2, ap->name, ap->namelen); + sp.ssid[1] = ap->namelen; + sp.rates = &rates[0]; + sp.tstamp = (uint8_t *)&rstamp; + printf("calling add_scan \n"); + ieee80211_add_scan(ic, &sp, &wh, 0, ap->signal, ap->noise, rstamp); } done: /* Done scanning */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701020726.l027QWfQ056035>