]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Determine whether Beacon frame information is newer in scan results
authorJouni Malinen <j@w1.fi>
Sun, 24 Apr 2022 09:06:56 +0000 (12:06 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 24 Apr 2022 09:08:28 +0000 (12:08 +0300)
It can be helpful to know whether the information elements from the
Beacon frame or the Probe Response frame are newer when using BSS table
entries, so make this information known, if available. This allows the
Beacon frame elements to be preferred over the Probe Response frame
elements when desired.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/drivers/driver.h
src/drivers/driver_nl80211_scan.c
wpa_supplicant/bss.c
wpa_supplicant/bss.h

index 31bf1407c0c76f8351eb58b52e62248a26b95f65..49fe84dd869fef0f915cc722170d57fcb005c059 100644 (file)
@@ -338,6 +338,7 @@ struct hostapd_hw_modes {
  * @parent_tsf: Time when the Beacon/Probe Response frame was received in terms
  * of TSF of the BSS specified by %tsf_bssid.
  * @tsf_bssid: The BSS that %parent_tsf TSF time refers to.
+ * @beacon_newer: Whether the Beacon frame data is known to be newer
  * @ie_len: length of the following IE field in octets
  * @beacon_ie_len: length of the following Beacon IE field in octets
  *
@@ -370,6 +371,7 @@ struct wpa_scan_res {
        int snr;
        u64 parent_tsf;
        u8 tsf_bssid[ETH_ALEN];
+       bool beacon_newer;
        size_t ie_len;
        size_t beacon_ie_len;
        /* Followed by ie_len + beacon_ie_len octets of IE data */
index 1316084805a3c4b4de474d23f756ef8d85a0e0c6..b82e5af2a2eda3ce7c29c0e6b474b69895a26dcb 100644 (file)
@@ -713,6 +713,7 @@ nl80211_parse_bss_info(struct wpa_driver_nl80211_data *drv,
                [NL80211_BSS_STATUS] = { .type = NLA_U32 },
                [NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 },
                [NL80211_BSS_BEACON_IES] = { .type = NLA_UNSPEC },
+               [NL80211_BSS_BEACON_TSF] = { .type = NLA_U64 },
                [NL80211_BSS_PARENT_TSF] = { .type = NLA_U64 },
                [NL80211_BSS_PARENT_BSSID] = { .type = NLA_UNSPEC },
                [NL80211_BSS_LAST_SEEN_BOOTTIME] = { .type = NLA_U64 },
@@ -774,8 +775,10 @@ nl80211_parse_bss_info(struct wpa_driver_nl80211_data *drv,
                r->tsf = nla_get_u64(bss[NL80211_BSS_TSF]);
        if (bss[NL80211_BSS_BEACON_TSF]) {
                u64 tsf = nla_get_u64(bss[NL80211_BSS_BEACON_TSF]);
-               if (tsf > r->tsf)
+               if (tsf > r->tsf) {
                        r->tsf = tsf;
+                       r->beacon_newer = true;
+               }
        }
        if (bss[NL80211_BSS_SEEN_MS_AGO])
                r->age = nla_get_u32(bss[NL80211_BSS_SEEN_MS_AGO]);
index e13783ce1995fe3f847051ddb2b8f3c2700e2ddd..429c6e7547707f46c65b5bbf0b5683050b7252e6 100644 (file)
@@ -291,6 +291,7 @@ static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
        dst->noise = src->noise;
        dst->level = src->level;
        dst->tsf = src->tsf;
+       dst->beacon_newer = src->beacon_newer;
        dst->est_throughput = src->est_throughput;
        dst->snr = src->snr;
 
index 4078b9b9d0a43e32130cde13e582920a55906ed3..146aaee7f42869e225580fcafb5df133afe31821 100644 (file)
@@ -108,6 +108,8 @@ struct wpa_bss {
        int level;
        /** Timestamp of last Beacon/Probe Response frame */
        u64 tsf;
+       /** Whether the Beacon frame data is known to be newer */
+       bool beacon_newer;
        /** Time of the last update (i.e., Beacon or Probe Response RX) */
        struct os_reltime last_update;
        /** Estimated throughput in kbps */