Date: Sun, 14 Nov 2004 06:13:39 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 65079 for review Message-ID: <200411140613.iAE6Dd7U058247@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=65079 Change 65079 by sam@sam_ebb on 2004/11/14 06:12:54 improve the meaningfulness of rssi estimates for hostap, ibss, and ahdemo modes Affected files ... .. //depot/projects/wifi/sys/net80211/ieee80211_node.c#14 edit Differences ... ==== //depot/projects/wifi/sys/net80211/ieee80211_node.c#14 (text+ko) ==== @@ -1571,42 +1571,54 @@ ieee80211_getrssi(struct ieee80211com *ic) { #define NZ(x) ((x) == 0 ? 1 : (x)) - u_int8_t rssi; + struct ieee80211_node_table *nt = ic->ic_sta; + u_int32_t rssi_samples, rssi_total; + struct ieee80211_node *ni; + rssi_total = 0; + rssi_samples = 0; switch (ic->ic_opmode) { - case IEEE80211_M_IBSS: - case IEEE80211_M_AHDEMO: - case IEEE80211_M_HOSTAP: { - u_int32_t rssi_samples, rssi_total; - struct ieee80211_node_table *nt = ic->ic_sta; - - /* average stats from all neighbors */ - rssi_samples = 0; - rssi_total = 0; - if (nt != NULL) { - struct ieee80211_node *ni; - /* XXX locking */ - TAILQ_FOREACH(ni, &ic->ic_sta->nt_node, ni_list) - if (ic->ic_opmode != IEEE80211_M_HOSTAP || - IEEE80211_AID(ni->ni_associd) != 0) { - rssi_samples++; - rssi_total += ic->ic_node_getrssi(ni); - } + case IEEE80211_M_IBSS: /* average of all ibss neighbors */ + nt = ic->ic_sta; + if (nt == NULL) + break; + /* XXX locking */ + TAILQ_FOREACH(ni, &ic->ic_sta->nt_node, ni_list) + if (ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) { + rssi_samples++; + rssi_total += ic->ic_node_getrssi(ni); + } + break; + case IEEE80211_M_AHDEMO: /* average of all neighbors */ + nt = ic->ic_sta; + if (nt == NULL) + break; + /* XXX locking */ + TAILQ_FOREACH(ni, &ic->ic_sta->nt_node, ni_list) { + rssi_samples++; + rssi_total += ic->ic_node_getrssi(ni); } - rssi = rssi_total / NZ(rssi_samples); + break; + case IEEE80211_M_HOSTAP: /* average of all associated stations */ + nt = ic->ic_sta; + if (nt == NULL) + break; + /* XXX locking */ + TAILQ_FOREACH(ni, &ic->ic_sta->nt_node, ni_list) + if (IEEE80211_AID(ni->ni_associd) != 0) { + rssi_samples++; + rssi_total += ic->ic_node_getrssi(ni); + } break; - } - case IEEE80211_M_STA: - case IEEE80211_M_MONITOR: + case IEEE80211_M_MONITOR: /* XXX */ + case IEEE80211_M_STA: /* use stats from associated ap */ default: - /* use stats from associated ap */ if (ic->ic_bss != NULL) - rssi = ic->ic_node_getrssi(ic->ic_bss); - else - rssi = 0; + rssi_total = ic->ic_node_getrssi(ic->ic_bss); + rssi_samples = 1; break; } - return rssi; + return rssi_total / NZ(rssi_samples); #undef NZ }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411140613.iAE6Dd7U058247>