scan: add scan_passive_full variant
PATCH v2 1/7 scan: add scan_passive_full variant
Just like active scans, add an API for passive scans which take in the full scan_parameters structure.
--- src/scan.c | 10 ++++++++++ src/scan.h | 5 +++++ 2 files changed, 15 insertions(+)
src/scan.c +10 -0
@@ -556,6 +556,16 @@ uint32_t scan_passive(uint64_t wdev_id, struct scan_freq_set *freqs, userdata, destroy); } +uint32_t scan_passive_full (uint64_t wdev_id, +const struct scan_parameters *params, +scan_trigger_func_t trigger, +scan_notify_func_t notify,void *userdata, +scan_destroy_func_t destroy) +{ +return scan_common (wdev_id, true, params, trigger, + notify, userdata, destroy); +} + uint32_t scan_active(uint64_t wdev_id, uint8_t *extra_ie, size_t extra_ie_size, scan_trigger_func_t trigger, scan_notify_func_t notify, void *userdata,
src/scan.h +5 -0
@@ -102,6 +102,11 @@ static inline bool scan_bss_addr_eq(const struct scan_bss *a1,uint32_t scan_passive (uint64_t wdev_id,struct scan_freq_set *freqs,scan_trigger_func_t trigger,scan_notify_func_t notify,void *userdata,scan_destroy_func_t destroy); +uint32_t scan_passive_full (uint64_t wdev_id, +const struct scan_parameters *params, +scan_trigger_func_t trigger, +scan_notify_func_t notify,void *userdata, +scan_destroy_func_t destroy); uint32_t scan_active(uint64_t wdev_id, uint8_t *extra_ie, size_t extra_ie_size, scan_trigger_func_t trigger, scan_notify_func_t notify, void *userdata,
Signature · 1 line
2.17.1
PATCH v2 2/7 scan: add duration scan_parameters
The kernel allows a scan duration and duration mandatory flag to be set in scan requests. RRM requests can contain these values so they have been added to scan_parameters.
Scanning with drivers which do not support EXT_FEATURE_SET_SCAN_DWELL will not include these values in scan requests.
--- src/scan.c | 13 +++++++++++++ src/scan.h | 2 ++ 2 files changed, 15 insertions(+)
src/scan.c +13 -0
@@ -396,6 +396,19 @@ static struct l_genl_msg *scan_build_cmd(struct scan_context *sc,l_free (scan_rates); } +if (wiphy_has_ext_feature (sc->wiphy, +NL80211_EXT_FEATURE_SET_SCAN_DWELL )) { +if (params->duration) +l_genl_msg_append_attr (msg, +NL80211_ATTR_MEASUREMENT_DURATION , +2 , ¶ms->duration); + +if (params->duration_mandatory) +l_genl_msg_append_attr (msg, +NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY , +0 ,NULL ); + } + done:return msg; }
src/scan.h +2 -0
@@ -81,9 +81,11 @@ struct scan_parameters {const uint8_t *extra_ie;size_t extra_ie_size;struct scan_freq_set *freqs; +uint16_t duration; bool flush : 1; bool randomize_mac_addr_hint : 1; bool no_cck_rates : 1; + bool duration_mandatory : 1;const char *ssid;/* Used for direct probe request */ };
Signature · 1 line
2.17.1
PATCH v2 3/7 rrm: support scan duration and mandatory flags
In reply to James PrestwoodBeacon requests can specify a scan duration, and set a flag which makes this duration mandatory. The kernel supports both these values for scan requests so we no longer need to reject requests which contain these.
Drivers which do not support EXT_FEATURE_SET_SCAN_DWELL will ignore the duration value, but if duration mandatory is set we must reject the request.
--- src/rrm.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-)
-v2:
* Include duration in report
src/rrm.c +28 -7
@@ -39,6 +39,7 @@#include "src/station.h" #include "src/scan.h" #include "src/nl80211util.h" +#include "src/wiphy.h" #include "linux/nl80211.h"
@@ -104,6 +105,7 @@ struct rrm_beacon_req_info {struct rrm_request_info info;uint8_t oper_class;uint8_t channel;/* The single channel provided in request */ +uint16_t duration;uint8_t bssid[6 ];/* Request filtered by BSSID */ char ssid[33 ];/* Request filtered by SSID */ bool has_ssid;
@@ -249,9 +251,11 @@ static size_t build_report_for_bss(struct rrm_beacon_req_info *beacon, *to++ = beacon->oper_class; *to++ =scan_freq_to_channel (bss->frequency,NULL ); -/* skip start time/duration */ -memset (to,0 ,10 ); - to +=10 ; +/* skip start time */ +memset (to,0 ,8 ); + to +=8 ; +l_put_le16 (beacon->duration, to); + to +=2 ; *to++ =rrm_phy_type (bss);/* 802.11 Table 9-154 - RCPI values */
@@ -395,7 +399,12 @@ static void rrm_handle_beacon_scan(struct rrm_state *rrm, bool passive) {struct scan_freq_set *freqs =scan_freq_set_new (); -struct scan_parameters params = { .freqs = freqs, .flush = true }; +struct scan_parameters params = { + .freqs = freqs, + .flush = true, + .duration = beacon->duration, + .duration_mandatory =util_is_bit_set (beacon->info.mode,4 ), + };enum scan_band band =scan_oper_class_to_band (NULL , beacon->oper_class);uint32_t freq;
@@ -403,7 +412,7 @@ static void rrm_handle_beacon_scan(struct rrm_state *rrm,scan_freq_set_add (freqs, freq);if (passive) - beacon->scan_id =scan_passive (rrm->wdev_id, freqs, + beacon->scan_id =scan_passive_full (rrm->wdev_id, ¶ms, rrm_scan_triggered, rrm_scan_results, rrm,NULL );
@@ -436,11 +445,11 @@ static bool rrm_verify_beacon_request(const uint8_t *request, size_t len)return false;/* -* Not handling interval/duration requests. We can omit this +* Not handling random interval requests. We can omit this * check for table requests since we just return whatever we * have cached. */ -if (!util_mem_is_zero (request +2 ,4 )) +if (!util_mem_is_zero (request +2 ,2 ))return false; }
@@ -455,6 +464,7 @@ static void rrm_handle_beacon_request(struct rrm_state *rrm,uint8_t dialog_token, const uint8_t *request, size_t len) { + struct wiphy *wiphy = station_get_wiphy(rrm->station);struct rrm_beacon_req_info *beacon;struct ie_tlv_iter iter;/*
@@ -486,6 +496,16 @@ static void rrm_handle_beacon_request(struct rrm_state *rrm,if (util_is_bit_set (beacon->info.mode,1 )) goto reject_refused; +/* +* Some drivers (non mac80211) do not allow setting a duration/mandatory +* bit in scan requests. The actual duration value can be ignored in +* this case but if the requests includes the duration mandatory bit we +* must reject this request. +*/ +if (!wiphy_has_ext_feature (wiphy,NL80211_EXT_FEATURE_SET_SCAN_DWELL ) + &&util_is_bit_set (beacon->info.mode,4 )) + goto reject_incapable; +/* advance to beacon request */ request +=3 ; len -=3 ;
@@ -495,6 +515,7 @@ static void rrm_handle_beacon_request(struct rrm_state *rrm, beacon->oper_class = request[0 ]; beacon->channel = request[1 ]; + beacon->duration =l_get_le16 (request +4 );memcpy (beacon->bssid, request +7 ,6 );ie_tlv_iter_init (&iter, request +13 , len -13 );
Signature · 1 line
2.17.1
PATCH v2 4/7 auto-t: add RRM test for scan duration
In reply to James Prestwoodmac80211_hwsim does not actually support SET_SCAN_DWELL, but since we are not setting duration mandatory the request should still be accepted.
--- autotests/testRRM/connection_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
autotests/testRRM/connection_test.py +12 -0
@@ -21,6 +21,8 @@ beacon_with_ssid = '51000000000002ffffffffffff02010000077373696452524d' beacon_passive = '510b0000000000ffffffffffff020100' # Active beacon with wildcard BSSID beacon_active = '510b0000000001ffffffffffff020100' +# Passive beacon with duration set +beacon_passive_duration = '510b0000c80000ffffffffffff020100' class Test(unittest.TestCase):
@@ -91,6 +93,16 @@ class Test(unittest.TestCase): hapd.req_beacon(device.address, beacon_active) # TODO: See if we are scanning here (scan not initiated from station) + event = hapd.wait_for_event('BEACON-RESP-RX') + if event: + print(event) + + sleep(0.5) + + # This should passive scan on channel 11, returning otherSSID + hapd.req_beacon(device.address, beacon_passive_duration) + # TODO: See if we are scanning here (scan not initiated from station) + event = hapd.wait_for_event('BEACON-RESP-RX') if event: print(event)
Signature · 1 line
2.17.1
PATCH v2 5/7 monitor: print parent TSF
In reply to James Prestwood--- monitor/nlmon.c | 1 + 1 file changed, 1 insertion(+)
monitor/nlmon.c +1 -0
@@ -4569,6 +4569,7 @@ static const struct attr_entry bss_table[] = { { NL80211_BSS_CHAN_WIDTH, "Chan Width", ATTR_U32 }, { NL80211_BSS_BEACON_TSF, "Beacon TSF", ATTR_U64 }, { NL80211_BSS_PRESP_DATA, "Probe Response", ATTR_FLAG }, + { NL80211_BSS_PARENT_TSF, "Parent TSF", ATTR_U64 }, { } };
Signature · 1 line
2.17.1
PATCH v2 6/7 scan: parse parent TSF value in scan results
In reply to James PrestwoodRRM can include this in measurement reports if present in scans
--- src/scan.c | 6 ++++++ src/scan.h | 1 + 2 files changed, 7 insertions(+)
src/scan.c +6 -0
@@ -1072,6 +1072,12 @@ static struct scan_bss *scan_parse_attr_bss(struct l_genl_attr *attr) &bss->p2p_size);break ; +case NL80211_BSS_PARENT_TSF : +if (len !=sizeof (uint64_t )) + goto fail; + + bss->parent_tsf =l_get_le64 (data); +break ; } }
src/scan.h +1 -0
@@ -67,6 +67,7 @@ struct scan_bss {uint8_t hessid[6 ];uint8_t *rc_ie;/* Roaming consortium IE */ uint8_t hs20_version; +uint64_t parent_tsf; bool mde_present : 1; bool cc_present : 1; bool cap_rm_neighbor_report : 1;
Signature · 1 line
2.17.1
Denis Kenzior
AppliedRe: [PATCH v2 6/7] scan: parse parent TSF value in scan results
Hi James,
Quoted 6 lines · James Prestwood
RRM can include this in measurement reports if present in scans
--- src/scan.c | 6 ++++++ src/scan.h | 1 + 2 files changed, 7 insertions(+)
Applied, thanks.
Regards,
-Denis
PATCH v2 7/7 rrm: include actual parent TSF value
In reply to James PrestwoodIf the scan results included a parent TSF value use it.
--- src/rrm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
src/rrm.c +7 -2
@@ -272,8 +272,13 @@ static size_t build_report_for_bss(struct rrm_beacon_req_info *beacon, to +=6 ;/* Antenna identifier unknown */ *to++ =0 ; -/* Parent TSF - zero */ -memset (to,0 ,4 ); +/* +* 802.11 9.4.2.22.7 Beacon report +* +* "The Parent TSF field contains the lower 4 octets of the measuring +* STA’s TSF timer value" +*/ +l_put_le32 ((uint32_t )(bss->parent_tsf &0xffffffff ), to); to +=4 ;/*
Signature · 1 line
2.17.1
Hi James,
Quoted 7 lines · James Prestwood
Just like active scans, add an API for passive scans which take in the full
scan_parametersstructure.--- src/scan.c | 10 ++++++++++ src/scan.h | 5 +++++ 2 files changed, 15 insertions(+)
Patches 1-55 applied, thanks.
Regards,
-Denis