Change the channel number in the scan results struct to be a pointer to the

operating channel and use this in the scan cache rather than directly using
ic_curchan. Some firmware cards can only do a full scan and so ic_curchan does
not have the correct value.

Also add IEEE80211_CHAN2IEEE to directly dereference ic_ieee from the channel
to be used in the fast path.

Reviewed by:	sam, sephe
Approved by:	re (kensmith)
This commit is contained in:
Andrew Thompson 2007-06-30 21:23:23 +00:00
parent d35985e711
commit b54b1bab4b
6 changed files with 20 additions and 11 deletions

View File

@ -3098,7 +3098,7 @@ wi_scan_result(struct wi_softc *sc, int fid, int cnt)
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->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;
@ -3114,6 +3114,12 @@ wi_scan_result(struct wi_softc *sc, int fid, int cnt)
sp.ssid = (uint8_t *)&ssid[0];
memcpy(sp.ssid + 2, ap->name, ap->namelen);
sp.ssid[1] = ap->namelen;
sp.bchan = ap->channel;
sp.curchan = ieee80211_find_channel(ic,
ieee80211_ieee2mhz(ap->channel, IEEE80211_CHAN_B),
IEEE80211_CHAN_B);
if (sp.curchan == NULL)
sp.curchan = &ic->ic_channels[0];
sp.rates = &rates[0];
sp.tstamp = (uint8_t *)&rstamp;
printf("calling add_scan \n");

View File

@ -229,6 +229,8 @@ struct ieee80211_channel {
(IEEE80211_IS_CHAN_2GHZ(_c) && \
((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
#define IEEE80211_CHAN2IEEE(_c) (_c)->ic_ieee
/* ni_chan encoding for FH phy */
#define IEEE80211_FH_CHANMOD 80
#define IEEE80211_FH_CHAN(set,pat) (((set)-1)*IEEE80211_FH_CHANMOD+(pat))

View File

@ -2090,8 +2090,8 @@ ieee80211_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0,
scan.tstamp = frm; frm += 8;
scan.bintval = le16toh(*(uint16_t *)frm); frm += 2;
scan.capinfo = le16toh(*(uint16_t *)frm); frm += 2;
scan.bchan = ieee80211_chan2ieee(ic, ic->ic_curchan);
scan.chan = scan.bchan;
scan.bchan = IEEE80211_CHAN2IEEE(ic->ic_curchan);
scan.curchan = ic->ic_curchan;
while (efrm - frm > 1) {
IEEE80211_VERIFY_LENGTH(efrm - frm, frm[1] + 2, return);
@ -2108,7 +2108,7 @@ ieee80211_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0,
case IEEE80211_ELEMID_FHPARMS:
if (ic->ic_phytype == IEEE80211_T_FH) {
scan.fhdwell = LE_READ_2(&frm[2]);
scan.chan = IEEE80211_FH_CHAN(frm[4], frm[5]);
scan.bchan = IEEE80211_FH_CHAN(frm[4], frm[5]);
scan.fhindex = frm[6];
}
break;
@ -2118,7 +2118,7 @@ ieee80211_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0,
* is problematic for multi-mode devices.
*/
if (ic->ic_phytype != IEEE80211_T_FH)
scan.chan = frm[2];
scan.bchan = frm[2];
break;
case IEEE80211_ELEMID_TIM:
/* XXX ATIM? */
@ -2194,7 +2194,7 @@ ieee80211_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0,
return;
}
#endif
if (scan.chan != scan.bchan &&
if (IEEE80211_CHAN2IEEE(scan.curchan) != scan.bchan &&
ic->ic_phytype != IEEE80211_T_FH) {
/*
* Frame was received on a channel different from the
@ -2210,7 +2210,8 @@ ieee80211_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0,
IEEE80211_MSG_ELEMID | IEEE80211_MSG_INPUT,
wh, ieee80211_mgt_subtype_name[subtype >>
IEEE80211_FC0_SUBTYPE_SHIFT],
"for off-channel %u", scan.chan);
"for off-channel %u",
IEEE80211_CHAN2IEEE(scan.curchan));
ic->ic_stats.is_rx_chanmismatch++;
return;
}

View File

@ -835,7 +835,7 @@ dump_probe_beacon(uint8_t subtype, int isnew,
printf("[%s] %s%s on chan %u (bss chan %u) ",
ether_sprintf(mac), isnew ? "new " : "",
ieee80211_mgt_subtype_name[subtype >> IEEE80211_FC0_SUBTYPE_SHIFT],
sp->chan, sp->bchan);
IEEE80211_CHAN2IEEE(sp->curchan), sp->bchan);
ieee80211_print_essid(sp->ssid + 2, sp->ssid[1]);
printf("\n");

View File

@ -117,8 +117,8 @@ void ieee80211_scan_iterate(struct ieee80211com *,
struct ieee80211_scanparams {
uint16_t capinfo; /* 802.11 capabilities */
uint16_t fhdwell; /* FHSS dwell interval */
uint8_t chan; /* */
uint8_t bchan;
struct ieee80211_channel *curchan;
uint8_t bchan; /* chan# advertised inside beacon */
uint8_t fhindex;
uint8_t erp;
uint16_t bintval;

View File

@ -257,7 +257,7 @@ found:
memcpy(ise->se_tstamp.data, sp->tstamp, sizeof(ise->se_tstamp));
ise->se_intval = sp->bintval;
ise->se_capinfo = sp->capinfo;
ise->se_chan = ic->ic_curchan;
ise->se_chan = sp->curchan;
ise->se_fhdwell = sp->fhdwell;
ise->se_fhindex = sp->fhindex;
ise->se_erp = sp->erp;