From: Johannes Berg Date: Fri, 24 Jan 2014 12:32:27 +0000 (+0100) Subject: nl80211: Treat RSSI as part of each sched scan matchset X-Git-Tag: hostap_2_1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff5e1d14af0a93095bb06ff031558fbd143b2c58;p=thirdparty%2Fhostap.git nl80211: Treat RSSI as part of each sched scan matchset The original RSSI filter semantics for scheduled scan were really confusing - a separate matchset was created, but it wasn't actually treated as a separate matchset in the kernel but rather used as the global RSSI value. The RSSI matchset thus behaved like an RSSI filter outside of the matchsets, being ANDed rather than ORed (as normal between matchsets.) To make this less confusing, I changed the kernel API a bit to actually treat the RSSI inside each matchset properly, but keeping it compatible with the old approach by using a matchset with only an RSSI value as the default for all the other matchsets, and adding it as a separate matchset only if it's the only one. The proper way for wpa_supplicant to do this then would be to add the RSSI to each SSID matchset, and only add another matchset without SSID if there's none with. However, to keep compatibility with older kernels, always keep the non-SSID matchset and only add the RSSI to all the other matchsets. This gets close to the desired behaviour, the only difference would be that we shouldn't add the RSSI matchset if there are others, but stays compatible with old and new kernels, as new ones ignore the RSSI-only matchset if there are others and those others have an RSSI. Signed-hostap: Johannes Berg --- diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 760170c63..fbe95fefc 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -4995,10 +4995,20 @@ static int wpa_driver_nl80211_sched_scan(void *priv, NLA_PUT(msg, NL80211_ATTR_SCHED_SCAN_MATCH_SSID, drv->filter_ssids[i].ssid_len, drv->filter_ssids[i].ssid); + if (params->filter_rssi) + NLA_PUT_U32(msg, + NL80211_SCHED_SCAN_MATCH_ATTR_RSSI, + params->filter_rssi); nla_nest_end(msg, match_set_ssid); } + /* + * Due to backward compatibility code, newer kernels treat this + * matchset (with only an RSSI filter) as the default for all + * other matchsets, unless it's the only one, in which case the + * matchset will actually allow all SSIDs above the RSSI. + */ if (params->filter_rssi) { struct nlattr *match_set_rssi; match_set_rssi = nla_nest_start(msg, 0);