From b3ad11bb80673b8579670c651d42bd7981a9163c Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 1 Oct 2009 17:53:22 +0300 Subject: [PATCH] nl80211: Add parsing of NL80211_BSS_SEEN_MS_AGO into scan results --- src/common/nl80211_copy.h | 2 ++ src/drivers/driver.h | 3 +++ src/drivers/driver_nl80211.c | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/common/nl80211_copy.h b/src/common/nl80211_copy.h index a8d71ed43..50afca3dc 100644 --- a/src/common/nl80211_copy.h +++ b/src/common/nl80211_copy.h @@ -1277,6 +1277,7 @@ enum nl80211_channel_type { * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon * in unspecified units, scaled to 0..100 (u8) * @NL80211_BSS_STATUS: status, if this BSS is "used" + * @NL80211_BSS_SEEN_MS_AGO: age of this BSS entry in ms * @__NL80211_BSS_AFTER_LAST: internal * @NL80211_BSS_MAX: highest BSS attribute */ @@ -1291,6 +1292,7 @@ enum nl80211_bss { NL80211_BSS_SIGNAL_MBM, NL80211_BSS_SIGNAL_UNSPEC, NL80211_BSS_STATUS, + NL80211_BSS_SEEN_MS_AGO, /* keep last */ __NL80211_BSS_AFTER_LAST, diff --git a/src/drivers/driver.h b/src/drivers/driver.h index c3be9d127..9b44f13dc 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -134,6 +134,8 @@ struct wpa_scan_result { * @noise: noise level * @level: signal level * @tsf: Timestamp + * @age: Age of the information in milliseconds (i.e., how many milliseconds + * ago the last Beacon or Probe Response frame was received) * @ie_len: length of the following IE field in octets * * This structure is used as a generic format for scan results from the @@ -155,6 +157,7 @@ struct wpa_scan_res { int noise; int level; u64 tsf; + unsigned int age; size_t ie_len; /* followed by ie_len octets of IEs */ }; diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index fee6cf9d4..bf741adbb 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -1654,6 +1654,7 @@ static int bss_info_handler(struct nl_msg *msg, void *arg) [NL80211_BSS_INFORMATION_ELEMENTS] = { .type = NLA_UNSPEC }, [NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 }, [NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 }, + [NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 }, }; struct wpa_scan_results *res = arg; struct wpa_scan_res **tmp; @@ -1700,6 +1701,8 @@ static int bss_info_handler(struct nl_msg *msg, void *arg) r->flags |= WPA_SCAN_LEVEL_INVALID | WPA_SCAN_QUAL_INVALID; if (bss[NL80211_BSS_TSF]) r->tsf = nla_get_u64(bss[NL80211_BSS_TSF]); + if (bss[NL80211_BSS_SEEN_MS_AGO]) + r->age = nla_get_u32(bss[NL80211_BSS_SEEN_MS_AGO]); r->ie_len = ie_len; if (ie) os_memcpy(r + 1, ie, ie_len);