From 284e3ad196e09eb322d85fa578e4831e87beb131 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 24 Apr 2022 12:06:56 +0300 Subject: [PATCH] Determine whether Beacon frame information is newer in scan results 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 --- src/drivers/driver.h | 2 ++ src/drivers/driver_nl80211_scan.c | 5 ++++- wpa_supplicant/bss.c | 1 + wpa_supplicant/bss.h | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 31bf1407c..49fe84dd8 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -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 */ diff --git a/src/drivers/driver_nl80211_scan.c b/src/drivers/driver_nl80211_scan.c index 131608480..b82e5af2a 100644 --- a/src/drivers/driver_nl80211_scan.c +++ b/src/drivers/driver_nl80211_scan.c @@ -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]); diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index e13783ce1..429c6e754 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -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; diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h index 4078b9b9d..146aaee7f 100644 --- a/wpa_supplicant/bss.h +++ b/wpa_supplicant/bss.h @@ -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 */