mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
nl80211: Use NL80211_BSS_LAST_SEEN_BOOTTIME if available
This allows a more accurate scan result age to be fetched than the one available through NL80211_BSS_SEEN_MS_AGO. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a6ea665300
commit
006fb845b8
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include <time.h>
|
||||
#include <netlink/genl/genl.h>
|
||||
|
||||
#include "utils/common.h"
|
||||
@ -696,6 +697,7 @@ nl80211_parse_bss_info(struct wpa_driver_nl80211_data *drv,
|
||||
[NL80211_BSS_BEACON_IES] = { .type = NLA_UNSPEC },
|
||||
[NL80211_BSS_PARENT_TSF] = { .type = NLA_U64 },
|
||||
[NL80211_BSS_PARENT_BSSID] = { .type = NLA_UNSPEC },
|
||||
[NL80211_BSS_LAST_SEEN_BOOTTIME] = { .type = NLA_U64 },
|
||||
};
|
||||
struct wpa_scan_res *r;
|
||||
const u8 *ie, *beacon_ie;
|
||||
@ -759,6 +761,23 @@ nl80211_parse_bss_info(struct wpa_driver_nl80211_data *drv,
|
||||
}
|
||||
if (bss[NL80211_BSS_SEEN_MS_AGO])
|
||||
r->age = nla_get_u32(bss[NL80211_BSS_SEEN_MS_AGO]);
|
||||
if (bss[NL80211_BSS_LAST_SEEN_BOOTTIME]) {
|
||||
u64 boottime;
|
||||
struct timespec ts;
|
||||
|
||||
#ifndef CLOCK_BOOTTIME
|
||||
#define CLOCK_BOOTTIME 7
|
||||
#endif
|
||||
if (clock_gettime(CLOCK_BOOTTIME, &ts) == 0) {
|
||||
/* Use more accurate boottime information to update the
|
||||
* scan result age since the driver reports this and
|
||||
* CLOCK_BOOTTIME is available. */
|
||||
boottime = nla_get_u64(
|
||||
bss[NL80211_BSS_LAST_SEEN_BOOTTIME]);
|
||||
r->age = ((u64) ts.tv_sec * 1000000000 +
|
||||
ts.tv_nsec - boottime) / 1000000;
|
||||
}
|
||||
}
|
||||
r->ie_len = ie_len;
|
||||
pos = (u8 *) (r + 1);
|
||||
if (ie) {
|
||||
|
Loading…
Reference in New Issue
Block a user