Hi,
Please inline your patch next time. It makes reviewing simpler
On 06.11.18 01:36, Володимир Остап wrote:
I am using connman for wifi connection and it is controlled over
dbus.
The system supports many wifi connections. The user can remove and add a
connection.
If there are saved connections and wifi is currently disconnected and
connman is asked over dbus to do a scan it falls into the scan on
channels retrieved from the saved services.
So user sees only APs on these channels.
Argh not again wifi scanning troubles. Somehow this is really hard to
get right with wpa_supplicant. Anyway thanks for the bug report
including the patch. Though I have a few comments:
diff --git a/include/device.h b/include/device.h
index 5a3ddc22..e444ea06 100644
--- a/include/device.h
+++ b/include/device.h
@@ -124,7 +124,7 @@ struct connman_device_driver {
struct connman_device *device,
const char *ssid, unsigned int ssid_len,
const char *identity, const char* passphrase,
- const char *security, void *user_data);
+ const char *security, bool force_full_scan, void *user_data);
void (*stop_scan) (enum connman_service_type type,
struct connman_device *device);
int (*set_regdom) (struct connman_device *device,
diff --git a/plugins/wifi.c b/plugins/wifi.c
index dc08c6af..ef73e843 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1861,7 +1861,8 @@ static int wifi_scan(enum connman_service_type type,
struct connman_device *device,
const char *ssid, unsigned int ssid_len,
const char *identity, const char* passphrase,
- const char *security, void *user_data)
+ const char *security, bool force_full_scan,
+ void *user_data)
I am not partucilar fan of adding a bool for this, because it is already
hard to figure out which parameters is what. Adding a bool makes it even
harder. Why not defining a enum for the forced scan?
{
struct wifi_data *wifi = connman_device_get_data(device);
GSupplicantScanParams *scan_params = NULL;
@@ -1884,7 +1885,8 @@ static int wifi_scan(enum connman_service_type type,
if (type == CONNMAN_SERVICE_TYPE_P2P)
return p2p_find(device);
- DBG("device %p wifi %p hidden ssid %s", device, wifi->interface, ssid);
+ DBG("device %p wifi %p hidden ssid %s forced full scan %d", device,
+ wifi->interface, ssid, force_full_scan);
and here I would change the text to 'scan type {forced|normal}'
scanning = connman_device_get_scanning(device, CONNMAN_SERVICE_TYPE_WIFI);
@@ -1950,7 +1952,7 @@ static int wifi_scan(enum connman_service_type type,
return 0;
}
- } else if (wifi->connected) {
+ } else if (wifi->connected || force_full_scan) {
If it is a forced scan, I guess we should do a active scan instead of a
passive. So you need to drop the scan_param and fall through to the
passive case.
g_supplicant_free_scan_params(scan_params);
return wifi_scan_simple(device);
} else {
diff --git a/src/config.c b/src/config.c
index 4178ea86..7d48267e 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1602,7 +1602,7 @@ int connman_config_provision_mutable_service(GKeyFile *keyfile)
__connman_service_provision_changed(vfile);
if (g_strcmp0(service_config->type, "wifi") == 0)
- __connman_device_request_scan(CONNMAN_SERVICE_TYPE_WIFI);
+ __connman_device_request_scan(CONNMAN_SERVICE_TYPE_WIFI, false);
Add a __connman_device_request_full_scan() function and then you don't
have to modify this call side.
g_free(group);
return 0;
diff --git a/src/connman.h b/src/connman.h
index 82e77d37..52c161ae 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -561,7 +561,7 @@ void __connman_device_list(DBusMessageIter *iter, void *user_data);
enum connman_service_type __connman_device_get_service_type(struct connman_device
*device);
struct connman_device *__connman_device_find_device(enum connman_service_type type);
-int __connman_device_request_scan(enum connman_service_type type);
+int __connman_device_request_scan(enum connman_service_type type, bool force_full_scan);
As mention above add a __connman_device_request_full_scan() function and
leave the original scan() function as it is.
int __connman_device_request_hidden_scan(struct connman_device
*device,
const char *ssid, unsigned int ssid_len,
const char *identity, const char *passphrase,
diff --git a/src/device.c b/src/device.c
index 5d343ae8..f50753cc 100644
--- a/src/device.c
+++ b/src/device.c
@@ -615,7 +615,7 @@ int connman_device_set_powered(struct connman_device *device,
if (device->driver && device->driver->scan)
device->driver->scan(CONNMAN_SERVICE_TYPE_UNKNOWN, device,
- NULL, 0, NULL, NULL, NULL, NULL);
+ NULL, 0, NULL, NULL, NULL, false, NULL);
As said, the 'false' is kind of not telling what it does. Havig an enum
for this makes it more readable.
return 0;
}
@@ -626,7 +626,8 @@ bool connman_device_get_powered(struct connman_device *device)
}
static int device_scan(enum connman_service_type type,
- struct connman_device *device)
+ struct connman_device *device,
+ bool force_full_scan)
{
if (!device->driver || !device->driver->scan)
return -EOPNOTSUPP;
@@ -635,7 +636,7 @@ static int device_scan(enum connman_service_type type,
return -ENOLINK;
return device->driver->scan(type, device, NULL, 0,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, force_full_scan, NULL);
}
int __connman_device_disconnect(struct connman_device *device)
@@ -1080,7 +1081,7 @@ void connman_device_regdom_notify(struct connman_device *device,
__connman_technology_notify_regdom_by_device(device, result, alpha2);
}
-int __connman_device_request_scan(enum connman_service_type type)
+int __connman_device_request_scan(enum connman_service_type type, bool force_full_scan)
You rename this function to device_requet_scan() and make it static and
call let __connman_device_request_scan() and
__connman_device_request_full_scan() call it.
{
bool success = false;
int last_err = -ENOSYS;
@@ -1108,7 +1109,7 @@ int __connman_device_request_scan(enum connman_service_type type)
if (!device_has_service_type(device, type))
continue;
- err = device_scan(type, device);
+ err = device_scan(type, device, force_full_scan);
if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
success = true;
} else {
@@ -1136,7 +1137,7 @@ int __connman_device_request_hidden_scan(struct connman_device
*device,
return device->driver->scan(CONNMAN_SERVICE_TYPE_UNKNOWN,
device, ssid, ssid_len, identity,
- passphrase, security, user_data);
+ passphrase, security, false, user_data);
}
void __connman_device_stop_scan(enum connman_service_type type)
diff --git a/src/technology.c b/src/technology.c
index 4c1cbbbb..d7a6f1f6 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1083,7 +1083,7 @@ static DBusMessage *scan(DBusConnection *conn, DBusMessage *msg,
void *data)
technology->scan_pending =
g_slist_prepend(technology->scan_pending, msg);
- err = __connman_device_request_scan(technology->type);
+ err = __connman_device_request_scan(technology->type, true);
if (err < 0)
reply_scan_pending(technology, err);
Thanks,
Daniel