]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add BSS flags to scan results to indicate signal quality validity
authorJouni Malinen <jouni.malinen@atheros.com>
Wed, 18 Feb 2009 11:40:38 +0000 (13:40 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 18 Feb 2009 11:40:38 +0000 (13:40 +0200)
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.

src/drivers/driver.h
src/drivers/driver_nl80211.c
src/drivers/driver_wext.c
wpa_supplicant/ctrl_iface_dbus_handlers.c

index c5f210627ad5fd04245e7f224aa8d44569d084cd..ea0cba8110e77ea8e1dbc7e08a301750a019d0ef 100644 (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;
index b75c10ef629d6ee40842b449700139fe16c562ba..2f530b2e48336be350ebf072d8120fababd8c5da 100644 (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;
index 1c9105b28a727b25cb63588aa06101b76a6c38fa..e6242da60eca169cfe019ada18e7afeed8ebb27c 100644 (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;
 }
 
 
index 3c298043b3f77c6f4b063d8f7cf3441b7e907b6d..161f7f8874db0d8817e0167398f36da3c7ae7a10 100644 (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))