Add BSS flags to scan results to indicate signal quality validity

These flags are used to mark which values (level, noise, qual) are
invalid (not available from the driver) and whether level is using dBm.
D-Bus interface will now only report the values that were available.
This commit is contained in:
Jouni Malinen 2009-02-18 13:40:38 +02:00 committed by Jouni Malinen
parent d173df5232
commit 7c2849d2a0
4 changed files with 30 additions and 6 deletions

View file

@ -81,8 +81,14 @@ struct wpa_scan_result {
};
#define WPA_SCAN_QUAL_INVALID BIT(0)
#define WPA_SCAN_NOISE_INVALID BIT(1)
#define WPA_SCAN_LEVEL_INVALID BIT(2)
#define WPA_SCAN_LEVEL_DBM BIT(3)
/**
* struct wpa_scan_res - Scan result for an BSS/IBSS
* @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
* @bssid: BSSID
* @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
* @beacon_int: beacon interval in TUs (host byte order)
@ -103,6 +109,7 @@ struct wpa_scan_result {
* report all IEs to make it easier to support future additions.
*/
struct wpa_scan_res {
unsigned int flags;
u8 bssid[ETH_ALEN];
int freq;
u16 beacon_int;

View file

@ -1769,10 +1769,16 @@ static int bss_info_handler(struct nl_msg *msg, void *arg)
r->beacon_int = nla_get_u16(bss[NL80211_BSS_BEACON_INTERVAL]);
if (bss[NL80211_BSS_CAPABILITY])
r->caps = nla_get_u16(bss[NL80211_BSS_CAPABILITY]);
if (bss[NL80211_BSS_SIGNAL_UNSPEC])
r->qual = nla_get_u8(bss[NL80211_BSS_SIGNAL_UNSPEC]);
if (bss[NL80211_BSS_SIGNAL_MBM])
r->flags |= WPA_SCAN_NOISE_INVALID;
if (bss[NL80211_BSS_SIGNAL_MBM]) {
r->level = nla_get_u32(bss[NL80211_BSS_SIGNAL_MBM]);
r->level /= 100; /* mBm to dBm */
r->flags |= WPA_SCAN_LEVEL_DBM | WPA_SCAN_QUAL_INVALID;
} else if (bss[NL80211_BSS_SIGNAL_UNSPEC]) {
r->level = nla_get_u8(bss[NL80211_BSS_SIGNAL_UNSPEC]);
r->flags |= WPA_SCAN_LEVEL_INVALID;
} else
r->flags |= WPA_SCAN_LEVEL_INVALID | WPA_SCAN_QUAL_INVALID;
if (bss[NL80211_BSS_TSF])
r->tsf = nla_get_u64(bss[NL80211_BSS_TSF]);
r->ie_len = ie_len;

View file

@ -1267,6 +1267,14 @@ static void wext_get_scan_qual(struct iw_event *iwe,
res->res.qual = iwe->u.qual.qual;
res->res.noise = iwe->u.qual.noise;
res->res.level = iwe->u.qual.level;
if (iwe->u.qual.updated & IW_QUAL_QUAL_INVALID)
res->res.flags |= WPA_SCAN_QUAL_INVALID;
if (iwe->u.qual.updated & IW_QUAL_LEVEL_INVALID)
res->res.flags |= WPA_SCAN_LEVEL_INVALID;
if (iwe->u.qual.updated & IW_QUAL_NOISE_INVALID)
res->res.flags |= WPA_SCAN_NOISE_INVALID;
if (iwe->u.qual.updated & IW_QUAL_DBM)
res->res.flags |= WPA_SCAN_LEVEL_DBM;
}

View file

@ -436,11 +436,14 @@ DBusMessage * wpas_dbus_bssid_properties(DBusMessage *message,
if (!wpa_dbus_dict_append_uint16(&iter_dict, "capabilities",
res->caps))
goto error;
if (!wpa_dbus_dict_append_int32(&iter_dict, "quality", res->qual))
if (!(res->flags & WPA_SCAN_QUAL_INVALID) &&
!wpa_dbus_dict_append_int32(&iter_dict, "quality", res->qual))
goto error;
if (!wpa_dbus_dict_append_int32(&iter_dict, "noise", res->noise))
if (!(res->flags & WPA_SCAN_NOISE_INVALID) &&
!wpa_dbus_dict_append_int32(&iter_dict, "noise", res->noise))
goto error;
if (!wpa_dbus_dict_append_int32(&iter_dict, "level", res->level))
if (!(res->flags & WPA_SCAN_LEVEL_INVALID) &&
!wpa_dbus_dict_append_int32(&iter_dict, "level", res->level))
goto error;
if (!wpa_dbus_dict_append_int32(&iter_dict, "maxrate",
wpa_scan_get_max_rate(res) * 500000))