device: change scan command logic
This patch allows alternating between the passive and active scans taking into consideration an existence of the known hidden networks and previous observation of them in the scan results, as well as an ability to randomize the MAC address.
This commit is contained in:
parent
5828073cd5
commit
27e305c9d2
33
src/device.c
33
src/device.c
|
@ -1759,7 +1759,6 @@ static struct l_dbus_message *device_scan(struct l_dbus *dbus,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct device *device = user_data;
|
struct device *device = user_data;
|
||||||
uint32_t id;
|
|
||||||
|
|
||||||
l_debug("Scan called from DBus");
|
l_debug("Scan called from DBus");
|
||||||
|
|
||||||
|
@ -1773,19 +1772,29 @@ static struct l_dbus_message *device_scan(struct l_dbus *dbus,
|
||||||
device->scan_pending = l_dbus_message_ref(message);
|
device->scan_pending = l_dbus_message_ref(message);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If device is not connected to a BSS use a passive scan to
|
* If we're not connected and no hidden networks are seen & configured,
|
||||||
* avoid advertising our address until we support address
|
* use passive scanning to hide our MAC address
|
||||||
* randomization (on the devices that support it).
|
|
||||||
*/
|
*/
|
||||||
if (!device->connected_bss)
|
if (!device->connected_bss &&
|
||||||
id = scan_passive(device->index, device_scan_triggered,
|
!(device->seen_hidden_networks &&
|
||||||
new_scan_results, device, NULL);
|
network_info_has_hidden())) {
|
||||||
else
|
if (!scan_passive(device->index, device_scan_triggered,
|
||||||
id = scan_active(device->index, NULL, 0, device_scan_triggered,
|
new_scan_results, device, NULL))
|
||||||
new_scan_results, device, NULL);
|
return dbus_error_failed(message);
|
||||||
|
} else {
|
||||||
|
struct scan_parameters params;
|
||||||
|
|
||||||
if (!id)
|
memset(¶ms, 0, sizeof(params));
|
||||||
return dbus_error_failed(message);
|
|
||||||
|
/* If we're connected, HW cannot randomize our MAC */
|
||||||
|
if (!device->connected_bss)
|
||||||
|
params.randomize_mac_addr_hint = true;
|
||||||
|
|
||||||
|
if (!scan_active_full(device->index, ¶ms,
|
||||||
|
device_scan_triggered,
|
||||||
|
new_scan_results, device, NULL))
|
||||||
|
return dbus_error_failed(message);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue